Increase STATES_TO_KEEP from 900 to 3000#241
Conversation
Extends state retention from ~1 hour to ~3.3 hours (at 4-second slots), reducing the likelihood of state-header gaps during finalization stalls. Closes #239
🤖 Kimi Code ReviewReview SummaryThe PR increases Issues Found
The change itself is straightforward and the assertion on lines 88-91 correctly ensures Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewFindings (ordered by severity):
Overall assessment:
Validation note:
Automated review by OpenAI Codex · custom prompt |
Greptile SummaryThis PR increases Key observations:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| crates/storage/src/store.rs | Increases STATES_TO_KEEP from 900 to 3_000 and updates the doc-comment; the compile-time assertion BLOCKS_TO_KEEP >= STATES_TO_KEEP still holds. One test comment (lines 1489–1491) retains the old hardcoded numbers and should be updated to match the new constant. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[New block/state arrives] --> B{States count > STATES_TO_KEEP\n3_000}
B -- No --> C[Keep all states — no pruning]
B -- Yes --> D[Sort states by slot descending]
D --> E[Skip top 3_000 newest states]
E --> F{Is state root in\nprotected_roots?\nfinalized / justified}
F -- Yes --> G[Preserve state]
F -- No --> H[Delete state from storage]
G --> I[Pruning complete]
H --> I
Comments Outside Diff (1)
-
crates/storage/src/store.rs, line 1489-1491 (link)Stale hardcoded numbers in test comment
After increasing
STATES_TO_KEEPfrom900to3_000, this comment still references the old concrete values (905,900,902). The assertion below correctly usesSTATES_TO_KEEP + 2, but the explanatory comment is now misleading — it describes a scenario with 905 total entries and a 900-slot window, when the actual values are 3005 and 3000.Prompt To Fix With AI
This is a comment left during a code review. Path: crates/storage/src/store.rs Line: 1489-1491 Comment: **Stale hardcoded numbers in test comment** After increasing `STATES_TO_KEEP` from `900` to `3_000`, this comment still references the old concrete values (`905`, `900`, `902`). The assertion below correctly uses `STATES_TO_KEEP + 2`, but the explanatory comment is now misleading — it describes a scenario with 905 total entries and a 900-slot window, when the actual values are 3005 and 3000. How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: crates/storage/src/store.rs
Line: 1489-1491
Comment:
**Stale hardcoded numbers in test comment**
After increasing `STATES_TO_KEEP` from `900` to `3_000`, this comment still references the old concrete values (`905`, `900`, `902`). The assertion below correctly uses `STATES_TO_KEEP + 2`, but the explanatory comment is now misleading — it describes a scenario with 905 total entries and a 900-slot window, when the actual values are 3005 and 3000.
```suggestion
// 3005 headers total. Top 3000 by slot are kept in the retention window,
// leaving 5 candidates. 2 are protected (finalized + justified),
// so 3 are pruned → 3005 - 3 = 3002 states remaining.
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 637b131
🤖 Claude Code ReviewHere is the review: PR Review: Increase
|
MegaRedHand
left a comment
There was a problem hiding this comment.
LGTM. Left a comment about a typo in a comment
Co-authored-by: Tomás Grüner <[email protected]>
Motivation
Increase state retention window from ~1 hour (900 slots) to ~3.3 hours (3000 slots) at 4-second slot times. This reduces the gap between state retention and block retention (
BLOCKS_TO_KEEP=21600), making state-header mismatches less likely during finalization stalls.Changes
Single constant change in
crates/storage/src/store.rs:How to Test
make test— all tests pass.Closes #239