trufflesuite / ganache-cli-archive

Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.
https://www.trufflesuite.com/ganache
MIT License
3.36k stars 695 forks source link

eth_getTransactionCount returns an incorrect value #781

Closed thekevinbrown closed 3 years ago

thekevinbrown commented 3 years ago

Expected Behavior

Expected eth_getTransactionCount return value to be able to be used as a nonce in subsequent transactions.

Current Behavior

TXRejectedError: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 4
    at validateNonce ([project directory]/node_modules/ganache-core/lib/statemanager.js:1010:11)
    at [project directory]/node_modules/ganache-core/lib/statemanager.js:1019:7
    at [project directory]/node_modules/ganache-core/lib/blockchain_double.js:444:5
    at [project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:77:5
    at [project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:461:14
    at Object.return ([project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:485:9)
    at processNode ([project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:288:30)
    at processNode ([project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:521:5)
    at [project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:516:13
    at [project directory]/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:180:7
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Possible Solution

Unsure

Steps to Reproduce (for bugs)

I can create a script to reproduce this if necessary, just let me know.

Context

This is currently blocking us from using ganache as a testing environment locally.

Your Environment

thekevinbrown commented 3 years ago

After extensive debugging, this was on our side. It's still strange that ganache insists on sequential nonces, unlike normal clients, but that's likely intended behaviour for some reason, so I'll close this issue. Sorry for the noise!

davidmurdoch commented 3 years ago

Thanks for following up on this, @thekevinbrown! (and sorry I didn't reply sooner)

Yes, you are correct that Ganache doesn't support non-sequential nonces (or pending transactions/blocks). However, it will fully support it in the next major release!