Can anyone tell me how to fork a live Cosmos testnet?
I want to fork a running chain to my local environment and use the fork as a testing chain. Similar to how anvil --forkworks, I know one method is to use a snapshot provider to sync with the local chain. However, the chain I want to fork does not provide snapshots. Is there any other way to achieve this?
(post deleted by author)
One approach is exporting the genesis file and then replaying blocks from the current height. It takes longer than using snapshots but gives a functional forked chain for testing.
Cosmos doesn’t have an exact drop-in equivalent to anvil --fork because IAVL state trees can’t easily be served on-demand via standard JSON-RPC queries like Ethereum. If the testnet doesn’t offer downloadable snapshot archives, the cleanest alternative is running State Sync on your local node against two public testnet RPCs to pull the latest state root in a couple of minutes without syncing old block history. Once your local node catches up to the current block height, kill the daemon and run appd export --height <height> > genesis.json. From there, you just modify the exported genesis to change the chain-id, replace the existing validator set with your own local keyring, and reset the state to boot your isolated local cluster. For more automated simulation testing, a lot of Cosmos teams are also using Strangelove’s interchaintest framework to spin up local instances with state preloads, especially as cross-chain dev tooling keeps expanding.