-
Notifications
You must be signed in to change notification settings - Fork 3
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
Zksync era integration tests #208
Conversation
Fixes decommit opcode, which was not account for if the code had already been decommitted
Adds mandated gass, handles decommit cost err, and fixes the params of mimic call
@@ -50,6 +51,23 @@ pub struct Execution { | |||
pub use_hooks: bool, |
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.
If you extract the program, then the ExecutionSnapshot
becomes just a clone of this. Maybe we could move the program out and turn ExecutionSnapshot
in a simple wrapper?
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.
Yes I thought of that as well, but I didn't want to change the vm initial struct tbh. If you consider this change to be worth it, I'll go ahead and make the appropriate changes. I would prefer to leave it for a later general code refactor thou, but you call the shots!! 😉.
src/state.rs
Outdated
pub struct FullStateSnapshot { | ||
pub internal_snapshot: StateSnapshot, |
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.
FullStateSnapshot
and StateSnapshot
are named in a confusing way IMO, maybe renaming StateSnapshot
to InternalStateSnapshot
is a bit better.
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 agree that names can be a bit confusing, I've added some new comments, and renamed FullStateSnapshot
to ExternalStateSnapshot
. Tell me if you think that is clearer 😁.
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.
LGTM
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.
Let's discuss some things.
self.decommitted_hashes.map.insert(hash); | ||
self.storage.borrow_mut().decommit(hash) | ||
pub fn decommit(&mut self, hash: U256) -> (Option<Vec<U256>>, bool) { | ||
let was_decommitted = !self.decommitted_hashes.map.insert(hash); |
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.
What we're doing here, Exactly? A bit confused since we're mixing Option + Bool. Let's discus this a bit.
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 decommiting, we want to know whether the hash has already been decommited or not to calculate refunds and decommit costs.
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.
Let's add a comment clarifying this then.
I’ve removed the cache for the initial storage to reduce confusion. We can consider re-adding it later if necessary. |
Ergs comparison results:
|
This pr introduces several changes and fixes to the vm:
Contex(IncrementTxNumber)
opcode: it was not clearing the transient storage.decommit
opcode: it was not accounting if the contract had already been decommitted.farcall
opcode: adds mandated gas, handles decommit cost err, and fixes the params of mimic callfar_calls
we were not supposed to add theevm_interpreter
stipend gas to the new frame.All of this changes have been made to finish the integration with the bootloader. See here.