Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to do about "transaction nonce too high" errors in RSK?

Tags:

web3js

web3

rsk

I have a decentralised application deployed on RSK, and has been working for several months. Everything works correctly using the public node, however infrequently, we start getting a totally random error:

Unknown Error: { 
  "jsonrpc": "2.0", 
  "id": 2978041344968143, 
  "error": { 
    "code": -32010, 
    "message": "transaction nonce too high" 
  } 
}

There is no information about “too high” nonces but many threads about “too slow”. I’m using web3.Contract.method.send().

like image 220
7alip Avatar asked Jan 18 '21 13:01

7alip


People also ask

How do you fix nonce errors too low?

In the MetaMask, Go to Settings > Advanced > Reset Account. This will reset the Nonce count associated with your wallet to 0 by clearing all previous transaction history stored in the cache of your browser. The next transaction that you initiate will be Nonce 0 and will be executed first.

How do you set a nonce transaction?

Step-1: Go to your account on the top right corner of your MetaMask extension and click on Settings. Step-2: Under Settings, click on Advanced Settings. Then find the setting that says: “Customize transaction nonce” Turn this on to change the nonce (transaction number) on confirmation screens.

What is nonce of transaction?

The nonce is the number of transactions sent from a given address. In English, a nonce is a number that can only be used once. In cryptography, a nonce is a one-time code selected in a random or pseudo-random manner that is used to securely transmit a main password, preventing replay attacks.


3 Answers

In Metamask, ensure you are on your dev/test account then:

1 click on the avatar circle top right 2 In the menu, choose Settings 3 Click Advanced 4 Scroll down a bit, make sure again you are on your testnet account, click Reset Account

like image 64
Nihi Gabriel Avatar answered Oct 22 '22 16:10

Nihi Gabriel


There is a limit on the number transactions the same address can have on the transaction pool.

This limit is 4 for RSK, and is defined within TxValidatorNonceRangeValidator within the rskj code base:

BigInteger maxNumberOfTxsPerAddress = BigInteger.valueOf(4);

Note that Ethereum has a similar limit, but the limit that is configured in geth is 10. So if we have already sent 4 transactions, that have not been mined yet, and send a 5th transaction before the next block is mined, it will get an error that the nonce is too high. If a block was mined and it had let's say all 4 of the transactions, then we would be able to add up to 4 transactions for the next block.

Workarounds

(1) Send no more than 4 transactions from an address, until there is a new block.

(2) Aggregate all of the calls and then use a contract that executes them in a single go. An example of this is seen in RNS Batch Client ExecuteRegistrations.

like image 33
Alvaro Avatar answered Oct 22 '22 18:10

Alvaro


For me it happened when i restarted the node, following instruction fixed it:

Open up your MetaMask window and click on the icon in the top right to display accounts. Go to Settings, then Advanced and hit Reset Account.

like image 43
vivex Avatar answered Oct 22 '22 17:10

vivex