Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(yellowpaper): finish AVM Context definitions #3709
docs(yellowpaper): finish AVM Context definitions #3709
Changes from all commits
e7ce819
dbdd430
e0b5a03
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The world state structure here is a memory snapshot of persistent data. Could you mention in this lifecycle when the snapshot is made, where modifications happen in memory and when the memory modifications are executed persistently? Maybe no need to describe all details on how we prevent conflicts, etc, but just the model when read and write are performed persistently vs. in memory.
Re-reading what you wrote, I realize it is actually pretty good. Maybe enhancing the above text with explicit mentions about memory changes vs persistent would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeanmon I don't totally follow 🤔 World State is separate from memory. Something like
SSTORE
takes a word from memory and stores it into the world state. If a message call fails, any such modifications it made will be rolled back.So when a caller encounters a nested call, it will take a world state snapshot. If the message call reverts, the caller will reject its world state updates by rolling back to that snapshot.
The circuit doesn't really care about any of this. The circuit just has a storage access trace. Even a reverted message call will have access trace entries for its
SSTORE
s, but the entire message call will be flagged asreverted
, so the kernel knows not to consider those updates for when processing later reads/writes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snapshots of world state will not be stored in VM memory. In fact they won't even be handled by the VM circuit at all. They are really a higher-level concept that the AVM simulator will use to populate the state traces for each call. And the kernel or rollup circuits will need to know that when a revert happens it shouldn't consider any reverted state updates when validating state accesses that happen later (with higher sideEffectCounter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I used the word "memory" I meant a memory snapshot of the world state not the memory space of the VM circuit. Sorry for the misunderstanding, the discussion deviated far beyond the original scope. My point was to emphasize a bit more when the memory snapshot is made and when it is written persistently.
Let us align on a call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the VM circuit I can constrain that memory is initialized with 0 and flag type 0, so that any initial read at memory location (on which we did not write to) returns to zero. If Noir compiler can ensure that we never read from uninitialized memory, we can simply constrain the memory trace that the first memory operation per address is always a write. My point is that we can support both ways. We should just be on the same page with the noir team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flag type
0
meansuninitialized
, and I thought that any "loads" from an uninitialized cell would fail. Is that true? Could we get rid of the concept ofuninitialized
and just say that all cells start tagged asfield
and initialized to 0?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think enforcing type field initialized with 0 is a bad trade-off. I would consider 2 options:
In the current VM circuit implementation, variant 2) is implemented.
My point is that the circuit should not have any difficulty to support these variants. That's why I would check with Noir team what is preferable.