Skip to content

fix(provider): filter low-traffic blocks in EIP-1559 fee estimation#3828

Open
joohhnnn wants to merge 6 commits intoalloy-rs:mainfrom
joohhnnn:tempo-low-traffic
Open

fix(provider): filter low-traffic blocks in EIP-1559 fee estimation#3828
joohhnnn wants to merge 6 commits intoalloy-rs:mainfrom
joohhnnn:tempo-low-traffic

Conversation

@joohhnnn
Copy link
Copy Markdown

@joohhnnn joohhnnn commented Mar 23, 2026

On low-traffic chains like Tempo, most blocks have gasUsedRatio close to zero. The EIP-1559 fee estimator was ignoring this — it pulled reward samples from all blocks and took the median. A single transaction with an inflated priority fee in a near-empty block could push the estimate up by orders of magnitude.

hit this in practice while testing Foundry on Tempo mainnet. forge script reported an estimated gas price of 41000 gwei when the actual baseFeePerGas was 20 gwei and eth_maxPriorityFeePerGas returned 0. After a few test transactions landed in otherwise empty blocks, their priority fees dominated the fee history and the estimator picked them up as representative.

With this fix applied, forge script on Tempo reports 40 gwei (= 2 × base_fee + min_priority), which matches expected behavior.

Two fixes:

  • Blocks with gasUsedRatio < 0.1 are now excluded from reward sampling. Near-empty blocks carry no useful fee signal.
  • Priority fee is capped at 3 * base_fee as a safety bound against remaining outliers.

To pass gasUsedRatio into the estimator, the old (base_fee, rewards) params are replaced with a FeeEstimationContext struct. This is a breaking change to Eip1559EstimatorFn / EstimatorFunction / eip1559_default_estimator. Migration: wrap params into FeeEstimationContext { base_fee_per_gas, rewards, gas_used_ratio }.

@joohhnnn joohhnnn changed the title feat(provider): filter low-traffic blocks in EIP-1559 fee estimation fix(provider): filter low-traffic blocks in EIP-1559 fee estimation Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants