chore: Introduce helper type for evm cfg and env tuple (#13377)

This commit is contained in:
Ayodeji Akinola
2024-12-14 09:53:59 +01:00
committed by GitHub
parent 16f6d7a0c3
commit b525231224
33 changed files with 290 additions and 165 deletions

View File

@ -17,7 +17,7 @@ use alloy_rpc_types_eth::{
};
use futures::Future;
use reth_chainspec::EthChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv};
use reth_node_api::BlockBody;
use reth_primitives_traits::SignedTransaction;
use reth_provider::{BlockIdReader, ChainSpecProvider, ProviderHeader};
@ -86,8 +86,8 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
}
// Build cfg and block env, we'll reuse those.
let (mut cfg, mut block_env, block) =
self.evm_env_at(block.unwrap_or_default()).await?;
let (evm_env, block) = self.evm_env_at(block.unwrap_or_default()).await?;
let EvmEnv { mut cfg_env_with_handler_cfg, mut block_env } = evm_env;
// Gas cap for entire operation
let total_gas_limit = self.call_gas_limit();
@ -97,9 +97,9 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
let mut parent_hash = base_block.hash();
// Only enforce base fee if validation is enabled
cfg.disable_base_fee = !validation;
cfg_env_with_handler_cfg.disable_base_fee = !validation;
// Always disable EIP-3607
cfg.disable_eip3607 = true;
cfg_env_with_handler_cfg.disable_eip3607 = true;
let this = self.clone();
self.spawn_with_state_at_block(block, move |state| {
@ -155,7 +155,7 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
&mut calls,
validation,
block_env.gas_limit.to(),
cfg.chain_id,
cfg_env_with_handler_cfg.chain_id,
&mut db,
this.tx_resp_builder(),
)?;
@ -165,7 +165,11 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
let mut results = Vec::with_capacity(calls.len());
while let Some(tx) = calls.next() {
let env = this.build_call_evm_env(cfg.clone(), block_env.clone(), tx)?;
let env = this.build_call_evm_env(
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
tx,
)?;
let (res, env) = {
if trace_transfers {
@ -268,10 +272,11 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
.into();
}
let ((cfg, block_env, _), block) = futures::try_join!(
let ((evm_env, _), block) = futures::try_join!(
self.evm_env_at(target_block),
self.block_with_senders(target_block)
)?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
let block = block.ok_or(EthApiError::HeaderNotFound(target_block))?;
@ -302,7 +307,7 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
let transactions = block.transactions_with_sender().take(num_txs);
for (signer, tx) in transactions {
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg.clone(),
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
RpcNodeCore::evm_config(&this).tx_env(tx, *signer),
);
@ -320,7 +325,13 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
let overrides = EvmOverrides::new(state_overrides, block_overrides.clone());
let env = this
.prepare_call_env(cfg.clone(), block_env.clone(), tx, &mut db, overrides)
.prepare_call_env(
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
tx,
&mut db,
overrides,
)
.map(Into::into)?;
let (res, _) = this.transact(&mut db, env)?;
@ -361,10 +372,11 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
{
async move {
let block_id = block_number.unwrap_or_default();
let (cfg, block, at) = self.evm_env_at(block_id).await?;
let (evm_env, at) = self.evm_env_at(block_id).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
self.spawn_blocking_io(move |this| {
this.create_access_list_with(cfg, block, at, request)
this.create_access_list_with(cfg_env_with_handler_cfg, block_env, at, request)
})
.await
}
@ -571,14 +583,21 @@ pub trait Call:
R: Send + 'static,
{
async move {
let (cfg, block_env, at) = self.evm_env_at(at).await?;
let (evm_env, at) = self.evm_env_at(at).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
let this = self.clone();
self.spawn_blocking_io(move |_| {
let state = this.state_at_block_id(at)?;
let mut db =
CacheDB::new(StateProviderDatabase::new(StateProviderTraitObjWrapper(&state)));
let env = this.prepare_call_env(cfg, block_env, request, &mut db, overrides)?;
let env = this.prepare_call_env(
cfg_env_with_handler_cfg,
block_env,
request,
&mut db,
overrides,
)?;
f(StateCacheDbRefMutWrapper(&mut db), env)
})
@ -614,7 +633,8 @@ pub trait Call:
};
let (tx, tx_info) = transaction.split();
let (cfg, block_env, _) = self.evm_env_at(block.hash().into()).await?;
let (evm_env, _) = self.evm_env_at(block.hash().into()).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
// we need to get the state of the parent block because we're essentially replaying the
// block the transaction is included in
@ -628,14 +648,14 @@ pub trait Call:
// replay all transactions prior to the targeted transaction
this.replay_transactions_until(
&mut db,
cfg.clone(),
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
block_txs,
*tx.tx_hash(),
)?;
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg,
cfg_env_with_handler_cfg,
block_env,
RpcNodeCore::evm_config(&this).tx_env(tx.as_signed(), tx.signer()),
);

View File

@ -6,6 +6,7 @@ use alloy_primitives::U256;
use alloy_rpc_types_eth::{state::StateOverride, transaction::TransactionRequest, BlockId};
use futures::Future;
use reth_chainspec::MIN_TRANSACTION_GAS;
use reth_evm::env::EvmEnv;
use reth_provider::StateProvider;
use reth_revm::{
database::StateProviderDatabase,
@ -259,13 +260,14 @@ pub trait EstimateCall: Call {
Self: LoadPendingBlock,
{
async move {
let (cfg, block_env, at) = self.evm_env_at(at).await?;
let (evm_env, at) = self.evm_env_at(at).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
self.spawn_blocking_io(move |this| {
let state = this.state_at_block_id(at)?;
EstimateCall::estimate_gas_with(
&this,
cfg,
cfg_env_with_handler_cfg,
block_env,
request,
state,

View File

@ -12,8 +12,8 @@ use futures::Future;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_errors::RethError;
use reth_evm::{
state_change::post_block_withdrawals_balance_increments, system_calls::SystemCaller,
ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes,
env::EvmEnv, state_change::post_block_withdrawals_balance_increments,
system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes,
};
use reth_primitives::{BlockExt, InvalidTransactionError, SealedBlockWithSenders};
use reth_primitives_traits::Receipt;
@ -87,13 +87,15 @@ pub trait LoadPendingBlock:
// Note: for the PENDING block we assume it is past the known merge block and
// thus this will not fail when looking up the total
// difficulty value for the blockenv.
let (cfg, block_env) = self
let evm_env = self
.provider()
.env_with_header(block.header(), self.evm_config().clone())
.map_err(Self::Error::from_eth_err)?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
return Ok(PendingBlockEnv::new(
cfg,
cfg_env_with_handler_cfg,
block_env,
PendingBlockEnvOrigin::ActualPending(block, receipts),
));
@ -108,7 +110,7 @@ pub trait LoadPendingBlock:
.map_err(Self::Error::from_eth_err)?
.ok_or(EthApiError::HeaderNotFound(BlockNumberOrTag::Latest.into()))?;
let (cfg, block_env) = self
let EvmEnv { cfg_env_with_handler_cfg, block_env } = self
.evm_config()
.next_cfg_and_block_env(
&latest,
@ -123,7 +125,7 @@ pub trait LoadPendingBlock:
.map_err(Self::Error::from_eth_err)?;
Ok(PendingBlockEnv::new(
cfg,
cfg_env_with_handler_cfg,
block_env,
PendingBlockEnvOrigin::DerivedFromLatest(latest.hash()),
))

View File

@ -10,14 +10,14 @@ use alloy_serde::JsonStorageKey;
use futures::Future;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_errors::RethError;
use reth_evm::ConfigureEvmEnv;
use reth_evm::{env::EvmEnv, ConfigureEvmEnv};
use reth_provider::{
BlockIdReader, BlockNumReader, ChainSpecProvider, EvmEnvProvider as _, ProviderHeader,
StateProvider, StateProviderBox, StateProviderFactory,
};
use reth_rpc_eth_types::{EthApiError, PendingBlockEnv, RpcInvalidTransactionError};
use reth_transaction_pool::TransactionPool;
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId};
use revm_primitives::SpecId;
/// Helper methods for `eth_` methods relating to state (accounts).
pub trait EthState: LoadState + SpawnBlocking {
@ -214,7 +214,7 @@ pub trait LoadState:
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv, BlockId), Self::Error>> + Send
) -> impl Future<Output = Result<(EvmEnv, BlockId), Self::Error>> + Send
where
Self: LoadPendingBlock + SpawnBlocking,
{
@ -222,7 +222,7 @@ pub trait LoadState:
if at.is_pending() {
let PendingBlockEnv { cfg, block_env, origin } =
self.pending_block_env_and_cfg()?;
Ok((cfg, block_env, origin.state_block_id()))
Ok(((cfg, block_env).into(), origin.state_block_id()))
} else {
// Use cached values if there is no pending block
let block_hash = RpcNodeCore::provider(self)
@ -233,11 +233,11 @@ pub trait LoadState:
let header =
self.cache().get_header(block_hash).await.map_err(Self::Error::from_eth_err)?;
let evm_config = self.evm_config().clone();
let (cfg, block_env) = self
let evm_env = self
.provider()
.env_with_header(&header, evm_config)
.map_err(Self::Error::from_eth_err)?;
Ok((cfg, block_env, block_hash.into()))
Ok((evm_env, block_hash.into()))
}
}
}
@ -248,18 +248,19 @@ pub trait LoadState:
fn evm_env_for_raw_block(
&self,
header: &ProviderHeader<Self::Provider>,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv), Self::Error>> + Send
) -> impl Future<Output = Result<EvmEnv, Self::Error>> + Send
where
Self: LoadPendingBlock + SpawnBlocking,
{
async move {
// get the parent config first
let (cfg, mut block_env, _) = self.evm_env_at(header.parent_hash().into()).await?;
let (evm_env, _) = self.evm_env_at(header.parent_hash().into()).await?;
let EvmEnv { cfg_env_with_handler_cfg, mut block_env } = evm_env;
let after_merge = cfg.handler_cfg.spec_id >= SpecId::MERGE;
let after_merge = cfg_env_with_handler_cfg.handler_cfg.spec_id >= SpecId::MERGE;
self.evm_config().fill_block_env(&mut block_env, header, after_merge);
Ok((cfg, block_env))
Ok((cfg_env_with_handler_cfg, block_env).into())
}
}

View File

@ -8,7 +8,7 @@ use alloy_primitives::B256;
use alloy_rpc_types_eth::{BlockId, TransactionInfo};
use futures::Future;
use reth_chainspec::ChainSpecProvider;
use reth_evm::{system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv};
use reth_evm::{env::EvmEnv, system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::SealedBlockWithSenders;
use reth_primitives_traits::{BlockBody, SignedTransaction};
use reth_provider::{BlockReader, ProviderBlock, ProviderHeader, ProviderTx};
@ -195,7 +195,8 @@ pub trait Trace:
};
let (tx, tx_info) = transaction.split();
let (cfg, block_env, _) = self.evm_env_at(block.hash().into()).await?;
let (evm_env, _) = self.evm_env_at(block.hash().into()).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
// we need to get the state of the parent block because we're essentially replaying the
// block the transaction is included in
@ -206,19 +207,24 @@ pub trait Trace:
let mut db = CacheDB::new(StateProviderDatabase::new(state));
let block_txs = block.transactions_with_sender();
this.apply_pre_execution_changes(&block, &mut db, &cfg, &block_env)?;
this.apply_pre_execution_changes(
&block,
&mut db,
&cfg_env_with_handler_cfg,
&block_env,
)?;
// replay all transactions prior to the targeted transaction
this.replay_transactions_until(
&mut db,
cfg.clone(),
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
block_txs,
*tx.tx_hash(),
)?;
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg,
cfg_env_with_handler_cfg,
block_env,
RpcNodeCore::evm_config(&this).tx_env(tx.as_signed(), tx.signer()),
);
@ -308,8 +314,9 @@ pub trait Trace:
self.block_with_senders(block_id).await
};
let ((cfg, block_env, _), block) =
futures::try_join!(self.evm_env_at(block_id), block)?;
let ((evm_env, _), block) = futures::try_join!(self.evm_env_at(block_id), block)?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
let Some(block) = block else { return Ok(None) };
@ -333,7 +340,12 @@ pub trait Trace:
let mut db =
CacheDB::new(StateProviderDatabase::new(StateProviderTraitObjWrapper(&state)));
this.apply_pre_execution_changes(&block, &mut db, &cfg, &block_env)?;
this.apply_pre_execution_changes(
&block,
&mut db,
&cfg_env_with_handler_cfg,
&block_env,
)?;
// prepare transactions, we do everything upfront to reduce time spent with open
// state
@ -362,8 +374,11 @@ pub trait Trace:
.peekable();
while let Some((tx_info, tx)) = transactions.next() {
let env =
EnvWithHandlerCfg::new_with_cfg_env(cfg.clone(), block_env.clone(), tx);
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
tx,
);
let mut inspector = inspector_setup();
let (res, _) =

View File

@ -16,6 +16,7 @@ use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_chainspec::EthereumHardforks;
use reth_evm::{
env::EvmEnv,
execute::{BlockExecutorProvider, Executor},
ConfigureEvmEnv,
};
@ -161,7 +162,8 @@ where
.map_err(BlockError::RlpDecodeRawBlock)
.map_err(Eth::Error::from_eth_err)?;
let (cfg, block_env) = self.eth_api().evm_env_for_raw_block(block.header()).await?;
let evm_env = self.eth_api().evm_env_for_raw_block(block.header()).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
// Depending on EIP-2 we need to recover the transactions differently
let senders =
@ -191,7 +193,7 @@ where
self.trace_block(
Arc::new(block.with_senders_unchecked(senders).seal_slow()),
cfg,
cfg_env_with_handler_cfg,
block_env,
opts,
)
@ -210,14 +212,15 @@ where
.map_err(Eth::Error::from_eth_err)?
.ok_or(EthApiError::HeaderNotFound(block_id))?;
let ((cfg, block_env, _), block) = futures::try_join!(
let ((evm_env, _), block) = futures::try_join!(
self.eth_api().evm_env_at(block_hash.into()),
self.eth_api().block_with_senders(block_hash.into()),
)?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
let block = block.ok_or(EthApiError::HeaderNotFound(block_id))?;
self.trace_block(block, cfg, block_env, opts).await
self.trace_block(block, cfg_env_with_handler_cfg, block_env, opts).await
}
/// Trace the transaction according to the provided options.
@ -232,7 +235,8 @@ where
None => return Err(EthApiError::TransactionNotFound.into()),
Some(res) => res,
};
let (cfg, block_env, _) = self.eth_api().evm_env_at(block.hash().into()).await?;
let (evm_env, _) = self.eth_api().evm_env_at(block.hash().into()).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
// we need to get the state of the parent block because we're essentially replaying the
// block the transaction is included in
@ -249,12 +253,17 @@ where
let mut db = CacheDB::new(StateProviderDatabase::new(state));
this.eth_api().apply_pre_execution_changes(&block, &mut db, &cfg, &block_env)?;
this.eth_api().apply_pre_execution_changes(
&block,
&mut db,
&cfg_env_with_handler_cfg,
&block_env,
)?;
// replay all transactions prior to the targeted transaction
let index = this.eth_api().replay_transactions_until(
&mut db,
cfg.clone(),
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
block_txs,
*tx.tx_hash(),
@ -262,11 +271,11 @@ where
let env = EnvWithHandlerCfg {
env: Env::boxed(
cfg.cfg_env.clone(),
cfg_env_with_handler_cfg.cfg_env.clone(),
block_env,
this.eth_api().evm_config().tx_env(tx.as_signed(), tx.signer()),
),
handler_cfg: cfg.handler_cfg,
handler_cfg: cfg_env_with_handler_cfg.handler_cfg,
};
this.trace_transaction(
@ -440,7 +449,7 @@ where
GethDebugTracerType::JsTracer(code) => {
let config = tracer_config.into_json();
let (_, _, at) = self.eth_api().evm_env_at(at).await?;
let (_, at) = self.eth_api().evm_env_at(at).await?;
let res = self
.eth_api()
@ -502,10 +511,11 @@ where
let transaction_index = transaction_index.unwrap_or_default();
let target_block = block_number.unwrap_or_default();
let ((cfg, mut block_env, _), block) = futures::try_join!(
let ((evm_env, _), block) = futures::try_join!(
self.eth_api().evm_env_at(target_block),
self.eth_api().block_with_senders(target_block),
)?;
let EvmEnv { cfg_env_with_handler_cfg, mut block_env } = evm_env;
let opts = opts.unwrap_or_default();
let block = block.ok_or(EthApiError::HeaderNotFound(target_block))?;
@ -543,11 +553,11 @@ where
for (signer, tx) in transactions {
let env = EnvWithHandlerCfg {
env: Env::boxed(
cfg.cfg_env.clone(),
cfg_env_with_handler_cfg.cfg_env.clone(),
block_env.clone(),
this.eth_api().evm_config().tx_env(tx, *signer),
),
handler_cfg: cfg.handler_cfg,
handler_cfg: cfg_env_with_handler_cfg.handler_cfg,
};
let (res, _) = this.eth_api().transact(&mut db, env)?;
db.commit(res.state);
@ -570,7 +580,7 @@ where
let overrides = EvmOverrides::new(state_overrides, block_overrides.clone());
let env = this.eth_api().prepare_call_env(
cfg.clone(),
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
tx,
&mut db,

View File

@ -5,7 +5,7 @@ use alloy_primitives::{Keccak256, U256};
use alloy_rpc_types_mev::{EthCallBundle, EthCallBundleResponse, EthCallBundleTransactionResult};
use jsonrpsee::core::RpcResult;
use reth_chainspec::EthChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::PooledTransaction;
use reth_primitives_traits::SignedTransaction;
use reth_provider::{ChainSpecProvider, HeaderProvider};
@ -109,7 +109,8 @@ where
let block_id: alloy_rpc_types_eth::BlockId = state_block_number.into();
// Note: the block number is considered the `parent` block: <https://github.com/flashbots/mev-geth/blob/fddf97beec5877483f879a77b7dea2e58a58d653/internal/ethapi/api.go#L2104>
let (cfg, mut block_env, at) = self.eth_api().evm_env_at(block_id).await?;
let (evm_env, at) = self.eth_api().evm_env_at(block_id).await?;
let EvmEnv { cfg_env_with_handler_cfg, mut block_env } = evm_env;
if let Some(coinbase) = coinbase {
block_env.coinbase = coinbase;
@ -140,7 +141,7 @@ where
if let Some(base_fee) = base_fee {
block_env.basefee = U256::from(base_fee);
} else if cfg.handler_cfg.spec_id.is_enabled_in(SpecId::LONDON) {
} else if cfg_env_with_handler_cfg.handler_cfg.spec_id.is_enabled_in(SpecId::LONDON) {
let parent_block = block_env.number.saturating_to::<u64>();
// here we need to fetch the _next_ block's basefee based on the parent block <https://github.com/flashbots/mev-geth/blob/fddf97beec5877483f879a77b7dea2e58a58d653/internal/ethapi/api.go#L2130>
let parent = RpcNodeCore::provider(self.eth_api())
@ -166,7 +167,11 @@ where
.spawn_with_state_at_block(at, move |state| {
let coinbase = block_env.coinbase;
let basefee = Some(block_env.basefee.to::<u64>());
let env = EnvWithHandlerCfg::new_with_cfg_env(cfg, block_env, TxEnv::default());
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg_env_with_handler_cfg,
block_env,
TxEnv::default(),
);
let db = CacheDB::new(StateProviderDatabase::new(state));
let initial_coinbase = db

View File

@ -10,7 +10,7 @@ use alloy_rpc_types_mev::{
};
use jsonrpsee::core::RpcResult;
use reth_chainspec::EthChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv};
use reth_provider::{ChainSpecProvider, HeaderProvider, ProviderTx};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_api::MevSimApiServer;
@ -245,7 +245,8 @@ where
let flattened_bundle = self.parse_and_flatten_bundle(&request)?;
let block_id = parent_block.unwrap_or(BlockId::Number(BlockNumberOrTag::Pending));
let (cfg, mut block_env, current_block) = self.eth_api().evm_env_at(block_id).await?;
let (evm_env, current_block) = self.eth_api().evm_env_at(block_id).await?;
let EvmEnv { cfg_env_with_handler_cfg, mut block_env } = evm_env;
let parent_header = RpcNodeCore::provider(&self.inner.eth_api)
.header_by_number(block_env.number.saturating_to::<u64>())
@ -273,7 +274,7 @@ where
if let Some(base_fee) = base_fee {
block_env.basefee = U256::from(base_fee);
} else if cfg.handler_cfg.spec_id.is_enabled_in(SpecId::LONDON) {
} else if cfg_env_with_handler_cfg.handler_cfg.spec_id.is_enabled_in(SpecId::LONDON) {
if let Some(base_fee) = parent_header.next_block_base_fee(
RpcNodeCore::provider(&self.inner.eth_api)
.chain_spec()
@ -293,7 +294,11 @@ where
let current_block_number = current_block.as_u64().unwrap();
let coinbase = block_env.coinbase;
let basefee = block_env.basefee;
let env = EnvWithHandlerCfg::new_with_cfg_env(cfg, block_env, TxEnv::default());
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg_env_with_handler_cfg,
block_env,
TxEnv::default(),
);
let db = CacheDB::new(StateProviderDatabase::new(state));
let initial_coinbase_balance = DatabaseRef::basic_ref(&db, coinbase)

View File

@ -18,7 +18,7 @@ use reth_chainspec::EthereumHardforks;
use reth_consensus_common::calc::{
base_block_reward, base_block_reward_pre_merge, block_reward, ommer_reward,
};
use reth_evm::ConfigureEvmEnv;
use reth_evm::{env::EvmEnv, ConfigureEvmEnv};
use reth_primitives_traits::{BlockBody, BlockHeader};
use reth_provider::{BlockNumReader, BlockReader, ChainSpecProvider, HeaderProvider};
use reth_revm::database::StateProviderDatabase;
@ -117,11 +117,12 @@ where
let tx = recover_raw_transaction::<PoolPooledTx<Eth::Pool>>(&tx)?
.map_transaction(<Eth::Pool as TransactionPool>::Transaction::pooled_into_consensus);
let (cfg, block, at) = self.eth_api().evm_env_at(block_id.unwrap_or_default()).await?;
let (evm_env, at) = self.eth_api().evm_env_at(block_id.unwrap_or_default()).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg,
block,
cfg_env_with_handler_cfg,
block_env,
self.eth_api().evm_config().tx_env(tx.as_signed(), tx.signer()),
);
@ -147,7 +148,8 @@ where
block_id: Option<BlockId>,
) -> Result<Vec<TraceResults>, Eth::Error> {
let at = block_id.unwrap_or(BlockId::pending());
let (cfg, block_env, at) = self.eth_api().evm_env_at(at).await?;
let (evm_env, at) = self.eth_api().evm_env_at(at).await?;
let EvmEnv { cfg_env_with_handler_cfg, block_env } = evm_env;
let this = self.clone();
// execute all transactions on top of each other and record the traces
@ -160,7 +162,7 @@ where
while let Some((call, trace_types)) = calls.next() {
let env = this.eth_api().prepare_call_env(
cfg.clone(),
cfg_env_with_handler_cfg.clone(),
block_env.clone(),
call,
&mut db,