Skip to content

Commit 1f4e93f

Browse files
authored
Merge pull request #15 from Layr-Labs/chore/shim-interfaces-from-core
Chore: Create Shims for Interfaces from Core
2 parents 8c3fea2 + 1aacc07 commit 1f4e93f

13 files changed

+56
-498
lines changed

src/BLSOperatorStateRetriever.sol

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

4-
import {IStakeRegistry} from "src/interfaces/IStakeRegistry.sol";
5-
import {IBLSPubkeyRegistry} from "src/interfaces/IBLSPubkeyRegistry.sol";
6-
import {IIndexRegistry} from "src/interfaces/IIndexRegistry.sol";
7-
import {IBLSRegistryCoordinatorWithIndices} from "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
8-
import {BitmapUtils} from "eigenlayer-contracts/src/contracts/libraries/BitmapUtils.sol";
4+
import "src/interfaces/IStakeRegistry.sol";
5+
import "src/interfaces/IBLSPubkeyRegistry.sol";
6+
import "src/interfaces/IIndexRegistry.sol";
7+
import "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
8+
import "eigenlayer-contracts/src/contracts/libraries/BitmapUtils.sol";
99

1010
/**
1111
* @title BLSOperatorStateRetriever with view functions that allow to retrieve the state of an AVSs registry system.

src/BLSPubkeyRegistryStorage.sol

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

4-
import {IBLSPubkeyRegistry} from "src/interfaces/IBLSPubkeyRegistry.sol";
5-
import {IRegistryCoordinator} from "src/interfaces/IRegistryCoordinator.sol";
6-
import {IBLSPublicKeyCompendium} from "src/interfaces/IBLSPublicKeyCompendium.sol";
7-
import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
4+
import "src/interfaces/IBLSPubkeyRegistry.sol";
5+
import "src/interfaces/IRegistryCoordinator.sol";
6+
import "src/interfaces/IBLSPublicKeyCompendium.sol";
7+
import "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
88

99
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
1010

src/BLSRegistryCoordinatorWithIndices.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ pragma solidity =0.8.12;
44
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
55
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
66

7-
import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol";
8-
import {ISlasher} from "eigenlayer-contracts/src/contracts/interfaces/ISlasher.sol";
9-
import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
10-
import {EIP1271SignatureUtils} from "eigenlayer-contracts/src/contracts/libraries/EIP1271SignatureUtils.sol";
11-
import {BitmapUtils} from "eigenlayer-contracts/src/contracts/libraries/BitmapUtils.sol";
12-
import {Pausable} from "eigenlayer-contracts/src/contracts/permissions/Pausable.sol";
13-
14-
import {IBLSRegistryCoordinatorWithIndices} from "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
15-
import {ISocketUpdater} from "src/interfaces/ISocketUpdater.sol";
16-
import {IServiceManager} from "src/interfaces/IServiceManager.sol";
17-
import {IBLSPubkeyRegistry} from "src/interfaces/IBLSPubkeyRegistry.sol";
18-
import {IVoteWeigher} from "src/interfaces/IVoteWeigher.sol";
19-
import {IStakeRegistry} from "src/interfaces/IStakeRegistry.sol";
20-
import {IIndexRegistry} from "src/interfaces/IIndexRegistry.sol";
21-
import {IRegistryCoordinator} from "src/interfaces/IRegistryCoordinator.sol";
7+
import "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol";
8+
import "eigenlayer-contracts/src/contracts/interfaces/ISlasher.sol";
9+
import "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
10+
import "eigenlayer-contracts/src/contracts/libraries/EIP1271SignatureUtils.sol";
11+
import "eigenlayer-contracts/src/contracts/libraries/BitmapUtils.sol";
12+
import "eigenlayer-contracts/src/contracts/permissions/Pausable.sol";
13+
14+
import "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
15+
import "src/interfaces/ISocketUpdater.sol";
16+
import "src/interfaces/IServiceManager.sol";
17+
import "src/interfaces/IBLSPubkeyRegistry.sol";
18+
import "src/interfaces/IVoteWeigher.sol";
19+
import "src/interfaces/IStakeRegistry.sol";
20+
import "src/interfaces/IIndexRegistry.sol";
21+
import "src/interfaces/IRegistryCoordinator.sol";
2222

2323

2424

src/BLSSignatureChecker.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity =0.8.12;
33

4-
import {IBLSSignatureChecker} from "src/interfaces/IBLSSignatureChecker.sol";
5-
import {BitmapUtils} from "eigenlayer-contracts/src/contracts/libraries/BitmapUtils.sol";
6-
import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
7-
import {IRegistryCoordinator} from "src/interfaces/IRegistryCoordinator.sol";
8-
import {IStakeRegistry} from "src/interfaces/IStakeRegistry.sol";
9-
import {IBLSPubkeyRegistry} from "src/interfaces/IBLSPubkeyRegistry.sol";
10-
import {IBLSRegistryCoordinatorWithIndices} from "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
4+
import "src/interfaces/IBLSSignatureChecker.sol";
5+
import "eigenlayer-contracts/src/contracts/libraries/BitmapUtils.sol";
6+
import "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
7+
import "src/interfaces/IRegistryCoordinator.sol";
8+
import "src/interfaces/IStakeRegistry.sol";
9+
import "src/interfaces/IBLSPubkeyRegistry.sol";
10+
import "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
1111

1212
/**
1313
* @title Used for checking BLS aggregate signatures from the operators of a `BLSRegistry`.

src/ServiceManagerBase.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ pragma solidity ^0.8.9;
33

44
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
55
import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
6-
import {BLSSignatureChecker} from "src/BLSSignatureChecker.sol";
7-
import {IBLSRegistryCoordinatorWithIndices} from "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
8-
import {IServiceManager} from "src/interfaces/IServiceManager.sol";
6+
import "src/BLSSignatureChecker.sol";
7+
import "src/interfaces/IBLSRegistryCoordinatorWithIndices.sol";
8+
import "src/interfaces/IServiceManager.sol";
99

10-
import {Pausable} from "eigenlayer-contracts/src/contracts/permissions/Pausable.sol";
11-
import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol";
12-
import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
13-
import {ISlasher} from "eigenlayer-contracts/src/contracts/interfaces/ISlasher.sol";
14-
import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";
10+
import "eigenlayer-contracts/src/contracts/permissions/Pausable.sol";
11+
import "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol";
12+
import "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
13+
import "eigenlayer-contracts/src/contracts/interfaces/ISlasher.sol";
14+
import "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";
1515

1616
/**
1717
* @title Base implementation of `IServiceManager` interface, designed to be inherited from by more complex ServiceManagers.

src/VoteWeigherBase.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ contract VoteWeigherBase is VoteWeigherBaseStorage {
192192
return strategiesConsideredAndMultipliers[quorumNumber][index];
193193
}
194194

195+
196+
/// TODO remove when core gets updated
197+
function weightOfOperatorForQuorumView(
198+
uint8 quorumNumber,
199+
address operator
200+
) public virtual view validQuorumNumber(quorumNumber) returns (uint96) {}
195201
/**
196202
* @notice This function computes the total weight of the @param operator in the quorum @param quorumNumber.
197203
* @dev reverts in the case that `quorumNumber` is greater than or equal to `quorumCount`

src/interfaces/IBLSRegistry.sol

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,4 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity >=0.5.0;
33

4-
import "src/interfaces/IQuorumRegistry.sol";
5-
import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol";
6-
7-
8-
/**
9-
* @title Minimal interface extension to `IQuorumRegistry`.
10-
* @author Layr Labs, Inc.
11-
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
12-
* @notice Adds BLS-specific functions to the base interface.
13-
*/
14-
interface IBLSRegistry is IQuorumRegistry {
15-
/// @notice Data structure used to track the history of the Aggregate Public Key of all operators
16-
struct ApkUpdate {
17-
// keccak256(apk_x0, apk_x1, apk_y0, apk_y1)
18-
bytes32 apkHash;
19-
// block number at which the update occurred
20-
uint32 blockNumber;
21-
}
22-
23-
// EVENTS
24-
/**
25-
* @notice Emitted upon the registration of a new operator for the middleware
26-
* @param operator Address of the new operator
27-
* @param pkHash The keccak256 hash of the operator's public key
28-
* @param pk The operator's public key itself
29-
* @param apkHashIndex The index of the latest (i.e. the new) APK update
30-
* @param apkHash The keccak256 hash of the new Aggregate Public Key
31-
*/
32-
event Registration(
33-
address indexed operator,
34-
bytes32 pkHash,
35-
BN254.G1Point pk,
36-
uint32 apkHashIndex,
37-
bytes32 apkHash,
38-
string socket
39-
);
40-
41-
/// @notice Emitted when the `operatorWhitelister` role is transferred.
42-
event OperatorWhitelisterTransferred(address previousAddress, address newAddress);
43-
44-
/**
45-
* @notice get hash of a historical aggregated public key corresponding to a given index;
46-
* called by checkSignatures in BLSSignatureChecker.sol.
47-
*/
48-
function getCorrectApkHash(uint256 index, uint32 blockNumber) external returns (bytes32);
49-
50-
/// @notice returns the `ApkUpdate` struct at `index` in the list of APK updates
51-
function apkUpdates(uint256 index) external view returns (ApkUpdate memory);
52-
53-
/// @notice returns the APK hash that resulted from the `index`th APK update
54-
function apkHashes(uint256 index) external view returns (bytes32);
55-
56-
/// @notice returns the block number at which the `index`th APK update occurred
57-
function apkUpdateBlockNumbers(uint256 index) external view returns (uint32);
58-
59-
function operatorWhitelister() external view returns (address);
60-
61-
function operatorWhitelistEnabled() external view returns (bool);
62-
63-
function whitelisted(address) external view returns (bool);
64-
65-
function setOperatorWhitelistStatus(bool _operatorWhitelistEnabled) external;
66-
67-
function addToOperatorWhitelist(address[] calldata) external;
68-
69-
function removeFromWhitelist(address[] calldata operators) external;
70-
}
4+
import "eigenlayer-contracts/src/contracts/interfaces/IBLSRegistry.sol";

