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

UI displaying wrong transaction nonce when quickly executing transactions #1667

Closed
johannesmoormann opened this issue Feb 13, 2023 · 3 comments · Fixed by #1676
Closed

UI displaying wrong transaction nonce when quickly executing transactions #1667

johannesmoormann opened this issue Feb 13, 2023 · 3 comments · Fixed by #1676
Assignees
Labels
bug Something isn't working major Major bug (to be solved in the next release)

Comments

@johannesmoormann
Copy link
Member

johannesmoormann commented Feb 13, 2023

Bug description

When executing a transaction (tested with a 1/n Safe) and quickly creating a new transaction, the UI will show the nonce of the previously executed transaction but submit the transaction with the correct nonce (or at least a nonce higher then is being displayed).

Environment

  • Browser: Chrome
  • Wallet: MetaMask
  • Chain: Ethereum mainnet and Görli

Steps to reproduce

With a 1/n Safe create and execute multiple transactions and observe the nonce being displayed in the UI.

Expected result

The submitted and signed nonce should always match the displayed nonce in the UI.

Obtained result

see video

https://user-images.githubusercontent.com/93598450/218501568-b099bce8-6b67-48bf-8921-343a3563bebf.mp4
image (7)

Screenshots

@johannesmoormann johannesmoormann added bug Something isn't working major Major bug (to be solved in the next release) labels Feb 13, 2023
@github-project-automation github-project-automation bot moved this to New issues in Safe{Wallet} Feb 13, 2023
@johannesmoormann johannesmoormann moved this from New issues to Todo in Safe{Wallet} Feb 13, 2023
@katspaugh katspaugh moved this from Todo to In Progress in Safe{Wallet} Feb 16, 2023
@katspaugh katspaugh self-assigned this Feb 16, 2023
@katspaugh
Copy link
Member

katspaugh commented Feb 16, 2023

I’ve reproduced the bug with the nonce magically incrementing after creating and immediately executing in a 1/X Safe.

I've created and executed this tx which showed nonce 18

But it landed in the history with nonce 19.

Why?

tl;dr: it’s because such txs don’t land in the queue and thus don’t affect the nonce counter on the backend.

Longer explanation

The contract doesn’t care what nonce a tx has in the data [edit]for unsigned transactions[/edit], it just increments its own nonce on each execution.

The nonce that we use in the UI is generated by the backend based on the queue.
However, if you create and execute a tx w/o signing it (the so-called "immediate execution"), it won't be added to the queue, because it’s “untrusted”. Consequently, it also won't increment the "recommended" nonce on the backend.
Only after the tx is actually executed and indexed, will the backend pick it up, and sync the nonce with the contract nonce.

Solution

IMHO the cleanest solution would be to make users sign all transactions on creation. Or at least when there are pending transactions.
Execution w/o signature is a cool gimmick, which we can leave for already signed transactions, but not for newly created ones.
This will solve this bug and also avoid untrusted txs in principle.

@mmv08
Copy link
Member

mmv08 commented Feb 16, 2023

The contract doesn’t care what nonce a tx has in the data, it always just increments its own nonce on each execution.

This is only true for pre-validated signatures (aka msg.sender based ones). For all other types nonce is a part of the signed transaction hash and a different nonce on-chain would result in a failed transaction authorization.

More context:
safe-global/safe-smart-account#187

@katspaugh
Copy link
Member

Thanks for the correction, makes sense. 👍

@katspaugh katspaugh moved this from In Progress to Ready for QA in Safe{Wallet} Feb 17, 2023
@francovenica francovenica moved this from Ready for QA to QA in progress in Safe{Wallet} Feb 17, 2023
@francovenica francovenica moved this from QA in progress to In Progress in Safe{Wallet} Feb 21, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Safe{Wallet} Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major Major bug (to be solved in the next release)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants