trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

evm_revert regression #4093

Closed brendene closed 1 year ago

brendene commented 1 year ago

On the latest stable release: ganache v7.7.2 (@ganache/cli: 0.8.1, @ganache/core: 0.8.1) The last version that doesn't have the issue is 7.6.0. 7.7.0 and 7.7.2 exhibit the issue detailed below.

I am having a hard time creating a self contained repro but the issue is reliably reproduced.

ganache is launched with: ganache-cli --chain.vmErrorsOnRPCResponse true --fork.url <LOCAL INSTANCE> --fork.blockNumber 16257210 --miner.blockTime 3600 --chain.chainId 1 -v --miner.timestampIncrement 12 --wallet.deterministic --logging.debug

The miner.blockTime is set very high so that I can manually mine using evm_mine

The gist of the application flow is:

send transactions evm_mine send transactions evm_mine evm_snapshot # SNAPSHOT1 send transactions evm_mine evm_snapshot # SNAPSHOT2 send transactions evm_mine evm_revert back to #SNAPSHOT2 (this succeeds) send transactions evm_mine evm_revert back to #SNAPSHOT1 (this fails)

There are no logs in from ganache, only 'Reverting to snapshot #1\' But the json response from ganache is:

{'id': 101, 'jsonrpc': '2.0', 'error': {'message': '.for is not iterable', 'stack': 'TypeError: .for is not iterable\n at ForkTrie.revertMetaData (/usr/local/lib/node_modules/ganache/dist/node/1.js:2:143320)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Blockchain.<anonymous> (/usr/local/lib/node_modules/ganache/dist/node/1.js:2:63016)\n at async Blockchain.revert (/usr/local/lib/node_modules/ganache/dist/node/1.js:2:70613)', 'code': -32700}}

And after querying for the current block, as expected the evm did not revert.

brendene commented 1 year ago

It might be this block of code as part of the big release to support the merge:

https://github.com/trufflesuite/ganache/blame/b816de218202e3f10182c61de9bae505b3c42710/src/chains/ethereum/ethereum/src/forking/trie.ts#L99

davidmurdoch commented 1 year ago

Yikes. The merge was an incredibly tricky and complex update. Sorry we didn't catch this already. Most of the team here is off until the 3rd or so, but we'll try to get a fix out for this as soon as we get back.