Skip to content

feat(provider): add anvil_dump_state_with_history to AnvilApi - #4025

Merged
mattsse merged 1 commit into
alloy-rs:mainfrom
antonbaliasnikov:main
Jun 7, 2026
Merged

mattsse merged 1 commit into
alloy-rs:mainfrom
antonbaliasnikov:main

Conversation

@antonbaliasnikov

Copy link
Copy Markdown
Contributor

Motivation

anvil_dumpState accepts an optional preserve_historical_states: bool parameter (added in foundry-rs/foundry), but AnvilApi::anvil_dump_state always calls the RPC without any parameter, which makes the server default to false — 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_history as a non-breaking addition to AnvilApi. It calls anvil_dumpState with true, 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_state is unchanged to avoid breaking changes.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

  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.
@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Jun 7, 2026
@mattsse
mattsse merged commit b33ad07 into alloy-rs:main Jun 7, 2026
15 of 29 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants