mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: generic TxEnv (#13957)
This commit is contained in:
@ -19,7 +19,7 @@ use reth_evm::{
|
||||
},
|
||||
state_change::post_block_balance_increments,
|
||||
system_calls::{OnStateHook, SystemCaller},
|
||||
ConfigureEvm, Evm, TxEnvOverrides,
|
||||
ConfigureEvm, Evm,
|
||||
};
|
||||
use reth_primitives::{EthPrimitives, Receipt, RecoveredBlock};
|
||||
use reth_primitives_traits::{BlockBody, SignedTransaction};
|
||||
@ -94,8 +94,6 @@ where
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
/// How to create an EVM.
|
||||
evm_config: EvmConfig,
|
||||
/// Optional overrides for the transactions environment.
|
||||
tx_env_overrides: Option<Box<dyn TxEnvOverrides>>,
|
||||
/// Current state for block execution.
|
||||
state: State<DB>,
|
||||
/// Utility to call system smart contracts.
|
||||
@ -109,7 +107,7 @@ where
|
||||
/// Creates a new [`EthExecutionStrategy`]
|
||||
pub fn new(state: State<DB>, chain_spec: Arc<ChainSpec>, evm_config: EvmConfig) -> Self {
|
||||
let system_caller = SystemCaller::new(evm_config.clone(), chain_spec.clone());
|
||||
Self { state, chain_spec, evm_config, system_caller, tx_env_overrides: None }
|
||||
Self { state, chain_spec, evm_config, system_caller }
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,13 +121,8 @@ where
|
||||
{
|
||||
type DB = DB;
|
||||
type Error = BlockExecutionError;
|
||||
|
||||
type Primitives = EthPrimitives;
|
||||
|
||||
fn init(&mut self, tx_env_overrides: Box<dyn TxEnvOverrides>) {
|
||||
self.tx_env_overrides = Some(tx_env_overrides);
|
||||
}
|
||||
|
||||
fn apply_pre_execution_changes(
|
||||
&mut self,
|
||||
block: &RecoveredBlock<reth_primitives::Block>,
|
||||
@ -166,11 +159,7 @@ where
|
||||
.into())
|
||||
}
|
||||
|
||||
let mut tx_env = self.evm_config.tx_env(transaction, *sender);
|
||||
|
||||
if let Some(tx_env_overrides) = &mut self.tx_env_overrides {
|
||||
tx_env_overrides.apply(&mut tx_env);
|
||||
}
|
||||
let tx_env = self.evm_config.tx_env(transaction, *sender);
|
||||
|
||||
// Execute transaction.
|
||||
let result_and_state = evm.transact(tx_env).map_err(move |err| {
|
||||
|
||||
@ -150,6 +150,7 @@ impl ConfigureEvmEnv for EthEvmConfig {
|
||||
type Header = Header;
|
||||
type Transaction = TransactionSigned;
|
||||
type Error = Infallible;
|
||||
type TxEnv = TxEnv;
|
||||
|
||||
fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
|
||||
transaction.fill_tx_env(tx_env, sender);
|
||||
|
||||
Reference in New Issue
Block a user