Skip to content

Commit 4f75b3c

Browse files
authored
fix: SocketRegistry-related fixes (#389)
* fix: SocketRegistry-related fixes * chore: forge fmt + tweak docstrings * chore(test): remove unnecessary socket registry mock
1 parent 292d340 commit 4f75b3c

8 files changed

+49
-45
lines changed

src/RegistryCoordinator.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/Ownabl
1818
import {RegistryCoordinatorStorage} from "./RegistryCoordinatorStorage.sol";
1919

2020
/**
21-
* @title A `RegistryCoordinator` that has three registries:
21+
* @title A `RegistryCoordinator` that has four registries:
2222
* 1) a `StakeRegistry` that keeps track of operators' stakes
2323
* 2) a `BLSApkRegistry` that keeps track of operators' BLS public keys and aggregate BLS public keys for each quorum
2424
* 3) an `IndexRegistry` that keeps track of an ordered list of operators for each quorum
25+
* 4) a `SocketRegistry` that keeps track of operators' sockets (arbitrary strings)
2526
*
2627
* @author Layr Labs, Inc.
2728
*/

src/SlashingRegistryCoordinator.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ import {Pausable} from "eigenlayer-contracts/src/contracts/permissions/Pausable.
2929
import {SlashingRegistryCoordinatorStorage} from "./SlashingRegistryCoordinatorStorage.sol";
3030

3131
/**
32-
* @title A `RegistryCoordinator` that has three registries:
32+
* @title A `RegistryCoordinator` that has four registries:
3333
* 1) a `StakeRegistry` that keeps track of operators' stakes
3434
* 2) a `BLSApkRegistry` that keeps track of operators' BLS public keys and aggregate BLS public keys for each quorum
3535
* 3) an `IndexRegistry` that keeps track of an ordered list of operators for each quorum
36+
* 4) a `SocketRegistry` that keeps track of operators' sockets (arbitrary strings)
3637
*
3738
* @author Layr Labs, Inc.
3839
*/
@@ -104,10 +105,12 @@ contract SlashingRegistryCoordinator is
104105
_setPausedStatus(_initialPausedStatus);
105106
_setEjector(_ejector);
106107
_setAccountIdentifier(_accountIdentifier);
108+
107109
// Add registry contracts to the registries array
108110
registries.push(address(stakeRegistry));
109111
registries.push(address(blsApkRegistry));
110112
registries.push(address(indexRegistry));
113+
registries.push(address(socketRegistry));
111114
}
112115

113116
/// @inheritdoc ISlashingRegistryCoordinator

src/SlashingRegistryCoordinatorStorage.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract contract SlashingRegistryCoordinatorStorage is ISlashingRegistryCoordin
4141
/// @notice The maximum number of quorums this contract supports
4242
uint8 internal constant MAX_QUORUM_COUNT = 192;
4343

44-
/// @notice
44+
/// @notice the Socket Registry contract that will keep track of operators' sockets (arbitrary strings)
4545
ISocketRegistry public immutable socketRegistry;
4646
/// @notice the BLS Aggregate Pubkey Registry contract that will keep track of operators' aggregate BLS public keys per quorum
4747
IBLSApkRegistry public immutable blsApkRegistry;

src/SocketRegistry.sol

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,29 @@ import {SocketRegistryStorage} from "./SocketRegistryStorage.sol";
77
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
88

99
/**
10-
* @title A `Registry` that keeps track of operator sockets.
10+
* @title A `Registry` that keeps track of operator sockets (arbitrary strings).
1111
* @author Layr Labs, Inc.
1212
*/
13-
contract SocketRegistry is ISocketRegistry, SocketRegistryStorage {
14-
/// @notice A modifier that only allows the RegistryCoordinator to call a function
13+
contract SocketRegistry is SocketRegistryStorage {
14+
/// @notice A modifier that only allows the SlashingRegistryCoordinator to call a function
1515
modifier onlySlashingRegistryCoordinator() {
1616
require(msg.sender == slashingRegistryCoordinator, OnlySlashingRegistryCoordinator());
1717
_;
1818
}
1919

20-
/// @notice A modifier that only allows the owner of the SlashingRegistryCoordinator to call a function
21-
modifier onlyCoordinatorOwner() {
22-
require(
23-
msg.sender == Ownable(slashingRegistryCoordinator).owner(),
24-
OnlySlashingRegistryCoordinatorOwner()
25-
);
26-
_;
27-
}
28-
2920
constructor(
3021
ISlashingRegistryCoordinator _slashingRegistryCoordinator
3122
) SocketRegistryStorage(address(_slashingRegistryCoordinator)) {}
3223

33-
/// @notice sets the socket for an operator only callable by the RegistryCoordinator
24+
/// @inheritdoc ISocketRegistry
3425
function setOperatorSocket(
3526
bytes32 _operatorId,
3627
string memory _socket
3728
) external onlySlashingRegistryCoordinator {
3829
operatorIdToSocket[_operatorId] = _socket;
3930
}
4031

41-
/// @notice gets the stored socket for an operator
32+
/// @inheritdoc ISocketRegistry
4233
function getOperatorSocket(
4334
bytes32 _operatorId
4435
) external view returns (string memory) {

src/SocketRegistryStorage.sol

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.12;
33

4+
import {ISocketRegistry} from "./interfaces/ISocketRegistry.sol";
5+
46
/**
5-
* @title Storage contract for SocketRegistry
7+
* @title Storage variables for the `SocketRegistry` contract.
68
* @author Layr Labs, Inc.
79
*/
8-
contract SocketRegistryStorage {
9-
/// @notice The address of the RegistryCoordinator
10+
abstract contract SocketRegistryStorage is ISocketRegistry {
11+
/**
12+
*
13+
* CONSTANTS AND IMMUTABLES
14+
*
15+
*/
16+
17+
/// @notice The address of the SlashingRegistryCoordinator
1018
address public immutable slashingRegistryCoordinator;
1119

20+
/**
21+
*
22+
* STATE
23+
*
24+
*/
25+
1226
/// @notice A mapping from operator IDs to their sockets
1327
mapping(bytes32 => string) public operatorIdToSocket;
1428

@@ -18,5 +32,5 @@ contract SocketRegistryStorage {
1832
slashingRegistryCoordinator = _slashingRegistryCoordinator;
1933
}
2034

21-
uint256[48] private __GAP;
35+
uint256[49] private __GAP;
2236
}

src/interfaces/ISlashingRegistryCoordinator.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {IAllocationManager} from
1010
import {IBLSApkRegistry} from "./IBLSApkRegistry.sol";
1111
import {IStakeRegistry, IStakeRegistryTypes} from "./IStakeRegistry.sol";
1212
import {IIndexRegistry} from "./IIndexRegistry.sol";
13+
import {ISocketRegistry} from "./ISocketRegistry.sol";
1314
import {BN254} from "../libraries/BN254.sol";
1415
import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol";
1516

@@ -232,6 +233,12 @@ interface ISlashingRegistryCoordinator is
232233
*/
233234
function allocationManager() external view returns (IAllocationManager);
234235

236+
/**
237+
* @notice Reference to the SocketRegistry contract.
238+
* @return The SocketRegistry contract interface.
239+
*/
240+
function socketRegistry() external view returns (ISocketRegistry);
241+
235242
/// STORAGE
236243

237244
/**

src/interfaces/ISocketRegistry.sol

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.0;
33

44
interface ISocketRegistryErrors {
5-
/// @notice Thrown when the caller is not the owner of the SlashingRegistryCoordinator
6-
error OnlySlashingRegistryCoordinatorOwner();
75
/// @notice Thrown when the caller is not the SlashingRegistryCoordinator
86
error OnlySlashingRegistryCoordinator();
97
}
108

119
interface ISocketRegistry is ISocketRegistryErrors {
12-
/// @notice sets the socket for an operator only callable by the RegistryCoordinator
10+
/**
11+
* @notice Sets the socket for an operator.
12+
* @param _operatorId The id of the operator to set the socket for.
13+
* @param _socket The socket (any arbitrary string as deemed useful by an AVS) to set.
14+
* @dev Only callable by the SlashingRegistryCoordinator.
15+
*/
1316
function setOperatorSocket(bytes32 _operatorId, string memory _socket) external;
1417

15-
/// @notice gets the stored socket for an operator
18+
/**
19+
* @notice Gets the stored socket for an operator.
20+
* @param _operatorId The id of the operator to query.
21+
* @return The stored socket associated with the operator.
22+
*/
1623
function getOperatorSocket(
1724
bytes32 _operatorId
1825
) external view returns (string memory);

test/unit/SocketRegistryUnit.t.sol

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,11 @@ interface IOwnable {
1111
function owner() external view returns (address);
1212
}
1313

14-
contract MockSocketRegistry is SocketRegistry {
15-
constructor(
16-
ISlashingRegistryCoordinator _slashingRegistryCoordinator
17-
) SocketRegistry(_slashingRegistryCoordinator) {}
18-
19-
function onlyCoordinatorOwnerFn() external view onlyCoordinatorOwner {}
20-
}
21-
2214
contract SocketRegistryUnitTests is MockAVSDeployer {
2315
function setUp() public virtual {
2416
_deployMockEigenLayerAndAVS();
2517
}
2618

27-
function testFuzz_revert_onlyCoordinatorOwner(
28-
address caller
29-
) public {
30-
MockSocketRegistry _socketRegistry = new MockSocketRegistry(registryCoordinator);
31-
32-
vm.prank(caller);
33-
vm.assume(caller != IOwnable(address(registryCoordinator)).owner());
34-
vm.expectRevert(ISocketRegistryErrors.OnlySlashingRegistryCoordinatorOwner.selector);
35-
_socketRegistry.onlyCoordinatorOwnerFn();
36-
}
37-
3819
function test_setOperatorSocket() public {
3920
vm.startPrank(address(registryCoordinator));
4021
socketRegistry.setOperatorSocket(defaultOperatorId, "testSocket");

0 commit comments

Comments
 (0)