feat(blockchain): aggregate only current-slot raw signatures at interval 2#485
Conversation
…val 2 The interval-2 aggregation worker processed jobs in HashMap-iteration order (gossip groups then payload-only merges) with no slot ordering, so the 750ms deadline could drop current-slot work in favor of stale-slot or recursive-merge jobs. Since only the current slot's votes get promoted and packed into the next block, that budget was misspent. Add snapshot_current_slot_aggregation_inputs: it builds pure raw-signature jobs for gossip groups whose data.slot matches the current slot only, with no existing-proof reuse and no payload-only pass. Wire it into start_aggregation_session. snapshot_aggregation_inputs is left intact.
🤖 Kimi Code ReviewThe PR introduces a targeted optimization to aggregate only current-slot gossip signatures, avoiding wasteful re-aggregation of stale attestations. The logic is sound, but I have concerns about signature deletion behavior and state validity. Critical: Potential Loss of Unresolved Signatures
In let keys_to_delete: Vec<(u64, H256)> = validator_sigs
.iter()
.map(|(vid, _)| (*vid, data_root))
.collect();If resolution fails due to transient state issues (e.g., head state not yet updated for a new validator set), these signatures are permanently lost from gossip rather than retried later. Recommendation: Only delete successfully resolved signatures (those in State Validity Concern
Using Minor Issues
Positive Observations
Consensus Safety Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code Review
No security or memory-safety issue stands out in this diff beyond those behavioral regressions. I would also want a regression test for “attestation arrives after slot N interval 2, gets aggregated at slot N+1” before merging. Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Greptile SummaryThis PR narrows interval-2 aggregation to current-slot raw gossip signatures. The main changes are:
Confidence Score: 4/5The changed flow looks mergeable after checking the payload-only aggregate path.
crates/blockchain/src/lib.rs
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/aggregation.rs | Adds current-slot raw-signature snapshotting and raw-only job construction. |
| crates/blockchain/src/lib.rs | Routes interval-2 aggregation through the new current-slot-only snapshot path. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
crates/blockchain/src/lib.rs:392-394
**Payload-Only Aggregates Stop Merging**
When the node receives current-slot aggregated payloads without matching raw gossip signatures, this path now returns early because `snapshot_current_slot_aggregation_inputs` never scans `new_payload_keys`. The old snapshot built payload-only merge jobs for those proofs, so interval-2 aggregation can now skip recursive merging for valid current-slot payloads and leave the block builder with less compact aggregate coverage.
Reviews (1): Last reviewed commit: "feat(blockchain): aggregate only current..." | Re-trigger Greptile
🤖 Claude Code ReviewReview:
|
What
Adds
snapshot_current_slot_aggregation_inputsand wires it intostart_aggregation_session, so the interval-2 aggregation worker aggregates only the current slot's raw gossip signatures.Why
The old
snapshot_aggregation_inputsbuilt jobs inHashMap-iteration order: Pass 1 gossip groups (in randomHashMap::values()order) followed by Pass 2 payload-only recursive merges. There was no slot ordering.Since the worker stops at the
AGGREGATION_DEADLINE(750ms) and drops any remaining jobs, under load the deadline could sacrifice current-slot aggregation in favor of stale-slot or recursive-merge work, purely by random iteration order. Only the current slot's aggregates get promoted toknown_payloadsand packed into the next block, so that deadline budget was misspent.How
New function restricts aggregation to gossip groups whose
data.slot == current_slot, building pure raw-signature jobs:snapshot_aggregation_inputs)snapshot_current_slot_aggregation_inputs)data.slot == current_slotHashMapordersnapshot_aggregation_inputsandbuild_jobare left untouched.Consequences
Testing
make fmt,make lint(workspace clippy-D warnings) clean. Per request, no unit tests added in this PR.