File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -487,8 +487,9 @@ contract TallySlashingProposer is EIP712 {
487487 /**
488488 * @notice Load committees for all epochs to be potentially slashed in a round from the rollup instance
489489 * @dev This is an expensive call. It is not marked as view since `getEpochCommittee` may modify rollup state.
490+ * If `getEpochCommittee` throws (eg committee not yet formed), an empty committee is returned for that epoch.
490491 * @param _round The round number to load committees for
491- * @return committees Array of committees, one for each epoch in the round
492+ * @return committees Array of committees, one for each epoch in the round (may contain empty arrays for early epochs)
492493 */
493494 function getSlashTargetCommittees (SlashRound _round ) external returns (address [][] memory committees ) {
494495 committees = new address [][](ROUND_SIZE_IN_EPOCHS);
@@ -497,7 +498,11 @@ contract TallySlashingProposer is EIP712 {
497498 unchecked {
498499 for (uint256 epochIndex; epochIndex < ROUND_SIZE_IN_EPOCHS; ++ epochIndex) {
499500 Epoch epoch = getSlashTargetEpoch (_round, epochIndex);
500- committees[epochIndex] = rollup.getEpochCommittee (epoch);
501+ try rollup.getEpochCommittee (epoch) returns (address [] memory committee ) {
502+ committees[epochIndex] = committee;
503+ } catch {
504+ committees[epochIndex] = new address [](0 );
505+ }
501506 }
502507 }
503508
Original file line number Diff line number Diff line change @@ -864,4 +864,29 @@ contract TallySlashingProposerTest is TestBase {
864864 }
865865 }
866866 }
867+
868+ function test_getSlashTargetCommitteesEarlyEpochs () public {
869+ // Test that getSlashTargetCommittees handles epochs 0 and 1 without throwing
870+ // when ValidatorSelection__InsufficientValidatorSetSize is thrown
871+
872+ // Use a very early slash round that would target epochs 0 and 1
873+ // With SLASH_OFFSET_IN_ROUNDS = 2, round 2 targets epochs starting from (2-2)*ROUND_SIZE_IN_EPOCHS = 0
874+ SlashRound earlyRound = SlashRound.wrap (SLASH_OFFSET_IN_ROUNDS);
875+
876+ // This should not revert and should return empty committees for early epochs
877+ address [][] memory committees = slashingProposer.getSlashTargetCommittees (earlyRound);
878+
879+ // Verify we get the expected number of committees
880+ assertEq (committees.length , ROUND_SIZE_IN_EPOCHS, "Should return correct number of committees " );
881+
882+ // For very early rounds, we expect empty committees for epochs 0 and 1
883+ // Since ROUND_SIZE_IN_EPOCHS = 2, both epochs should be empty
884+ for (uint256 i = 0 ; i < ROUND_SIZE_IN_EPOCHS; i++ ) {
885+ Epoch targetEpoch = slashingProposer.getSlashTargetEpoch (earlyRound, i);
886+ if (Epoch.unwrap (targetEpoch) <= 1 ) {
887+ assertEq (committees[i].length , 0 , "Committee for early epochs should be empty " );
888+ }
889+ // For epochs > 1, we might get actual committees, but that depends on the test setup
890+ }
891+ }
867892}
You can’t perform that action at this time.
0 commit comments