-
Notifications
You must be signed in to change notification settings - Fork 98
feat: vendor op-revm into pevm and bump revm to v39 #507
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
Open
duyquang6
wants to merge
4
commits into
main
Choose a base branch
from
downstream-op-revm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| use super::precompiles::RisePrecompiles; | ||
| use super::{ | ||
| RiseContext, RiseHaltReason, RiseTransaction, RiseTransactionError, handler::RiseHandler, | ||
| }; | ||
| use revm::{ | ||
| Database, ExecuteEvm, | ||
| context::{BlockEnv, ContextError, ContextSetters, Evm, FrameStack}, | ||
| context_interface::{ | ||
| ContextTr, | ||
| result::{EVMError, ExecResultAndState, ExecutionResult}, | ||
| }, | ||
| handler::{ | ||
| EthFrame, EvmTr, FrameInitOrResult, FrameResult, Handler, ItemOrResult, evm::FrameTr, | ||
| instructions::EthInstructions, | ||
| }, | ||
| interpreter::interpreter::EthInterpreter, | ||
| state::EvmState, | ||
| }; | ||
|
|
||
| pub(crate) type RiseError<DB> = EVMError<<DB as Database>::Error, RiseTransactionError>; | ||
|
|
||
| /// RISE EVM wrapping [`Evm`] with RISE-specific precompiles and handler dispatch. | ||
| #[derive(Debug)] | ||
| #[allow(clippy::type_complexity)] | ||
| pub struct RiseEvm<DB: Database>( | ||
| Evm< | ||
| RiseContext<DB>, | ||
| (), | ||
| EthInstructions<EthInterpreter, RiseContext<DB>>, | ||
| RisePrecompiles, | ||
| EthFrame<EthInterpreter>, | ||
| >, | ||
| ); | ||
|
|
||
| impl<DB: Database> RiseEvm<DB> { | ||
| pub(crate) fn new(ctx: RiseContext<DB>) -> Self { | ||
| let spec = *ctx.cfg().spec(); | ||
| Self(Evm { | ||
| ctx, | ||
| inspector: (), | ||
| instruction: EthInstructions::new_mainnet_with_spec(spec), | ||
| precompiles: RisePrecompiles::default(), | ||
| frame_stack: FrameStack::new_prealloc(8), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl<DB: Database> EvmTr for RiseEvm<DB> { | ||
| type Context = RiseContext<DB>; | ||
| type Instructions = EthInstructions<EthInterpreter, RiseContext<DB>>; | ||
| type Precompiles = RisePrecompiles; | ||
| type Frame = EthFrame<EthInterpreter>; | ||
|
|
||
| fn all( | ||
| &self, | ||
| ) -> ( | ||
| &Self::Context, | ||
| &Self::Instructions, | ||
| &Self::Precompiles, | ||
| &FrameStack<Self::Frame>, | ||
| ) { | ||
| self.0.all() | ||
| } | ||
|
|
||
| fn all_mut( | ||
| &mut self, | ||
| ) -> ( | ||
| &mut Self::Context, | ||
| &mut Self::Instructions, | ||
| &mut Self::Precompiles, | ||
| &mut FrameStack<Self::Frame>, | ||
| ) { | ||
| self.0.all_mut() | ||
| } | ||
|
|
||
| fn frame_init( | ||
| &mut self, | ||
| frame_input: <Self::Frame as FrameTr>::FrameInit, | ||
| ) -> Result<ItemOrResult<&mut Self::Frame, FrameResult>, ContextError<DB::Error>> { | ||
| self.0.frame_init(frame_input) | ||
| } | ||
|
|
||
| fn frame_run(&mut self) -> Result<FrameInitOrResult<Self::Frame>, ContextError<DB::Error>> { | ||
| self.0.frame_run() | ||
| } | ||
|
|
||
| fn frame_return_result( | ||
| &mut self, | ||
| result: FrameResult, | ||
| ) -> Result<Option<FrameResult>, ContextError<DB::Error>> { | ||
| self.0.frame_return_result(result) | ||
| } | ||
| } | ||
|
|
||
| impl<DB: Database> ExecuteEvm for RiseEvm<DB> { | ||
| type Tx = RiseTransaction; | ||
| type Block = BlockEnv; | ||
| type State = EvmState; | ||
| type Error = RiseError<DB>; | ||
| type ExecutionResult = ExecutionResult<RiseHaltReason>; | ||
|
|
||
| fn set_block(&mut self, block: Self::Block) { | ||
| self.0.ctx.set_block(block); | ||
| } | ||
|
|
||
| fn transact_one(&mut self, tx: Self::Tx) -> Result<Self::ExecutionResult, Self::Error> { | ||
| self.0.ctx.set_tx(tx); | ||
| RiseHandler::default().run(self) | ||
| } | ||
|
|
||
| fn finalize(&mut self) -> Self::State { | ||
| self.0.ctx.journal_mut().finalize() | ||
| } | ||
|
|
||
| fn replay( | ||
| &mut self, | ||
| ) -> Result<ExecResultAndState<Self::ExecutionResult, Self::State>, Self::Error> { | ||
| RiseHandler::default() | ||
| .run(self) | ||
| .map(|result| ExecResultAndState::new(result, self.finalize())) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 update sha3-asm to 0.1.7, performance regressed 15% on bench mainnet, root caused:
Despite SHA3 instructions being faster per-round on paper, scalar version wins on Graviton. Likely reasons:
Worth reporting to crate author
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.
related: DaniPopes/keccak-asm#12
Uh oh!
There was an error while loading. Please reload this page.
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.
reported DaniPopes/keccak-asm#15