Skip to content

fix(anvil): handle zero prune history safely#14307

Merged
figtracer merged 9 commits into
foundry-rs:masterfrom
mk0walsk:fix/anvil-zero-prune-history
Jun 8, 2026
Merged

fix(anvil): handle zero prune history safely#14307
figtracer merged 9 commits into
foundry-rs:masterfrom
mk0walsk:fix/anvil-zero-prune-history

Conversation

@mk0walsk

Copy link
Copy Markdown
Contributor

Motivation

--prune-history 0 currently reaches the in-memory history cache as 0. InMemoryBlockStates::enforce_limits() then loops on while self.present.len() >= self.in_memory_limit, which can hang block production when the limit is zero.

Solution

Normalize max_memory_history == 0 to the unsupported path in PruneStateHistoryConfig, and defensively clamp in-memory cache limits to at least 1 inside InMemoryBlockStates. Add regression tests for the config normalization and zero-limit cache guard.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

Comment thread crates/anvil/src/eth/backend/mem/storage.rs
@mk0walsk

Copy link
Copy Markdown
Contributor Author

@mablr Done, please take another look, thanks!

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smol pedantic nit :)

otherwise it's good.

Comment thread crates/anvil/src/eth/backend/mem/storage.rs Outdated
mablr
mablr previously approved these changes Apr 16, 2026

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm, pending another review ...

Comment thread crates/anvil/src/eth/backend/mem/storage.rs
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open for 14 days with no activity. It will be closed in 7 days if there is no further activity.

@figtracer figtracer enabled auto-merge (squash) June 8, 2026 08:35
@figtracer figtracer merged commit 58e6e10 into foundry-rs:master Jun 8, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Foundry Jun 8, 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.

3 participants