diff --git a/Cargo.toml b/Cargo.toml index 6f500c1..550a2f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,4 +55,4 @@ serde = { version = "1", default-features = false, features = ["derive"] } [patch.crates-io] revm = { git = "https://github.com/bluealloy/revm", rev = "b67ca3e" } -revm-optimism = { git = "https://github.com/bluealloy/revm", rev = "b67ca3e" } +revm-optimism = { git = "https://github.com/bluealloy/revm", rev = "b67ca3e" } \ No newline at end of file diff --git a/crates/evm/src/eth.rs b/crates/evm/src/eth.rs index 0872e85..7875bd8 100644 --- a/crates/evm/src/eth.rs +++ b/crates/evm/src/eth.rs @@ -8,10 +8,13 @@ use core::{ ops::{Deref, DerefMut}, }; use revm::{ - context::{BlockEnv, CfgEnv, TxEnv}, + context::{BlockEnv, CfgEnv, Evm as RevmEvm, TxEnv}, context_interface::result::{EVMError, HaltReason, ResultAndState}, - handler::{Inspector, NoOpInspector}, - Context, ExecuteEvm, InspectEvm, MainBuilder, MainContext, MainnetEvm, + handler::{ + instructions::EthInstructions, EthPrecompiles, Inspector, NoOpInspector, PrecompileProvider, + }, + interpreter::{interpreter::EthInterpreter, InterpreterResult}, + Context, ExecuteEvm, InspectEvm, MainBuilder, MainContext, }; /// The Ethereum EVM context type. @@ -19,9 +22,31 @@ pub type EthEvmContext = Context; /// Ethereum EVM implementation. #[expect(missing_debug_implementations)] -pub struct EthEvm(MainnetEvm, I>); +pub struct EthEvm>>( + RevmEvm, I, EthInstructions>, PRECOMPILE>, +); + +impl EthEvm { + /// Creates a new Ethereum EVM instance. + pub const fn new( + evm: RevmEvm< + EthEvmContext, + I, + EthInstructions>, + PRECOMPILE, + >, + ) -> Self { + Self(evm) + } + + /// Consumes self and return the inner EVM instance. + pub fn into_inner( + self, + ) -> RevmEvm, I, EthInstructions>, PRECOMPILE> + { + self.0 + } -impl EthEvm { /// Provides a reference to the EVM context. pub const fn ctx(&self) -> &EthEvmContext { &self.0.data.ctx @@ -33,7 +58,7 @@ impl EthEvm { } } -impl Deref for EthEvm { +impl Deref for EthEvm { type Target = EthEvmContext; #[inline] @@ -42,17 +67,18 @@ impl Deref for EthEvm { } } -impl DerefMut for EthEvm { +impl DerefMut for EthEvm { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { self.ctx_mut() } } -impl EthEvm +impl EthEvm where DB: Database, I: Inspector>, + PRECOMPILE: PrecompileProvider, Output = InterpreterResult>, { fn transact(&mut self, tx: TxEnv) -> Result> { if self.0.enabled_inspection { @@ -64,10 +90,11 @@ where } } -impl Evm for EthEvm +impl Evm for EthEvm where DB: Database, I: Inspector>, + PRECOMPILE: PrecompileProvider, Output = InterpreterResult>, { type DB = DB; type Tx = TxEnv; @@ -79,7 +106,7 @@ where } fn transact(&mut self, tx: Self::Tx) -> Result { - self.transact(tx) + self.0.transact(tx) } fn transact_system_call( diff --git a/crates/op-evm/src/lib.rs b/crates/op-evm/src/lib.rs index d048d90..d3d3dc3 100644 --- a/crates/op-evm/src/lib.rs +++ b/crates/op-evm/src/lib.rs @@ -94,7 +94,7 @@ where } fn transact(&mut self, tx: Self::Tx) -> Result, Self::Error> { - self.transact(tx) + self.0.transact(tx) } fn transact_system_call(