Commit 9b2a8b1
authored
fix: ignore saved advanced gas fees for bridge transactions (#9401)
## 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:
```ts
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
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc) for new or updated code as
appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes gas pricing for all internal transactions (bridges, swaps,
etc.); behavior is intentional but affects submission paths where wrong
fees caused production failures.
>
> **Overview**
> **`updateGasFees`** no longer applies user-saved (advanced) gas fees
when **`txMeta.isInternal`** is true. Saved fees are only loaded for
non-internal (dApp) transactions.
>
> The previous logic skipped saved fees only for
**`SWAP_TRANSACTION_TYPES`**, so bridge and other internal flows could
inherit a low saved max base fee and submit underpriced txs. The
swap-type check and **`SWAP_TRANSACTION_TYPES`** import were removed in
favor of **`isInternal`**.
>
> Tests cover applying saved fees for non-internal txs and ignoring them
(without calling **`getSavedGasFees`**) for internal txs. The changelog
documents the fix.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
eb622eb. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 545f66c commit 9b2a8b1
3 files changed
Lines changed: 49 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
133 | 172 | | |
134 | 173 | | |
135 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
0 commit comments