chore(rpc): remove redundant LoadState::cache (#12147)

This commit is contained in:
Emilia Hane
2024-10-29 02:10:30 +08:00
committed by GitHub
parent 28f8c47dc0
commit 37d9643607
3 changed files with 7 additions and 23 deletions

View File

@ -215,17 +215,12 @@ where
} }
} }
impl<N> LoadState for OpEthApi<N> impl<N> LoadState for OpEthApi<N> where
where
N: RpcNodeCore< N: RpcNodeCore<
Provider: StateProviderFactory + ChainSpecProvider<ChainSpec: EthereumHardforks>, Provider: StateProviderFactory + ChainSpecProvider<ChainSpec: EthereumHardforks>,
Pool: TransactionPool, Pool: TransactionPool,
>, >
{ {
#[inline]
fn cache(&self) -> &EthStateCache {
self.inner.cache()
}
} }
impl<N> EthState for OpEthApi<N> impl<N> EthState for OpEthApi<N>

View File

@ -13,12 +13,12 @@ use reth_provider::{
BlockIdReader, BlockNumReader, ChainSpecProvider, StateProvider, StateProviderBox, BlockIdReader, BlockNumReader, ChainSpecProvider, StateProvider, StateProviderBox,
StateProviderFactory, StateProviderFactory,
}; };
use reth_rpc_eth_types::{EthApiError, EthStateCache, PendingBlockEnv, RpcInvalidTransactionError}; use reth_rpc_eth_types::{EthApiError, PendingBlockEnv, RpcInvalidTransactionError};
use reth_rpc_types_compat::proof::from_primitive_account_proof; use reth_rpc_types_compat::proof::from_primitive_account_proof;
use reth_transaction_pool::TransactionPool; use reth_transaction_pool::TransactionPool;
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId}; use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId};
use crate::{EthApiTypes, FromEthApiError, RpcNodeCore}; use crate::{EthApiTypes, FromEthApiError, RpcNodeCore, RpcNodeCoreExt};
use super::{EthApiSpec, LoadPendingBlock, SpawnBlocking}; use super::{EthApiSpec, LoadPendingBlock, SpawnBlocking};
@ -170,17 +170,12 @@ pub trait EthState: LoadState + SpawnBlocking {
/// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` state RPC methods. /// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` state RPC methods.
pub trait LoadState: pub trait LoadState:
EthApiTypes EthApiTypes
+ RpcNodeCore< + RpcNodeCoreExt<
Provider: StateProviderFactory Provider: StateProviderFactory
+ ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>, + ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>,
Pool: TransactionPool, Pool: TransactionPool,
> >
{ {
/// Returns a handle for reading data from memory.
///
/// Data access in default (L1) trait method implementations.
fn cache(&self) -> &EthStateCache;
/// Returns the state at the given block number /// Returns the state at the given block number
fn state_at_hash(&self, block_hash: B256) -> Result<StateProviderBox, Self::Error> { fn state_at_hash(&self, block_hash: B256) -> Result<StateProviderBox, Self::Error> {
self.provider().history_by_block_hash(block_hash).map_err(Self::Error::from_eth_err) self.provider().history_by_block_hash(block_hash).map_err(Self::Error::from_eth_err)

View File

@ -8,7 +8,6 @@ use reth_rpc_eth_api::{
helpers::{EthState, LoadState, SpawnBlocking}, helpers::{EthState, LoadState, SpawnBlocking},
RpcNodeCore, RpcNodeCore,
}; };
use reth_rpc_eth_types::EthStateCache;
use crate::EthApi; use crate::EthApi;
@ -21,17 +20,12 @@ where
} }
} }
impl<Provider, Pool, Network, EvmConfig> LoadState for EthApi<Provider, Pool, Network, EvmConfig> impl<Provider, Pool, Network, EvmConfig> LoadState for EthApi<Provider, Pool, Network, EvmConfig> where
where
Self: RpcNodeCore< Self: RpcNodeCore<
Provider: StateProviderFactory + ChainSpecProvider<ChainSpec: EthereumHardforks>, Provider: StateProviderFactory + ChainSpecProvider<ChainSpec: EthereumHardforks>,
Pool: TransactionPool, Pool: TransactionPool,
>, >
{ {
#[inline]
fn cache(&self) -> &EthStateCache {
self.inner.cache()
}
} }
#[cfg(test)] #[cfg(test)]