diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index d3790251e5..0ad6c7ba0c 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -666,7 +666,7 @@ pub trait Call: }; let (tx, tx_info) = transaction.split(); - let (evm_env, _) = self.evm_env_at(block.hash().into()).await?; + let evm_env = self.evm_env_for_header(block.sealed_block().sealed_header())?; // we need to get the state of the parent block because we're essentially replaying the // block the transaction is included in diff --git a/crates/rpc/rpc-eth-api/src/helpers/state.rs b/crates/rpc/rpc-eth-api/src/helpers/state.rs index 9f55bae972..0638e1eea1 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/state.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/state.rs @@ -11,6 +11,7 @@ use alloy_serde::JsonStorageKey; use futures::Future; use reth_errors::RethError; use reth_evm::{ConfigureEvm, EvmEnvFor}; +use reth_primitives_traits::SealedHeaderFor; use reth_rpc_convert::RpcConvert; use reth_rpc_eth_types::{ error::FromEvmError, EthApiError, PendingBlockEnv, RpcInvalidTransactionError, @@ -256,6 +257,17 @@ pub trait LoadState: } } + /// Returns the revm evm env for the given sealed header. + fn evm_env_for_header( + &self, + header: &SealedHeaderFor, + ) -> Result, Self::Error> { + self.evm_config() + .evm_env(header) + .map_err(RethError::other) + .map_err(Self::Error::from_eth_err) + } + /// Returns the revm evm env for the requested [`BlockId`] /// /// If the [`BlockId`] this will return the [`BlockId`] of the block the env was configured @@ -281,11 +293,7 @@ pub trait LoadState: .sealed_header_by_id(at) .map_err(Self::Error::from_eth_err)? .ok_or_else(|| EthApiError::HeaderNotFound(at))?; - let evm_env = self - .evm_config() - .evm_env(&header) - .map_err(RethError::other) - .map_err(Self::Error::from_eth_err)?; + let evm_env = self.evm_env_for_header(&header)?; Ok((evm_env, header.hash().into())) } diff --git a/crates/rpc/rpc-eth-api/src/helpers/trace.rs b/crates/rpc/rpc-eth-api/src/helpers/trace.rs index 20440725a8..ef6443c382 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/trace.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/trace.rs @@ -168,7 +168,7 @@ pub trait Trace: LoadState> + Call { }; let (tx, tx_info) = transaction.split(); - let (evm_env, _) = self.evm_env_at(block.hash().into()).await?; + let evm_env = self.evm_env_for_header(block.sealed_block().sealed_header())?; // we need to get the state of the parent block because we're essentially replaying the // block the transaction is included in