diff --git a/crates/rpc/rpc/src/eth/api/mod.rs b/crates/rpc/rpc/src/eth/api/mod.rs index dac35c88db..20eb3e9daf 100644 --- a/crates/rpc/rpc/src/eth/api/mod.rs +++ b/crates/rpc/rpc/src/eth/api/mod.rs @@ -3,14 +3,13 @@ //! The entire implementation of the namespace is quite large, hence it is divided across several //! files. -use crate::eth::{cache::EthStateCache, error::EthResult, signer::EthSigner}; +use crate::eth::{cache::EthStateCache, signer::EthSigner}; use async_trait::async_trait; use reth_interfaces::Result; use reth_network_api::NetworkInfo; use reth_primitives::{Address, BlockId, BlockNumberOrTag, ChainInfo, H256, U64}; use reth_provider::{ - providers::ChainState, BlockProvider, EvmEnvProvider, StateProvider as StateProviderTrait, - StateProviderFactory, + BlockProvider, EvmEnvProvider, StateProvider as StateProviderTrait, StateProviderFactory, }; use reth_rpc_types::FeeHistoryCache; use reth_transaction_pool::TransactionPool; @@ -134,14 +133,6 @@ where self.client().convert_block_number(num) } - /// Helper function to execute a closure with the database at a specific block. - pub(crate) fn with_state_at(&self, _at: BlockId, _f: F) -> EthResult - where - F: FnOnce(ChainState<'_>) -> T, - { - unimplemented!() - } - /// Returns the state at the given [BlockId] enum or the latest. pub(crate) fn state_at_block_id_or_latest( &self, diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 16d898e48a..c603226483 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -8,7 +8,7 @@ use reth_primitives::{ BlockId, BlockNumberOrTag, Bytes, FromRecoveredTransaction, IntoRecoveredTransaction, TransactionSigned, TransactionSignedEcRecovered, H256, U256, }; -use reth_provider::{BlockProvider, EvmEnvProvider, StateProviderFactory}; +use reth_provider::{providers::ChainState, BlockProvider, EvmEnvProvider, StateProviderFactory}; use reth_rlp::Decodable; use reth_rpc_types::{Index, Transaction, TransactionRequest}; use reth_transaction_pool::{TransactionOrigin, TransactionPool}; @@ -17,6 +17,11 @@ use revm::primitives::{BlockEnv, CfgEnv}; /// Commonly used transaction related functions for the [EthApi] type in the `eth_` namespace #[async_trait::async_trait] pub trait EthTransactions: Send + Sync { + /// Executes the closure with the state that corresponds to the given [BlockId]. + fn with_state_at(&self, _at: BlockId, _f: F) -> EthResult + where + F: FnOnce(ChainState<'_>) -> EthResult; + /// Returns the revm evm env for the requested [BlockId] /// /// If the [BlockId] this will return the [BlockId::Hash] of the block the env was configured @@ -44,6 +49,13 @@ where Client: BlockProvider + StateProviderFactory + EvmEnvProvider + 'static, Network: Send + Sync + 'static, { + fn with_state_at(&self, _at: BlockId, _f: F) -> EthResult + where + F: FnOnce(ChainState<'_>) -> EthResult, + { + unimplemented!() + } + async fn evm_env_at(&self, at: BlockId) -> EthResult<(CfgEnv, BlockEnv, BlockId)> { // TODO handle Pending state's env match at {