feat: ConfigureEvm::NextBlockEnvCtx (#14801)

This commit is contained in:
Arsenii Kulikov
2025-03-03 21:11:57 +04:00
committed by GitHub
parent 6a4a1e1f67
commit 7413f11aa2
17 changed files with 150 additions and 79 deletions

View File

@@ -107,7 +107,7 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
for block in block_state_calls {
let mut evm_env = this
.evm_config()
.next_evm_env(&parent, this.next_env_attributes(&parent)?)
.next_evm_env(&parent, &this.next_env_attributes(&parent)?)
.map_err(RethError::other)
.map_err(Self::Error::from_eth_err)?;

View File

@@ -12,7 +12,7 @@ use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_errors::{BlockExecutionError, BlockValidationError, RethError};
use reth_evm::{
execute::{BlockExecutionStrategy, BlockExecutionStrategyFactory},
ConfigureEvmEnv, Evm, NextBlockEnvAttributes,
ConfigureEvmEnv, Evm,
};
use reth_node_api::NodePrimitives;
use reth_primitives::{InvalidTransactionError, RecoveredBlock, SealedHeader};
@@ -111,27 +111,18 @@ pub trait LoadPendingBlock:
let evm_env = self
.evm_config()
.next_evm_env(&latest, self.next_env_attributes(&latest)?)
.next_evm_env(&latest, &self.next_env_attributes(&latest)?)
.map_err(RethError::other)
.map_err(Self::Error::from_eth_err)?;
Ok(PendingBlockEnv::new(evm_env, PendingBlockEnvOrigin::DerivedFromLatest(latest)))
}
/// Returns [`NextBlockEnvAttributes`] for building a local pending block.
/// Returns [`ConfigureEvmEnv::NextBlockEnvCtx`] for building a local pending block.
fn next_env_attributes(
&self,
parent: &SealedHeader<ProviderHeader<Self::Provider>>,
) -> Result<NextBlockEnvAttributes<'_>, Self::Error> {
Ok(NextBlockEnvAttributes {
timestamp: parent.timestamp().saturating_add(12),
suggested_fee_recipient: parent.beneficiary(),
prev_randao: B256::random(),
gas_limit: parent.gas_limit(),
parent_beacon_block_root: parent.parent_beacon_block_root(),
withdrawals: None,
})
}
) -> Result<<Self::Evm as ConfigureEvmEnv>::NextBlockEnvCtx, Self::Error>;
/// Returns the locally built pending block
#[expect(clippy::type_complexity)]