Skip to content

feat(sdk): keep historical states in the devnet anvil - #574

Merged
brunomenezes merged 1 commit into
feat/bump-kernel-versionfrom
feat/increase-state-retention
Nov 3, 2026
Merged

brunomenezes merged 1 commit into
feat/bump-kernel-versionfrom
feat/increase-state-retention

Conversation

@brunomenezes

Copy link
Copy Markdown
Member

Summary

Anvil keeps recent states in memory and spills older ones to a temp directory on disk, up to --max-persisted-states of them, 3,600 by default (foundry 1.5.1, crates/anvil/src/eth/backend/mem/storage.rs). Beyond that the oldest states are deleted, so a state read (eth_call, eth_getBalance, …) at an older block fails with BlockOutOfRangeError. At cartesi run --block-time 2 that is about two hours of history.

The devnet script now starts anvil with --preserve-historical-states --max-persisted-states 86400, the same configuration the rollups-node devnet uses (cartesi/rollups-node@47c7a6c9, test/devnet/Dockerfile), so reads at older blocks keep working through long cartesi run sessions: two days at a 2s block time. The cost is disk inside the container, not memory.

--preserve-historical-states only matters for --dump-state: it includes the historical states in the dump, so a developer who passes --dump-state to the devnet during development gets them back on --load-state. cartesi run doesn't dump state, so it has no effect there; it's kept so the devnet matches the rollups-node devnet's configuration.

Nothing on rollups-node next/2.0 reads state at a block hash today. The upcoming node release pins claimer and PRT calls to block hashes (cartesi/rollups-node#813, cartesi/rollups-node#814). Once a pinned block's state is gone, those calls fail and PRT apps stop joining tournaments or accepting claims, in a way that doesn't point at anvil. This prepares the SDK that ships with #562 for that node.

Order: cartesi run → cartesi/sdk devnet --block-time N → anvil --load-state … --preserve-historical-states --max-persisted-states 86400

Fork mode (cartesi run --fork-url) runs plain anvil --fork-url and is unchanged.

Changes

  • packages/sdk/devnet: add the two anvil flags to the exec anvil line.
  • .changeset/shiny-wings-play.md: @cartesi/sdk patch.

@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 96ed521

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brunomenezes brunomenezes moved this to 👁 In Review in Rollups Tooling Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Waiting Merge in Rollups SDK Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from 👁 In Review to 👍 Waiting Merge in Rollups Tooling Nov 3, 2026
@brunomenezes
brunomenezes merged commit c367e78 into feat/bump-kernel-version Nov 3, 2026
6 of 7 checks passed
@brunomenezes
brunomenezes deleted the feat/increase-state-retention branch November 3, 2026 11:58
@github-project-automation github-project-automation Bot moved this from 👍 Waiting Merge to 📦 Done in Rollups Tooling Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Waiting Merge to Done in Rollups SDK Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done
Status: 📦 Done

Development

Successfully merging this pull request may close these issues.

2 participants