Ethereum Multi Node network design - nonce management for address

by Dzeki Novak   Last Updated February 27, 2019 17:28 PM

I am running two nodes on two different machines and geth installed, and for educational purposes I would like to make both nodes work concurrently. I know that nonce management is quite pain in the *** by default on only one machine, but I am very keen into implementing this with concurrency. Challenge on max level.

Problem I am trying to resolve is how to keep nonces synchronized between different nodes for an address 0x123 for example.

So I have to follow nonce per address. Giving that we are using address 0x123 for this example.

Step 1:

  • before doing transaction, query both nodes via rpc api, and get latest nonce number, and store(update) higher into centralized db for that address 0x123

State: Largest nonce from both nodes is 4. Updates db with 4.

Step 2:

  • Pending transactions - I do transaction on node A, with nonce 5, this is now pending transaction. This is stored in centralized location for Node A for account with address 0x123. Node A goes down.

State: Account Nonce 4, Node A Pending transaction nonce 5, Node B Pending transaction nonce is lower than Node A

Step 3:

  • I check health status of Node A, if node A is down, I resend pending transaction with Node B, taking larger pending transaction nonce number from both nodes, which in this case is Node A. Update Node B pending transaction for account 0x123.

State: Account Nonce 4, Node A Pending transaction nonce 5, Node B Pending transaction nonce 5

Step 4:

  • Whatever nodes pending transaction with nonce 5 goes first is winner, second node with already confirmed transaction nonce 5, won't go through.

So pretty much idea is to keep a track for nonce between different nodes. Is this viable option, or is there better and more robust way to do this?



Related Questions


Updated July 19, 2018 20:28 PM

Updated January 24, 2019 07:28 AM

Updated May 23, 2019 07:28 AM

Updated June 03, 2019 04:28 AM

Updated September 11, 2017 12:28 PM