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
8.29k stars 1.75k forks source link

feat(`anvil`): option to persist all archive data #3760

Open fubhy opened 1 year ago

fubhy commented 1 year ago

Component

Anvil

Describe the feature you would like

As described here it would be great if there was an option for Anvil to act as a full-blown a archive node, persisting all data also between restarts.

This would be required for using Anvil in a local or shared development environment with Subgraphs, Substreams, Firehose, etc. but would also be useful in development environments without these components.

The ability to restart Anvil without losing any data is crucial for a smooth developer experience from back to front and would enable Anvil to be used in similar fashion to how Ganache and Hardhat are being used today to develop and test dApp frontends and data pipelines.

Additional context

Original discussion: https://github.com/foundry-rs/foundry/pull/3730#issuecomment-1323605612

desi commented 1 year ago

+1

golden-expiriensu commented 1 year ago

Hi guys! Is this still planned? We use anvil as a private testnet to develop our application in the context of the mainnet. We fork mainnet and deploy a ton of contracts on that fork and then set up dozens of integrations with protocols (CurveFi, UniV3, Aave and others). Anvil node runs in the cloud 24/7 and obviously after a certain time all information about old transactions (made on the fork) removes from memory cache => disappears forever. At the moment we use hardhat-deploy (unfortunately we are still dependent on hardhat, but we are trying to switch completely to foundry) to deploy contracts. The problems start when we need to update/deploy contracts without redeploying the whole system, as the information about the old contracts (transactions are checked by the hh-deploy library) being deleted from memory. It turns out that if we need to update one facet in Diamond, we need to redeploy entire system :(. Why is this not a solution? If you update contracts, you have to drop all the data on dev databases on the backend, because they store data relevant to previous version of contracts, and if you leave everything as it is, there will be a disynchronisation with the blockchain. I hope I have described why persistent transactions would be incredibly helpful to our project. By the way, for us, it would be enough that in addition to state.json foundry would also write a transaction.json file with all transactions made after forking. Maybe you would consider this as a one step of making everything persistent? Thanks in advance :)

vseae commented 1 month ago

+1

naps62 commented 1 month ago

Am I misinterpreting or is this already solved as of https://github.com/foundry-rs/foundry/pull/3730#issuecomment-1332256545 ?