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
update evm trait to work with inspectors
  • Loading branch information
Rjected committed Feb 23, 2024
commit 4d4c319b4b3eecd2cbf5e3fc498824041388d90b
19 changes: 9 additions & 10 deletions crates/node-api/src/evm/traits.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use reth_primitives::{
revm::env::fill_block_env, Address, BlockWithSenders, ChainSpec, Header, Receipt, Transaction,
U256,
};
// use revm::{builder::SetGenericStage, db::EmptyDB, EvmBuilder};
use revm::{db::EmptyDB, Database, Evm, EvmBuilder};
use reth_primitives::{revm::env::fill_block_env, Address, ChainSpec, Header, Transaction, U256};
use revm::{Database, Evm, EvmBuilder};
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId, TxEnv};

/// Trait for configuring the EVM for executing full blocks.
pub trait EvmConfig: ConfigureEvmEnv {
// type Executor;

/// Returns new EVM builder
fn evm<DB: Database>(&self, db: DB) -> Evm<'static, (), DB> {
/// Returns new EVM with the given database
fn evm<'a, DB: Database + 'a>(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> {
EvmBuilder::default().with_db(db).with_external_context(inspector).build()
}
}

/// This represents the set of methods used to configure the EVM before execution.
Expand Down
3 changes: 1 addition & 2 deletions crates/node-ethereum/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ impl ConfigureEvmEnv for EthEvmConfig {
}
}

impl EvmConfig for EthEvmConfig {
}
impl EvmConfig for EthEvmConfig {}

#[cfg(test)]
mod tests {
Expand Down
6 changes: 2 additions & 4 deletions crates/revm/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ where
revm_state: StateDBBox<'a, ProviderError>,
evm_config: EvmConfig,
) -> Self {
let evm = Evm::builder()
.with_db(revm_state)
.with_external_context(InspectorStack::new(InspectorStackConfig::default()))
.build();
let stack = InspectorStack::new(InspectorStackConfig::default());
let evm = EvmConfig::evm_with_inspector(revm_state, stack);
EVMProcessor {
chain_spec,
evm,
Expand Down