feat(rpc): remove total difficulty (#13303)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Miguel Oliveira
2024-12-12 09:52:34 -03:00
committed by GitHub
parent dcdf13731e
commit aca4a2db39
4 changed files with 7 additions and 33 deletions

View File

@@ -2,7 +2,6 @@
use std::sync::Arc;
use alloy_consensus::BlockHeader;
use alloy_eips::BlockId;
use alloy_primitives::Sealable;
use alloy_rlp::Encodable;
@@ -11,7 +10,7 @@ use futures::Future;
use reth_node_api::BlockBody;
use reth_primitives::{SealedBlockFor, SealedBlockWithSenders};
use reth_provider::{
BlockIdReader, BlockReader, BlockReaderIdExt, HeaderProvider, ProviderHeader, ProviderReceipt,
BlockIdReader, BlockReader, BlockReaderIdExt, ProviderHeader, ProviderReceipt,
};
use reth_rpc_types_compat::block::from_block;
use revm_primitives::U256;
@@ -64,20 +63,9 @@ pub trait EthBlocks: LoadBlock {
async move {
let Some(block) = self.block_with_senders(block_id).await? else { return Ok(None) };
let block_hash = block.hash();
let mut total_difficulty = self
.provider()
.header_td_by_number(block.number())
.map_err(Self::Error::from_eth_err)?;
if total_difficulty.is_none() {
// if we failed to find td after we successfully loaded the block, try again using
// the hash this only matters if the chain is currently transitioning the merge block and there's a reorg: <https://github.com/paradigmxyz/reth/issues/10941>
total_difficulty =
self.provider().header_td(&block.hash()).map_err(Self::Error::from_eth_err)?;
}
let block = from_block(
(*block).clone().unseal(),
total_difficulty.unwrap_or_default(),
full.into(),
Some(block_hash),
self.tx_resp_builder(),

View File

@@ -20,7 +20,7 @@ use reth_chainspec::EthChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_node_api::BlockBody;
use reth_primitives_traits::SignedTransaction;
use reth_provider::{BlockIdReader, ChainSpecProvider, HeaderProvider, ProviderHeader};
use reth_provider::{BlockIdReader, ChainSpecProvider, ProviderHeader};
use reth_revm::{
database::StateProviderDatabase,
db::CacheDB,
@@ -95,10 +95,6 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
let base_block =
self.block_with_senders(block).await?.ok_or(EthApiError::HeaderNotFound(block))?;
let mut parent_hash = base_block.header.hash();
let total_difficulty = RpcNodeCore::provider(self)
.header_td_by_number(block_env.number.to())
.map_err(Self::Error::from_eth_err)?
.ok_or(EthApiError::HeaderNotFound(block))?;
// Only enforce base fee if validation is enabled
cfg.disable_base_fee = !validation;
@@ -206,7 +202,6 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA
simulate::build_simulated_block(
senders,
results,
total_difficulty,
return_full_transactions,
this.tx_resp_builder(),
block,