chore(revm): defer bytecode load#1588
Merged
rakita merged 3 commits intobluealloy:mainfrom Jul 10, 2024
Merged
Conversation
39b3b2a to
932f850
Compare
Member
|
Looks reasonable, will check it again to be sure |
rakita
reviewed
Jul 8, 2024
Comment on lines
220
to
236
| 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) | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| 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
rakita
reviewed
Jul 8, 2024
| let (account, _) = self | ||
| .inner | ||
| .journaled_state | ||
| .load_code(inputs.bytecode_address, &mut self.inner.db)?; |
Member
There was a problem hiding this comment.
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(..)?
This was referenced Jul 10, 2024
Closed
Closed
Closed
Closed
Closed
Closed
Merged
j75689
pushed a commit
to j75689/revm
that referenced
this pull request
Aug 1, 2024
* defer bytecode load * apply review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.