Ganache-CLI –fork – How Does It Work in EVM?

evmganache-cli

I am trying to fork a chain with ganache for dry running transactions. But I still can't understand it exactly, so here are my questions :

Q1: does it download the whole blockchain? or just a minimal version only or not downloading at all?

Q2: does it continue to contact the original node for some data fetching after the fork?

I can't seem to find anything about these questions in the official docs.

Best Answer

It relies on an external source (fork from) for pre-fork information and then relies on its own block producer and append new blocks after the fork. It will continue to rely on the external source for information about the pre-fork state.

You can use it to test interactions. For example, if you want to run unit tests that interact with a liquidity pool and you want the test to be as realistic as possible. You can fork a chain where these things already exist, then deploy your contract and run interaction scenarios.

Hope it helps.

Related Topic