You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some situations it maybe desirable to specify some data which a given program assumes to be available in the advice provider. One example of this is read-only data output by the compiler, but there could be may other examples. Currently, such data needs to be loaded separately into the VM which introduces extra complexities.
One way around this is to allow users to define data which is to be loaded into the advice provider before a given program starts executing. The syntax for this in MASM could look like so:
advent.FOO.0x9dfb1fc9f2d5625a5a304b9012b4de14df5cf6e0155cdd63a27c25360562587a
642174d286a4f38e4d2e09a79d048fe7c89dec9a03fce29cbe10d32aa18a1dc4
bb48645fa4ffe141f9a139aef4fa98aec50bded67d45a29e545e386b79d8cefe
0f87d6b3c174fad0099f7296ded3abfef1a282567c4182b925abd69b0ed487c3
c251ce5e4e2da760658f29f6a8c54788d52ae749afd1aef6531bf1457b8ea5fb
end
Here, advent specifies that we want to add an entry to the advice map. The key for the entry would be the word defined by 0x9dfb1fc9f2d5625a... value. The data of the entry would be the list of field elements defined by the hex encoded string. We also provide a way to specify a label FOO by which they key can be referred to from the code. For example:
being
push.FOO
end
Would push the key 0x9dfb1fc9f2d5625a... onto the stack.
Upon assembly, this data would be added to the MastForest. For this, we'd need to add a single AdviceMap property to the MastForest struct - e.g., something like this:
pubstructMastForest{/// All of the nodes local to the trees comprising the MAST forest.nodes:Vec<MastNode>,/// Roots of procedures defined within this MAST forest.roots:Vec<MastNodeId>,/// All the decorators included in the MAST forest.decorators:Vec<Decorator>,/// Advice map to be loaded into the VM prior to executing procedures from this MAST forest.advice_map:AdviceMap,}
Then, when the VM starts executing a given MAST forest, it'll copy the contents of the advice map into its advice provider (we can also use a slightly more sophisticated strategy to make sure that the map is copied only once).
Open questions
While the above approach should work, there are a few things we need to clarify before implementing it:
In the above example FOO refers to a full word. All our constants currently refer to single elements. Ideally, we should be able to tell by looking at the constant name whether it is for a full word or a single element. So, maybe we should come up with some simple scheme here to differentiate them?
Should the key handle FOO be accessible outside of the module it was defined in? It seems like it would be a good idea, but then we need to be able to apply some kind of visibility modifiers to advent.
How should we handle conflicting keys during assembly and execution?
If we encounter two entries with the same key but different data during assembly, this should probably be an error.
But what to do if we start executing a MAST forest which wants to load data into the advice provider but an entry with the same key but different data is already in the advice map? Should we error out? Silently replace the existing data with the new one? Anything else?
The text was updated successfully, but these errors were encountered:
In some situations it maybe desirable to specify some data which a given program assumes to be available in the advice provider. One example of this is read-only data output by the compiler, but there could be may other examples. Currently, such data needs to be loaded separately into the VM which introduces extra complexities.
One way around this is to allow users to define data which is to be loaded into the advice provider before a given program starts executing. The syntax for this in MASM could look like so:
Here,
advent
specifies that we want to add an entry to the advice map. The key for the entry would be the word defined by0x9dfb1fc9f2d5625a...
value. The data of the entry would be the list of field elements defined by the hex encoded string. We also provide a way to specify a labelFOO
by which they key can be referred to from the code. For example:Would push the key
0x9dfb1fc9f2d5625a...
onto the stack.Upon assembly, this data would be added to the
MastForest
. For this, we'd need to add a singleAdviceMap
property to theMastForest
struct - e.g., something like this:Then, when the VM starts executing a given MAST forest, it'll copy the contents of the advice map into its advice provider (we can also use a slightly more sophisticated strategy to make sure that the map is copied only once).
Open questions
While the above approach should work, there are a few things we need to clarify before implementing it:
FOO
refers to a full word. All our constants currently refer to single elements. Ideally, we should be able to tell by looking at the constant name whether it is for a full word or a single element. So, maybe we should come up with some simple scheme here to differentiate them?FOO
be accessible outside of the module it was defined in? It seems like it would be a good idea, but then we need to be able to apply some kind of visibility modifiers toadvent
.The text was updated successfully, but these errors were encountered: