Skip to content

fix: ignore saved advanced gas fees for bridge transactions#9401

Open
cloudonshore wants to merge 2 commits into
mainfrom
fix/bridge-ignore-saved-gas-fees
Open

fix: ignore saved advanced gas fees for bridge transactions#9401
cloudonshore wants to merge 2 commits into
mainfrom
fix/bridge-ignore-saved-gas-fees

Conversation

@cloudonshore

@cloudonshore cloudonshore commented Jul 7, 2026

Copy link
Copy Markdown

Explanation

Bridge transactions apply the user's saved advanced gas fees, whereas swaps deliberately ignore them.

In updateGasFees, saved gas fees are skipped only for SWAP_TRANSACTION_TYPES (swap, swapAndSend, swapApproval). bridge / bridgeApproval are not in that list, so a user's saved advanced gas fees are applied to bridge transactions.

For a user who has saved a low max base fee (observed in production: maxBaseFee: "0.05" gwei, priorityFee: "0" for mainnet), every bridge is submitted underpriced — below the current base fee — causing it to fail (GAS_TOO_LOW on the relay) or get stuck as pending. This is exactly the failure swaps were already protected from.

Fix

Ignore saved gas fees for bridge transactions as well, via a dedicated list:

const SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES: TransactionType[] = [
  ...SWAP_TRANSACTION_TYPES,
  TransactionType.bridge,
  TransactionType.bridgeApproval,
];

I intentionally did not add the bridge types to SWAP_TRANSACTION_TYPES itself, because that constant also gates swap-specific behavior in updateSwapsTransaction (e.g. the simulationFails cancel-and-throw, and transactionNewSwap* events). Keeping a separate, purpose-named list decouples "ignore saved gas fees" from "is a swap".

References

  • Root-caused from production state logs where a bridge smart transaction was submitted with maxFeePerGas: 0x2faf080 (0.05 gwei) / maxPriorityFeePerGas: 0x0, sourced from advancedGasFee["0x1"] = { maxBaseFee: "0.05", priorityFee: "0" }.

Changelog

@metamask/transaction-controller

  • FIXED: bridge and bridgeApproval transactions now ignore user-saved (advanced) gas fees, matching swaps.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

Note

Low Risk
Small, localized change to gas-fee selection in updateGasFees with tests; fixes production bridge failures without altering swap-only code paths.

Overview
Bridge and bridge approval transactions no longer apply user-saved advanced gas fees in updateGasFees, aligning them with swap flows where aggregator/relay pricing must win.

updateGasFees previously skipped saved fees only when the tx type was in SWAP_TRANSACTION_TYPES. bridge and bridgeApproval are now included via a dedicated SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES list (swaps plus bridge types), without folding bridge into SWAP_TRANSACTION_TYPES so swap-only logic elsewhere stays unchanged.

Tests cover that saved fees still apply for ordinary sends and are ignored for swap and bridge types. Changelog documents the fix for underpriced bridges stuck or failing on relay.

Reviewed by Cursor Bugbot for commit 21a2f82. Bugbot is set up for automated code reviews on this repo. Configure here.

Bridge and bridge approval transactions applied the user's saved advanced
gas fees, which swaps already deliberately ignore. A user with a low saved
max base fee (e.g. 0.05 gwei on mainnet) would therefore submit underpriced
bridge transactions that fail or get stuck as pending.

Introduce a dedicated SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES list
(swap + bridge types) to decide whether saved gas fees apply, keeping the
"ignore saved gas fees" concern decoupled from SWAP_TRANSACTION_TYPES, which
also gates swap-specific behavior.
@cloudonshore cloudonshore requested review from a team as code owners July 7, 2026 04:07
@matthewwalsh0 matthewwalsh0 requested a review from dan437 July 7, 2026 11:00
* fees are dictated by the swap/bridge aggregator or relay; applying saved gas
* fees could underprice the transaction and cause it to fail or get stuck.
*/
const SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES: TransactionType[] = [

@matthewwalsh0 matthewwalsh0 Jul 7, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than doing this per type, should we just exclude based on isInternal so it only applies to dApp transactions as was the intent?

@dan437 dan437 removed their request for review July 7, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants