leather-io / extension

Leather browser extension
https://leather.io
MIT License
305 stars 144 forks source link

Nonce gap not detected, wallet sets wrong nonce #5934

Open 314159265359879 opened 1 month ago

314159265359879 commented 1 month ago

This issue used to be solved, not sure if there is a change to the API or the wallet. It is my understanding that the "next nonce" api should know if there is a missing nonce between the last processed transaction nonce and the lowest nonce still pending.

reproduction steps:

  1. In a new wallet account with some STX
  2. Create a STX transfer and edit the nonce to 20
  3. Sign transaction, this will remain pending, because the first nonce that can be processed for this account is 0
  4. Now create another transaction and do not edit the nonce
  5. Sign transaction
  6. See the issue: the transaction is send with a nonce of 21 instead of 0.

The API or Wallet wrongfully deduces that the next nonce is 21, while there is a gap of nonce 0 through 19 before 21 can get processed.

Tested on the public testnet.

linear[bot] commented 1 month ago

LEA-1694 Nonce gap not detected, wallet sets wrong nonce

314159265359879 commented 1 month ago

It is possible this only occurs on an address that hasn't signed any transactions yet. I just retested on an other address that already had a transaction with nonce 0 processed and then this didn't occur.

camerow commented 1 week ago

This seems like a self inflicted wound, no? You edited the nonce to 20 - is the expectation that if you edit the nonce we then revert back to the previous nonce value before you edited it?