Skip to content

Commit

Permalink
fix: parallel regs
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Jan 7, 2025
1 parent d89faa8 commit d94d3b9
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ contract RegistryCoordinator is
*/
bytes32 operatorId = _getOrCreateOperatorId(msg.sender, params);

// Validate that the quorums are M2 quorums and not operatorSets in the AllocationManager
_validateM2Quorums(quorumNumbers);

// Register the operator in each of the registry contracts and update the operator's
// quorum bitmap and registration status
uint32[] memory numOperatorsPerQuorum = _registerOperator({
Expand All @@ -168,7 +171,6 @@ contract RegistryCoordinator is
// (If it does, an operator needs to be replaced -- see `registerOperatorWithChurn`)
for (uint256 i = 0; i < quorumNumbers.length; i++) {
uint8 quorumNumber = uint8(quorumNumbers[i]);

require(
numOperatorsPerQuorum[i] <= _quorumParams[quorumNumber].maxOperatorCount,
MaxQuorumsReached()
Expand Down Expand Up @@ -205,11 +207,15 @@ contract RegistryCoordinator is
SignatureWithSaltAndExpiry memory churnApproverSignature,
SignatureWithSaltAndExpiry memory operatorSignature
) external onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
require(!isOperatorSetAVS, "registerOperator: is operatorSet AVS");
require(
operatorKickParams.length == quorumNumbers.length,
InputLengthMismatch()
);

// Validate that the quorums are M2 quorums and not operatorSets in the AllocationManager
_validateM2Quorums(quorumNumbers);

/**
* If the operator has NEVER registered a pubkey before, use `params` to register
* their pubkey in blsApkRegistry
Expand Down Expand Up @@ -279,12 +285,7 @@ contract RegistryCoordinator is
// Validate that the quorum is not an operatorSet
for (uint256 i = 0; i < quorumNumbers.length; i++) {
uint8 quorumNumber = uint8(quorumNumbers[i]);
IAllocationManager allocationManager = IAllocationManager(serviceManager.allocationManager());
bool isOperatorSet = allocationManager.isOperatorSet(OperatorSet({
avs: address(serviceManager),
id: quorumNumber
}));
require(!isOperatorSet, "quorum should not be an operatorSet");
require(!_isOperatorSet(quorumNumber), "quorum should not be an operatorSet in core");
}

_deregisterOperator({operator: msg.sender, quorumNumbers: quorumNumbers});
Expand Down Expand Up @@ -1020,6 +1021,20 @@ contract RegistryCoordinator is
ejector = newEjector;
}

function _validateM2Quorums(bytes memory quorumNumbers) internal {
for (uint256 i = 0; i < quorumNumbers.length; i++) {
require(_isOperatorSet(uint8(quorumNumbers[i])), "quorum should not be an operatorSet in core");
}
}

function _isOperatorSet(uint8 quorumNumber) internal view returns (bool) {
IAllocationManager allocationManager = IAllocationManager(serviceManager.allocationManager());
return allocationManager.isOperatorSet(OperatorSet({
avs: address(serviceManager),
id: quorumNumber
}));
}

/**
*
* VIEW FUNCTIONS
Expand Down

0 comments on commit d94d3b9

Please sign in to comment.