diff --git a/crates/context/src/evm.rs b/crates/context/src/evm.rs index d71e05dfbf..41ada34f2f 100644 --- a/crates/context/src/evm.rs +++ b/crates/context/src/evm.rs @@ -24,6 +24,36 @@ impl Evm { } } +impl Evm { + /// Consumed self and returns new Evm type with given Inspector. + pub fn with_inspector(self, inspector: OINSP) -> Evm { + Evm { + data: EvmData { + ctx: self.data.ctx, + inspector, + }, + enabled_inspection: self.enabled_inspection, + instruction: self.instruction, + precompiles: self.precompiles, + } + } + + /// Consumes self and returns new Evm type with given Precompiles. + pub fn with_precompiles(self, precompiles: OP) -> Evm { + Evm { + data: self.data, + enabled_inspection: self.enabled_inspection, + instruction: self.instruction, + precompiles, + } + } + + /// Consumes self and returns inner Inspector. + pub fn into_inspector(self) -> INSP { + self.data.inspector + } +} + impl ContextSetters for Evm { type Tx = ::Tx; type Block = ::Block; diff --git a/crates/handler/src/handler.rs b/crates/handler/src/handler.rs index 999cc2cb2c..760aec2239 100644 --- a/crates/handler/src/handler.rs +++ b/crates/handler/src/handler.rs @@ -160,6 +160,11 @@ where &self.data.ctx } + #[inline] + fn inspector(&mut self) -> &mut Self::Inspector { + &mut self.data.inspector + } + #[inline] fn ctx_inspector(&mut self) -> (&mut Self::Context, &mut Self::Inspector) { (&mut self.data.ctx, &mut self.data.inspector) @@ -194,6 +199,8 @@ pub trait EvmTrait { fn ctx(&mut self) -> &mut Self::Context; + fn inspector(&mut self) -> &mut Self::Inspector; + fn ctx_ref(&self) -> &Self::Context; fn ctx_inspector(&mut self) -> (&mut Self::Context, &mut Self::Inspector); diff --git a/crates/optimism/src/evm.rs b/crates/optimism/src/evm.rs index 110cfedf27..37ec9ad2c6 100644 --- a/crates/optimism/src/evm.rs +++ b/crates/optimism/src/evm.rs @@ -87,6 +87,10 @@ where &self.data.ctx } + fn inspector(&mut self) -> &mut Self::Inspector { + &mut self.data.inspector + } + fn ctx_inspector(&mut self) -> (&mut Self::Context, &mut Self::Inspector) { (&mut self.data.ctx, &mut self.data.inspector) } diff --git a/crates/revm/src/exec_inspect.rs b/crates/revm/src/exec_inspect.rs index bc636e656e..bbc408f595 100644 --- a/crates/revm/src/exec_inspect.rs +++ b/crates/revm/src/exec_inspect.rs @@ -37,6 +37,11 @@ pub trait InspectEvm: ExecuteEvm { self.inspect_previous() } + fn inspect_previous_with_tx(&mut self, tx: ::Tx) -> Self::Output { + self.set_tx(tx); + self.inspect_previous() + } + fn inspect( &mut self, tx: ::Tx,