From 8957188b82eb8aa1568c2e74d5b5f0af121fc866 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Wed, 23 Oct 2024 11:46:03 +0200 Subject: [PATCH] feat(holesky): EL script for DelegationManager.registerAsOperator --- .../eigenlayer/registerAsOperator.json | 8 +++++ .../RegisterEigenLayerOperator.s.sol | 34 ++++++++++++++++++- testnets/holesky/README.md | 24 +++++++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 bolt-contracts/config/holesky/operators/eigenlayer/registerAsOperator.json diff --git a/bolt-contracts/config/holesky/operators/eigenlayer/registerAsOperator.json b/bolt-contracts/config/holesky/operators/eigenlayer/registerAsOperator.json new file mode 100644 index 000000000..12df9d6ee --- /dev/null +++ b/bolt-contracts/config/holesky/operators/eigenlayer/registerAsOperator.json @@ -0,0 +1,8 @@ +{ + "registeringOperatorDetails": { + "earningsReceiver": "", + "delegationApprover": "", + "stakerOptOutWindowBlocks": "" + }, + "metadataURI": "" +} diff --git a/bolt-contracts/script/holesky/operators/RegisterEigenLayerOperator.s.sol b/bolt-contracts/script/holesky/operators/RegisterEigenLayerOperator.s.sol index 3acbe2d81..6a7f4c58c 100644 --- a/bolt-contracts/script/holesky/operators/RegisterEigenLayerOperator.s.sol +++ b/bolt-contracts/script/holesky/operators/RegisterEigenLayerOperator.s.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.25; import {Script, console} from "forge-std/Script.sol"; import {IAVSDirectory} from "@eigenlayer/src/contracts/interfaces/IAVSDirectory.sol"; +import {IDelegationManager} from "@eigenlayer/src/contracts/interfaces/IDelegationManager.sol"; import {ISignatureUtils} from "@eigenlayer/src/contracts/interfaces/ISignatureUtils.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -19,9 +20,32 @@ contract RegisterEigenLayerOperator is Script { uint256 expiry; } - function run() public { + struct RegisterAsOperatorCalldata { + OperatorDetails registeringOperatorDetails; + string metadataURI; + } + + function S01_registerAsOperator() public { uint256 operatorSk = vm.envUint("OPERATOR_SK"); + address operator = vm.addr(operatorSk); + + IDelegationManager delegationManager = _readDelegationManager(); + + string memory json = vm.readFile("config/holesky/operators/eigenlayer/registerAsOperator.json"); + + bytes memory operatorDetailsRaw = vm.parseJson(json, ".operatorDetails"); + OperatorDetails memory registeringOperatorDetails = abi.decode(operatorDetailsRaw, (OperatorDetails)); + + string memory metadataURI = vm.parseJsonString(json, ".metadataURI"); + + vm.startBroadcast(operatorSk); + delegationManager.registerAsOperator(registeringOperatorDetails, metadataURI); + console.log("Successfully run DelegationManager.registerAsOperator"); + vm.stopBroadcast(); + } + function run() public { + uint256 operatorSk = vm.envUint("OPERATOR_SK"); address operator = vm.addr(operatorSk); BoltEigenLayerMiddlewareV1 middleware = _readMiddleware(); @@ -69,6 +93,14 @@ contract RegisterEigenLayerOperator is Script { return IAVSDirectory(vm.parseJsonAddress(json, ".eigenLayer.avsDirectory")); } + function _readDelegationManager() public view returns (IDelegationManager) { + string memory root = vm.projectRoot(); + string memory path = string.concat(root, "/config/holesky/deployments.json"); + string memory json = vm.readFile(path); + + return IDelegationManager(vm.parseJsonAddress(json, ".eigenLayer.delegationManager")); + } + function _readConfig( string memory path ) public view returns (OperatorConfig memory) { diff --git a/testnets/holesky/README.md b/testnets/holesky/README.md index 4a6f6df60..d6fd8edb6 100644 --- a/testnets/holesky/README.md +++ b/testnets/holesky/README.md @@ -526,11 +526,31 @@ If all goes well, your Symbiotic operator was registered into Bolt. The Operator will be represented by an Ethereum address that needs to follow the standard procedure outlined in the [EigenLayer -documentation](https://docs.eigenlayer.xyz/) to opt into EigenLayer. Let's go -through the steps: +documentation](https://docs.eigenlayer.xyz/) to opt into EigenLayer. + +We've provided scripts for every step to facilitate the procedures. Please set +the operator private key to an `OPERATOR_SK` environment variable. + +Let's go through the steps: 1. As an Operator, you register into EigenLayer using [`DelegationManager.registerAsOperator`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/testnet-holesky/src/contracts/core/DelegationManager.sol#L107-L119). + To do that, you need to first configure the `OperatorDetails` and the + metadataURI in this JSON file: + + ```bash + $EDITOR ./config/holesky/operators/eigenlayer/registerAsOperator.json + ``` + + Then you can run the following Forge script: + + ```bash + forge script script/holesky/operators/RegisterEigenLayerOperator.s.sol \ + --sig "S01_registerAsOperator()" \ + --rpc-url $HOLESKY_RPC \ + -vvvv \ + --broadcast + ``` 2. You can then use the same account to deposit into a supported EigenLayer strategy using