src/interfaces/IRegistry.sol

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity >=0.5.0;
33

4-
import "./IRegistryCoordinator.sol";
5-
6-
/**
7-
* @title Minimal interface for a `Registry`-type contract.
8-
* @author Layr Labs, Inc.
9-
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
10-
* @notice Functions related to the registration process itself have been intentionally excluded
11-
* because their function signatures may vary significantly.
12-
*/
13-
interface IRegistry {
14-
function registryCoordinator() external view returns (IRegistryCoordinator);
15-
}
4+
import "eigenlayer-contracts/src/contracts/interfaces/IRegistry.sol";
Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,4 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity =0.8.12;
33

4-
/**
5-
* @title Interface for a contract that coordinates between various registries for an AVS.
6-
* @author Layr Labs, Inc.
7-
*/
8-
interface IRegistryCoordinator {
9-
// EVENTS
10-
/// Emits when an operator is registered
11-
event OperatorRegistered(address indexed operator, bytes32 indexed operatorId);
12-
13-
/// Emits when an operator is deregistered
14-
event OperatorDeregistered(address indexed operator, bytes32 indexed operatorId);
15-
16-
// DATA STRUCTURES
17-
enum OperatorStatus
18-
{
19-
// default is NEVER_REGISTERED
20-
NEVER_REGISTERED,
21-
REGISTERED,
22-
DEREGISTERED
23-
}
24-
25-
// STRUCTS
26-
27-
/**
28-
* @notice Data structure for storing info on operators
29-
*/
30-
struct Operator {
31-
// the id of the operator, which is likely the keccak256 hash of the operator's public key if using BLSRegsitry
32-
bytes32 operatorId;
33-
// indicates whether the operator is actively registered for serving the middleware or not
34-
OperatorStatus status;
35-
}
36-
37-
/**
38-
* @notice Data structure for storing info on quorum bitmap updates where the `quorumBitmap` is the bitmap of the
39-
* quorums the operator is registered for starting at (inclusive)`updateBlockNumber` and ending at (exclusive) `nextUpdateBlockNumber`
40-
* @dev nextUpdateBlockNumber is initialized to 0 for the latest update
41-
*/
42-
struct QuorumBitmapUpdate {
43-
uint32 updateBlockNumber;
44-
uint32 nextUpdateBlockNumber;
45-
uint192 quorumBitmap;
46-
}
47-
48-
/// @notice Returns the operator struct for the given `operator`
49-
function getOperator(address operator) external view returns (Operator memory);
50-
51-
/// @notice Returns the operatorId for the given `operator`
52-
function getOperatorId(address operator) external view returns (bytes32);
53-
54-
/// @notice Returns the operator address for the given `operatorId`
55-
function getOperatorFromId(bytes32 operatorId) external view returns (address operator);
56-
57-
/// @notice Returns the status for the given `operator`
58-
function getOperatorStatus(address operator) external view returns (IRegistryCoordinator.OperatorStatus);
59-
60-
/// @notice Returns the indices of the quorumBitmaps for the provided `operatorIds` at the given `blockNumber`
61-
function getQuorumBitmapIndicesByOperatorIdsAtBlockNumber(uint32 blockNumber, bytes32[] memory operatorIds) external view returns (uint32[] memory);
62-
63-
/**
64-
* @notice Returns the quorum bitmap for the given `operatorId` at the given `blockNumber` via the `index`
65-
* @dev reverts if `index` is incorrect
66-
*/
67-
function getQuorumBitmapByOperatorIdAtBlockNumberByIndex(bytes32 operatorId, uint32 blockNumber, uint256 index) external view returns (uint192);
68-
69-
/// @notice Returns the `index`th entry in the operator with `operatorId`'s bitmap history
70-
function getQuorumBitmapUpdateByOperatorIdByIndex(bytes32 operatorId, uint256 index) external view returns (QuorumBitmapUpdate memory);
71-
72-
/// @notice Returns the current quorum bitmap for the given `operatorId`
73-
function getCurrentQuorumBitmapByOperatorId(bytes32 operatorId) external view returns (uint192);
74-
75-
/// @notice Returns the length of the quorum bitmap history for the given `operatorId`
76-
function getQuorumBitmapUpdateByOperatorIdLength(bytes32 operatorId) external view returns (uint256);
77-
78-
/// @notice Returns the registry at the desired index
79-
function registries(uint256) external view returns (address);
80-
81-
/// @notice Returns the number of registries
82-
function numRegistries() external view returns (uint256);
83-
84-
/**
85-
* @notice Registers msg.sender as an operator with the middleware
86-
* @param quorumNumbers are the bytes representing the quorum numbers that the operator is registering for
87-
* @param registrationData is the data that is decoded to get the operator's registration information
88-
*/
89-
function registerOperatorWithCoordinator(bytes memory quorumNumbers, bytes calldata registrationData) external;
90-
91-
/**
92-
* @notice Deregisters the msg.sender as an operator from the middleware
93-
* @param quorumNumbers are the bytes representing the quorum numbers that the operator is registered for
94-
* @param deregistrationData is the the data that is decoded to get the operator's deregistration information
95-
*/
96-
function deregisterOperatorWithCoordinator(bytes calldata quorumNumbers, bytes calldata deregistrationData) external;
97-
}
4+
import "eigenlayer-contracts/src/contracts/interfaces/IRegistryCoordinator.sol";

