fix: use store's latest_justified as attestation source (leanSpec #595)#315
Conversation
Revert PR 506's use of the head state's justified checkpoint for attestation production. Voting now uses the store's global latest_justified again, and liveness is preserved by the existing fixed-point loop in build_block plus a new invariant check: produced blocks must not lag the store's justified slot. The invariant surfaces as a recoverable StoreError variant so the node logs and skips proposal instead of crashing. See: leanEthereum/leanSpec#595
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
🤖 Kimi Code ReviewItem 1: Potential genesis checkpoint regression
Verify that Item 2: Missing test coverage for new invariant The removed test Add tests to verify:
Item 3: Unclear function reference
Item 4: Performance and safety improvement Acknowledged: The removal of Item 5: Invariant check correctness
Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code ReviewFindings:
I could not run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Claude Code ReviewNow I have sufficient context to write a thorough review. Here is the analysis: PR Review: fix: use store's
|
Summary
Applies leanSpec#595, which reverts leanSpec#506. Attestation production now uses the store's global
latest_justifiedcheckpoint again; liveness under a justified-divergence is preserved by the existing fixed-point loop inbuild_block, guarded by a new invariant that blocks must not lag the store's justified slot.produce_attestation_datareturnssource = store.latest_justified()(drops the head-state-derived source and the genesis ZERO-root patch;latest_justifiedis seeded to the anchor block root at genesis, so no correction is needed).produce_block_with_signaturescheckspost_checkpoints.justified.slot >= store.latest_justified().slotand otherwise returns a newStoreError::JustifiedDivergenceNotClosedvariant. The existing call site incrates/blockchain/src/lib.rsalready usesinspect_err+ early return, so the node logsFailed to build blockand skips proposal rather than crashing.produce_attestation_data_uses_head_state_justifiedsince it codified the reverted behavior. No new tests were added; the self-healing block-production path is exercised by the fork-choice spec tests against the currently pinned leanSpec commit.Spec fixture compatibility
The pinned
LEAN_SPEC_COMMIT_HASH(bc17f7ae…) is 30 commits ahead of leanSpec#595's merge commit (fcef7ef9…), with the merge base equal to that commit. No fixture regeneration is required: existing fixtures already reflect the post-595 behavior.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --release(313 passed, 6 ignored, 29 suites), includingforkchoice_spectests(70 tests) andstf_spectestsagainst the currently pinned leanSpec commit.claude/skills/test-pr-devnet/scripts/test-branch.shto confirm multi-client finalization still advances and the new invariant doesn't fire under normal operation