Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ serde = { version = "1", default-features = false, features = ["derive"] }
thiserror = { version = "2.0.0", default-features = false }
serde_json = "1"

#[patch.crates-io]
#revm = { git = "https://github.com/bluealloy/revm", rev = "11b16259" }
#op-revm = { git = "https://github.com/bluealloy/revm", rev = "11b16259" }
[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
op-revm = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
9 changes: 9 additions & 0 deletions crates/evm/src/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ where
either::for_both!(self, evm => evm.transact(tx))
}

fn inspect_system_call(
&mut self,
caller: Address,
contract: Address,
data: Bytes,
) -> Result<revm::context::result::ResultAndState<Self::HaltReason>, Self::Error> {
either::for_both!(self, evm => evm.inspect_system_call(caller, contract, data))
}

fn transact_system_call(
&mut self,
caller: Address,
Expand Down
14 changes: 12 additions & 2 deletions crates/evm/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use revm::{
interpreter::{interpreter::EthInterpreter, InterpreterResult},
precompile::{PrecompileSpecId, Precompiles},
primitives::hardfork::SpecId,
Context, ExecuteEvm, InspectEvm, Inspector, MainBuilder, MainContext, SystemCallEvm,
Context, ExecuteEvm, InspectEvm, InspectSystemCallEvm, Inspector, MainBuilder, MainContext,
SystemCallEvm,
};

mod block;
Expand Down Expand Up @@ -136,13 +137,22 @@ where
}
}

fn inspect_system_call(
&mut self,
caller: Address,
contract: Address,
data: Bytes,
) -> Result<ResultAndState<Self::HaltReason>, Self::Error> {
self.inner.inspect_system_call_with_caller(caller, contract, data)
}

fn transact_system_call(
&mut self,
caller: Address,
contract: Address,
data: Bytes,
) -> Result<ResultAndState<Self::HaltReason>, Self::Error> {
self.inner.transact_system_call_with_caller_finalize(caller, contract, data)
self.inner.system_call_with_caller(caller, contract, data)
}

fn finish(self) -> (Self::DB, EvmEnv<Self::Spec>) {
Expand Down
12 changes: 12 additions & 0 deletions crates/evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ pub trait Evm {
self.transact_raw(tx.into_tx_env())
}

/// Inspects a system call without committing state changes.
///
/// This method executes a system call with inspection enabled, allowing observation of the
/// execution without modifying the underlying state. Similar to [`Evm::transact_system_call`]
/// but returns the result with state changes that can be examined or discarded.
fn inspect_system_call(
&mut self,
caller: Address,
contract: Address,
data: Bytes,
) -> Result<ResultAndState<Self::HaltReason>, Self::Error>;

/// Executes a system call.
///
/// Note: this will only keep the target `contract` in the state. This is done because revm is
Expand Down
13 changes: 11 additions & 2 deletions crates/op-evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use revm::{
handler::{instructions::EthInstructions, PrecompileProvider},
inspector::NoOpInspector,
interpreter::{interpreter::EthInterpreter, InterpreterResult},
Context, ExecuteEvm, InspectEvm, Inspector, SystemCallEvm,
Context, ExecuteEvm, InspectEvm, InspectSystemCallEvm, Inspector, SystemCallEvm,
};

pub mod block;
Expand Down Expand Up @@ -116,13 +116,22 @@ where
}
}

fn inspect_system_call(
&mut self,
caller: Address,
contract: Address,
data: Bytes,
) -> Result<ResultAndState<Self::HaltReason>, Self::Error> {
self.inner.inspect_system_call_with_caller(caller, contract, data)
}

fn transact_system_call(
&mut self,
caller: Address,
contract: Address,
data: Bytes,
) -> Result<ResultAndState<Self::HaltReason>, Self::Error> {
self.inner.transact_system_call_with_caller_finalize(caller, contract, data)
self.inner.system_call_with_caller(caller, contract, data)
}

fn finish(self) -> (Self::DB, EvmEnv<Self::Spec>) {
Expand Down