Skip to content

fix(confirmations): stabilize cancel/speed-up gas estimates#41437

Open
vinistevam wants to merge 1 commit intomainfrom
vs/fix-stuck-transaction-speedup-cancel
Open

fix(confirmations): stabilize cancel/speed-up gas estimates#41437
vinistevam wants to merge 1 commit intomainfrom
vs/fix-stuck-transaction-speedup-cancel

Conversation

@vinistevam
Copy link
Copy Markdown
Contributor

@vinistevam vinistevam commented Apr 2, 2026

Description

Cancel and speed-up use network gas estimates to choose between the medium fee level and a +10% bump. That path must only consume estimates in the shape returned by the gas fee layer (decimal GWEI fields such as suggestedMaxFeePerGas). A separate shape on transaction metadata (hex WEI maxFeePerGas per level) is not interchangeable.

Problem

  • Initial gas logic could run while estimates were still loading or with the wrong object shape, so comparisons in gasEstimateGreaterThanGasUsedPlusTenPercent could be wrong or misleading.
  • networkClientId was derived from network configuration even though it is already present on transaction metadata.
  • Legacy vs EIP-1559 branching relied on a narrow check instead of the same rules used elsewhere (useSupportsEIP1559).

Solution

  • Source networkClientId from the effective transaction (store or prop) and pass it into useGasFeeEstimates.
  • Expose isGasEstimatesLoading from cancel/speed-up gas state and skip initial gas application until loading finishes (alongside existing app loading guard).
  • Route legacy vs EIP-1559 cancel/speed-up using useSupportsEIP1559.

Changelog

CHANGELOG entry: Fixed reliability of gas handling when canceling or speeding up a pending transaction

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1007

Manual testing steps

  1. Submit an EIP-1559 send with custom advanced gas, then open Speed up or Cancel.
  2. Confirm the modal finishes loading, fees look sane, and confirm succeeds without the transaction staying stuck due to bad initial fee math.
  3. Repeat on a legacy gasPrice transaction.

Screenshots/Recordings

fix_ethe_mainnet_cancel.webm
fix_base_cancel.webm

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches cancel/speed-up fee selection and legacy/EIP-1559 branching, which can affect replacement transaction fees and user ability to unstick transactions. Changes are localized and covered by updated tests, but regressions could impact transaction confirmation behavior.

Overview
Cancel/Speed-up now waits for valid network gas estimates before applying the initial fee rule. The cancel/speed-up modal wires through isGasEstimatesLoading from useGasFeeEstimates and useCancelSpeedupGasState, and useCancelSpeedupInitialGas skips applying medium-vs-+10% logic while estimates are still loading.

Gas estimate sourcing and flow selection were tightened. useCancelSpeedupGasState now takes networkClientId directly from the effective transaction when calling useGasFeeEstimates (removing network config derivation/fallback), and legacy vs EIP-1559 routing is based on useSupportsEIP1559 rather than checking for maxFeePerGas. Tests were updated/added to cover the new loading guard and EIP-1559 support branching.

Written by Cursor Bugbot for commit 2d50909. This will update automatically on new commits. Configure here.

@vinistevam vinistevam added the team-confirmations Push issues to confirmations team label Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Apr 2, 2026

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (5 files, +157 -229)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 cancel-speedup/
          • 📄 cancel-speedup.tsx +2 -0
        • 📁 hooks/
          • 📄 useCancelSpeedupGasState.test.ts +29 -11
          • 📄 useCancelSpeedupGasState.ts +17 -36
          • 📄 useCancelSpeedupInitialGas.test.ts +100 -181
          • 📄 useCancelSpeedupInitialGas.ts +9 -1

@github-actions github-actions bot added the size-M label Apr 2, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

@vinistevam vinistevam marked this pull request as ready for review April 2, 2026 09:27
@vinistevam vinistevam requested a review from a team as a code owner April 2, 2026 09:27
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Apr 2, 2026

Builds ready [2d50909]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): f47ee32 | Date: 5/23/58221 | Pipeline: 23892719517 | Baseline logs

Interaction Benchmarks
Benchmarkchrome-browserify
loadNewAccount🟢 [Show logs]
confirmTx🟢 [Show logs]
bridgeUserActions🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: -34%
  • loadNewAccount/total: -34%
  • bridgeUserActions/bridge_load_asset_picker: -24%
Startup Benchmarks
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/initialActions: +25%
  • startupPowerUserHome/backgroundConnect: +36%
  • startupPowerUserHome/numNetworkReqs: +53%
  • startupStandardHome/domInteractive: +13%
  • startupStandardHome/initialActions: -17%
  • startupPowerUserHome/setupStore: +79%
  • startupStandardHome/initialActions: +25%
  • startupStandardHome/setupStore: -15%
  • startupPowerUserHome/setupStore: +53%
User Journey Benchmarks
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟢 [Show logs]
solanaAssetDetails🟢 [Show logs]
importSrpHome🟢 [Show logs]
sendTransactions🟢 [Show logs]
swap🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/metricsToWalletReadyScreen: -28%
  • onboardingImportWallet/doneButtonToHomeScreen: -78%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +53%
  • onboardingImportWallet/total: -35%
  • onboardingNewWallet/skipBackupToMetricsScreen: -28%
  • onboardingNewWallet/doneButtonToAssetList: -21%
  • onboardingNewWallet/total: -17%
  • assetDetails/assetClickToPriceChart: -54%
  • assetDetails/total: -54%
  • solanaAssetDetails/assetClickToPriceChart: -27%
  • solanaAssetDetails/total: -27%
  • importSrpHome/loginToHomeScreen: +10%
  • importSrpHome/openAccountMenuAfterLogin: -62%
  • importSrpHome/homeAfterImportWithNewWallet: -44%
  • importSrpHome/total: -38%
  • swap/openSwapPageFromHome: -83%
  • swap/fetchAndDisplaySwapQuotes: +38%
  • swap/total: +19%
🌐 Dapp Page Load Benchmarks

Current Commit: 2d50909 | Date: 4/2/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±38ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 720ms (±37ms) 🟢 | historical mean value: 730ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 84ms (±9ms) 🟢 | historical mean value: 85ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 38ms 1.00s 1.31s 1.04s 1.31s
domContentLoaded 720ms 37ms 699ms 996ms 737ms 996ms
firstPaint 84ms 9ms 68ms 156ms 92ms 156ms
firstContentfulPaint 84ms 9ms 68ms 156ms 92ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.3 KiB (-0.02%)
  • ui: 16 Bytes (0%)
  • common: -4 Bytes (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant