Repository navigation
feat(sdk): keep historical states in the devnet anvil - #574
Merged
brunomenezes merged 1 commit intoNov 3, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 96ed521 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
tuler
approved these changes
Nov 3, 2026
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.
Summary
Anvil keeps recent states in memory and spills older ones to a temp directory on disk, up to
--max-persisted-statesof 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 withBlockOutOfRangeError. Atcartesi run --block-time 2that is about two hours of history.The
devnetscript 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 longcartesi runsessions: two days at a 2s block time. The cost is disk inside the container, not memory.--preserve-historical-statesonly matters for--dump-state: it includes the historical states in the dump, so a developer who passes--dump-stateto the devnet during development gets them back on--load-state.cartesi rundoesn'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.0reads 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 86400Fork mode (
cartesi run --fork-url) runs plainanvil --fork-urland is unchanged.Changes
packages/sdk/devnet: add the two anvil flags to theexec anvilline..changeset/shiny-wings-play.md:@cartesi/sdkpatch.