Repository navigation
feat(provider): add anvil_dump_state_with_history to AnvilApi - #4025
Merged
Merged
Conversation
Adds a non-breaking `anvil_dump_state_with_history` method alongside the existing `anvil_dump_state`. It passes `true` to the `anvil_dumpState` RPC, which includes historical states of accounts and storage at particular block hashes in the dump — allowing a reloaded node to serve RPC calls for blocks prior to the one at which state was dumped. Equivalent to running anvil with `--preserve-historical-states` at startup.
antonbaliasnikov
requested review from
DaniPopes,
grandizzy,
klkvr,
mattsse and
onbjerg
as code owners
June 5, 2026 09:44
mattsse
approved these changes
Jun 7, 2026
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
anvil_dumpStateaccepts an optionalpreserve_historical_states: boolparameter (added in foundry-rs/foundry), butAnvilApi::anvil_dump_statealways calls the RPC without any parameter, which makes the server default tofalse— silently omitting historical states from the dump even when the node was started with--preserve-historical-states.There is no way to get a full state dump (including historical account and storage states at each block hash) through the typed provider API.
Solution
Adds
anvil_dump_state_with_historyas a non-breaking addition toAnvilApi. It callsanvil_dumpStatewithtrue, including historical states in the returned buffer. A reloaded node can then serve RPC calls for blocks prior to the one at which state was dumped.The existing
anvil_dump_stateis unchanged to avoid breaking changes.PR Checklist