question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Corrupted signature or message sometimes leads to invalid nonce error

See original GitHub issue

How to reproduce:

  1. Start a new instance of ganache-cli (v6.2.5/docker)
  2. Use account A from the auto-generated accounts with funds
  3. Send some valid transactions to the blockchain
  4. Query latest nonce, send an ETH send transaction with (a) corrupted signature or (b) corrupted data field

Instead of a “invalid signature” message this leads to:

{
  "code": -32000,
  "message": "the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 14",
  "data": {
    "stack": "n: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 14\n    at i (/app/ganache-core.docker.cli.js:37:300962)\n    at blockchain.getQueuedNonce (/app/ganache-core.docker.cli.js:37:301093)\n    at /app/ganache-core.docker.cli.js:25:150975\n    at /app/ganache-core.docker.cli.js:37:630596\n    at /app/ganache-core.docker.cli.js:37:634357\n    at Object.return (/app/ganache-core.docker.cli.js:37:633934)\n    at /app/ganache-core.docker.cli.js:37:632186\n    at e (/app/ganache-core.docker.cli.js:37:634305)\n    at /app/ganache-core.docker.cli.js:37:634316\n    at /app/ganache-core.docker.cli.js:37:631398\n    at process._tickCallback (internal/process/next_tick.js:61:11)",
    "name": "n"
  }
}

However, there is probably a race condition involved since sometimes instead I get

{
  "code": -32000,
  "message": "Invalid Signature",
  "data": {
    "stack": "Error: Invalid Signature\n    at e.getSenderPublicKey (/app/ganache-core.docker.cli.js:10:88137)\n    at e.getSenderAddress (/app/ganache-core.docker.cli.js:10:87941)\n    at A.queueRawTransaction (/app/ganache-core.docker.cli.js:37:292154)\n    at u.eth_sendRawTransaction (/app/ganache-core.docker.cli.js:37:283039)\n    at u.handleRequest (/app/ganache-core.docker.cli.js:37:280006)\n    at t (/app/ganache-core.docker.cli.js:37:143367)\n    at a.handleRequest (/app/ganache-core.docker.cli.js:37:278371)\n    at t (/app/ganache-core.docker.cli.js:37:143367)\n    at s.f.handleRequest (/app/ganache-core.docker.cli.js:37:271502)\n    at s.handleRequest (/app/ganache-core.docker.cli.js:37:269329)\n    at t (/app/ganache-core.docker.cli.js:37:143367)\n    at c.handleRequest (/app/ganache-core.docker.cli.js:37:277385)\n    at t (/app/ganache-core.docker.cli.js:37:143367)\n    at a.handleRequest (/app/ganache-core.docker.cli.js:37:276832)\n    at t (/app/ganache-core.docker.cli.js:37:143367)\n    at d._handleAsync (/app/ganache-core.docker.cli.js:37:143403)\n    at Timeout._onTimeout (/app/ganache-core.docker.cli.js:37:142828)\n    at ontimeout (timers.js:436:11)\n    at tryOnTimeout (timers.js:300:5)\n    at listOnTimeout (timers.js:263:5)\n    at Timer.processTimers (timers.js:223:10)",
    "name": "Error"
  }
}

The ratio incorrect nonce to invalid signature is about half half.

I suspect the following: the sender is calculated from signature+message via the secp256k1 public key recovery algorithm. Now before the signature is checked for validity, the nonce is compared to the nonce of a wrong account B != A.

On Rinkeby I observe the same problem. They just report {"code":-32000,"message":"invalid sender"} which is a little bit less confusing but still not great.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
webmaster128commented, Sep 30, 2021

It has been years since I opened this one and I don’t work in this particular technology anymore. I also don’t know what this is about anymore. So from my side this can be closed. However, if anything of the above is still useful, feel free to use this ticket but don’t expect activity from me anymore. Cheers!

0reactions
davidmurdochcommented, Apr 22, 2022

Closing this for issue maintenance. Please leave a comment if this is still an issue and we’ll reopen and look into it further!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What a Nonce Error Is & How to Fix It - HubSpot Blog
A nonce error is caused when a user makes a request without having the correct nonce generated by WordPress and given to the...
Read more >
“Invalid Nonce” Error in login/register page - WordPress.org
I am using your plugin and getting this error- “Invalid Nonce” while trying to login or register, from last week or so (last...
Read more >
micro uniquestamp, what is this? - Stack Overflow
"Invalid Nonce is sent when nonce you sent is smaller or equal to the nonce that was previously sent." And,. "if you make...
Read more >
Source Code Survey | NEAR Documentation
This page provides a very high level, sometimes "pseudocode", view of error types and related messages as implemented by the NEAR platform.
Read more >
Fix "invalid or corrupted package (PGP signature)" Error In ...
How To Fix “invalid or corrupted package (PGP signature)” Error In Arch Linux ... 69 signed: 7 trust: 69-, 0q, 0n, 0m, 0f,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found