mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 08:08:15 -05:00
chore(rpc): define trait RpcNodeCoreExt and replace LoadBlock::cache (#12141)
This commit is contained in:
@@ -4,7 +4,6 @@ use alloy_rpc_types::BlockId;
|
||||
use op_alloy_network::Network;
|
||||
use op_alloy_rpc_types::OpTransactionReceipt;
|
||||
use reth_chainspec::ChainSpecProvider;
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_primitives::TransactionMeta;
|
||||
use reth_provider::HeaderProvider;
|
||||
@@ -12,7 +11,6 @@ use reth_rpc_eth_api::{
|
||||
helpers::{EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt, SpawnBlocking},
|
||||
RpcNodeCore, RpcReceipt,
|
||||
};
|
||||
use reth_rpc_eth_types::EthStateCache;
|
||||
|
||||
use crate::{OpEthApi, OpEthApiError, OpReceiptBuilder};
|
||||
|
||||
@@ -80,10 +78,6 @@ where
|
||||
impl<N> LoadBlock for OpEthApi<N>
|
||||
where
|
||||
Self: LoadPendingBlock + SpawnBlocking,
|
||||
N: FullNodeComponents,
|
||||
N: RpcNodeCore,
|
||||
{
|
||||
#[inline]
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
self.inner.cache()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ use reth_rpc_eth_api::{
|
||||
AddDevSigners, EthApiSpec, EthFees, EthSigner, EthState, LoadBlock, LoadFee, LoadState,
|
||||
SpawnBlocking, Trace,
|
||||
},
|
||||
EthApiTypes, RpcNodeCore,
|
||||
EthApiTypes, RpcNodeCore, RpcNodeCoreExt,
|
||||
};
|
||||
use reth_rpc_eth_types::{EthStateCache, FeeHistoryCache, GasPriceOracle};
|
||||
use reth_tasks::{
|
||||
@@ -116,7 +116,6 @@ where
|
||||
|
||||
impl<N> RpcNodeCore for OpEthApi<N>
|
||||
where
|
||||
Self: Clone,
|
||||
N: RpcNodeCore,
|
||||
{
|
||||
type Provider = N::Provider;
|
||||
@@ -141,6 +140,16 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> RpcNodeCoreExt for OpEthApi<N>
|
||||
where
|
||||
N: RpcNodeCore,
|
||||
{
|
||||
#[inline]
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
self.inner.cache()
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> EthApiSpec for OpEthApi<N>
|
||||
where
|
||||
N: RpcNodeCore<
|
||||
|
||||
@@ -6,10 +6,9 @@ use alloy_rpc_types::{Header, Index};
|
||||
use futures::Future;
|
||||
use reth_primitives::{BlockId, Receipt, SealedBlock, SealedBlockWithSenders};
|
||||
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, HeaderProvider};
|
||||
use reth_rpc_eth_types::EthStateCache;
|
||||
use reth_rpc_types_compat::block::{from_block, uncle_block_from_header};
|
||||
|
||||
use crate::{FromEthApiError, FullEthApiTypes, RpcBlock, RpcReceipt};
|
||||
use crate::{node::RpcNodeCoreExt, FromEthApiError, FullEthApiTypes, RpcBlock, RpcReceipt};
|
||||
|
||||
use super::{LoadPendingBlock, LoadReceipt, SpawnBlocking};
|
||||
|
||||
@@ -196,12 +195,7 @@ pub trait EthBlocks: LoadBlock {
|
||||
/// Loads a block from database.
|
||||
///
|
||||
/// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` blocks RPC methods.
|
||||
pub trait LoadBlock: LoadPendingBlock + SpawnBlocking {
|
||||
/// Returns a handle for reading data from memory.
|
||||
///
|
||||
/// Data access in default (L1) trait method implementations.
|
||||
fn cache(&self) -> &EthStateCache;
|
||||
|
||||
pub trait LoadBlock: LoadPendingBlock + SpawnBlocking + RpcNodeCoreExt {
|
||||
/// Returns the block object for the given block id.
|
||||
fn block_with_senders(
|
||||
&self,
|
||||
|
||||
@@ -26,7 +26,7 @@ pub use bundle::{EthBundleApiServer, EthCallBundleApiServer};
|
||||
pub use core::{EthApiServer, FullEthApiServer};
|
||||
pub use filter::EthFilterApiServer;
|
||||
pub use helpers::error::{AsEthApiError, FromEthApiError, FromEvmError, IntoEthApiError};
|
||||
pub use node::RpcNodeCore;
|
||||
pub use node::{RpcNodeCore, RpcNodeCoreExt};
|
||||
pub use pubsub::EthPubSubApiServer;
|
||||
pub use types::{EthApiTypes, FullEthApiTypes, RpcBlock, RpcReceipt, RpcTransaction};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Helper trait for interfacing with [`FullNodeComponents`].
|
||||
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use reth_rpc_eth_types::EthStateCache;
|
||||
|
||||
/// Helper trait to relax trait bounds on [`FullNodeComponents`].
|
||||
///
|
||||
@@ -56,3 +57,10 @@ where
|
||||
FullNodeComponents::provider(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Additional components, asides the core node components, needed to run `eth_` namespace API
|
||||
/// server.
|
||||
pub trait RpcNodeCoreExt: RpcNodeCore {
|
||||
/// Returns handle to RPC cache service.
|
||||
fn cache(&self) -> &EthStateCache;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use reth_primitives::BlockNumberOrTag;
|
||||
use reth_provider::{BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider};
|
||||
use reth_rpc_eth_api::{
|
||||
helpers::{EthSigner, SpawnBlocking},
|
||||
node::RpcNodeCoreExt,
|
||||
EthApiTypes, RpcNodeCore,
|
||||
};
|
||||
use reth_rpc_eth_types::{
|
||||
@@ -169,6 +170,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> RpcNodeCoreExt
|
||||
for EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Self: RpcNodeCore,
|
||||
{
|
||||
#[inline]
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
self.inner.cache()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> std::fmt::Debug
|
||||
for EthApi<Provider, Pool, Network, EvmConfig>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use reth_rpc_eth_api::{
|
||||
helpers::{EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt, SpawnBlocking},
|
||||
RpcReceipt,
|
||||
};
|
||||
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
|
||||
use reth_rpc_eth_types::{EthApiError, ReceiptBuilder};
|
||||
|
||||
use crate::EthApi;
|
||||
|
||||
@@ -68,8 +68,4 @@ where
|
||||
Self: LoadPendingBlock + SpawnBlocking,
|
||||
Provider: BlockReaderIdExt,
|
||||
{
|
||||
#[inline]
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
self.inner.cache()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user