2
2
pragma solidity ^ 0.8.27 ;
3
3
4
4
import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol " ;
5
- import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol " ;
6
- import {IStrategy } from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol " ;
7
- import {IAllocationManager, OperatorSet, IAllocationManagerTypes} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol " ;
8
- import {ISocketUpdater} from "./interfaces/ISocketUpdater.sol " ;
5
+ import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol " ;
9
6
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol " ;
10
- import {IStakeRegistry, StakeType } from "./interfaces/IStakeRegistry.sol " ;
7
+ import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol " ;
11
8
import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol " ;
12
9
import {IServiceManager} from "./interfaces/IServiceManager.sol " ;
13
10
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol " ;
14
11
15
12
import {BitmapUtils} from "./libraries/BitmapUtils.sol " ;
16
- import {BN254} from "./libraries/BN254.sol " ;
17
- import {SignatureCheckerLib} from "./libraries/SignatureCheckerLib.sol " ;
18
- import {QuorumBitmapHistoryLib} from "./libraries/QuorumBitmapHistoryLib.sol " ;
19
- import {AVSRegistrar} from "./AVSRegistrar.sol " ;
20
-
21
- import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol " ;
22
- import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol " ;
23
- import {EIP712} from "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol " ;
24
-
25
- import {Pausable} from "eigenlayer-contracts/src/contracts/permissions/Pausable.sol " ;
26
- import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol " ;
27
-
28
13
import {SlashingRegistryCoordinator} from "./SlashingRegistryCoordinator.sol " ;
29
14
30
15
/**
@@ -37,7 +22,9 @@ import {SlashingRegistryCoordinator} from "./SlashingRegistryCoordinator.sol";
37
22
*/
38
23
contract RegistryCoordinator is SlashingRegistryCoordinator , IRegistryCoordinator {
39
24
using BitmapUtils for * ;
40
- using BN254 for BN254.G1Point;
25
+
26
+ /// @notice the ServiceManager for this AVS, which forwards calls onto EigenLayer's core contracts
27
+ IServiceManager public immutable serviceManager;
41
28
42
29
constructor (
43
30
IServiceManager _serviceManager ,
@@ -48,14 +35,15 @@ contract RegistryCoordinator is SlashingRegistryCoordinator, IRegistryCoordinato
48
35
IPauserRegistry _pauserRegistry
49
36
)
50
37
SlashingRegistryCoordinator (
51
- _serviceManager,
52
38
_stakeRegistry,
53
39
_blsApkRegistry,
54
40
_indexRegistry,
55
41
_allocationManager,
56
42
_pauserRegistry
57
43
)
58
- {}
44
+ {
45
+ serviceManager = _serviceManager;
46
+ }
59
47
60
48
/**
61
49
*
@@ -192,4 +180,84 @@ contract RegistryCoordinator is SlashingRegistryCoordinator, IRegistryCoordinato
192
180
// Enable operator sets mode
193
181
isOperatorSetAVS = true ;
194
182
}
183
+
184
+ /**
185
+ *
186
+ * INTERNAL FUNCTIONS
187
+ *
188
+ */
189
+
190
+ /**
191
+ * @notice Register the operator for one or more quorums. This method updates the
192
+ * operator's quorum bitmap, socket, and status, then registers them with each registry.
193
+ */
194
+ function _registerOperator (
195
+ address operator ,
196
+ bytes32 operatorId ,
197
+ bytes memory quorumNumbers ,
198
+ string memory socket ,
199
+ SignatureWithSaltAndExpiry memory operatorSignature
200
+ ) internal virtual returns (RegisterResults memory results ) {
201
+ /**
202
+ * Get bitmap of quorums to register for and operator's current bitmap. Validate that:
203
+ * - we're trying to register for at least 1 quorum
204
+ * - the quorums we're registering for exist (checked against `quorumCount` in orderedBytesArrayToBitmap)
205
+ * - the operator is not currently registered for any quorums we're registering for
206
+ * Then, calculate the operator's new bitmap after registration
207
+ */
208
+ uint192 quorumsToAdd =
209
+ uint192 (BitmapUtils.orderedBytesArrayToBitmap (quorumNumbers, quorumCount));
210
+ uint192 currentBitmap = _currentOperatorBitmap (operatorId);
211
+ require (
212
+ ! quorumsToAdd.isEmpty (), BitmapEmpty ()
213
+ );
214
+ require (
215
+ quorumsToAdd.noBitsInCommon (currentBitmap),
216
+ AlreadyRegisteredForQuorums ()
217
+ );
218
+ uint192 newBitmap = uint192 (currentBitmap.plus (quorumsToAdd));
219
+
220
+ // Check that the operator can reregister if ejected
221
+ require (
222
+ lastEjectionTimestamp[operator] + ejectionCooldown < block .timestamp ,
223
+ CannotReregisterYet ()
224
+ );
225
+
226
+ /**
227
+ * Update operator's bitmap, socket, and status. Only update operatorInfo if needed:
228
+ * if we're `REGISTERED`, the operatorId and status are already correct.
229
+ */
230
+ _updateOperatorBitmap ({operatorId: operatorId, newBitmap: newBitmap});
231
+
232
+ emit OperatorSocketUpdate (operatorId, socket);
233
+
234
+ // If the operator wasn't registered for any quorums, update their status
235
+ // and register them with this AVS in EigenLayer core (DelegationManager)
236
+ if (_operatorInfo[operator].status != OperatorStatus.REGISTERED) {
237
+ _operatorInfo[operator] =
238
+ OperatorInfo ({operatorId: operatorId, status: OperatorStatus.REGISTERED});
239
+
240
+ serviceManager.registerOperatorToAVS (operator, operatorSignature);
241
+ emit OperatorRegistered (operator, operatorId);
242
+ }
243
+
244
+ // Register the operator with the BLSApkRegistry, StakeRegistry, and IndexRegistry
245
+ blsApkRegistry.registerOperator (operator, quorumNumbers);
246
+ (results.operatorStakes, results.totalStakes) =
247
+ stakeRegistry.registerOperator (operator, operatorId, quorumNumbers);
248
+ results.numOperatorsPerQuorum = indexRegistry.registerOperator (operatorId, quorumNumbers);
249
+
250
+ return results;
251
+ }
252
+
253
+ /// @dev Hook to allow for any post-deregister logic
254
+ function _afterDeregisterOperator (address operator , bytes32 operatorId , bytes memory quorumNumbers , uint192 newBitmap ) internal virtual override {
255
+ // If the operator is no longer registered for any quorums, update their status and deregister
256
+ // them from the AVS via the EigenLayer core contracts
257
+ if (newBitmap.isEmpty ()) {
258
+ _operatorInfo[operator].status = OperatorStatus.DEREGISTERED;
259
+ serviceManager.deregisterOperatorFromAVS (operator);
260
+ emit OperatorDeregistered (operator, operatorId);
261
+ }
262
+ }
195
263
}
0 commit comments