Ganache-cli does not restore blockchain correctly after killing the process or reboot
See original GitHub issueVersion: ganache v7.0.0-alpha.2 (@ganache/cli: 0.1.1-alpha.2, @ganache/core: 0.1.1-alpha.2) Operating System: Ubuntu 20.04.3 LTS
I’ve noticed an issue with Ganache-cli, when i save the database in a directory using --database.dbPath and reboot my system or kill the process and then restart ganache using the same database it seems to go back in time and doesn’t reload the exact state of the blockchain when the process was killed or reboot occurred.
I know rebooting or killing the process isn’t an ideal way to stop ganache, but i am testing worst case scenario of using this in a production envrionment, so its important to retain the exact blockchain state.
Proof of Concept:
Start ganache:
ganache-cli --database.dbPath /opt/db -a 20 --wallet.defaultBalance 10 --wallet.mnemonic "* * * * * * * * * * * * -g 0 -p 7545 --chain.networkId 111 -h 127.0.0.1 --miner.blockTime 0 --server.ws --chain.hardfork berlin
Check the balance of an account with Ether:
0x***** : 10 Ether
Send 5 Ether to another account
Check Balance 0x***** : 5 Ether
Reboot
Restart Ganache
ganache-cli --database.dbPath /opt/db -a 20 --wallet.defaultBalance 10 --wallet.mnemonic "* * * * * * * * * * * * -g 0 -p 7545 --chain.networkId 111 -h 127.0.0.1 --miner.blockTime 0 --server.ws --chain.hardfork berlin
Check Balance 0x***** : 10 Ether
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
Tested the fix, it’s working perfectly for both killing the process and rebooting. Thanks!
Fixed! https://github.com/trufflesuite/ganache/releases/tag/v7.0.1