chore(rpc): Add super trait RpcNodeCore to LoadPendingBlock (#12098)

This commit is contained in:
Emilia Hane
2024-10-27 07:11:53 +08:00
committed by GitHub
parent a98dc3973f
commit 988c5ee4c5
8 changed files with 48 additions and 89 deletions

View File

@ -1,14 +1,12 @@
use alloy_primitives::{Bytes, TxKind, U256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use reth_chainspec::EthereumHardforks;
use reth_evm::ConfigureEvm;
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_primitives::{
revm_primitives::{BlockEnv, OptimismFields, TxEnv},
Header,
};
use reth_rpc_eth_api::{
helpers::{Call, EthCall, LoadState, SpawnBlocking},
helpers::{Call, EthCall, LoadPendingBlock, LoadState, SpawnBlocking},
FromEthApiError, IntoEthApiError, RpcNodeCore,
};
use reth_rpc_eth_types::{revm_utils::CallFees, RpcInvalidTransactionError};
@ -17,8 +15,8 @@ use crate::{OpEthApi, OpEthApiError};
impl<N> EthCall for OpEthApi<N>
where
Self: Call,
N: FullNodeComponents<Types: NodeTypes<ChainSpec: EthereumHardforks>>,
Self: Call + LoadPendingBlock,
N: RpcNodeCore,
{
}

View File

@ -1,9 +1,8 @@
//! Loads OP pending block for a RPC response.
use alloy_primitives::{BlockNumber, B256};
use reth_chainspec::EthereumHardforks;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_evm::ConfigureEvm;
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_optimism_consensus::calculate_receipt_root_no_memo_optimism;
use reth_primitives::{
revm_primitives::BlockEnv, BlockNumberOrTag, Header, Receipt, SealedBlockWithSenders,
@ -14,7 +13,7 @@ use reth_provider::{
};
use reth_rpc_eth_api::{
helpers::{LoadPendingBlock, SpawnBlocking},
FromEthApiError,
FromEthApiError, RpcNodeCore,
};
use reth_rpc_eth_types::{EthApiError, PendingBlock};
use reth_transaction_pool::TransactionPool;
@ -24,33 +23,20 @@ use crate::OpEthApi;
impl<N> LoadPendingBlock for OpEthApi<N>
where
Self: SpawnBlocking,
N: FullNodeComponents<Types: NodeTypes<ChainSpec: EthereumHardforks>>,
N: RpcNodeCore<
Provider: BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>
+ StateProviderFactory,
Pool: TransactionPool,
Evm: ConfigureEvm<Header = Header>,
>,
{
#[inline]
fn provider(
&self,
) -> impl BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec: EthereumHardforks>
+ StateProviderFactory {
self.inner.provider()
}
#[inline]
fn pool(&self) -> impl TransactionPool {
self.inner.pool()
}
#[inline]
fn pending_block(&self) -> &tokio::sync::Mutex<Option<PendingBlock>> {
self.inner.pending_block()
}
#[inline]
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header> {
self.inner.evm_config()
}
/// Returns the locally built pending block
async fn local_pending_block(
&self,