Skip to content

Commit fee128d

Browse files
authored
feat: 🐛 fix using latest header (#16614)
1 parent 1e69bf4 commit fee128d

File tree

1 file changed

+10
-7
lines changed
  • crates/rpc/rpc-eth-api/src/helpers

1 file changed

+10
-7
lines changed

crates/rpc/rpc-eth-api/src/helpers/fee.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use reth_rpc_eth_types::{
1313
fee_history::calculate_reward_percentiles_for_block, EthApiError, FeeHistoryCache,
1414
FeeHistoryEntry, GasPriceOracle, RpcInvalidTransactionError,
1515
};
16-
use reth_storage_api::{BlockIdReader, HeaderProvider};
16+
use reth_storage_api::{BlockIdReader, BlockReaderIdExt, HeaderProvider};
1717
use tracing::debug;
1818

1919
/// Fee related functions for the [`EthApiServer`](crate::EthApiServer) trait in the
@@ -256,7 +256,10 @@ pub trait EthFees: LoadFee {
256256
/// Loads fee from database.
257257
///
258258
/// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` fees RPC methods.
259-
pub trait LoadFee: LoadBlock {
259+
pub trait LoadFee: LoadBlock
260+
where
261+
Self::Provider: BlockReaderIdExt,
262+
{
260263
/// Returns a handle for reading gas price.
261264
///
262265
/// Data access in default (L1) trait method implementations.
@@ -335,10 +338,9 @@ pub trait LoadFee: LoadBlock {
335338
///
336339
/// See also: <https://github.com/ethereum/pm/issues/328#issuecomment-853234014>
337340
fn gas_price(&self) -> impl Future<Output = Result<U256, Self::Error>> + Send {
338-
let header = self.recovered_block(BlockNumberOrTag::Latest.into());
339-
let suggested_tip = self.suggested_priority_fee();
340341
async move {
341-
let (header, suggested_tip) = futures::try_join!(header, suggested_tip)?;
342+
let header = self.provider().latest_header().map_err(Self::Error::from_eth_err)?;
343+
let suggested_tip = self.suggested_priority_fee().await?;
342344
let base_fee = header.and_then(|h| h.base_fee_per_gas()).unwrap_or_default();
343345
Ok(suggested_tip + U256::from(base_fee))
344346
}
@@ -347,8 +349,9 @@ pub trait LoadFee: LoadBlock {
347349
/// Returns a suggestion for a base fee for blob transactions.
348350
fn blob_base_fee(&self) -> impl Future<Output = Result<U256, Self::Error>> + Send {
349351
async move {
350-
self.recovered_block(BlockNumberOrTag::Latest.into())
351-
.await?
352+
self.provider()
353+
.latest_header()
354+
.map_err(Self::Error::from_eth_err)?
352355
.and_then(|h| {
353356
h.maybe_next_block_blob_fee(
354357
self.provider().chain_spec().blob_params_at_timestamp(h.timestamp()),

0 commit comments

Comments
 (0)