fix(evm): replace sunset blocknative gas oracle with eth_feeHistory - #1281
Conversation
Blocknative's gas platform was sunset on 2026-06-19, so /gas/fees now 404s on every EVM coinstack (MoralisService.getGasFees queried api.blocknative.com/gasprices/blockprices). Replace it with eth_feeHistory-based estimation off the existing PublicClient (no third-party gas vendor): - next-block base fee from feeHistory (protocol-deterministic) - priority fees from reward percentiles [50, 70, 90] -> slow/average/fast - clip tips above median * 10 to drop mev/overpayer outliers - 100-block sample window, baseFee * 2 maxFee buffer, minPriorityFee floor Remove the now-unused BLOCKNATIVE_API_KEY env var across coinstacks, and delete the dead BlockbookService and GasOracle (no coinstack has instantiated them since the Moralis cutover in 2025-11). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 43 minutes and 2 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoves ChangesBlocknative and BlockbookService removal
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
node/coinstacks/common/api/src/evm/moralisService.ts (1)
386-395: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueTiers may not be monotonic across slow/average/fast.
Each tier's priority fee is averaged with an independent median-based outlier clip, so in skewed samples it's possible for a lower percentile tier to produce a higher estimate than a higher one (e.g.
slow>average). Consider clamping soslow ≤ average ≤ fastto avoid surfacing inverted fee tiers to clients.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@node/coinstacks/common/api/src/evm/moralisService.ts` around lines 386 - 395, The fee tier calculations in the REWARD_PERCENTILES.map block calculate slow, average, and fast tiers independently, which can result in non-monotonic fee values where slower tiers have higher fees than faster ones. After the array destructuring of [slow, average, fast], add clamping logic to ensure monotonic ordering by enforcing that slow's fees are clamped to be at most average's fees, and average's fees are clamped to be at most fast's fees. This should be applied to the gasPrice, maxFeePerGas, and maxPriorityFeePerGas values in each tier object.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@node/coinstacks/common/api/src/evm/moralisService.ts`:
- Around line 386-395: The fee tier calculations in the REWARD_PERCENTILES.map
block calculate slow, average, and fast tiers independently, which can result in
non-monotonic fee values where slower tiers have higher fees than faster ones.
After the array destructuring of [slow, average, fast], add clamping logic to
ensure monotonic ordering by enforcing that slow's fees are clamped to be at
most average's fees, and average's fees are clamped to be at most fast's fees.
This should be applied to the gasPrice, maxFeePerGas, and maxPriorityFeePerGas
values in each tier object.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 61e29b74-c934-4b11-ae64-84b95352ad34
📒 Files selected for processing (14)
node/coinstacks/arbitrum/sample.envnode/coinstacks/avalanche/sample.envnode/coinstacks/base/sample.envnode/coinstacks/bnbsmartchain/sample.envnode/coinstacks/common/api/src/evm/blockbookService.tsnode/coinstacks/common/api/src/evm/controller.tsnode/coinstacks/common/api/src/evm/gasOracle.tsnode/coinstacks/common/api/src/evm/index.tsnode/coinstacks/common/api/src/evm/moralisService.tsnode/coinstacks/common/api/src/evm/types.tsnode/coinstacks/ethereum/sample.envnode/coinstacks/gnosis/sample.envnode/coinstacks/optimism/sample.envnode/coinstacks/polygon/sample.env
💤 Files with no reviewable changes (12)
- node/coinstacks/ethereum/sample.env
- node/coinstacks/polygon/sample.env
- node/coinstacks/optimism/sample.env
- node/coinstacks/base/sample.env
- node/coinstacks/gnosis/sample.env
- node/coinstacks/arbitrum/sample.env
- node/coinstacks/common/api/src/evm/blockbookService.ts
- node/coinstacks/common/api/src/evm/index.ts
- node/coinstacks/bnbsmartchain/sample.env
- node/coinstacks/common/api/src/evm/gasOracle.ts
- node/coinstacks/common/api/src/evm/types.ts
- node/coinstacks/avalanche/sample.env
Each tier's priority fee is averaged with an independent median-based outlier clip, so on skewed samples a lower percentile tier could exceed a higher one (e.g. slow > fast). Use a running max to enforce slow <= average <= fast while also applying the minPriorityFee floor. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Problem
Blocknative's gas platform was sunset on 2026-06-19, so
GET /gas/feesnow returns a404on every EVM coinstack.MoralisService.getGasFees()was queryingapi.blocknative.com/gasprices/blockprices:Fix
Replace Blocknative with
eth_feeHistory-based estimation off thePublicClientthe service already holds — no third-party gas vendor, no new credentials:feeHistory(protocol-deterministic, exact)rewardpercentiles[50, 70, 90]→slow/average/fastmedian × 10so MEV/overpayer txs don't skew the average (ported from the oldGasOracle.getFeeThreshold; adaptive — clips relative to current conditions)baseFee × 2maxFeePerGasbuffer, existingminPriorityFeefloor preservedOutput shape (
GasFees) is unchanged, so the OP-stack L1-fee wrappers (OptimismGasFees/BaseGasFees) and all downstream consumers are untouched.Percentile tuning
[50, 70, 90]was chosen empirically against live RPCs:p50slow (notp1) keeps the low tier robust against under-quoting / stuck txs.p90fast (notp95) avoids chasing Ethereum's persistent MEV-tip tail, which madefast~2× more expensive than needed on an idle chain.Cleanup
BLOCKNATIVE_API_KEYenv var across all coinstacks.BlockbookServiceandGasOracle— no coinstack has instantiated them since the Moralis cutover (2025-11); they survived only as a type union + aninstanceofbranch in the EVM controller.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes