fix: prevent invalid range in fee_history when newest_block is pending (#16910)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Matthias Seitz
2025-06-18 19:11:28 +02:00
committed by GitHub
parent f6ad01de4a
commit da42c0c582
2 changed files with 5 additions and 3 deletions

View File

@@ -86,8 +86,6 @@ pub trait EthFees: LoadFee {
if newest_block.is_pending() {
// cap the target block since we don't have fee history for the pending block
newest_block = BlockNumberOrTag::Latest;
// account for missing pending block
block_count = block_count.saturating_sub(1);
}
let end_block = self

View File

@@ -132,7 +132,7 @@ impl FeeHistoryCache {
self.inner.lower_bound.load(SeqCst)
}
/// Collect fee history for given range.
/// Collect fee history for the given range (inclusive `start_block..=end_block`).
///
/// This function retrieves fee history entries from the cache for the specified range.
/// If the requested range (`start_block` to `end_block`) is within the cache bounds,
@@ -143,6 +143,10 @@ impl FeeHistoryCache {
start_block: u64,
end_block: u64,
) -> Option<Vec<FeeHistoryEntry>> {
if end_block < start_block {
// invalid range, return None
return None
}
let lower_bound = self.lower_bound();
let upper_bound = self.upper_bound();
if start_block >= lower_bound && end_block <= upper_bound {