Skip to content

fix: reconstruct recent blockhash history - #88

Merged
bmuddha merged 1 commit into
devfrom
fix/reconstruct-block-history
Aug 26, 2026
Merged

fix: reconstruct recent blockhash history#88
bmuddha merged 1 commit into
devfrom
fix/reconstruct-block-history

Conversation

@bmuddha

@bmuddha bmuddha commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Reconstruct the Keeper recent-blockhash cache from ledger history anchored at the AccountsDB slot.
  • Extend persisted SlotHashes with older retained ledger entries and preserve original slots for TTL expiry.
  • Reuse the same ledger traversal when creating a missing SlotHashes account.
  • Cover both retained-ledger recovery beyond 512 hashes and clean-ledger snapshot fallback.

Closes #87

Impact

Verifier-only restarts retain recent blockhash validity consistent with the uninterrupted leader when ledger history is available. Snapshot-staged AccountsDB instances without ledger history continue to fall back to persisted SlotHashes. No public API or storage encoding changes.

Reviewer notes

AccountsDB is the recovery authority: ledger entries newer than its slot are ignored because they may belong to an uncommitted crash tail. Ledger block ranges are consumed newest-first.

@bmuddha bmuddha added the bug Something isn't working label Aug 25, 2026
@bmuddha bmuddha self-assigned this Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a52c443c-d88f-44f4-8973-409fa75d5e09

📥 Commits

Reviewing files that changed from the base of the PR and between 9aab2c7 and 55ad328.

📒 Files selected for processing (6)
  • keeper/README.md
  • keeper/src/builder.rs
  • keeper/src/cache.rs
  • keeper/src/tests/recovery.rs
  • ledger/src/reader.rs
  • ledger/src/tests/integration.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Keeper startup now reconstructs recent blockhash history from retained ledger blocks and persisted SlotHashes, bounded by the AccountsDB slot and validity window. BlockSeed carries the latest block and retained history into BlocksCache. Snapshot recovery uses SlotHashes when ledger history is unavailable. Ledger block ranges now use descending slot order. Recovery tests cover both ledger-backed restoration and snapshot-only fallback.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #87 by reconstructing the validity window from retained ledger history, combining older entries with SlotHashes, anchoring recovery at the AccountsDB slot, supporting snapsho…
Out of Scope Changes check ✅ Passed The changes remain focused on recent blockhash recovery. Ledger traversal updates and integration tests directly support the required startup reconstruction behavior.
Docstring Coverage ✅ Passed Docstring coverage is 94.12% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 5 files. (1 skipped: 1 …
Title check ✅ Passed The title clearly and concisely describes the main change: reconstructing recent blockhash history during Keeper startup.
Description check ✅ Passed The description directly explains the ledger-based blockhash reconstruction, SlotHashes fallback, recovery behavior, and test coverage.
Full details: Linked Issues check

Explanation

The changes satisfy issue #87 by reconstructing the validity window from retained ledger history, combining older entries with SlotHashes, anchoring recovery at the AccountsDB slot, supporting snapshot fallback, and testing replayed blockhash validity.

Full details: Docstring Coverage

Explanation

Docstring coverage is 94.12% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 5 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reconstruct-block-history

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bmuddha
bmuddha marked this pull request as ready for review August 25, 2026 13:23
@bmuddha
bmuddha merged commit 026fc23 into dev Aug 26, 2026
4 checks passed
@bmuddha
bmuddha deleted the fix/reconstruct-block-history branch August 26, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verifier restart discards valid recent blockhash history

1 participant