@@ -423,78 +423,7 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
423423
424424 // TallySlashingProposer constructor validations
425425 if ( config . slasherFlavor === 'tally' ) {
426- // From: require(SLASH_OFFSET_IN_ROUNDS > 0, Errors.TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(...));
427- if ( config . slashingOffsetInRounds <= 0 ) {
428- errors . push ( `slashingOffsetInRounds (${ config . slashingOffsetInRounds } ) must be greater than 0` ) ;
429- }
430-
431- // From: require(ROUND_SIZE_IN_EPOCHS * _epochDuration == ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeMustBeMultipleOfEpochDuration(...));
432- const roundSizeInSlots = config . slashingRoundSizeInEpochs * config . aztecEpochDuration ;
433-
434- // From: require(QUORUM > 0, Errors.TallySlashingProposer__QuorumMustBeGreaterThanZero());
435- if ( slashingQuorum !== undefined && slashingQuorum <= 0 ) {
436- errors . push ( `slashingQuorum (${ slashingQuorum } ) must be greater than 0` ) ;
437- }
438-
439- // From: require(ROUND_SIZE > 1, Errors.TallySlashingProposer__InvalidQuorumAndRoundSize(QUORUM, ROUND_SIZE));
440- if ( roundSizeInSlots <= 1 ) {
441- errors . push ( `slashing round size in slots (${ roundSizeInSlots } ) must be greater than 1` ) ;
442- }
443-
444- // From: require(_slashAmounts[0] <= _slashAmounts[1], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
445- if ( config . slashAmountSmall > config . slashAmountMedium ) {
446- errors . push (
447- `slashAmountSmall (${ config . slashAmountSmall } ) must be less than or equal to slashAmountMedium (${ config . slashAmountMedium } )` ,
448- ) ;
449- }
450-
451- // From: require(_slashAmounts[1] <= _slashAmounts[2], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
452- if ( config . slashAmountMedium > config . slashAmountLarge ) {
453- errors . push (
454- `slashAmountMedium (${ config . slashAmountMedium } ) must be less than or equal to slashAmountLarge (${ config . slashAmountLarge } )` ,
455- ) ;
456- }
457-
458- // From: require(LIFETIME_IN_ROUNDS < ROUNDABOUT_SIZE, Errors.TallySlashingProposer__LifetimeMustBeLessThanRoundabout(...));
459- const ROUNDABOUT_SIZE = 128 ; // Constant from TallySlashingProposer
460- if ( config . slashingLifetimeInRounds >= ROUNDABOUT_SIZE ) {
461- errors . push ( `slashingLifetimeInRounds (${ config . slashingLifetimeInRounds } ) must be less than ${ ROUNDABOUT_SIZE } ` ) ;
462- }
463-
464- // From: require(ROUND_SIZE_IN_EPOCHS > 0, Errors.TallySlashingProposer__RoundSizeInEpochsMustBeGreaterThanZero(...));
465- if ( config . slashingRoundSizeInEpochs <= 0 ) {
466- errors . push ( `slashingRoundSizeInEpochs (${ config . slashingRoundSizeInEpochs } ) must be greater than 0` ) ;
467- }
468-
469- // From: require(ROUND_SIZE < MAX_ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeTooLarge(ROUND_SIZE, MAX_ROUND_SIZE));
470- const MAX_ROUND_SIZE = 1024 ; // Constant from TallySlashingProposer
471- if ( roundSizeInSlots >= MAX_ROUND_SIZE ) {
472- errors . push ( `slashing round size in slots (${ roundSizeInSlots } ) must be less than ${ MAX_ROUND_SIZE } ` ) ;
473- }
474-
475- // From: require(COMMITTEE_SIZE > 0, Errors.TallySlashingProposer__CommitteeSizeMustBeGreaterThanZero(COMMITTEE_SIZE));
476- if ( config . aztecTargetCommitteeSize <= 0 ) {
477- errors . push ( `aztecTargetCommitteeSize (${ config . aztecTargetCommitteeSize } ) must be greater than 0` ) ;
478- }
479-
480- // From: require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
481- // voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4
482- const voteSize = ( config . aztecTargetCommitteeSize * config . slashingRoundSizeInEpochs ) / 4 ;
483- if ( voteSize > 128 ) {
484- errors . push ( `vote size (${ voteSize } ) must be <= 128 (committee size * round size in epochs / 4)` ) ;
485- }
486-
487- // From: require(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0, Errors.TallySlashingProposer__InvalidCommitteeAndRoundSize(...));
488- if ( ( config . aztecTargetCommitteeSize * config . slashingRoundSizeInEpochs ) % 4 !== 0 ) {
489- errors . push (
490- `aztecTargetCommitteeSize * slashingRoundSizeInEpochs (${ config . aztecTargetCommitteeSize * config . slashingRoundSizeInEpochs } ) must be divisible by 4` ,
491- ) ;
492- }
493-
494- // Slashing offset validation: should be positive to allow proper slashing timing
495- if ( config . slashingOffsetInRounds < 0 ) {
496- errors . push ( 'slashingOffsetInRounds cannot be negative' ) ;
497- }
426+ validateTallySlasherConfig ( config , errors ) ;
498427 }
499428
500429 // Epoch and slot duration validations
@@ -541,3 +470,83 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
541470 ) ;
542471 }
543472}
473+
474+ function validateTallySlasherConfig ( config : L1ContractsConfig , errors : string [ ] ) {
475+ if ( config . slasherFlavor !== 'tally' ) {
476+ return ;
477+ }
478+
479+ // From: require(SLASH_OFFSET_IN_ROUNDS > 0, Errors.TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(...));
480+ if ( config . slashingOffsetInRounds <= 0 ) {
481+ errors . push ( `slashingOffsetInRounds (${ config . slashingOffsetInRounds } ) must be greater than 0` ) ;
482+ }
483+
484+ // From: require(ROUND_SIZE_IN_EPOCHS * _epochDuration == ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeMustBeMultipleOfEpochDuration(...));
485+ const roundSizeInSlots = config . slashingRoundSizeInEpochs * config . aztecEpochDuration ;
486+
487+ // From: require(QUORUM > 0, Errors.TallySlashingProposer__QuorumMustBeGreaterThanZero());
488+ const { slashingQuorum } = config ;
489+ if ( slashingQuorum !== undefined && slashingQuorum <= 0 ) {
490+ errors . push ( `slashingQuorum (${ slashingQuorum } ) must be greater than 0` ) ;
491+ }
492+
493+ // From: require(ROUND_SIZE > 1, Errors.TallySlashingProposer__InvalidQuorumAndRoundSize(QUORUM, ROUND_SIZE));
494+ if ( roundSizeInSlots <= 1 ) {
495+ errors . push ( `slashing round size in slots (${ roundSizeInSlots } ) must be greater than 1` ) ;
496+ }
497+
498+ // From: require(_slashAmounts[0] <= _slashAmounts[1], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
499+ if ( config . slashAmountSmall > config . slashAmountMedium ) {
500+ errors . push (
501+ `slashAmountSmall (${ config . slashAmountSmall } ) must be less than or equal to slashAmountMedium (${ config . slashAmountMedium } )` ,
502+ ) ;
503+ }
504+
505+ // From: require(_slashAmounts[1] <= _slashAmounts[2], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
506+ if ( config . slashAmountMedium > config . slashAmountLarge ) {
507+ errors . push (
508+ `slashAmountMedium (${ config . slashAmountMedium } ) must be less than or equal to slashAmountLarge (${ config . slashAmountLarge } )` ,
509+ ) ;
510+ }
511+
512+ // From: require(LIFETIME_IN_ROUNDS < ROUNDABOUT_SIZE, Errors.TallySlashingProposer__LifetimeMustBeLessThanRoundabout(...));
513+ const ROUNDABOUT_SIZE = 128 ; // Constant from TallySlashingProposer
514+ if ( config . slashingLifetimeInRounds >= ROUNDABOUT_SIZE ) {
515+ errors . push ( `slashingLifetimeInRounds (${ config . slashingLifetimeInRounds } ) must be less than ${ ROUNDABOUT_SIZE } ` ) ;
516+ }
517+
518+ // From: require(ROUND_SIZE_IN_EPOCHS > 0, Errors.TallySlashingProposer__RoundSizeInEpochsMustBeGreaterThanZero(...));
519+ if ( config . slashingRoundSizeInEpochs <= 0 ) {
520+ errors . push ( `slashingRoundSizeInEpochs (${ config . slashingRoundSizeInEpochs } ) must be greater than 0` ) ;
521+ }
522+
523+ // From: require(ROUND_SIZE < MAX_ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeTooLarge(ROUND_SIZE, MAX_ROUND_SIZE));
524+ const MAX_ROUND_SIZE = 1024 ; // Constant from TallySlashingProposer
525+ if ( roundSizeInSlots >= MAX_ROUND_SIZE ) {
526+ errors . push ( `slashing round size in slots (${ roundSizeInSlots } ) must be less than ${ MAX_ROUND_SIZE } ` ) ;
527+ }
528+
529+ // From: require(COMMITTEE_SIZE > 0, Errors.TallySlashingProposer__CommitteeSizeMustBeGreaterThanZero(COMMITTEE_SIZE));
530+ if ( config . aztecTargetCommitteeSize <= 0 ) {
531+ errors . push ( `aztecTargetCommitteeSize (${ config . aztecTargetCommitteeSize } ) must be greater than 0` ) ;
532+ }
533+
534+ // From: require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
535+ // voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4
536+ const voteSize = ( config . aztecTargetCommitteeSize * config . slashingRoundSizeInEpochs ) / 4 ;
537+ if ( voteSize > 128 ) {
538+ errors . push ( `vote size (${ voteSize } ) must be <= 128 (committee size * round size in epochs / 4)` ) ;
539+ }
540+
541+ // From: require(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0, Errors.TallySlashingProposer__InvalidCommitteeAndRoundSize(...));
542+ if ( ( config . aztecTargetCommitteeSize * config . slashingRoundSizeInEpochs ) % 4 !== 0 ) {
543+ errors . push (
544+ `aztecTargetCommitteeSize * slashingRoundSizeInEpochs (${ config . aztecTargetCommitteeSize * config . slashingRoundSizeInEpochs } ) must be divisible by 4` ,
545+ ) ;
546+ }
547+
548+ // Slashing offset validation: should be positive to allow proper slashing timing
549+ if ( config . slashingOffsetInRounds < 0 ) {
550+ errors . push ( 'slashingOffsetInRounds cannot be negative' ) ;
551+ }
552+ }
0 commit comments