refactor(evm): drop silent fallbacks in token gas estimation#3698
Merged
Conversation
Remove two implicit defaults in getTokenGasLimitForContact: - the amount parameter is now required; the previous `amount ?? 1` hid the intent at the call site - the try/catch returning a hardcoded 100k gas limit on estimateGas failure is removed; estimation errors now propagate to the caller (existing outer error handlers log and let the affected flow retry on the next cron pass) getTokenGasLimitForAsset passes an explicit 1-wei sample amount, documented as fee-estimation only.
davidleomay
approved these changes
May 12, 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.
Summary
Remove two implicit defaults in
getTokenGasLimitForContactso that callers always work with a real estimate or see the error explicitly.Changes
amountparameter is now required — the previousamount ?? 1hid the intent at the call site.getTokenGasLimitForAssetnow passes an explicitBigNumber.from(1)documented as fee-estimation sample only.try/catchreturning a hardcoded 100k gas fallback onestimateGasfailure is removed. Errors now propagate to the caller. Existing outer error handlers (inEvmStrategy.doPayout, the sell prepare flow, and the Polygon bridge adapter) already log and let the affected flow retry on the next cron pass.Why
A silent 100k fallback could send a transaction with a gas limit that doesn't reflect the real cost — either over-paying or under-paying. Failing loudly is preferable: the caller knows the estimate is unreliable and can decide what to do (retry, alert, etc.) instead of silently shipping a wrong number.
Test plan