Skip to content

Commit 4b0d16e

Browse files
committed
fix: validate multiple quorums
1 parent c2db0b8 commit 4b0d16e

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/RegistryCoordinator.sol

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,14 @@ contract RegistryCoordinator is
155155

156156
// For each quorum, validate that the new operator count does not exceed the maximum
157157
// (If it does, an operator needs to be replaced -- see `registerOperatorWithChurn`)
158-
require(
159-
numOperatorsPerQuorum[0] <= _quorumParams[0].maxOperatorCount,
160-
"qMaxOp"
161-
);
158+
for (uint256 i = 0; i < quorumNumbers.length; i++) {
159+
uint8 quorumNumber = uint8(quorumNumbers[i]);
160+
161+
require(
162+
numOperatorsPerQuorum[i] <= _quorumParams[quorumNumber].maxOperatorCount,
163+
"c"
164+
);
165+
}
162166
}
163167

164168
/**
@@ -212,25 +216,26 @@ contract RegistryCoordinator is
212216

213217
// Check that each quorum's operator count is below the configured maximum. If the max
214218
// is exceeded, use `operatorKickParams` to deregister an existing operator to make space
215-
OperatorSetParam memory operatorSetParams = _quorumParams[uint8(quorumNumbers[0])];
216-
217-
/**
218-
* If the new operator count for any quorum exceeds the maximum, validate
219-
* that churn can be performed, then deregister the specified operator
220-
*/
221-
if (results.numOperatorsPerQuorum[0] > operatorSetParams.maxOperatorCount) {
222-
_validateChurn({
223-
quorumNumber: uint8(quorumNumbers[0]),
224-
totalQuorumStake: results.totalStakes[0],
225-
newOperator: msg.sender,
226-
newOperatorStake: results.operatorStakes[0],
227-
kickParams: operatorKickParams[0],
228-
setParams: operatorSetParams
229-
});
219+
for (uint256 i = 0; i < quorumNumbers.length; i++) {
220+
OperatorSetParam memory operatorSetParams = _quorumParams[uint8(quorumNumbers[i])];
230221

231-
_deregisterOperator(operatorKickParams[0].operator, quorumNumbers[0:1]);
222+
/**
223+
* If the new operator count for any quorum exceeds the maximum, validate
224+
* that churn can be performed, then deregister the specified operator
225+
*/
226+
if (results.numOperatorsPerQuorum[i] > operatorSetParams.maxOperatorCount) {
227+
_validateChurn({
228+
quorumNumber: uint8(quorumNumbers[i]),
229+
totalQuorumStake: results.totalStakes[i],
230+
newOperator: msg.sender,
231+
newOperatorStake: results.operatorStakes[i],
232+
kickParams: operatorKickParams[i],
233+
setParams: operatorSetParams
234+
});
235+
236+
_deregisterOperator(operatorKickParams[i].operator, quorumNumbers[i:i+1]);
237+
}
232238
}
233-
234239
}
235240

236241
/**

0 commit comments

Comments
 (0)