-
Notifications
You must be signed in to change notification settings - Fork 555
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
chore(revm): defer bytecode load #1588
Conversation
39b3b2a
to
932f850
Compare
Looks reasonable, will check it again to be sure |
if !bytecode.is_empty() { | ||
let contract = Contract::new_with_context( | ||
inputs.input.clone(), | ||
bytecode, | ||
Some(code_hash), | ||
inputs, | ||
); | ||
// Create interpreter and executes call and push new CallStackFrame. | ||
Ok(FrameOrResult::new_call_frame( | ||
inputs.return_memory_offset.clone(), | ||
checkpoint, | ||
Interpreter::new(contract, gas.limit(), inputs.is_static), | ||
)) | ||
} else { | ||
self.journaled_state.checkpoint_commit(); | ||
return_result(InstructionResult::Stop) | ||
} |
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 !bytecode.is_empty() { | |
let contract = Contract::new_with_context( | |
inputs.input.clone(), | |
bytecode, | |
Some(code_hash), | |
inputs, | |
); | |
// Create interpreter and executes call and push new CallStackFrame. | |
Ok(FrameOrResult::new_call_frame( | |
inputs.return_memory_offset.clone(), | |
checkpoint, | |
Interpreter::new(contract, gas.limit(), inputs.is_static), | |
)) | |
} else { | |
self.journaled_state.checkpoint_commit(); | |
return_result(InstructionResult::Stop) | |
} | |
if bytecode.is_empty() { | |
self.journaled_state.checkpoint_commit(); | |
return_result(InstructionResult::Stop) | |
} | |
let contract = Contract::new_with_context( | |
inputs.input.clone(), | |
bytecode, | |
Some(code_hash), | |
inputs, | |
); | |
// Create interpreter and executes call and push new CallStackFrame. | |
Ok(FrameOrResult::new_call_frame( | |
inputs.return_memory_offset.clone(), | |
checkpoint, | |
Interpreter::new(contract, gas.limit(), inputs.is_static), | |
)) |
code style nit. Maybe it needs fmt
let (account, _) = self | ||
.inner | ||
.journaled_state | ||
.load_code(inputs.bytecode_address, &mut self.inner.db)?; |
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.
This is slightly an edge case that is not a consensus error but would fix it to be consistent. CALL from instruction loads account that makes account warm loaded, while if we do it from tx as in TransactTo
this is not the case, this is really a edge case where it is noticeable only that account will not be returned from finalization and only if tx is calling precompile.
We can add here load_account
in place of load_code
, something like let _ = self...load_acccount(..)?
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.
Left comment, and one nit
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
* defer bytecode load * apply review
Current revm try to load bytecode just after depth check, but there are some conditions the code is not needed:
As long as the code is not needed, the database provider may not have corresponding code, like in our implementation scroll-tech/stateless-block-verifier#15 use this as an optimization.