Skip to content

Commit 1218256

Browse files
authored
fix: add allowlist to TaskAVSRegistarBase (#533)
**Motivation:** To ensure that AVSs have control over the aggregators registering for Hourglass, an allowlist is added to prevent arbitrary aggregator registration. **Modifications:** Inherited `Allowlist` into the TaskAVSRegistarBase **Result:** Stronger permissions around registration
1 parent 510bdb1 commit 1218256

File tree

4 files changed

+613
-12
lines changed

4 files changed

+613
-12
lines changed

src/avs/task/TaskAVSRegistrarBase.sol

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.27;
33

4-
import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
5-
import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
64
import {IAllocationManager} from
75
"eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
86
import {IPermissionController} from
97
"eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol";
108
import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol";
11-
import {AVSRegistrarWithSocket} from
12-
"../../middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol";
9+
import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol";
10+
11+
import {AVSRegistrar} from "../../middlewareV2/registrar/AVSRegistrar.sol";
12+
import {SocketRegistry} from "../../middlewareV2/registrar/modules/SocketRegistry.sol";
13+
import {Allowlist} from "../../middlewareV2/registrar/modules/Allowlist.sol";
1314
import {ITaskAVSRegistrarBase} from "../../interfaces/ITaskAVSRegistrarBase.sol";
1415
import {TaskAVSRegistrarBaseStorage} from "./TaskAVSRegistrarBaseStorage.sol";
1516

@@ -19,9 +20,9 @@ import {TaskAVSRegistrarBaseStorage} from "./TaskAVSRegistrarBaseStorage.sol";
1920
* @notice Abstract AVS Registrar for task-based AVSs
2021
*/
2122
abstract contract TaskAVSRegistrarBase is
22-
Initializable,
23-
OwnableUpgradeable,
24-
AVSRegistrarWithSocket,
23+
AVSRegistrar,
24+
SocketRegistry,
25+
Allowlist,
2526
TaskAVSRegistrarBaseStorage
2627
{
2728
/**
@@ -34,7 +35,7 @@ abstract contract TaskAVSRegistrarBase is
3435
IAllocationManager _allocationManager,
3536
IKeyRegistrar _keyRegistrar,
3637
IPermissionController _permissionController
37-
) AVSRegistrarWithSocket(_allocationManager, _keyRegistrar, _permissionController) {
38+
) AVSRegistrar(_allocationManager, _keyRegistrar) SocketRegistry(_permissionController) {
3839
_disableInitializers();
3940
}
4041

@@ -49,9 +50,9 @@ abstract contract TaskAVSRegistrarBase is
4950
address _owner,
5051
AvsConfig memory _initialConfig
5152
) internal onlyInitializing {
53+
__Allowlist_init(_owner); // initializes Ownable
5254
__AVSRegistrar_init(_avs);
53-
__Ownable_init();
54-
_transferOwnership(_owner);
55+
5556
_setAvsConfig(_initialConfig);
5657
}
5758

@@ -93,4 +94,48 @@ abstract contract TaskAVSRegistrarBase is
9394
avsConfig = config;
9495
emit AvsConfigSet(config.aggregatorOperatorSetId, config.executorOperatorSetIds);
9596
}
97+
98+
/**
99+
* @notice Before registering operator, check if the operator is in the allowlist for the aggregator operator set
100+
* @dev Only the aggregator operator set requires allowlist validation. Executor operator sets do not require allowlist checks.
101+
* @param operator The address of the operator
102+
* @param operatorSetIds The IDs of the operator sets
103+
* @param data The data passed to the operator
104+
*/
105+
function _beforeRegisterOperator(
106+
address operator,
107+
uint32[] calldata operatorSetIds,
108+
bytes calldata data
109+
) internal override {
110+
super._beforeRegisterOperator(operator, operatorSetIds, data);
111+
112+
for (uint32 i = 0; i < operatorSetIds.length; i++) {
113+
if (operatorSetIds[i] == avsConfig.aggregatorOperatorSetId) {
114+
require(
115+
isOperatorAllowed(OperatorSet({avs: avs, id: operatorSetIds[i]}), operator),
116+
OperatorNotInAllowlist()
117+
);
118+
}
119+
}
120+
}
121+
122+
/**
123+
* @notice Set the socket for the operator
124+
* @dev This function sets the socket even if the operator is already registered
125+
* @dev Operators should make sure to always provide the socket when registering
126+
* @param operator The address of the operator
127+
* @param operatorSetIds The IDs of the operator sets
128+
* @param data The data passed to the operator
129+
*/
130+
function _afterRegisterOperator(
131+
address operator,
132+
uint32[] calldata operatorSetIds,
133+
bytes calldata data
134+
) internal override {
135+
super._afterRegisterOperator(operator, operatorSetIds, data);
136+
137+
// Set operator socket
138+
string memory socket = abi.decode(data, (string));
139+
_setOperatorSocket(operator, socket);
140+
}
96141
}

src/interfaces/ITaskAVSRegistrarBase.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.8.27;
44
import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol";
55
import {IAVSRegistrarInternal} from "./IAVSRegistrarInternal.sol";
66
import {ISocketRegistryV2} from "./ISocketRegistryV2.sol";
7+
import {IAllowlist} from "./IAllowlist.sol";
78

89
/**
910
* @title ITaskAVSRegistrarBaseTypes
@@ -59,7 +60,8 @@ interface ITaskAVSRegistrarBase is
5960
ITaskAVSRegistrarBaseEvents,
6061
IAVSRegistrar,
6162
IAVSRegistrarInternal,
62-
ISocketRegistryV2
63+
ISocketRegistryV2,
64+
IAllowlist
6365
{
6466
/**
6567
* @notice Sets the configuration for this AVS

test/mocks/AllocationManagerMock.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,18 @@ contract AllocationManagerMock is AllocationManagerIntermediate {
332332

333333
return minimumSlashableStake;
334334
}
335+
336+
/**
337+
* @notice Register an operator to an AVS through the AVS registrar
338+
* @dev This function delegates to the appropriate AVS registrar
339+
*/
340+
function registerOperator(
341+
address avs,
342+
address operator,
343+
uint32[] calldata operatorSetIds,
344+
bytes calldata data
345+
) external {
346+
IAVSRegistrar avsRegistrar = IAVSRegistrar(_avsRegistrar[avs]);
347+
avsRegistrar.registerOperator(operator, avs, operatorSetIds, data);
348+
}
335349
}

0 commit comments

Comments
 (0)