src/interfaces/IServiceManager.sol

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,4 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity >=0.5.0;
33

4-
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5-
import {ISlasher} from "eigenlayer-contracts/src/contracts/interfaces/ISlasher.sol";
6-
7-
/**
8-
* @title Interface for a `ServiceManager`-type contract.
9-
* @author Layr Labs, Inc.
10-
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
11-
*/
12-
interface IServiceManager {
13-
14-
// ServiceManager proxies to the slasher
15-
function slasher() external view returns (ISlasher);
16-
17-
/// @notice Returns the current 'taskNumber' for the middleware
18-
function taskNumber() external view returns (uint32);
19-
20-
/// @notice function that causes the ServiceManager to freeze the operator on EigenLayer, through a call to the Slasher contract
21-
/// @dev this function should contain slashing logic, to make sure operators are not needlessly being slashed
22-
function freezeOperator(address operator) external;
23-
24-
/// @notice proxy call to the slasher, recording an initial stake update (on operator registration)
25-
function recordFirstStakeUpdate(address operator, uint32 serveUntilBlock) external;
26-
27-
/// @notice proxy call to the slasher, recording a stake update
28-
function recordStakeUpdate(address operator, uint32 updateBlock, uint32 serveUntilBlock, uint256 prevElement) external;
29-
30-
/// @notice proxy call to the slasher, recording a final stake update (on operator deregistration)
31-
function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilBlock) external;
32-
33-
/// @notice Returns the latest block until which operators must serve (could be in the past or future).
34-
/// @dev this should be called and the response passed to the recordStakeUpdate functionss' serveUntilBlock parameter
35-
function latestServeUntilBlock() external view returns (uint32);
36-
37-
/// @notice required since the registry contract will call this function to permission its upgrades to be done by the same owner as the service manager
38-
function owner() external view returns (address);
39-
}
4+
import "eigenlayer-contracts/src/contracts/interfaces/IServiceManager.sol";

0 commit comments

Comments
 (0)