remove pending block support from OpEthApi (#10074)

This commit is contained in:
nk_ysg
2024-08-06 19:07:14 +08:00
committed by GitHub
parent 06e7afbd2d
commit bdb8b9fae2

View File

@ -1,17 +1,22 @@
//! Loads OP pending block for a RPC response.
use crate::OpEthApi;
use reth_evm::ConfigureEvm;
use reth_node_api::FullNodeComponents;
use reth_primitives::{revm_primitives::BlockEnv, BlockNumber, B256};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ExecutionOutcome, StateProviderFactory,
use reth_primitives::{
revm_primitives::BlockEnv, BlockHashOrNumber, BlockNumber, SealedBlockWithSenders, B256,
};
use reth_rpc_eth_api::helpers::{LoadPendingBlock, SpawnBlocking};
use reth_rpc_eth_types::PendingBlock;
use reth_provider::{
BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ExecutionOutcome,
StateProviderFactory,
};
use reth_rpc_eth_api::{
helpers::{LoadPendingBlock, SpawnBlocking},
FromEthApiError,
};
use reth_rpc_eth_types::{EthApiError, PendingBlock};
use reth_transaction_pool::TransactionPool;
use crate::OpEthApi;
impl<N> LoadPendingBlock for OpEthApi<N>
where
Self: SpawnBlocking,
@ -39,6 +44,20 @@ where
self.inner.evm_config()
}
/// Returns the locally built pending block
async fn local_pending_block(&self) -> Result<Option<SealedBlockWithSenders>, Self::Error> {
// See: <https://github.com/ethereum-optimism/op-geth/blob/f2e69450c6eec9c35d56af91389a1c47737206ca/miner/worker.go#L367-L375>
let latest = self
.provider()
.latest_header()
.map_err(Self::Error::from_eth_err)?
.ok_or_else(|| EthApiError::UnknownBlockNumber)?;
let (_, block_hash) = latest.split();
self.provider()
.sealed_block_with_senders(BlockHashOrNumber::from(block_hash), Default::default())
.map_err(Self::Error::from_eth_err)
}
fn receipts_root(
&self,
_block_env: &BlockEnv,