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.31k stars 1.76k forks source link

feat(`anvil`): be able to specify a prefix path for temp disk storage #3512

Open kahuang opened 2 years ago

kahuang commented 2 years ago

Component

Anvil

Describe the feature you would like

When anvil state grows, it persists it temporarily to disk. I'd like to be able to specify a prefix path for the directory that gets created by anvil for this state.

Additional context

I am running Anvil in the cloud, and want to attach a persistent disk to the instance and mount it at the path anvil will use for storing state. Because it's a random directory each time, there's no way for me to programatically mount my disk at that location before anvil starts.

gakonst commented 2 years ago

@mattsse PTAL^

mattsse commented 2 years ago

Does this also concern the RPC cache dir @kahuang ?

kahuang commented 2 years ago

Anywhere that disk space can grow unbounded!

kahuang commented 2 years ago

Actually after reading the code, it seems like this always mounts at /tmp then generate a random filename.Although it may be nice to be able to specify a dir specifically for this data: https://docs.rs/tempdir/latest/tempdir/struct.TempDir.html

Not high pri IMO

emilianobonassi commented 1 year ago

I need it too to be able to restart a session from a specific state.

grandizzy commented 1 month ago

I need it too to be able to restart a session from a specific state.

@emilianobonassi this is possible in latest versions by using

      --state <PATH>
          This is an alias for both --load-state and --dump-state.

          It initializes the chain with the state and block environment stored
          at the file, if it exists, and dumps the chain's state on exit.

https://book.getfoundry.sh/reference/anvil/

We're also going to look into implementing the original cache dir request