@@ -30,6 +30,9 @@ library VerificationLib {
3030 /// @notice The length of a signature in bytes.
3131 uint256 internal constant SIGNATURE_LENGTH_THRESHOLD = 65 ;
3232
33+ /// @notice The max allowed base signer count
34+ uint256 internal constant MAX_BASE_SIGNER_COUNT = 16 ;
35+
3336 /// @dev Slot for the `VerificationLibStorage` struct in storage.
3437 /// Computed from:
3538 /// keccak256(abi.encode(uint256(keccak256("coinbase.storage.VerificationLib")) - 1)) &
@@ -59,6 +62,9 @@ library VerificationLib {
5962 /// @notice Thrown when threshold is invalid (0 or exceeds validator count).
6063 error InvalidThreshold ();
6164
65+ /// @notice Thrown when base signer count is too high.
66+ error BaseSignerCountTooHigh ();
67+
6268 /// @notice Thrown when a validator address is 0.
6369 error InvalidValidatorAddress ();
6470
@@ -92,6 +98,7 @@ library VerificationLib {
9298 VerificationLibStorage storage $ = getVerificationLibStorage ();
9399
94100 require (threshold > 0 && threshold <= validators.length , InvalidThreshold ());
101+ require (validators.length <= MAX_BASE_SIGNER_COUNT, BaseSignerCountTooHigh ());
95102
96103 for (uint256 i; i < validators.length ; i++ ) {
97104 require (validators[i] != address (0 ), InvalidValidatorAddress ());
@@ -122,12 +129,15 @@ library VerificationLib {
122129 require (validator != address (0 ), InvalidValidatorAddress ());
123130 require (! $.validators[validator], ValidatorAlreadyAdded ());
124131
125- $.validators[validator] = true ;
126-
132+ uint128 newValidatorCount;
127133 unchecked {
128- $.validatorCount++ ;
134+ newValidatorCount = $.validatorCount + 1 ;
129135 }
130136
137+ require (newValidatorCount <= MAX_BASE_SIGNER_COUNT, BaseSignerCountTooHigh ());
138+ $.validators[validator] = true ;
139+ $.validatorCount = newValidatorCount;
140+
131141 emit ValidatorAdded (validator);
132142 }
133143
0 commit comments