0xMiden / 0xMiden/miden-vm

Only statically-link AdviceMap data that is used

オープン
#1,891 コメント 2 件 リアクション 1 件 担当者 1 名 @bitwalker が担当を希望しています GitHub で見る
assembly
主要言語
Rust
スター
772
フォーク
352
平均マージ
1日 12時間
マージ済み PR(30日)
93

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。