Repository navigation
fix(rpc): bound sync duties by the wall clock - #671
MegaRedHand wants to merge 2 commits into
Conversation
…eposit_contract and POST /eth/v1/validator/duties/sync/{epoch} from ethlambda beacon, three of the four Beacon API endpoints validator clients call that were missing. fork returns the state's own Fork through the same state_id resolution as the other state endpoints, so a state root is the same 404. deposit_contract returns the Config's deposit chain id and contract address. duties/sync reads the head state's current_sync_committee for an epoch in the head's own sync committee period and next_sync_committee for the next one, matches each requested validator by pubkey and returns every seat it holds (the committee is drawn with replacement), leaves out validators with no seat, and answers 400 for an unknown index or any other period and 503 while syncing. An earlier period is refused rather than answered from a historical state, recorded in docs/spec_deviations.md. compute_sync_committee_period is added to the altair helpers as validator.md defines it.
POST /eth/v1/validator/duties/sync/{epoch} accepted only the head state's
sync committee period and the next one. The Beacon API bounds the period by
the current epoch's: at the first slot of period P with the head still in
P-1 (its boundary block late or missing), a validator client asks for P+1
and got a 400.
The upper bound is now max(wall-clock period, head period) + 1. A period
past the head's next one is read from a copy of the head advanced, through
fork choice's checkpoint-state cache on a blocking thread, to the first epoch
of the period before it, whose next_sync_committee is the requested one. An
earlier period than the head's, an unknown index and a syncing node keep
their 400 and 503.
Adds a controlled-clock store helper to the rpc test utilities, and adapts
the period-after-next test to pin the clock to the head's period, since the
bound is no longer head-relative.
🤖 Kimi Code ReviewI'll review this PR which extends sync committee duty serving to handle cases where the head lags behind the wall clock across a period boundary. Overall AssessmentThe PR correctly implements Beacon API semantics for sync duties: bounding requests by the wall clock rather than the head state, with state advancement via Issues Found1. Critical:
|
| Priority | Issue | Location |
|---|---|---|
| High | Verify checkpoint_state behavior with wrong root in Checkpoint |
validator.rs:119-128 |
| Medium | Add error logging before discarding errors | validator.rs:126-127, 152 |
| Medium | Test fragility from real system time | lib.rs:470-476 |
| Low | Add test for head ahead of clock | validator.rs tests |
| Low | Rename first_epoch for clarity |
validator.rs:164 |
Automated review by Kimi (Moonshot AI) · kimi-k2.6 · custom prompt
🤖 Claude Code ReviewReview: PR 671, sync duties bounded by the wall clockI read the diff only and did not build or run the tests. The logic is sound. The period arithmetic checks out:
The tests cover the interesting cases: the rotation-proof assertion on the committee, the clock's own period, and two periods past the clock. Concerns
Nits
Overall this is a good change. I would address Point 1 (blocking-pool exposure) and Point 2 (error logging) before merging. Automated review by Claude (Anthropic) · sonnet · custom prompt |
🤖 Codex Code ReviewFound two correctness risks; the rest looks reasonable and the boundary tests are good.
Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
b252fbc to
49359e3
Compare
Motivation
POST /eth/v1/validator/duties/sync/{epoch}answered only the head state's sync-committee period and the next one. At a period boundary whose first block is late or missing, the head is still in period P-1 while the wall clock is in P, so a validator client asking for period P+1 (the next one, which beacon-APIs allows) got a 400. Same bug class as #663 (duties) and #670 (liveness): the bound must follow the wall-clock current epoch, not the head.Change
max(wall-clock period, head period) + 1.checkpoint_state, on a blocking thread) to the first epoch of the period before it, whosenext_sync_committeeanswers it.docs/spec_deviations.md).the_period_after_next_is_a_400asserted the old head-relative bound and now pins the clock to the head's period.cargo test -p ethlambda-rpc --lib --profile release-fast, clippy and fmt clean.