-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add checkpoint-sync #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🤖 Kimi Code ReviewReview SummaryThis PR adds checkpoint sync functionality to ethlambda, allowing nodes to sync from a recent finalized state instead of genesis. The implementation is well-structured and follows Rust best practices, but there are several important issues to address: Critical Issues
Important Issues
Minor Issues
Line-specific Feedback
The PR is well-structured overall, but the security and consensus issues must be addressed before merging. Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewReview Findings (ordered by severity)
Consensus-layer considerations
Rust/maintainability notes
Open questions
If you address the anchoring and validation gaps above, the rest of the changes look clean and well-structured. Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewPerfect! Now I have a complete picture of the PR. Let me compile my review findings. Code Review: PR #93 - Add Checkpoint Sync SupportSummaryThis PR adds checkpoint sync functionality to allow nodes to sync from a trusted checkpoint state instead of starting from genesis. The implementation is well-structured with proper validation and error handling. Below are my findings. ✅ Strengths
🔴 Critical Issues1. State Root Mismatch Not Validated (Security)Location: The Issue: pub fn construct_anchor_block(state: &State) -> Block {
Block {
slot: state.latest_block_header.slot,
parent_root: state.latest_block_header.parent_root,
proposer_index: state.latest_block_header.proposer_index,
state_root: state.latest_block_header.state_root,
body: BlockBody::default(), // ⚠️ Default body - root may not match!
}
}The block's Recommendation:
2. No HTTPS Enforcement (Security)Location: Checkpoint sync downloads consensus state over HTTP without enforcing HTTPS. An attacker performing a MITM attack could provide a malicious state that passes validation checks. Current code: let url = format!("{base_url}/lean/v0/states/finalized");
let client = Client::builder()
.connect_timeout(CHECKPOINT_CONNECT_TIMEOUT)
.read_timeout(CHECKPOINT_READ_TIMEOUT)
.build()?;Recommendation:
3. Potential Type Confusion in Checkpoint ValidationLocation: The validation checks if let block_root = state.latest_block_header.tree_hash_root(); // Header root
if state.latest_block_header.slot == state.latest_finalized.slot
&& block_root != state.latest_finalized.root.0 // Comparing to block root?
{
return Err(CheckpointSyncError::BlockHeaderFinalizedRootMismatch);
}Question: Does Investigation needed: Check the consensus spec to confirm what
|
| Category | Status |
|---|---|
| Correctness | |
| Security | 🔴 Issues #1, #2 are critical |
| Performance | ✅ Good timeout strategy |
| Memory Safety | |
| Error Handling | ✅ Well-structured |
| Testing | ✅ Comprehensive unit tests |
| Code Quality | ✅ Clean, readable |
Recommendations Priority
- MUST FIX: State root validation (docs: add initial roadmap #1)
- MUST FIX: HTTPS enforcement (chore: initial repo setup #2)
- MUST INVESTIGATE: Checkpoint root type confusion (docs: improve readme #3)
- SHOULD FIX: Download size limit (feat: load genesis network configuration and state #5)
- SHOULD FIX: Future slot check (docs: add philosophy and design principles #4)
- CONSIDER: Anchor block root mismatch implications (feat: listen for gossipsub blocks #9)
The core implementation is solid, but the consensus-critical validation needs strengthening before merge.
Automated review by Claude (Anthropic) · custom prompt
Required for #93 This PR streamlines block storage by splitting block headers from bodies. This simplifies the handling of the anchor state, since the block header is readily available from it, but the body is not, even if it's unnecessary for child block processing.
460575a to
8a27971
Compare
This PR adds checkpoint-sync functionality when
--checkpoint-sync-urlis specified. This means the node will fetch the latest finalized state from the URL specified in the flag.NOTE: has some changes from #96, they'll be gone once that's merged.