-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add handler constructor and Context to revm::ChainSpec
- Loading branch information
Showing
28 changed files
with
236 additions
and
385 deletions.
There are no files selected for viewing
This file contains 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 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,38 @@ | ||
use crate::{ | ||
handler::{ExecutionHandler, PostExecutionHandler, PreExecutionHandler, ValidationHandler}, | ||
interpreter::opcode::InstructionTables, | ||
primitives::{db::Database, spec_to_generic, EthChainSpec}, | ||
EvmHandler, | ||
}; | ||
|
||
pub trait ChainSpec: crate::primitives::ChainSpec { | ||
/// The type that contains all context information for the chain's EVM execution. | ||
type Context: Default; | ||
|
||
/// Creates a new handler with the given hardfork. | ||
fn handler<'evm, EXT, DB>(hardfork: Self::Hardfork) -> EvmHandler<'evm, Self, EXT, DB> | ||
where | ||
DB: Database; | ||
} | ||
|
||
impl ChainSpec for EthChainSpec { | ||
type Context = (); | ||
|
||
fn handler<'evm, EXT, DB>(hardfork: Self::Hardfork) -> EvmHandler<'evm, Self, EXT, DB> | ||
where | ||
DB: Database, | ||
{ | ||
spec_to_generic!( | ||
hardfork, | ||
EvmHandler { | ||
spec_id: hardfork, | ||
instruction_table: InstructionTables::new_plain::<SPEC>(), | ||
registers: Vec::new(), | ||
validation: ValidationHandler::new::<SPEC>(), | ||
pre_execution: PreExecutionHandler::new::<SPEC>(), | ||
post_execution: PostExecutionHandler::mainnet::<SPEC>(), | ||
execution: ExecutionHandler::new::<SPEC>(), | ||
} | ||
) | ||
} | ||
} |
This file contains 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
Oops, something went wrong.