Conversation
There was a problem hiding this comment.
Pull request overview
This PR modifies the Round Robin proposer selection algorithm to incorporate epoch-based variance. The change adds an epoch offset (calculated as height/32) to the proposer index calculation, which introduces variation across epochs and prevents the same proposer pattern from repeating every epoch when the number of operators evenly divides 32.
Key changes:
- Modified the
RoundRobinProposerfunction to add an epoch offset based onheight/32 - Updated test cases for committees with 4, 7, 10, and 13 operators to reflect the new algorithm
- Regenerated test data JSON files to match expected proposer sequences under the new algorithm
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| qbft/round_robin_proposer.go | Core algorithm change: adds epoch-based offset (height/32) to the proposer index calculation |
| qbft/round_robin_proposer_test.go | Removes empty test file (contained only package declaration) |
| qbft/spectest/tests/proposer/four_operators.go | Updates test to use new formula (h+h/32)%4 for 4-operator committee |
| qbft/spectest/tests/proposer/seven_operators.go | Updates test to use new formula (h+h/32)%7 for 7-operator committee |
| qbft/spectest/tests/proposer/ten_operators.go | Updates test to use new formula (h+h/32)%10 for 10-operator committee |
| qbft/spectest/tests/proposer/thirteen_operators.go | Updates test to use new formula (h+h/32)%13 for 13-operator committee |
| qbft/spectest/generate/tests/tests.RoundRobinSpecTest_qbft_round_robin_4_member_committee.json | Regenerated test data reflecting new proposer sequences for 4-member committee |
| qbft/spectest/generate/tests/tests.RoundRobinSpecTest_qbft_round_robin_7_member_committee.json | Regenerated test data reflecting new proposer sequences for 7-member committee |
| qbft/spectest/generate/tests/tests.RoundRobinSpecTest_qbft_round_robin_10_member_committee.json | Regenerated test data reflecting new proposer sequences for 10-member committee |
| qbft/spectest/generate/tests/tests.RoundRobinSpecTest_qbft_round_robin_13_member_committee.json | Regenerated test data reflecting new proposer sequences for 13-member committee |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile OverviewGreptile SummaryThis PR adds epoch-based variance to the round-robin proposer selection algorithm by incorporating Ethereum epochs (calculated as Key Changes
Implementation Notes
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Caller
participant RoundRobinProposer
participant State
participant Committee
Caller->>RoundRobinProposer: RoundRobinProposer(state, round)
RoundRobinProposer->>RoundRobinProposer: Initialize firstRoundIndex = 0
alt Height != FirstHeight (0)
RoundRobinProposer->>State: Get Height
State-->>RoundRobinProposer: Height value
RoundRobinProposer->>Committee: Get Committee length
Committee-->>RoundRobinProposer: Committee size
RoundRobinProposer->>RoundRobinProposer: firstRoundIndex = Height % Committee size
end
RoundRobinProposer->>State: Get Height
State-->>RoundRobinProposer: Height value
RoundRobinProposer->>RoundRobinProposer: ethEpoch = Height / 32
Note over RoundRobinProposer: NEW: Epoch-based variance added
RoundRobinProposer->>RoundRobinProposer: index = (firstRoundIndex + round - FirstRound + ethEpoch) % Committee size
RoundRobinProposer->>Committee: Get operator at index
Committee-->>RoundRobinProposer: OperatorID
RoundRobinProposer-->>Caller: Return OperatorID
|
There was a problem hiding this comment.
Additional Comments (1)
-
qbft/round_robin_proposer.go, line 5-8 (link)style: update comment to reflect epoch-based calculation - the proposer no longer simply increments by 1 from the previous height, it now includes epoch variance
10 files reviewed, 1 comment
GalRogozinski
left a comment
There was a problem hiding this comment.
We just need to make a SIP
Overview
This PR adds epochs into the Round Robin proposer computation in order to generate variance through epochs.
More precisely, the previous round robin function rotated only through slots and rounds.
Because there are 32 slots in an epoch and 32%4=0, for committees with 4 operators every epoch had the same profile of proposers.