feat(blockchain): disable attestation compaction, keep single best proof#473
feat(blockchain): disable attestation compaction, keep single best proof#473MegaRedHand wants to merge 2 commits into
Conversation
Alternative to the supermajority-cutoff approach (#472): instead of packing proofs up to the 2/3 threshold and merging the rest, pack exactly one proof per AttestationData (the one covering the most validators not already counted for the target) and never merge. This removes compact_attestations and its recursive aggregate_proofs call from block building entirely. The multi-proof XMSS merge is the dominant cost of building blocks that carry attestations, so this trades some per-block vote coverage for a much cheaper build path: a target whose 2/3 is split across multiple proofs may take more slots to justify, but each block is built with no recursive proof merge. Safe for the same reasons as #472: fork-choice weight is gossip-sourced (not block-sourced), justification is binary at 2/3, and there are no inclusion rewards. - select_best_proof replaces extend_proofs_greedily: picks the single proof with the most net-new voters (deterministic slice-order tie-break) and returns the voters it packed so the selection projection stays consistent with the block. - build_block drops the compact step; score_entry / pick_best_candidate no longer return the per-entry voter set. - Removes compact_attestations, union_aggregation_bits, and the aggregate_proofs import. Tests: select_best_proof unit tests (largest pick, net-new-over-prior ranking, packs-nothing guard) and a build_block end-to-end test proving a multi-proof entry packs one proof and still justifies via the real STF.
🤖 Kimi Code ReviewOverall Assessment: The PR correctly disables attestation compaction by selecting a single best proof per Specific Comments:
Security/Liveness Note: Disabling compaction means blocks cannot combine multiple partial proofs for the same Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code Review
I did not find a memory-safety issue in the diff itself, but the consensus-layer scoring/projection mismatch above is a blocker. I did not run tests. Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Greptile SummaryThis PR changes block building to keep one attestation proof per data entry. The main changes are:
Confidence Score: 4/5The changed attestation selection path needs a fix before merging.
crates/blockchain/src/block_builder.rs
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/block_builder.rs | Disables compaction and adds single-best-proof selection, but candidate tiering still uses union coverage from all proofs. |
Comments Outside Diff (1)
-
crates/blockchain/src/block_builder.rs, line 403-409 (link)Union Score Projects Justification
When one
AttestationDatahas several fragmented proofs whose combined voters cross 2/3 but no single proof does, this tier is marked asJustifyfrom the union even thoughselect_best_proofonly packs one proof.select_attestationsthen records the target as justified fromscore.tier, can skip a competing single-proof supermajority entry or admit dependent attestations, and the final STF can fail or produce a block that misses a justification it could have included.Prompt To Fix With AI
This is a comment left during a code review. Path: crates/blockchain/src/block_builder.rs Line: 403-409 Comment: **Union Score Projects Justification** When one `AttestationData` has several fragmented proofs whose combined voters cross 2/3 but no single proof does, this tier is marked as `Justify` from the union even though `select_best_proof` only packs one proof. `select_attestations` then records the target as justified from `score.tier`, can skip a competing single-proof supermajority entry or admit dependent attestations, and the final STF can fail or produce a block that misses a justification it could have included. How can I resolve this? If you propose a fix, please make it concise.
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/block_builder.rs:403-409
**Union Score Projects Justification**
When one `AttestationData` has several fragmented proofs whose combined voters cross 2/3 but no single proof does, this tier is marked as `Justify` from the union even though `select_best_proof` only packs one proof. `select_attestations` then records the target as justified from `score.tier`, can skip a competing single-proof supermajority entry or admit dependent attestations, and the final STF can fail or produce a block that misses a justification it could have included.
Reviews (1): Last reviewed commit: "feat(blockchain): disable attestation co..." | Re-trigger Greptile
🤖 Claude Code ReviewI have everything I need. Here is the review: PR #473 —
|
What
An alternative to PR #472 (the 2/3 supermajority cutoff). This PR disables compaction entirely: block building packs exactly one proof per
AttestationData(the best one) and never merges proofs.The two PRs are independent (both branch from
main) so they can be compared/benchmarked; only one should be merged.compact_attestationsWhy
The recursive XMSS merge (
compact_attestations→aggregate_proofs) is the dominant cost of building blocks that carry attestations. Removing it makes the build path much cheaper, at the cost of per-block vote coverage: a target whose 2/3 is split across multiple gossip proofs may take more slots to justify, but each block is built with no recursive proof merge.How
select_best_proofreplacesextend_proofs_greedily: picks the single proof covering the most validators not already counted for the target (prior_voters), so a proof that is mostly prior voters loses to an all-new one. Ranking iterates the proof slice in order, so ties are deterministic.select_attestationsupdates its projection from that set, keeping the projection consistent with the block.build_blockdrops the compact step.score_entry/pick_best_candidateno longer return the per-entry voter set.compact_attestations,union_aggregation_bits, and theaggregate_proofsimport. (StoreError::SignatureAggregationFailedis retained; it is part of the public error enum.)propose_blockis unchanged — that is the block signature, not compaction.Safety
Same basis as #472: fork-choice weight is gossip-sourced (not block-sourced), justification is binary at 2/3, and there are no inclusion rewards. Dropping voters from a block changes neither head selection nor finalization.
Tests
select_best_proofunit tests: packs the single largest proof; ranks by net-new overprior_voters; packs nothing when no proof adds a new voter.build_block_packs_single_best_proof_and_justifies: end-to-end — a data entry with multiple proofs packs only the best one and still justifies the target through the real STF.make fmt, workspace clippy-D warnings, andcargo test -p ethlambda-blockchain --lib(38 pass) all green.