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.

Ganache-cli does not restore blockchain correctly after killing the process or reboot

See original GitHub issue

Version: 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:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
teknoxiccommented, Jan 27, 2022

Tested the fix, it’s working perfectly for both killing the process and rebooting. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

contracts missing from ganache-cli after restart
Suggestion: Try to run ganache-cli locally on your machine, then close it, then run it again. If the problem at hand is solved,...
Read more >
How to Exploit Ethereum in a Virtual Environment - ConsenSys
A little-known feature of Ganache is forking another blockchain. You can think about this as cloning an existing blockchain, but don't worry, ...
Read more >
python - killing ganache in brownie - Stack Overflow
So when you deploy a contract to your local ganache chain the first time, brownie stores addresses in its build folder. Those contracts...
Read more >
Creating your First Truffle Project (part 1 of 2) - Ippon
This is an introduction on how to get started with a Truffle-based Solidity project. This article series will not only explain how to...
Read more >
Network API — Brownie 1.19.2 documentation - Read the Docs
The Web3 provider is cleared, the active network is set to None and the local RPC client is terminated if it was launched...
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