Skip to content

Commit 02ae04e

Browse files
committed
chore: push
1 parent 38f4805 commit 02ae04e

8 files changed

Lines changed: 185 additions & 0 deletions

src/poc/AVSRegistrar.sol

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import {
5+
IAllocationManager,
6+
OperatorSet
7+
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
8+
9+
import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol";
10+
11+
import {AVSRegistrarStorage} from "./AVSRegistrarStorage.sol";
12+
13+
abstract contract AVSRegistrar is AVSRegistrarStorage {
14+
modifier onlyAllocationManager() {
15+
require(msg.sender == address(allocationManager), OnlyAllocationManager());
16+
_;
17+
}
18+
19+
constructor(
20+
address _allocationManager,
21+
address _avs
22+
) AVSRegistrarStorage(_allocationManager, _avs) {}
23+
24+
/// @inheritdoc IAVSRegistrar
25+
/// @dev EigenLayer Core checks that:
26+
/// 1. The operator set is valid
27+
/// 2. The operator is not already registered for the AVS
28+
function registerOperator(
29+
address operator,
30+
address avs,
31+
uint32[] calldata operatorSetIds,
32+
bytes calldata data
33+
) external virtual override onlyAllocationManager {}
34+
35+
/// @inheritdoc IAVSRegistrar
36+
/// @dev EigenLayer Core checks that:
37+
/// 1. The operator set is valid
38+
/// 2. The operator is registered for the AVS
39+
function deregisterOperator(
40+
address operator,
41+
address avs,
42+
uint32[] calldata operatorSetIds
43+
) external virtual override onlyAllocationManager {}
44+
45+
/// @inheritdoc IAVSRegistrar
46+
function supportsAVS(
47+
address _avs
48+
) external view override returns (bool) {
49+
return avs == _avs;
50+
}
51+
}

src/poc/AVSRegistrarStorage.sol

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import {
5+
IAllocationManager,
6+
OperatorSet
7+
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
8+
9+
import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol";
10+
11+
abstract contract AVSRegistrarStorage is IAVSRegistrar {
12+
// Immutables
13+
14+
/// @notice The allocation manager core contract.
15+
IAllocationManager public immutable allocationManager;
16+
17+
/// @notice The AVS the registrar is for.
18+
address public immutable avs;
19+
20+
constructor(address _allocationManager, address _avs) {
21+
allocationManager = IAllocationManager(_allocationManager);
22+
avs = _avs;
23+
}
24+
25+
// TODO: Move errors to the interface
26+
error OnlyAllocationManager();
27+
}

src/poc/ECDSARegistrar.sol

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import {
5+
IAllocationManager,
6+
OperatorSet
7+
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
8+
9+
import {AVSRegistrar} from "./AVSRegistrar.sol";
10+
import {ECDSARegistrarStorage} from "./ECDSARegistrarStorage.sol";
11+
12+
abstract contract ECDSARegistrar is ECDSARegistrarStorage, AVSRegistrar {
13+
14+
constructor(address _allocationManager, address _avs) AVSRegistrar(_allocationManager, _avs) {}
15+
16+
/// @inheritdoc AVSRegistrar
17+
function registerOperator(
18+
address operator,
19+
address avs,
20+
uint32[] calldata operatorSetIds,
21+
bytes calldata data
22+
) external virtual override onlyAllocationManager {
23+
ECDSARegistrarStorageStruct storage $ = _getECDSARegistrarStorage();
24+
$._operatorMetadata[operator] = OperatorMetadata({
25+
signingKey: data.signingKey
26+
});
27+
28+
_afterRegisterOperator(operator, avs, operatorSetIds, data);
29+
}
30+
31+
function _afterRegisterOperator(
32+
address operator,
33+
address avs,
34+
uint32[] calldata operatorSetIds,
35+
bytes calldata data
36+
) internal virtual {}
37+
38+
function _afterDeregisterOperator(
39+
address operator,
40+
address avs,
41+
uint32[] calldata operatorSetIds
42+
) internal virtual {}
43+
}

src/poc/ECDSARegistrarStorage.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import {IECDSARegistrar} from "./interfaces/IECDSARegistrar.sol";
5+
6+
abstract contract ECDSARegistrarStorage is IECDSARegistrar {
7+
8+
/// @custom:storage-location erc7201:eigenlayermiddleware.storage.ECDSARegistrarStorage
9+
struct ECDSARegistrarStorageStruct {
10+
mapping(address operator => OperatorMetadata metadata) _operatorMetadata;
11+
}
12+
13+
/// @dev The storage location for the ECDSARegistrarStorage struct
14+
/// TODO: update to proper storage slot
15+
bytes32 private constant ECDSARegistrarStorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
16+
17+
function _getECDSARegistrarStorage() private pure returns (ECDSARegistrarStorageStruct storage $) {
18+
assembly {
19+
$.slot := ECDSARegistrarStorageLocation
20+
}
21+
}
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import {
5+
ISignatureUtilsMixin,
6+
ISignatureUtilsMixinTypes
7+
} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol";
8+
9+
/// @title ISignatureRegistrar
10+
/// @notice Interface for common getters on for SignatureRegistrars, namely ECDSA and BLS
11+
interface IECDSARegistrar {
12+
13+
// TODO: Move to types/events/errors
14+
struct OperatorMetadata {
15+
address signingKey;
16+
}
17+
18+
/**
19+
* @notice Registers a new operator using a provided operators signature and signing key.
20+
* @param operatorSignature Contains the operator's signature, salt, and expiry.
21+
* @param signingKey The signing key associated with the operator
22+
*/
23+
function registerOperatorWithSig(address operator, ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory operatorSignature, address signingKey) external;
24+
25+
/**
26+
* @notice Deregisters an existing operator.
27+
* @param operator The operator to deregister
28+
*/
29+
function deregisterOperator(address operator) external;
30+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
/// @title ISignatureRegistrar
5+
/// @notice Interface for common getters on for SignatureRegistrars, namely ECDSA and BLS
6+
interface ISignatureRegistrar {
7+
function registerOperator(address operator, address avs, uint32[] calldata operatorSetIds, bytes calldata data) external;
8+
function deregisterOperator(address operator, address avs, uint32[] calldata operatorSetIds) external;
9+
function supportsAVS(address avs) external view returns (bool);
10+
}

0 commit comments

Comments
 (0)