MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
12.04k stars 4.92k forks source link

[Bug]: Nonce - Nonce doesn't update while having 2 pending transactions, and after confirming the first one #27617

Open seaona opened 1 month ago

seaona commented 1 month ago

Describe the bug

While having the Custom Nonce settings enabled, if I queue 2 transactions and confirm the first one, I can see how the nonce for the 2nd transaction is never updated.

Expected behavior

Same as in prod? The nonce is updated after confirming the first transaction

Screenshots/Recordings

In the first part of the video you see the issue, in the second part, you see how it's the behaviour currently in production 12.3.1

https://github.com/user-attachments/assets/9227e7ca-925f-41ea-ab33-cd777b86d47b

Steps to reproduce

  1. Go to Advanced Settings
  2. Enable Custom nonce
  3. Go to the test dapp
  4. Trigger 2 transactions
  5. Confirm the first one
  6. See how the second one still has the old nonce
  7. Confirming the second one leads to nonce too low error

Error messages or log output

No response

Detection stage

During release testing

Version

12.5.0

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

Severity

No response

jpuri commented 1 month ago

Hey @seaona : I am not able to replicate this issue in release branch 12.5

https://github.com/user-attachments/assets/4037b939-0695-4ed6-b2d6-f295c38b9352

seaona commented 4 weeks ago

hey @jpuri I'm still able to reproduce it consistently. Could it be something around settings? I have smart transactions disabled. See how the popup nonce never updates. If I open the full view, I see that the nonce is updated in full view but not in the popup, and sending the transaction from the popup makes it fail with the nonce too low error.

https://github.com/user-attachments/assets/da975740-22f8-4050-a458-26edcb654879

sleepytanya commented 4 weeks ago

@seaona @jpuri

Probably we are encountering two distinct issues related to nonce management?

RC 12.5.0, STX disabled.

  1. Two transactions were initiated, both assigned the same nonce value of 65, as indicated in the popup
  2. Following the submission of the first transaction, the nonce value for the pending second transaction does not update
  3. Upon attempting to confirm the second transaction, the correct subsequent nonce value of 66 is momentarily displayed, followed by an 'already known' error message
  4. Only one transaction, with the nonce 65, is submitted / visible in the Activity list

https://github.com/user-attachments/assets/7e0e18e6-fa3d-4906-9170-49018d335f5a

  1. The nonce for the last transaction that was submitted (and confirmed on the block explorer) is 65
  2. Three subsequent transactions were initiated, each displaying a nonce of 66 in the popup
  3. However, when viewed in the expanded interface, all three transactions are shown to have a nonce of 65

https://github.com/user-attachments/assets/b7d1e2cf-2438-4503-a67b-96671f6f60ef

sleepytanya commented 2 weeks ago

The issue is present in the latest 12.6.0

On the legacy confirmations nonce value is not updated for second transaction after the first one is submitted (the second transaction is created with the incorrect nonce value):

https://github.com/user-attachments/assets/0b60ef5a-f662-4bab-b47d-04012293f870

https://github.com/user-attachments/assets/1f8c317a-1180-441d-a29c-2fa90e046e13

On redesigned confirmations nonce is updated after first transaction is submitted:

https://github.com/user-attachments/assets/71a10ba0-6a92-4bf7-af36-66ea2ed4116f

metamaskbot commented 2 weeks ago

Missing release label release-12.6.0 on issue. Adding release label release-12.6.0 on issue, as issue is linked to PR #27874 which has this release label.

bschorchit commented 2 weeks ago

Re-posting this here for visibility. This is not a regression and we're not considering this issue no longer a release blocker. We'll go forward with the path of making the redesigned confirmations the default ones (on v12.8) as the main fix for this. There's also a task being planned to refactor the nonce implementation in the wallet to prevent similar issues in the future.

Slack message

hey all, I was testing the nonce one issue, and I am not sure it should be considered a release blocker. Actual issue: trigger 2 transactions with the custom nonce option enable and see that when one transaction is submitted, the nonce does not automatically updates on the other transaction

Behaviour on 12.5: fixed on new confirmations (so contract interactions + contract deployments) old confirmations the issue highlighted above persists

Behaviour on 12.4.1 (downloaded from the Chrome store): old confirmations - the custom nonce on the 2nd confirmation is cleared. Bottom line: issue occurs on old confirmations, for users that have custom nonce enabled and have multiple transactions to confirm at the same time.

behaviour on 12.4.1 is doubtfully better, as the user needs to remember which is the next sequential nonce and input it manually, while on 12.5.0 the user needs to bump that value by 1 (if he does not bump it and keep the same value, we will not submit the transaction and will return an error to the dapp for that transaction)

For the reasons above I would not consider this a release blocker and would even question if it makes sense for us to fix this ahead of enabling the new confirmations by default for all users.

metamaskbot commented 2 weeks ago

Missing release label release-12.6.0 on issue. Adding release label release-12.6.0 on issue, as issue is linked to PR #27874 which has this release label.

seaona commented 1 week ago

could be the same as these users are experiencing? cc @bschorchit

https://github.com/MetaMask/metamask-extension/issues/28239

sleepytanya commented 6 days ago

Possibly fixed by https://github.com/MetaMask/metamask-extension/pull/28272