@@ -126,9 +126,11 @@ contract RegistryCoordinator is RegistryCoordinatorStorage {
126
126
bytes memory quorumNumbers
127
127
) external override onlyWhenNotPaused (PAUSED_DEREGISTER_OPERATOR) {
128
128
// Check that the quorum numbers are M2 quorums
129
- for (uint256 i = 0 ; i < quorumNumbers.length ; i++ ) {
130
- require (_isM2Quorum (uint8 (quorumNumbers[i])), OperatorSetQuorum ());
131
- }
129
+ require (
130
+ quorumNumbers.orderedBytesArrayToBitmap ().isSubsetOf (m2QuorumBitmap ()),
131
+ OnlyM2QuorumsAllowed ()
132
+ );
133
+
132
134
_deregisterOperator ({operator: msg .sender , quorumNumbers: quorumNumbers});
133
135
}
134
136
@@ -154,7 +156,8 @@ contract RegistryCoordinator is RegistryCoordinatorStorage {
154
156
bytes memory quorumNumbers
155
157
) internal virtual override {
156
158
// filter out M2 quorums from the quorum numbers
157
- uint256 operatorSetBitmap = quorumNumbers.orderedBytesArrayToBitmap ().minus (m2QuorumBitmap ());
159
+ uint256 operatorSetBitmap =
160
+ quorumNumbers.orderedBytesArrayToBitmap ().minus (m2QuorumBitmap ());
158
161
if (! operatorSetBitmap.isEmpty ()) {
159
162
// call the parent _forceDeregisterOperator function for operator sets quorums
160
163
super ._forceDeregisterOperator (operator, operatorSetBitmap.bitmapToBytesArray ());
@@ -180,22 +183,22 @@ contract RegistryCoordinator is RegistryCoordinatorStorage {
180
183
bytes memory ,
181
184
uint192 newBitmap
182
185
) internal virtual override {
183
- uint256 operatorM2QuorumBitmap = newBitmap.minus (m2QuorumBitmap ());
186
+ // Bitmap representing all quorums including M2 and OperatorSet quorums
187
+ uint256 totalQuorumBitmap = _getTotalQuorumBitmap ();
188
+ // Bitmap representing only OperatorSet quorums. Equal to 0 if operatorSets not enabled
189
+ uint256 operatorSetQuorumBitmap = totalQuorumBitmap.minus (m2QuorumBitmap ());
190
+ // Operators updated M2 quorum bitmap, clear all the bits of operatorSetQuorumBitmap which gives the
191
+ // operator's M2 quorum bitmap.
192
+ uint256 operatorM2QuorumBitmap = newBitmap.minus (operatorSetQuorumBitmap);
184
193
// If the operator is no longer registered for any M2 quorums, update their status and deregister
185
194
// them from the AVS via the EigenLayer core contracts
186
195
if (operatorM2QuorumBitmap.isEmpty ()) {
187
196
serviceManager.deregisterOperatorFromAVS (operator);
188
197
}
189
198
}
190
199
191
- /// @dev Returns a bitmap with all bits set up to `quorumCount`. Used for bit-masking quorum numbers
192
- /// and differentiating between operator sets and M2 quorums
193
- function m2QuorumBitmap () public view returns (uint256 ) {
194
- // If operator sets are enabled, return the current m2 quorum bitmap
195
- if (operatorSetsEnabled) {
196
- return _m2QuorumBitmap;
197
- }
198
-
200
+ /// @notice Return bitmap representing all quorums(Legacy M2 and OperatorSet) quorums
201
+ function _getTotalQuorumBitmap () internal view returns (uint256 ) {
199
202
// This creates a number where all bits up to quorumCount are set to 1
200
203
// For example:
201
204
// quorumCount = 3 -> 0111 (7 in decimal)
@@ -218,6 +221,17 @@ contract RegistryCoordinator is RegistryCoordinatorStorage {
218
221
*
219
222
*/
220
223
224
+ /// @dev Returns a bitmap with all bits set up to `quorumCount`. Used for bit-masking quorum numbers
225
+ /// and differentiating between operator sets and M2 quorums
226
+ function m2QuorumBitmap () public view returns (uint256 ) {
227
+ // If operator sets are enabled, return the current m2 quorum bitmap
228
+ if (operatorSetsEnabled) {
229
+ return _m2QuorumBitmap;
230
+ }
231
+
232
+ return _getTotalQuorumBitmap ();
233
+ }
234
+
221
235
/// @notice Returns true if the quorum number is an M2 quorum
222
236
function isM2Quorum (
223
237
uint8 quorumNumber
0 commit comments