File tree Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -245,9 +245,7 @@ contract SlashingRegistryCoordinator is
245
245
for (uint256 j = 0 ; j < quorumNumbers.length ; j++ ) {
246
246
// update the operator's stake for each quorum
247
247
_updateStakesAndDeregisterLoiterers (
248
- singleOperator,
249
- singleOperatorId,
250
- uint8 (quorumNumbers[j])
248
+ singleOperator, singleOperatorId, uint8 (quorumNumbers[j])
251
249
);
252
250
}
253
251
}
@@ -299,11 +297,7 @@ contract SlashingRegistryCoordinator is
299
297
prevOperatorAddress = operator;
300
298
}
301
299
302
- _updateStakesAndDeregisterLoiterers (
303
- currQuorumOperators,
304
- operatorIds,
305
- quorumNumber
306
- );
300
+ _updateStakesAndDeregisterLoiterers (currQuorumOperators, operatorIds, quorumNumber);
307
301
308
302
// Update timestamp that all operators in quorum have been updated all at once
309
303
quorumUpdateBlockNumber[quorumNumber] = block .number ;
Original file line number Diff line number Diff line change @@ -117,6 +117,30 @@ contract OperatorSetUser is User {
117
117
allocationManager.deregisterFromOperatorSets ({params: deregisterParams});
118
118
}
119
119
120
+ /// @dev Uses updateOperators to update this user's stake
121
+ function updateStakes () public virtual override createSnapshot {
122
+ _log ("updateStakes (updateOperators) " );
123
+
124
+ // get all quorums this operator is registered for
125
+ uint192 currentBitmap = slashingRegistryCoordinator.getCurrentQuorumBitmap (operatorId);
126
+ bytes memory quorumNumbers = currentBitmap.bitmapToBytesArray ();
127
+
128
+ // get all operators in those quorums
129
+ address [][] memory operatorsPerQuorum = new address [][](quorumNumbers.length );
130
+ for (uint256 i = 0 ; i < quorumNumbers.length ; i++ ) {
131
+ bytes32 [] memory operatorIds = indexRegistry.getOperatorListAtBlockNumber (
132
+ uint8 (quorumNumbers[i]), uint32 (block .number )
133
+ );
134
+ operatorsPerQuorum[i] = new address [](operatorIds.length );
135
+ for (uint256 j = 0 ; j < operatorIds.length ; j++ ) {
136
+ operatorsPerQuorum[i][j] = blsApkRegistry.pubkeyHashToOperator (operatorIds[j]);
137
+ }
138
+
139
+ operatorsPerQuorum[i] = Sort.sortAddresses (operatorsPerQuorum[i]);
140
+ }
141
+ slashingRegistryCoordinator.updateOperatorsForQuorum (operatorsPerQuorum, quorumNumbers);
142
+ }
143
+
120
144
function _getOperatorSetIds (
121
145
bytes memory quorums
122
146
) internal pure returns (uint32 [] memory ) {
Original file line number Diff line number Diff line change @@ -151,4 +151,25 @@ contract AllocationManagerIntermediate is IAllocationManager {
151
151
) external view virtual returns (bool ) {}
152
152
}
153
153
154
- contract AllocationManagerMock is AllocationManagerIntermediate {}
154
+ contract AllocationManagerMock is AllocationManagerIntermediate {
155
+ bool defaultIsMemberOfOperatorSet;
156
+
157
+ constructor () {
158
+ // Return true by default to so that the SlashingRegistryCoordinator won't force deregister
159
+ // an operator for every quorum when a `updateOperators`,`updateOperatorsForQuorum` call is made
160
+ defaultIsMemberOfOperatorSet = true ;
161
+ }
162
+
163
+ function isMemberOfOperatorSet (
164
+ address operator ,
165
+ OperatorSet memory operatorSet
166
+ ) external view virtual override returns (bool ) {
167
+ return defaultIsMemberOfOperatorSet;
168
+ }
169
+
170
+ function setDefaultIsMemberOfOperatorSet (
171
+ bool isMemberOfOperatorSet
172
+ ) external {
173
+ defaultIsMemberOfOperatorSet = isMemberOfOperatorSet;
174
+ }
175
+ }
You can’t perform that action at this time.
0 commit comments