Skip to content

Commit 2c04380

Browse files
committed
fix: quorum creation
1 parent d283fe5 commit 2c04380

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

src/RegistryCoordinator.sol

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ contract RegistryCoordinator is RegistryCoordinatorStorage {
139139

140140
/// @inheritdoc IRegistryCoordinator
141141
function disableM2QuorumRegistration() external onlyOwner {
142-
require(operatorSetsEnabled, OperatorSetsNotEnabled());
142+
require(!isM2QuorumRegistrationDisabled, M2QuorumRegistrationIsDisabled());
143143

144144
isM2QuorumRegistrationDisabled = true;
145145

@@ -154,16 +154,21 @@ contract RegistryCoordinator is RegistryCoordinatorStorage {
154154

155155
/// @dev override the _forceDeregisterOperator function to handle M2 quorum deregistration
156156
function _forceDeregisterOperator(address operator, bytes memory quorumNumbers) internal virtual override {
157-
if (operatorSetsEnabled) {
158-
// filter out M2 quorums from the quorum numbers
159-
uint256 operatorSetBitmap = quorumNumbers.orderedBytesArrayToBitmap().minus(m2QuorumBitmap);
160-
if (!operatorSetBitmap.isEmpty()) {
161-
// call the parent _forceDeregisterOperator function for operator sets quorums
162-
super._forceDeregisterOperator(operator, operatorSetBitmap.bitmapToBytesArray());
163-
}
157+
// filter out M2 quorums from the quorum numbers
158+
uint256 operatorSetBitmap = quorumNumbers.orderedBytesArrayToBitmap().minus(m2QuorumBitmap);
159+
if (!operatorSetBitmap.isEmpty()) {
160+
// call the parent _forceDeregisterOperator function for operator sets quorums
161+
super._forceDeregisterOperator(operator, operatorSetBitmap.bitmapToBytesArray());
164162
}
165163
}
166164

165+
/// @dev Hook to prevent any new quorums from being created if operator sets are not enabled
166+
function _beforeCreateQuorum(
167+
uint8 quorumNumber
168+
) internal virtual override {
169+
require(operatorSetsEnabled, OperatorSetsNotEnabled());
170+
}
171+
167172
/// @dev Hook to allow for any post-deregister logic
168173
function _afterDeregisterOperator(
169174
address operator,

src/RegistryCoordinatorStorage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ abstract contract RegistryCoordinatorStorage is IRegistryCoordinator, SlashingRe
2929
*
3030
*/
3131

32-
/// @notice Whether this AVS allows operator sets for registration
33-
/// @dev If true, operators may register to operator sets via the AllocationManager
32+
/// @notice Whether this AVS allows operator sets for creation/registration
33+
/// @dev If true, then operator sets may be created and operators may register to operator sets via the AllocationManager
3434
bool public operatorSetsEnabled;
3535

3636
/// @notice Whether this AVS allows M2 quorums for registration

src/SlashingRegistryCoordinator.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,9 @@ contract SlashingRegistryCoordinator is
822822
// The previous count is the new quorum's number
823823
uint8 quorumNumber = prevQuorumCount;
824824

825+
// Hook to allow for any pre-create quorum logic
826+
_beforeCreateQuorum(quorumNumber);
827+
825828
// Initialize the quorum here and in each registry
826829
_setOperatorSetParams(quorumNumber, operatorSetParams);
827830

@@ -853,6 +856,9 @@ contract SlashingRegistryCoordinator is
853856

854857
indexRegistry.initializeQuorum(quorumNumber);
855858
blsApkRegistry.initializeQuorum(quorumNumber);
859+
860+
// Hook to allow for any post-create quorum logic
861+
_afterCreateQuorum(quorumNumber);
856862
}
857863

858864
/**
@@ -935,6 +941,16 @@ contract SlashingRegistryCoordinator is
935941
accountIdentifier = _accountIdentifier;
936942
}
937943

944+
/// @dev Hook to allow for any pre-create quorum logic
945+
function _beforeCreateQuorum(
946+
uint8 quorumNumber
947+
) internal virtual {}
948+
949+
/// @dev Hook to allow for any post-create quorum logic
950+
function _afterCreateQuorum(
951+
uint8 quorumNumber
952+
) internal virtual {}
953+
938954
/// @dev Hook to allow for any pre-register logic in `_registerOperator`
939955
function _beforeRegisterOperator(
940956
address operator,

0 commit comments

Comments
 (0)