mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-10 07:48:19 -05:00
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:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user