networkconfig: single-source the aggregator-selection formula (#2968 item 5) - #2972
Open
momosh-ssv wants to merge 1 commit into
Open
networkconfig: single-source the aggregator-selection formula (#2968 item 5)#2972momosh-ssv wants to merge 1 commit into
momosh-ssv wants to merge 1 commit into
Conversation
beacon/goclient and protocol/v2/ssv/runner each hand-rolled the same sha256(slotSig) first-8-bytes-little-endian mod max(1, committeeCount/targetAggregatorsPerCommittee) == 0 computation, which must stay bit-identical or pre/post-Boole aggregator selection diverges. Extract networkconfig.IsAggregatorSelected and delegate both call sites; the runner keeps its mockable IsAggregator field (default now wraps the shared helper) and drops the pooled hasher, which had no remaining users. Pure refactor; parity asserted by an independent inline recompute across committee sizes, including the clamp-to-1 case. Item 5 of #2968.
Contributor
Greptile SummaryCentralizes beacon-chain aggregator selection without changing its formula.
Confidence Score: 5/5The PR appears safe to merge with no actionable behavioral, build, or security regressions identified. Both aggregator-selection paths preserve the existing parameter order and converge on a helper with the same SHA-256 input, little-endian digest interpretation, division, minimum-modulo clamp, and selection comparison.
|
| Filename | Overview |
|---|---|
| networkconfig/aggregator.go | Introduces a shared implementation that preserves the previous hash, byte-order, division, clamp, and modulo behavior. |
| beacon/goclient/aggregator.go | Replaces the local selection formula with an argument-equivalent call to the shared helper. |
| protocol/v2/ssv/runner/aggregator.go | Preserves the mockable function field while replacing the pooled hashing closure with the shared stateless helper. |
| networkconfig/aggregator_test.go | Covers representative committee sizes and independently recomputes the documented selection formula. |
| protocol/v2/ssv/runner/aggregator_test.go | Verifies runner/helper parity while retaining concurrent determinism coverage. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Pre-fork beacon/goclient] --> H[networkconfig.IsAggregatorSelected]
B[Post-fork AggregatorRunner] --> H
C[AggregatorCommitteeRunner] --> A
H --> D[SHA-256 slot signature]
D --> E[First 8 bytes, little-endian]
E --> F[Modulo max 1, committee count / target]
F --> G[Selected when remainder is zero]
Reviews (1): Last reviewed commit: "networkconfig: single-source the aggrega..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 5 of #2968. Pure refactor — zero behavioral change.
beacon/goclient(pre-fork path) andprotocol/v2/ssv/runner(post-fork AggregatorCommittee path) each hand-rolled the same selection computation — sha256(slotSig), first 8 bytes little-endian, modmax(1, committeeCount/targetAggregatorsPerCommittee),== 0— which must stay bit-identical or pre/post-Boole aggregator selection diverges (a consensus-level split on who aggregates).Extract
networkconfig.IsAggregatorSelectedand delegate both sites. The runner keeps its mockableIsAggregatorfield (default now wraps the shared helper); the pooled hasher is dropped (no remaining users; selection runs once per aggregator duty, not per message).Deep review notes (passed): byte-for-byte equivalence verified in both directions against the pre-change implementations (hash input, digest slicing, endianness, clamp-before-mod order, truncating division); with
AggregatorCommitteeRunneralready routing throughgoclient.IsAggregator, every selection path now converges on the single helper, making drift structurally impossible; test seam (protocol/v2/ssv/testing/runner.gooverrides) intact; parity test covers the clamp-to-1 case.