Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anvil tmp state growth issues in supersim #183

Open
Tracked by #308
tremarkley opened this issue Oct 2, 2024 · 1 comment
Open
Tracked by #308

anvil tmp state growth issues in supersim #183

tremarkley opened this issue Oct 2, 2024 · 1 comment

Comments

@tremarkley
Copy link
Contributor

tremarkley commented Oct 2, 2024

The issue

anvil generates state files while running. these files continue to grow the longer anvil runs and are not automatically deleted. this issue is amplified by the fact that supersim runs with 2s block times, which causes the state files to grow even more. On my macbook these files are being stored under the /Users/<username>/.foundry/anvil/tmp/ directory.

Recommended fix

anvil provides a --max-persisted-states states flag to help with this (see this issue from foundry: foundry-rs/foundry#8399). I recommend we set this to a low number for now and if there is a user demand for making this configurable we can add a cli flag that allows them to configure it.

Background

The --max-persisted-states flag controls how many blockchain state snapshots are persisted (saved) during the execution of the local Ethereum development chain. State snapshots refer to stored representations of the blockchain at a specific point in time. Anvil allows developers to "snapshot" the current state of the chain, which can later be restored (using the evm_revert JSON-RPC call). This feature is useful for testing because you can run a series of tests, revert the chain to a prior state, and then run another set of tests on the exact same blockchain state.

The --max-persisted-states flag sets a limit on how many of these snapshots (states) are saved or persisted on disk. This is useful for controlling disk usage and preventing your system from filling up with old or unnecessary snapshots. Without this flag, Anvil will keep all snapshots, potentially using a lot of disk space if you create a large number of them during testing. By using the --max-persisted-states flag, you can limit the number of snapshots to a certain number. For example, if you set it to 10, Anvil will only keep the last 10 snapshots, and older snapshots will be deleted as new ones are created.

@fainashalts
Copy link
Collaborator

Might be worthwhile to consider:

  • direct to a .supersim
  • auto delete

Needs a spike to consider the best approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants