Skip to content

Commit dde53b0

Browse files
committed
fix: quorum creation
1 parent 2f85899 commit dde53b0

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
@@ -770,6 +770,9 @@ contract SlashingRegistryCoordinator is
770770
// The previous count is the new quorum's number
771771
uint8 quorumNumber = prevQuorumCount;
772772

773+
// Hook to allow for any pre-create quorum logic
774+
_beforeCreateQuorum(quorumNumber);
775+
773776
// Initialize the quorum here and in each registry
774777
_setOperatorSetParams(quorumNumber, operatorSetParams);
775778

@@ -801,6 +804,9 @@ contract SlashingRegistryCoordinator is
801804

802805
indexRegistry.initializeQuorum(quorumNumber);
803806
blsApkRegistry.initializeQuorum(quorumNumber);
807+
808+
// Hook to allow for any post-create quorum logic
809+
_afterCreateQuorum(quorumNumber);
804810
}
805811

806812
/**
@@ -883,6 +889,16 @@ contract SlashingRegistryCoordinator is
883889
accountIdentifier = _accountIdentifier;
884890
}
885891

892+
/// @dev Hook to allow for any pre-create quorum logic
893+
function _beforeCreateQuorum(
894+
uint8 quorumNumber
895+
) internal virtual {}
896+
897+
/// @dev Hook to allow for any post-create quorum logic
898+
function _afterCreateQuorum(
899+
uint8 quorumNumber
900+
) internal virtual {}
901+
886902
/// @dev Hook to allow for any pre-register logic in `_registerOperator`
887903
function _beforeRegisterOperator(
888904
address operator,

0 commit comments

Comments
 (0)