0xMiden / 0xMiden/miden-vm

Only statically-link AdviceMap data that is used

Ouverte
#1,891 2 commentaires 1 réaction 1 personne assignée Réclamée par @bitwalker Voir sur GitHub
assembly
Langage dominant
Rust
Étoiles
772
Forks
352
Merge moyen
1 j 12 h
PR mergées (30 j)
93

Description

Currently, when the assembler is assembling a library or program, the `MastForestBuilder` is constructed with the set of statically-linked libraries, whose code (when referenced) will be copied into the final assembly. Additionally, to ensure that advice data provided (and used) by those libraries is present at runtime, it copies _all_ of the advice data of every statically-linked library into the final assembly.

That's a problem for assembled artifacts that need to be stored on-chain, as advice data can drastically inflate the size of the resulting binary. It is likely that the advice map data of a library may not be referenced at all by the parts of the library that are statically-linked, meaning that data is just wasting space.

I would suggest that we implement an analysis pass as part of the `Linker`, that determines what `AdviceMap` entries of statically-linked libraries are actually referenced by statically-linked procedures. This requires us to visit the MAST of those procedures and perform a kind of dataflow analysis, that looks for advice map instructions that take a key as argument and read data from the advice map, and reify the key passed as an argument.

In cases where the key cannot be statically computed (e.g. it is provided as an argument to a procedure, rather than referenced literally), we could handle them conservatively (i.e. mark all `AdviceMap` entries of the containing library as possibly-referenced). This would be safe, but possibly overly-conservative.

The initial task here is to take a look at how we would identify whether an advice map entry is used, in what cases we cannot do so, and then determine the feasibility and benefit of implementing the proposed analysis.

I also think we need to gather some data on how often advice map data is shipped with a library, how much data there is, and how likely it is that parts of a library that don't use that data are linked in to other artifacts _without_ the parts that do use the data.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.