simplify aggregated payload(s) processing from block or from gossip#625
simplify aggregated payload(s) processing from block or from gossip#625
Conversation
Consolidate the two separate paths for storing aggregated attestation payloads into a single forkchoice.storeAggregatedPayload function. Previously, block attestations called storeAggregatedPayload (single validator_id, stored in latest_known_aggregated_payloads) while gossip attestations called onGossipAggregatedAttestation (stored in latest_new_aggregated_payloads with attestation tracker updates). Now storeAggregatedPayload accepts a validator_ids slice and an is_from_block bool. When is_from_block is true, payloads go into latest_known_aggregated_payloads; when false, they go into latest_new_aggregated_payloads and attestation trackers are updated (previously done by the removed onGossipAggregatedAttestation). chain.storeAggregatedPayloads now collects all validator ids per attestation and calls the unified function with is_from_block=true. chain.onGossipAggregatedAttestation now extracts validator ids and calls the unified function with is_from_block=false directly, removing the delegation to forkchoice.onGossipAggregatedAttestation. Remove forkchoice.onGossipAggregatedAttestation and its unlocked helper as they are no longer needed. https://claude.ai/code/session_01Wc3TmWgYtBTY6wmyLubq6R
Remove the storeAggregatedPayloads helper and store each attestation's aggregated payload directly inside the existing aggregated_attestations loop in onBlock, reusing the already-computed signature_proof and validator_indices. https://claude.ai/code/session_01Wc3TmWgYtBTY6wmyLubq6R
…station, always store signature Rename forkchoice's onGossipAttestation/onGossipAttestationUnlocked to onSignedAttestation/onSignedAttestationUnlocked and remove the store_signature bool parameter since signatures are always stored. Update all call sites in chain.zig, forkchoice.zig tests, and spectest/fork_choice_runner.zig accordingly. https://claude.ai/code/session_01Wc3TmWgYtBTY6wmyLubq6R
| &signature_groups[index] | ||
| else | ||
| null; | ||
| // Get participant indices from the signature proof, length already validated |
There was a problem hiding this comment.
We have validated the length but we are not rejecting the block if there is a length mismatch, we should reject the blocks if the aggregated_attestations length don't match with signatures_groups
There was a problem hiding this comment.
wouldn't verifyaignatures take care of it?
|
|
||
| // Internal unlocked version - assumes caller holds lock | ||
| fn onGossipAttestationUnlocked(self: *Self, signed_attestation: types.SignedAttestation, store_signature: bool) !void { | ||
| fn onSignedAttestationUnlocked(self: *Self, signed_attestation: types.SignedAttestation) !void { |
There was a problem hiding this comment.
I think we should have store_signature, and properly set is unlike hardcoded true like we were passing before. If the node is not aggregator, what purpose would gossip_signatures map serve? I think it only makes sense for aggregator nodes since only they can aggregate it.
There was a problem hiding this comment.
you only subscribe to the subnet to listen to if you are an aggregator, can you verify if this is the case, if not create an issue for the same
Summary
Refactored the aggregated signature proof storage mechanism to accept multiple validators at once, eliminating redundant per-validator operations and simplifying the API.
Key Changes
storeAggregatedPayloadAPI: Changed from storing proofs for a single validator to accepting a slice of validator IDs, reducing code duplication across call sitesis_from_blockparameter to distinguish between:latest_known_aggregated_payloads(immediately available)latest_new_aggregated_payloads(promoted via periodic ticks)onGossipAggregatedAttestationmethod: Consolidated gossip attestation handling into the unifiedstoreAggregatedPayloadfunctionchain.zig,fork_choice_runner.zig,stageAggregatedAttestation) to build validator ID arrays and call the unified methodImplementation Details
!is_from_block) to avoid unnecessary fork choice updates for block-sourced proofssignatures_mutexis always held for proof storage, whilemutexis only locked for gossip attestationshttps://claude.ai/code/session_01Wc3TmWgYtBTY6wmyLubq6R