Consensys / starknet-snap

The MetaMask Snap for Starknet
https://snaps.consensys.net/starknet
Apache License 2.0
69 stars 24 forks source link

Bug Report: Fail to sign multiple transactions consecutively #150

Open ColinWttt opened 9 months ago

ColinWttt commented 9 months ago

Bug: When signing multiple transactions in succession manually, the second and subsequent transactions fail after signing. After some time, I am able to successfully sign transactions.

This error can be reproduced on snaps.consensys.net/starknet, when you send tokens consecutively, the second one fails.

error.png

console log two types of errors randomly error1: MetaMask - RPC Error: 59: A transaction with the same hash already exists in the mempool

error2: MetaMask - RPC Error: 52: Invalid transaction nonce error52.png

starknet-snap version: @consensys/starknet-snap 2.2.0

MetaMask version: 11.0.0

Chrome: 117.0.5938.92 (arm 64)

Network: Starknet Goerli Testnet

stanleyyconsensys commented 8 months ago

the issue was introduced when the transaction has sent, but it is still pending at the block, hence the latest block nonce is not updated on chain.

when we send another transaction in between the nonce update, it will occur such issue

we can resolve the issue by Opt1 : adding a wait for transaction to block the UI Opt2 : increment the nonce by adding a memory store to remember the last nonce from snap Opt3 : retry the request with nonce increment when it has nonce error