mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
feat(node_builder): allow borrowing self in ConfigureEvm::evm (#8024)
This commit is contained in:
@@ -46,11 +46,8 @@ where
|
||||
sp: SP,
|
||||
) -> Box<dyn PrunableBlockExecutor<Error = BlockExecutionError> + 'a> {
|
||||
let database_state = StateProviderDatabase::new(sp);
|
||||
let mut evm = EVMProcessor::new_with_db(
|
||||
self.chain_spec.clone(),
|
||||
database_state,
|
||||
self.evm_config.clone(),
|
||||
);
|
||||
let mut evm =
|
||||
EVMProcessor::new_with_db(self.chain_spec.clone(), database_state, &self.evm_config);
|
||||
if let Some(stack) = &self.stack {
|
||||
evm.set_stack(stack.clone());
|
||||
}
|
||||
|
||||
@@ -242,10 +242,11 @@ mod tests {
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
db: StateProviderTest,
|
||||
) -> EVMProcessor<'a, TestEvmConfig> {
|
||||
static CONFIG: std::sync::OnceLock<TestEvmConfig> = std::sync::OnceLock::new();
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
CONFIG.get_or_init(TestEvmConfig::default),
|
||||
);
|
||||
executor.evm.context.evm.db.load_cache_account(L1_BLOCK_CONTRACT).unwrap();
|
||||
executor
|
||||
|
||||
@@ -7,7 +7,7 @@ use revm::{
|
||||
primitives::{CfgEnvWithHandlerCfg, ResultAndState},
|
||||
Evm, State,
|
||||
};
|
||||
use std::{sync::Arc, time::Instant};
|
||||
use std::{marker::PhantomData, sync::Arc, time::Instant};
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
use tracing::{debug, trace};
|
||||
|
||||
@@ -59,7 +59,7 @@ pub struct EVMProcessor<'a, EvmConfig> {
|
||||
/// Execution stats
|
||||
pub(crate) stats: BlockExecutorStats,
|
||||
/// The type that is able to configure the EVM environment.
|
||||
_evm_config: EvmConfig,
|
||||
_phantom: PhantomData<EvmConfig>,
|
||||
}
|
||||
|
||||
impl<'a, EvmConfig> EVMProcessor<'a, EvmConfig>
|
||||
@@ -75,7 +75,7 @@ where
|
||||
pub fn new_with_db<DB: StateProvider + 'a>(
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
db: StateProviderDatabase<DB>,
|
||||
evm_config: EvmConfig,
|
||||
evm_config: &'a EvmConfig,
|
||||
) -> Self {
|
||||
let state = State::builder()
|
||||
.with_database_boxed(Box::new(db))
|
||||
@@ -89,7 +89,7 @@ where
|
||||
pub fn new_with_state(
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
revm_state: StateDBBox<'a, ProviderError>,
|
||||
evm_config: EvmConfig,
|
||||
evm_config: &'a EvmConfig,
|
||||
) -> Self {
|
||||
let stack = InspectorStack::new(InspectorStackConfig::default());
|
||||
let evm = evm_config.evm_with_inspector(revm_state, stack);
|
||||
@@ -98,7 +98,7 @@ where
|
||||
evm,
|
||||
batch_record: BlockBatchRecord::default(),
|
||||
stats: BlockExecutorStats::default(),
|
||||
_evm_config: evm_config,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,11 +507,9 @@ mod tests {
|
||||
);
|
||||
|
||||
// execute invalid header (no parent beacon block root)
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
);
|
||||
let evm_config = TestEvmConfig::default();
|
||||
let mut executor =
|
||||
EVMProcessor::new_with_db(chain_spec, StateProviderDatabase::new(db), &evm_config);
|
||||
|
||||
// attempt to execute a block without parent beacon block root, expect err
|
||||
let err = executor
|
||||
@@ -599,11 +597,9 @@ mod tests {
|
||||
.build(),
|
||||
);
|
||||
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
);
|
||||
let evm_config = TestEvmConfig::default();
|
||||
let mut executor =
|
||||
EVMProcessor::new_with_db(chain_spec, StateProviderDatabase::new(db), &evm_config);
|
||||
executor.init_env(&header, U256::ZERO);
|
||||
|
||||
// get the env
|
||||
@@ -648,11 +644,9 @@ mod tests {
|
||||
.build(),
|
||||
);
|
||||
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
);
|
||||
let evm_config = TestEvmConfig::default();
|
||||
let mut executor =
|
||||
EVMProcessor::new_with_db(chain_spec, StateProviderDatabase::new(db), &evm_config);
|
||||
|
||||
// construct the header for block one
|
||||
let header = Header {
|
||||
@@ -702,11 +696,9 @@ mod tests {
|
||||
|
||||
let mut header = chain_spec.genesis_header();
|
||||
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
);
|
||||
let evm_config = TestEvmConfig::default();
|
||||
let mut executor =
|
||||
EVMProcessor::new_with_db(chain_spec, StateProviderDatabase::new(db), &evm_config);
|
||||
executor.init_env(&header, U256::ZERO);
|
||||
|
||||
// attempt to execute the genesis block with non-zero parent beacon block root, expect err
|
||||
@@ -781,11 +773,9 @@ mod tests {
|
||||
);
|
||||
|
||||
// execute header
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
);
|
||||
let evm_config = TestEvmConfig::default();
|
||||
let mut executor =
|
||||
EVMProcessor::new_with_db(chain_spec, StateProviderDatabase::new(db), &evm_config);
|
||||
executor.init_env(&header, U256::ZERO);
|
||||
|
||||
// ensure that the env is configured with a base fee
|
||||
@@ -843,11 +833,9 @@ mod tests {
|
||||
let chain_id = chain_spec.chain.id();
|
||||
|
||||
// execute header
|
||||
let mut executor = EVMProcessor::new_with_db(
|
||||
chain_spec,
|
||||
StateProviderDatabase::new(db),
|
||||
TestEvmConfig::default(),
|
||||
);
|
||||
let evm_config = TestEvmConfig::default();
|
||||
let mut executor =
|
||||
EVMProcessor::new_with_db(chain_spec, StateProviderDatabase::new(db), &evm_config);
|
||||
|
||||
// Create a test transaction that gonna fail
|
||||
let transaction = TransactionSigned::from_transaction_and_signature(
|
||||
|
||||
Reference in New Issue
Block a user