Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3596 +/- ##
==========================================
+ Coverage 75.80% 75.93% +0.12%
==========================================
Files 381 386 +5
Lines 34377 34818 +441
==========================================
+ Hits 26059 26438 +379
- Misses 6492 6516 +24
- Partials 1826 1864 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
What happens if there is a re-org on L1? |
15a5437 to
22030a1
Compare
rodrodros
reviewed
May 6, 2026
Contributor
rodrodros
left a comment
There was a problem hiding this comment.
All looking good so far, some initial comments
rodrodros
reviewed
May 6, 2026
rodrodros
reviewed
May 6, 2026
rodrodros
reviewed
May 6, 2026
Contributor
rodrodros
left a comment
There was a problem hiding this comment.
Two test files should be correctly set as pruner_test
Switch the test file to an external test package so it exercises the pruner through its public API instead of package internals.
4c820cc to
b899d50
Compare
rodrodros
approved these changes
May 7, 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
Adds a
prunerservice that bounds on-disk storage by deleting block data and state history below a configurable retention window. With--retained-blocks=N, the node keeps blocks in(l1_head - N, l2_head]and prunes everything below.(l1_head - N, l2_head]answers normally (events, traces, state-at-block, etc.). Below the floor:event_filtersurfaces a typedErrBlockPruned;statebackendreturnsdb.ErrKeyNotFound(i.e. block-not-found), same as if the block never existed.--retained-blocksshrinks the window on the next sweep. Raising it grows the window gradually — the pruner pauses until the L1 head advances enough to reach the new floor; nothing is "un-pruned".--retained-blocks=0keeps existing behaviour.Open for discussion
starknet_getEventswith an unsetfrom_blockcurrently errors withErrBlockPrunedinstead of silently clamping to the oldest retained block. Strict over silent — an unbounded query against a pruned node has clearly lost data, and we'd rather surface that than return a partial result the caller doesn't know is partial. Happy to flip to clamp-to-oldest if reviewers prefer.Details
See the package doc on
pruner/pruner.goand the contract onPruneUptoinpruner/accessors.gofor the exact deletion set, the two intentional carve-outs (BlockHashLag headers and the parent-hash mapping), and resume semantics on cancellation.Touches outside
pruner/:blockchain/event_filter.go,blockchain/statebackend/*— gate reads on retention viapruner.RequireRetained/pruner.HeaderBy*IfStateRetained.core/block.go—BlockHashLagandBlockHashStorageContractmoved here fromsyncso the pruner carve-out and RPCgetRevealedBlockHashshare one source of truth.node/node.go,cmd/juno/juno.go—--retained-blocksflag and service wiring (sequencer and sync paths).node/metrics.go— Prometheus listener for prune events.