Skip to content

Fix incorrect transaction statuses#22319

Merged
matthewwalsh0 merged 6 commits intodevelopfrom
fix/pending-and-dropped-transactions
Dec 19, 2023
Merged

Fix incorrect transaction statuses#22319
matthewwalsh0 merged 6 commits intodevelopfrom
fix/pending-and-dropped-transactions

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Dec 18, 2023

Description

Update the transaction controller to:

  • Fix the dropped status detection.
  • Ensure previously pending transactions are monitored after switching network and not stuck as pending.
  • Prevent failed transactions on networks that use pending transaction receipts with null status.
  • Fix recording of v value to prevent errors when using eth_getTransactionByHash.

Also fix usage of saved gas fees.

See related core PR.

Related issues

Fixes: #21941 #22312 #22333

Manual testing steps

Pending Issue

  1. Add a transaction.
  2. Switch networks before the transaction is confirmed.
  3. Add a transaction on the new network, but do not need to approve.
  4. Switch back to the previous network.
  5. Ensure original transaction is confirmed and does not remain pending.

Dropped Issue

  1. Add a transaction.
  2. Wait until transaction is confirmed.
  3. Switch networks.
  4. Create a new transaction from the same account and with the same nonce.
  5. Ensure the new transaction is confirmed and not dropped.

Failed Issue

  1. Switch to ZK network or any network that returns transaction receipts for pending transactions.
  2. Add a transaction.
  3. Ensure transaction is confirmed and not immediately set to failed.

Saved Gas Fees

  1. Add transaction.
  2. Edit gas fee.
  3. Enter advanced value.
  4. Save for current chain.
  5. Create second transaction on same chain.
  6. Verify gas fee is saved value.
  7. Change network.
  8. Add transaction.
  9. Verify no saved gas fee.

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner December 18, 2023 13:22
@matthewwalsh0 matthewwalsh0 added the team-confirmations-system-deprecated DEPRECATED: please use "team-confirmations" instead label Dec 18, 2023
@seaona
Copy link
Copy Markdown
Member

seaona commented Dec 18, 2023

I see both issues fixed in this branch

Dropped tx fixed

dropped-fixed.mp4

Pending tx fixed

pending-fixed.mp4

Fix incorrectly marked failed transactions.
@matthewwalsh0 matthewwalsh0 changed the title Fix transactions incorrectly shown as pending or dropped Fix transactions incorrectly shown as pending, dropped, or failed Dec 18, 2023
@seaona
Copy link
Copy Markdown
Member

seaona commented Dec 18, 2023

Failed tx fixed

failed-fixed.mp4

Repro: seemed a bit trickier to repro - not happening always, but very frequently

  • sending tx
  • try speeding up / cancel
  • sending another tx
  • reset wallet
  • sending tx
sync-era-2.mp4

@sleepytanya
Copy link
Copy Markdown
Contributor

sleepytanya commented Dec 18, 2023

Dropped incoming transaction. Previous transaction nonce on the receiving account was 2 while dropped incoming transaction nonce (sent from another account) was 5. I didn't switch networks.
Dropped transaction shown as successful on block explorer https://sepolia.etherscan.io/tx/0xcb807c4f824a2435e20c96e29905a508623c3d55388b4f9a519db41ee5721fcf
State log:
dropped.json

Screenshot 2023-12-18 at 10 43 05 AM

dbrans
dbrans previously approved these changes Dec 18, 2023
@sleepytanya
Copy link
Copy Markdown
Contributor

Confirming that pending transaction is fixed:
Chrome

pending.mov

Firefox

pending_ff.mov

Dropped transaction looks fixed too:
Chrome

dropped.mov

Firefox

dropped_ff.mov

@sleepytanya
Copy link
Copy Markdown
Contributor

sleepytanya commented Dec 18, 2023

For some reason gas options (estimated fee) on this branch look like this:
Screenshot 2023-12-18 at 10 35 15 AM
11.8.0 gas options look:
Screenshot 2023-12-18 at 11 27 35 AM

vinistevam
vinistevam previously approved these changes Dec 18, 2023
@matthewwalsh0 matthewwalsh0 dismissed stale reviews from vinistevam and dbrans via c26ef9d December 18, 2023 17:55
vinistevam
vinistevam previously approved these changes Dec 19, 2023
@sleepytanya
Copy link
Copy Markdown
Contributor

Confirming that Advanced Gas feature work as expected - saved values are applied to subsequent transactions on the same network:

Firefox

adv_gas.mov

Chrome

adv_gas_chrome.mov

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (ec75187) 67.92% compared to head (10c4b2a) 67.90%.
Report is 1 commits behind head on develop.

Files Patch % Lines
app/scripts/metamask-controller.js 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #22319      +/-   ##
===========================================
- Coverage    67.92%   67.90%   -0.02%     
===========================================
  Files         1071     1071              
  Lines        41368    41378      +10     
  Branches     11115    11112       -3     
===========================================
- Hits         28098    28095       -3     
- Misses       13270    13283      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@matthewwalsh0 matthewwalsh0 changed the title Fix transactions incorrectly shown as pending, dropped, or failed Fix incorrect transaction statuses Dec 19, 2023
@matthewwalsh0 matthewwalsh0 merged commit c6d6946 into develop Dec 19, 2023
@matthewwalsh0 matthewwalsh0 deleted the fix/pending-and-dropped-transactions branch December 19, 2023 18:51
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2023
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [10c4b2a]
Page Load Metrics (1545 ± 112 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint872591584923
domContentLoaded10172374522
load95021301545233112
domInteractive10172374522
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 116 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 56 Bytes (0.00%)

@metamaskbot metamaskbot added the release-11.9.0 Issue or pull request that will be included in release 11.9.0 label Dec 19, 2023
@metamaskbot metamaskbot added release-11.7.2 Issue or pull request that will be included in release 11.7.2 and removed release-11.9.0 Issue or pull request that will be included in release 11.9.0 labels Jan 2, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Missing release label release-11.7.2 on PR. Adding release label release-11.7.2 on PR and removing other release labels(release-11.9.0), as PR was cherry-picked in branch 11.7.2.

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

Labels

QA Passed release-11.7.2 Issue or pull request that will be included in release 11.7.2 team-confirmations-system-deprecated DEPRECATED: please use "team-confirmations" instead

Projects

None yet

6 participants