Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert nonce logic in transaction controller [HOTFIX] #7653

Merged

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Oct 31, 2023

Description

This PR is identical to #7651 but targeting a hotfix branch.

The TransactionController was recently upgraded to a version using the NonceTracker package.

This looks at local transactions for the same address and chain to determine the best nonce value.

Since the mobile client monitors incoming token transfers, this was resulting in incorrect nonce values due to the associated transactions having the from address of the account sending the balance, rather than the address of the account creating the transaction.

The temporary fix is to revert the nonce logic in the TransactionController by removing usage of the NonceTracker.

Related issues

Fixes: #7646

Manual testing steps

  1. Add account X to the wallet.
  2. Add a token balance to account X.
  3. Send an approve transaction from account X for the same token to account Y.
  4. Send a transferFrom transaction from account Y (ideally from a different wallet), that transfers the token from account X.
  5. Wait for the incoming transaction to be detected, this is not visible in the activity list but polled every ~30 seconds.
  6. Try and send any transaction from account X and confirm the nonce is not the transfer nonce from account Y + 1.

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 October 31, 2023 17:19
@matthewwalsh0 matthewwalsh0 added DO-NOT-MERGE Pull requests that should not be merged team-confirmations-system DEPRECATED: please use "team-confirmations" label instead labels Oct 31, 2023
@sleepytanya
Copy link
Contributor

sleepytanya commented Oct 31, 2023

Confirmed that transactions nonce on account X are not the transfer nonce on account Y both on iOS and Android.
transferFrom from account Y (iOS):
Screenshot_20231031_151322_MetaMask
Approve and Send transactions from account X (iOS):
Screenshot 2023-10-31 at 3 14 26 PM

Screenshot 2023-10-31 at 3 14 44 PM

transferFrom from account Y (Android):

Screenshot_20231031_161518_MetaMask

Approve and Send transactions from account X (Android):

Screenshot 2023-10-31 at 5 24 10 PM Screenshot 2023-10-31 at 5 23 46 PM

@sleepytanya sleepytanya added the QA Passed A successful QA run through has been done label Oct 31, 2023
@sethkfman sethkfman added the release-7.9.1 Issue or pull request that will be included in release 7.9.1 label Oct 31, 2023
@matthewwalsh0 matthewwalsh0 removed the DO-NOT-MERGE Pull requests that should not be merged label Oct 31, 2023
Copy link
Contributor

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.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (release/7.9.1@0a2071c). Click here to learn what that means.

Additional details and impacted files
@@               Coverage Diff                @@
##             release/7.9.1    #7653   +/-   ##
================================================
  Coverage                 ?   34.58%           
================================================
  Files                    ?     1017           
  Lines                    ?    27161           
  Branches                 ?     2211           
================================================
  Hits                     ?     9394           
  Misses                   ?    17278           
  Partials                 ?      489           

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

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

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

LGTM

@sethkfman sethkfman merged commit 693c91a into release/7.9.1 Oct 31, 2023
23 checks passed
@sethkfman sethkfman deleted the fix/7646-hotfix-nonce-errors-incoming-transactions branch October 31, 2023 23:03
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
QA Passed A successful QA run through has been done release-7.9.1 Issue or pull request that will be included in release 7.9.1 team-confirmations-system DEPRECATED: please use "team-confirmations" label instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants