Skip to content

networkconfig: single-source the aggregator-selection formula (#2968 item 5) - #2972

Open
momosh-ssv wants to merge 1 commit into
integration/boole-convergencefrom
fix/2968-aggregator-selection-helper
Open

networkconfig: single-source the aggregator-selection formula (#2968 item 5)#2972
momosh-ssv wants to merge 1 commit into
integration/boole-convergencefrom
fix/2968-aggregator-selection-helper

Conversation

@momosh-ssv

Copy link
Copy Markdown
Contributor

Item 5 of #2968. Pure refactor — zero behavioral change.

beacon/goclient (pre-fork path) and protocol/v2/ssv/runner (post-fork AggregatorCommittee path) each hand-rolled the same selection computation — sha256(slotSig), first 8 bytes little-endian, mod max(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.IsAggregatorSelected and delegate both sites. The runner keeps its mockable IsAggregator field (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 AggregatorCommitteeRunner already routing through goclient.IsAggregator, every selection path now converges on the single helper, making drift structurally impossible; test seam (protocol/v2/ssv/testing/runner.go overrides) intact; parity test covers the clamp-to-1 case.

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.
@momosh-ssv
momosh-ssv requested review from a team as code owners July 30, 2026 12:30
@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Centralizes beacon-chain aggregator selection without changing its formula.

  • Adds networkconfig.IsAggregatorSelected for the SHA-256, little-endian, modulo-based selection check.
  • Delegates both the beacon client and runner implementations to the shared helper.
  • Removes the runner’s pooled hasher and adds parity, edge-case, and concurrency coverage.

Confidence Score: 5/5

The 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.

Important Files Changed

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]
Loading

Reviews (1): Last reviewed commit: "networkconfig: single-source the aggrega..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.1%. Comparing base (09a74d7) to head (32b3904).

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant