Skip to content

fix(anvil): sync state snapshots with reset and revert#14317

Open
solanaXpeter wants to merge 2 commits intofoundry-rs:masterfrom
solanaXpeter:fix-anvil-sync-state-snapshots
Open

fix(anvil): sync state snapshots with reset and revert#14317
solanaXpeter wants to merge 2 commits intofoundry-rs:masterfrom
solanaXpeter:fix-anvil-sync-state-snapshots

Conversation

@solanaXpeter
Copy link
Copy Markdown

Motivation

State snapshot metadata can diverge from backend state. anvil_reset clears chain and DB state without clearing active_state_snapshots, and revert_state_snapshot removed metadata before the DB revert succeeded. That can leave anvil_metadata reporting stale snapshots and make evm_revert depend on a partially applied rollback path.

Solution

Clear active_state_snapshots in both reset paths, and only remove a snapshot entry after the DB revert succeeds. When the backing snapshot block or DB snapshot is already gone, drop the stale metadata entry and return false without mutating chain state. Added regression tests for failed revert, in-memory reset, and fork reset paths.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant