Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make trait methods stateful
  • Loading branch information
Rjected committed Feb 23, 2024
commit 5f84bf0c6a92c19480e23f13f4db17c3132354b5
4 changes: 2 additions & 2 deletions crates/node-api/src/evm/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId, TxEnv};
/// Trait for configuring the EVM for executing full blocks.
pub trait ConfigureEvm: ConfigureEvmEnv {
/// Returns new EVM with the given database
fn evm<'a, DB: Database + 'a>(db: DB) -> Evm<'a, (), DB> {
fn evm<'a, DB: Database + 'a>(&self, db: DB) -> Evm<'a, (), DB> {
EvmBuilder::default().with_db(db).build()
}

/// Returns a new EVM with the given inspector
fn evm_with_inspector<'a, DB: Database + 'a, I>(db: DB, inspector: I) -> Evm<'a, I, DB> {
fn evm_with_inspector<'a, DB: Database + 'a, I>(&self, db: DB, inspector: I) -> Evm<'a, I, DB> {
EvmBuilder::default().with_db(db).with_external_context(inspector).build()
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/node-optimism/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ impl ConfigureEvmEnv for OptimismEvmConfig {

impl ConfigureEvm for OptimismEvmConfig {
/// Returns new EVM with the given database
fn evm<'a, DB: Database + 'a>(db: DB) -> Evm<'a, (), DB> {
fn evm<'a, DB: Database + 'a>(&self, db: DB) -> Evm<'a, (), DB> {
let handler_cfg = HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true };
EvmBuilder::default().with_db(db).with_handler_cfg(handler_cfg).build()
}

/// Returns a new EVM with the given inspector
fn evm_with_inspector<'a, DB: Database + 'a, I>(db: DB, inspector: I) -> Evm<'a, I, DB> {
fn evm_with_inspector<'a, DB: Database + 'a, I>(&self, db: DB, inspector: I) -> Evm<'a, I, DB> {
let handler_cfg = HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true };
EvmBuilder::default()
.with_db(db)
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where

// Hook and inspector stack that we want to invoke on that hook.
let stack = InspectorStack::new(InspectorStackConfig::default());
let evm = EvmConfig::evm_with_inspector(db, stack);
let evm = evm_config.evm_with_inspector(db, stack);
EVMProcessor {
chain_spec,
evm,
Expand Down Expand Up @@ -135,7 +135,7 @@ where
evm_config: EvmConfig,
) -> Self {
let stack = InspectorStack::new(InspectorStackConfig::default());
let evm = EvmConfig::evm_with_inspector(revm_state, stack);
let evm = evm_config.evm_with_inspector(revm_state, stack);
EVMProcessor {
chain_spec,
evm,
Expand Down