feat(transaction-controller): clamp gas estimate fallback to per-chain maxGasLimit#9191
Open
dan437 wants to merge 2 commits into
Open
feat(transaction-controller): clamp gas estimate fallback to per-chain maxGasLimit#9191dan437 wants to merge 2 commits into
dan437 wants to merge 2 commits into
Conversation
…n maxGasLimit When gas estimation fails, the fallback is a percentage of the block gas limit (default 35%). On chains with a high block gas limit but a lower per-transaction RPC cap (e.g. Polygon: ~140M block limit, ~33.5M per-tx cap), the percentage-derived fallback (~49M) overshoots the cap and the node rejects the transaction with "transaction gas limit too high". Add an optional maxGasLimit to the gasEstimateFallback feature flag config (per-chain or default) that clamps the fixed/percentage-derived fallback so it can never exceed the gas limit the RPC will accept.
…axGasLimit clamp (#9191)
jpuri
approved these changes
Jun 19, 2026
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.
Description
When gas estimation fails,
estimateGasfalls back to a percentage of the latest block gas limit (default 35%). On chains with a high block gas limit but a lower per-transaction RPC gas cap, that overshoots the cap: on Polygon, 35% of the ~140M block limit is ~49M, but the node caps a single tx at ~33.5M (2^25) and rejects it withtransaction gas limit too high. This surfaced as consistent failures for Predict / MetaMask Pay deposit-and-order batches submitted on the direct (non-relay) path.This adds an optional
maxGasLimitto thegasEstimateFallbackfeature-flag config (per-chain ordefault). The fixed/percentage-derived fallback is clamped tomaxGasLimit, so it can never exceed the gas limit the RPC will accept — on any submission path. It is opt-in via remote config (e.g. setperChainConfig["0x89"].maxGasLimit = 33554432); behaviour is unchanged when unset.Changelog
maxGasLimitto thegasEstimateFallbackfeature-flag config, clamping the gas estimate fallback to a chain's per-transaction gas cap.Manual testing steps
confirmations_transactions.gasEstimateFallback.perChainConfig["0x89"].maxGasLimit = 33554432.Checklist
gas.test.ts,feature-flags.test.ts)Note
Low Risk
Opt-in remote config with unchanged behavior when unset; limited to gas fallback on estimation failure, with solid unit test coverage.
Overview
Adds an optional
maxGasLimiton the remotegasEstimateFallbackfeature-flag config (per-chain ordefault).getGasEstimateFallbacknow surfaces it, with chain-specific values overriding the default.When gas estimation fails,
estimateGasstill uses the fixed or block-percentage fallback, but clamps that value tomaxGasLimitwhen configured so oversized fallbacks (e.g. ~49M from 35% of Polygon’s block limit vs a ~33.5M per-tx RPC cap) are not submitted. IfmaxGasLimitis unset, behavior is unchanged.Unit tests cover flag resolution and clamp/no-clamp paths; the changelog documents the addition.
Reviewed by Cursor Bugbot for commit 50d5e21. Bugbot is set up for automated code reviews on this repo. Configure here.