Skip to content

Commit 3a58a86

Browse files
authored
chore: update AVSRegistrar for new KeyRegistrar interface (#502)
**Motivation:** We've updated the `KeyRegistrar` interface to now only have an `isRegistered` call: Layr-Labs/eigenlayer-contracts#1551 **Modifications:** - Update call to `KeyRegistrar` from `AVSRegistrar` - Rev submodule - Also document table calculators in ReadME **Result:** Working integration
1 parent b88650c commit 3a58a86

File tree

6 files changed

+66
-30
lines changed

6 files changed

+66
-30
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,16 @@ forge test
6868

6969
The contracts in this repo are meant to be deployed by each AVS that wants to use them. The addresses listed below refer to EigenDA's deployment, and are included as an example.
7070

71-
### Current Mainnet Deployment
71+
### Current MiddlewareV2 Testnet Deployment
72+
The following testnet deployment is for our MiddlewareV2 release, deployed on Sepolia. The below table calculators calculate slashable stake for an operatorSet and value all strategies equally. For example, or example, if an operator allocates 100 stETH, 100 wETH, and 100 DAI the calculator would return 300 for the stake weight of the operator. See our [docs](./docs/middlewareV2/README.md) for more information.
73+
74+
| Name | Proxy | Implementation | Notes |
75+
| -------- | -------- | -------- | -------- |
76+
[`BN254TableCalculator`](./src/middlewareV2/tableCalculator/BN254TableCalculator.sol)| N/A | [`0xc2c0bc13571aC5115709C332dc7AE666606b08E8`](https://sepolia.etherscan.io/address/0xc2c0bc13571aC5115709C332dc7AE666606b08E8#code) | Singleton non-upgradeable |
77+
[`ECDSATableCalculator`](./src/middlewareV2/tableCalculator/ECDSATableCalculator.sol)| N/A | [`0x5612Fd146C2d40f1269E0e73945A534ec706dCDc`](https://sepolia.etherscan.io/address/0x5612Fd146C2d40f1269E0e73945A534ec706dCDc#code) | Singleton non-upgradeable |
78+
79+
80+
### Current AVS Mainnet Deployment
7281

7382
The current mainnet deployment is from our M2 mainnet release. You can view the deployed contract addresses below, or check out the code itself on the [`mainnet`](https://github.com/Layr-Labs/eigenlayer-middleware/tree/mainnet) branch.
7483

@@ -83,7 +92,7 @@ The current mainnet deployment is from our M2 mainnet release. You can view the
8392
[`ProxyAdmin`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/ProxyAdmin.sol) | - | [`0x8247...2E99`](https://etherscan.io/address/0x8247ef5705d3345516286b72bfe6d690197c2e99#code) | |
8493
[`eigenda/EigenDAServiceManager`](https://github.com/Layr-Labs/eigenda/blob/08d8781a2165c159ac9bb502dd61ed6ed340601c/contracts/src/core/EigenDAServiceManager.sol) | [`0x870679e138bcdf293b7ff14dd44b70fc97e12fc0`](https://etherscan.io/address/0x870679e138bcdf293b7ff14dd44b70fc97e12fc0#readProxyContract) | [`0xF5fD...899e`](https://etherscan.io/address/0xf5fd25a90902c27068cf5ebe53be8da693ac899e#code) | Proxy: [`[email protected]`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) |
8594

86-
### Current Testnet Deployment
95+
### Current AVS Testnet Deployment
8796

8897
The current testnet deployment is on holesky, is from our M2 beta release. You can view the deployed contract addresses below, or check out the code itself on the [`testnet-holesky`](https://github.com/Layr-Labs/eigenlayer-middleware/tree/testnet-holesky) branch.
8998

docs/middlewareV2/AVSRegistrar.md

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Interfaces:
2020

2121
## Overview
2222

23-
The AVSRegistrar is the interface between AVSs and the EigenLayer core protocol for managing operator registration. It enforces that operators have valid keys registered in the `KeyRegistrar` for a given `operatorSet` before allowing them to register. The `AVSRegistrar` manages multiple operatorSets for a single AVS.
23+
The AVSRegistrar is the interface between AVSs and the EigenLayer core protocol for managing operator registration. It enforces that operators have valid keys registered in the `KeyRegistrar` for a given `operatorSet` before allowing them to register. The `AVSRegistrar` manages multiple operatorSets for a single AVS.
2424

2525
### Key Features
2626

@@ -36,40 +36,71 @@ The below system diagrams assume the *basic* interaction with the AVSRegistrar.
3636
3. Gating operator registration based on custom stake-weighted parameters
3737

3838
#### Initialization
39+
3940
```mermaid
4041
sequenceDiagram
4142
participant AVSAdmin as AVS Admin
42-
participant AllocationManager
4343
participant AVSRegistrar
44-
45-
AVSAdmin->>AllocationManager: Tx1: set metadataURI
46-
AVSAdmin->>AVSRegistrar: Tx2: deploy AVSRegistrar
47-
AVSAdmin->>AllocationManager: Tx3: set AVSRegistrar
48-
AllocationManager->>AVSRegistrar: Tx3: check supportsAVS()
44+
participant OperatorTableCalculator
45+
participant AllocationManager
46+
participant KeyRegistrar
47+
participant CrossChainRegistry
48+
49+
AVS->>AVSRegistrar: Tx1: Deploy AVSRegistrar
50+
AVS->>AllocationManager: Tx2: updateMetadataURI()
51+
AVS->>AllocationManager: Tx3: setAVSRegistrar(AVSRegistrar)
52+
AllocationManager-->>: check supportsAVS()
53+
AVS->>KeyRegistrar: Tx4: configureOperatorSet(operatorSet, keyMaterial)
4954
```
5055

5156
The `AVSAdmin` is the entity that conducts on-chain operations on behalf of the AVS. It can be a multisig, eoa, or governance contract. In Tx1, when the `metadataURI` is set, the identifier for the AVS in the core protocol is the address of the `AVSAdmin`. For ergonomic purposes, it is possible to have the identifier be the [`AVSRegistrar`](#avsregistrarasidentifier). See the [Core `PermissionController`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/main/docs/permissions/PermissionController.md) for more information on how the admin can be changed.
5257

53-
#### Registration
58+
#### Registration
59+
60+
All registration/deregistration will flow from the `AllocationManager`. The `middlewareV2` architecture no longer requires an AVS to deploy a `KeyRegistrar`. Instead, the `AVSRegistrar` checks key membership in the core `KeyRegistrar` contract.
61+
5462
```mermaid
5563
sequenceDiagram
56-
participant Operator
57-
participant AllocationManager
58-
participant AVSRegistrar
59-
60-
Operator->>AllocationManager: Tx1: Register for opSet
61-
AllocationManager->>AVSRegistrar: Tx1: Send opSets, Data
64+
participant OP as Operator
65+
participant KR as KeyRegistrar
66+
participant AM as AllocationManager
67+
participant AVR as AVSRegistrar
68+
69+
OP->>KR: Tx1: registerKey
70+
OP->>AM: Tx2: registerForOperatorSets
71+
AM-->>AVR: registerForOperatorSets
72+
AVR-->>KR: isRegistered
6273
```
6374

6475
#### Deregistration
76+
77+
6578
```mermaid
6679
sequenceDiagram
6780
participant Operator
6881
participant AllocationManager
6982
participant AVSRegistrar
7083
7184
Operator->>AllocationManager: Tx1: Deregister
72-
AllocationManager->>AVSRegistrar: Tx1: Send Deregistration
85+
AllocationManager-->>AVSRegistrar: Tx1: Send Deregistration
86+
```
87+
88+
#### Operator Key Rotation
89+
90+
Rotation takes a dependency on the `AllocationManager`. In particular, operators are only allowed to deregister their key from an operatorSet if they are not slashable by said operatorSet.
91+
92+
To rotate a key, an operator must deregister from the operatorSet, wait until it is not slashable, deregister its key, and then register a new key. If the operator was not slashable, it can rotate its key without a delay.
93+
94+
```mermaid
95+
sequenceDiagram
96+
participant OP as Operator
97+
participant AM as AllocationManager
98+
participant KR as KeyRegistrar
99+
100+
OP->>AM: Tx1: deregisterFromOperatorSets
101+
Note over OP: Wait 14 days<br>(if previously allocated)
102+
OP->>KR: Tx2: deregisterKey
103+
OP->>AM: Tx3: register new key to operatorSet
73104
```
74105

75106
---
@@ -143,7 +174,7 @@ function deregisterOperator(
143174
) external virtual onlyAllocationManager;
144175
```
145176

146-
Deregisters an operator from one or more operator sets. This function can be called by an operator OR by the AVSs ejector if it has configured permissions in the [Core `Permission Controller`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/main/docs/permissions/PermissionController.md).
177+
Deregisters an operator from one or more operator sets. This function can be called by on the `AllocationManager` by either the operator OR the AVSs ejector if the AVS has configured permissions in the [Core `Permission Controller`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/main/docs/permissions/PermissionController.md).
147178

148179
*Effects:*
149180
- Emits `OperatorDeregistered` event
@@ -236,7 +267,6 @@ function _afterDeregisterOperator(
236267
- Triggering external notifications
237268
- Recording additional information
238269

239-
240270
---
241271

242272
## AVSRegistrarWithSocket
@@ -419,3 +449,5 @@ function initialize(address admin, string memory metadataURI) public initializer
419449
1. Updates AVS metadata URI in the AllocationManager
420450
2. Sets itself as the AVS registrar
421451
3. Initiates admin transfer via PermissionController
452+
453+
---

docs/middlewareV2/OperatorTableCalculator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ In addition, an AVS can build custom calculation methodologies that include:
3333
- Capping the stake of an operator
3434
- Using oracles to price stake
3535

36-
The [`ECDSATableCalculator`](../../src/middlewareV2/tableCalculator/ECDSATableCalculator.sol) and [`BN254TableCalculator`](../../src/middlewareV2/tableCalculator/BN254TableCalculator.sol) value slashable stake equally across all strategies. For example, if an operator allocates 100 stETH, 100 wETH, and 100 USDC the calculator would return 300 for the stake weight of the operator.
36+
The [`ECDSATableCalculator`](../../src/middlewareV2/tableCalculator/ECDSATableCalculator.sol) and [`BN254TableCalculator`](../../src/middlewareV2/tableCalculator/BN254TableCalculator.sol) value slashable stake equally across all strategies. For example, if an operator allocates 100 stETH, 100 wETH, and 100 DAI the calculator would return 300 for the stake weight of the operator.
3737

3838

3939
---

lib/eigenlayer-contracts

Submodule eigenlayer-contracts updated 58 files

src/middlewareV2/registrar/AVSRegistrar.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ contract AVSRegistrar is Initializable, AVSRegistrarStorage {
9595
) internal view {
9696
for (uint32 i = 0; i < operatorSetIds.length; i++) {
9797
OperatorSet memory operatorSet = OperatorSet({avs: avs, id: operatorSetIds[i]});
98-
require(keyRegistrar.checkKey(operatorSet, operator), KeyNotRegistered());
98+
require(keyRegistrar.isRegistered(operatorSet, operator), KeyNotRegistered());
9999
}
100100
}
101101

test/mocks/KeyRegistrarMock.sol

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ contract KeyRegistrarMock is IKeyRegistrar {
2626
_operatorRegistered[operatorSetKey][operator] = _isRegistered;
2727
}
2828

29-
function checkKey(
30-
OperatorSet calldata operatorSet,
31-
address operator
32-
) external view returns (bool) {
33-
return _operatorRegistered[operatorSet.key()][operator];
34-
}
35-
3629
function initialize(
3730
address initialOwner
3831
) external {}
@@ -51,7 +44,9 @@ contract KeyRegistrarMock is IKeyRegistrar {
5144
function isRegistered(
5245
OperatorSet memory operatorSet,
5346
address operator
54-
) external pure returns (bool) {}
47+
) external view returns (bool) {
48+
return _operatorRegistered[operatorSet.key()][operator];
49+
}
5550

5651
function getOperatorSetCurveType(
5752
OperatorSet memory operatorSet

0 commit comments

Comments
 (0)