diff --git a/crates/rpc/rpc-eth-api/src/helpers/state.rs b/crates/rpc/rpc-eth-api/src/helpers/state.rs index 7324705ca519..37ed66aba139 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/state.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/state.rs @@ -2,7 +2,7 @@ //! RPC methods. use super::{EthApiSpec, LoadPendingBlock, SpawnBlocking}; use crate::{EthApiTypes, FromEthApiError, RpcNodeCore, RpcNodeCoreExt}; -use alloy_consensus::{constants::KECCAK_EMPTY, BlockHeader}; +use alloy_consensus::constants::KECCAK_EMPTY; use alloy_eips::BlockId; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_rpc_types_eth::{Account, EIP1186AccountProofResponse}; @@ -10,14 +10,13 @@ use alloy_serde::JsonStorageKey; use futures::Future; use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_errors::RethError; -use reth_evm::{env::EvmEnv, ConfigureEvmEnv}; +use reth_evm::env::EvmEnv; use reth_provider::{ - BlockIdReader, BlockNumReader, ChainSpecProvider, EvmEnvProvider as _, ProviderHeader, - StateProvider, StateProviderBox, StateProviderFactory, + BlockIdReader, BlockNumReader, ChainSpecProvider, EvmEnvProvider as _, StateProvider, + StateProviderBox, StateProviderFactory, }; use reth_rpc_eth_types::{EthApiError, PendingBlockEnv, RpcInvalidTransactionError}; use reth_transaction_pool::TransactionPool; -use revm_primitives::SpecId; /// Helper methods for `eth_` methods relating to state (accounts). pub trait EthState: LoadState + SpawnBlocking { @@ -232,38 +231,15 @@ 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 evm_env = self .provider() - .env_with_header(&header, evm_config) + .env_with_header(&header, self.evm_config().clone()) .map_err(Self::Error::from_eth_err)?; Ok((evm_env, block_hash.into())) } } } - /// Returns the revm evm env for the raw block header - /// - /// This is used for tracing raw blocks - fn evm_env_for_raw_block( - &self, - header: &ProviderHeader, - ) -> impl Future> + Send - where - Self: LoadPendingBlock + SpawnBlocking, - { - async move { - // get the parent config first - 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_env_with_handler_cfg.handler_cfg.spec_id >= SpecId::MERGE; - self.evm_config().fill_block_env(&mut block_env, header, after_merge); - - Ok((cfg_env_with_handler_cfg, block_env).into()) - } - } - /// Returns the next available nonce without gaps for the given address /// Next available nonce is either the on chain nonce of the account or the highest consecutive /// nonce in the pool + 1 diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index ec405cab9d2c..5a431699b33a 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -23,8 +23,8 @@ use reth_evm::{ use reth_primitives::{BlockExt, NodePrimitives, ReceiptWithBloom, SealedBlockWithSenders}; use reth_primitives_traits::{Block as _, BlockBody, SignedTransaction}; use reth_provider::{ - BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider, ProviderBlock, - ReceiptProviderIdExt, StateProofProvider, TransactionVariant, + BlockIdReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, + ProviderBlock, ReceiptProviderIdExt, StateProofProvider, TransactionVariant, }; use reth_revm::{database::StateProviderDatabase, witness::ExecutionWitnessRecord}; use reth_rpc_api::DebugApiServer; @@ -162,8 +162,11 @@ where .map_err(BlockError::RlpDecodeRawBlock) .map_err(Eth::Error::from_eth_err)?; - 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; + // Note: we assume the block has a valid height + let EvmEnv { cfg_env_with_handler_cfg, block_env } = self + .provider() + .env_with_header(block.header(), self.eth_api().evm_config().clone()) + .map_err(Eth::Error::from_eth_err)?; // Depending on EIP-2 we need to recover the transactions differently let senders =