foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
7.88k stars 1.58k forks source link

Cheat to save/load the blockchain #7955

Open kayabaNerve opened 1 month ago

kayabaNerve commented 1 month ago

Component

Anvil

Describe the feature you would like

dumpState/loadState only dumps/loads the EVM state. I'm working on a multi-nodal testing environment where I control block production (making Kurtosis not a candidate for this environment) and was hoping for dumpState/loadState be usable to cause one Anvil instance's blockchain to become another Anvil instance's.

Since dumpState/loadState only explicitly covers the EVM state, I now have one instance with a bunch of blocks, one instance with no blocks, and two indexers on my end with different results.

I'm not explicitly requesting a behavior change in dumpState/loadState and am fine if this is introduced as dumpChain/loadChain.

Additional context

No response

stevenvaleri commented 1 month ago

Came here to request this feature for a different reason. I'd like to simulate a specific scenario of transactions and then run (non-foundry) scripts against them. The scenario uses cheats to advance the blocktime, and the script I'm testing is dependent on time passing. Of course I can execute all of the transactions every time to prepare the state / blocks, but this takes a while. LoadState doesn't work since the state is loaded, but the advances in block time are not accounted for.