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

Frequent nonce error #552

Open
Younghoon-Lee opened this issue Jul 10, 2022 · 5 comments
Open

Frequent nonce error #552

Younghoon-Lee opened this issue Jul 10, 2022 · 5 comments

Comments

@Younghoon-Lee
Copy link

Younghoon-Lee commented Jul 10, 2022

Hi
thanks for this beautiful engine in advance. I can see your great efforts.
To improve aurora network , I would like to raise one issue I am facing it at the moment.

I am testing on aurora testnet currently, and it seems there is something wrong with nonce tracking.
I faced a lot of ERR_INCORRECT_NONCE error messages, so I tracked it manually by web3.eth.getTransactionCount between each transactions.
And it turned out that nonce was not following up correctly( time delay I guess) between each transaction. So I looked up aurora-relayer github repo and It seems aurora-engine, this repo, is more related to this issue I am facing.
I apologize if I made wrong assumption due to lack of my engineering skill.

@birchmd
Copy link
Member

birchmd commented Jul 10, 2022

Thanks for the report @Younghoon-Lee

Could you provide more details about what nonce changes you observed? For example a sequence of transactions with the corresponding observed and expected nonce values.

@Younghoon-Lee
Copy link
Author

Younghoon-Lee commented Jul 11, 2022

Thanks for quick response @birchmd
Here is a piece of simple code I tested with to track nonce.

for (let i=0; i<1000; i++) {
    console.log('before:    ')
    console.log( await eth.getTransactionCount( myWallet.address))
    console.time("time duration");
    await Contract.methods
      .function(params)
      .send({ from: myWallet.address, gas: GAS_PRICE });

    console.timeEnd("time duration");
    console.log('after:     ')
    console.log( await eth.getTransactionCount( myWallet.address))
}

And this is the result of the code >>>

before:    
161
approvePlugin: 5.730s
after:     
162
before:    
162
approvePlugin: 5.439s
after:     
163
before:    
163
approvePlugin: 5.027s
after:     
163
before:    
163
approvePlugin: 4.429s
after:     
164
before:    
164
Error: Returned error: ERR_INCORRECT_NONCE
    at Object.ErrorResponse (/Users/younghoon/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /Users/younghoon/node_modules/web3-core-requestmanager/lib/index.js:300:36
    at request.onreadystatechange (/Users/younghoon/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/Users/younghoon/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/Users/younghoon/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/Users/younghoon/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/Users/younghoon/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1344:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  data: {
    host: 'https://testnet.aurora.dev',
    request_body: {
      jsonrpc: '2.0',
      id: 38,
      method: 'eth_sendRawTransaction',
      params: [Array]
    }
  }
}

However, if I control my nonce manually, it never gets nonce error.
Like below

let myNonce = await eth.getTransactionCount( myWallet.address)
    await Contract.methods
      .function(params)
      .send({ from: myWallet.address, gas: GAS_PRICE, nonce : myNonce++ });

@joshuajbouw
Copy link
Contributor

That gets us closer to solving the ERR NONCE error. Looks to be an infrastructure problem. I'll notify the correct person that can help resolve this.

@Younghoon-Lee
Copy link
Author

@joshuajbouw
Appreciate.
Please keep me updated in this thread. It would be very helpful!

@Umar-Abbas
Copy link

you can try this as well
let myNonce =await web3.eth.getTransactionCount(_toAddress)

  let NetxNonce= web3.utils.toHex(myNonce++)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants