fix(provider): filter low-traffic blocks in EIP-1559 fee estimation#3828
Open
joohhnnn wants to merge 6 commits intoalloy-rs:mainfrom
Open
fix(provider): filter low-traffic blocks in EIP-1559 fee estimation#3828joohhnnn wants to merge 6 commits intoalloy-rs:mainfrom
joohhnnn wants to merge 6 commits intoalloy-rs:mainfrom
Conversation
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On low-traffic chains like Tempo, most blocks have
gasUsedRatioclose 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 scriptreported an estimated gas price of 41000 gwei when the actualbaseFeePerGaswas 20 gwei andeth_maxPriorityFeePerGasreturned 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 scripton Tempo reports 40 gwei (= 2 × base_fee + min_priority), which matches expected behavior.Two fixes:
gasUsedRatio < 0.1are now excluded from reward sampling. Near-empty blocks carry no useful fee signal.3 * base_feeas a safety bound against remaining outliers.To pass
gasUsedRatiointo the estimator, the old(base_fee, rewards)params are replaced with aFeeEstimationContextstruct. This is a breaking change toEip1559EstimatorFn/EstimatorFunction/eip1559_default_estimator. Migration: wrap params intoFeeEstimationContext { base_fee_per_gas, rewards, gas_used_ratio }.