Skip to content

Commit

Permalink
Merge pull request #310 from chainbound/lore/feat/holesky-el-scripts
Browse files Browse the repository at this point in the history
feat(holesky): updated EL scripts and README
  • Loading branch information
thedevbirb authored Oct 24, 2024
2 parents 78d0f22 + 857260f commit 295a56a
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 32 deletions.
5 changes: 3 additions & 2 deletions bolt-contracts/config/holesky/deployments.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"bolt": {
"validators": "0x47D2DC1DE1eFEFA5e6944402f2eda3981D36a9c8"
"validators": "0x47D2DC1DE1eFEFA5e6944402f2eda3981D36a9c8",
"manager": "0x440202829b493F9FF43E730EB5e8379EEa3678CF"
},
"symbiotic": {
"network": "0xb017002D8024d8c8870A5CECeFCc63887650D2a4",
Expand Down Expand Up @@ -28,4 +29,4 @@
"0xaccc5A86732BE85b5012e8614AF237801636F8e5"
]
}
}
}
5 changes: 0 additions & 5 deletions bolt-contracts/config/holesky/operator.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"strategy": "",
"token": "",
"amount": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rpc": "<hostname>:<port>",
"salt": "0x0000000000000000000_salt_value_000000000000000000000000000000000",
"expiry": "0x00000000000000000_expiry_value_000000000000000000000000000000000"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ 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 {IStrategyManager} from "@eigenlayer/src/contracts/interfaces/IStrategyManager.sol";
import {IStrategy, IERC20} from "@eigenlayer/src/contracts/interfaces/IStrategy.sol";
import {ISignatureUtils} from "@eigenlayer/src/contracts/interfaces/ISignatureUtils.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

import {BoltEigenLayerMiddlewareV1} from "../../../src/contracts/BoltEigenLayerMiddlewareV1.sol";
import {IBoltMiddlewareV1} from "../../../src/interfaces/IBoltMiddlewareV1.sol";
import {IBoltManagerV1} from "../../../src/interfaces/IBoltManagerV1.sol";

contract RegisterEigenLayerOperator is Script {
struct OperatorConfig {
Expand All @@ -19,14 +20,32 @@ contract RegisterEigenLayerOperator is Script {
uint256 expiry;
}

function run() public {
function S01_depositIntoStrategy() public {
uint256 operatorSk = vm.envUint("OPERATOR_SK");

IStrategyManager strategyManager = _readStrategyManager();

string memory json = vm.readFile("config/holesky/operators/eigenlayer/depositIntoStrategy.json");

IStrategy strategy = IStrategy(vm.parseJsonAddress(json, ".strategy"));
IERC20 token = IERC20(vm.parseJsonAddress(json, ".token"));
uint256 amount = vm.parseJsonUint(json, ".amount");

vm.startBroadcast(operatorSk);
// Allowance must be set before depositing
token.approve(address(strategyManager), amount);
strategyManager.depositIntoStrategy(strategy, token, amount);
console.log("Successfully run StrategyManager.depositIntoStrategy");
vm.stopBroadcast();
}

function S02_registerIntoBoltAVS() public {
uint256 operatorSk = vm.envUint("OPERATOR_SK");
address operator = vm.addr(operatorSk);

BoltEigenLayerMiddlewareV1 middleware = _readMiddleware();
IAVSDirectory avsDirectory = _readAvsDirectory();
OperatorConfig memory config = _readConfig("config/holesky/operator.json");
OperatorConfig memory config = _readConfig("config/holesky/operators/eigenlayer/registerIntoBoltAVS.json");

console.log("Registering EigenLayer operator");
console.log("Operator address:", operator);
Expand All @@ -53,6 +72,16 @@ contract RegisterEigenLayerOperator is Script {
vm.stopBroadcast();
}

function S03_checkOperatorRegistration() public view {
address operatorPublicKey = vm.envAddress("OPERATOR_PK");
console.log("Checking operator registration for address", operatorPublicKey);

IBoltManagerV1 boltManager = _readBoltManager();
bool isRegistered = boltManager.isOperator(operatorPublicKey);
console.log("Operator is registered:", isRegistered);
require(isRegistered, "Operator is not registered");
}

function _readMiddleware() public view returns (BoltEigenLayerMiddlewareV1) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
Expand All @@ -69,6 +98,28 @@ 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 _readStrategyManager() public view returns (IStrategyManager) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory json = vm.readFile(path);
return IStrategyManager(vm.parseJsonAddress(json, ".eigenLayer.strategyManager"));
}

function _readBoltManager() public view returns (IBoltManagerV1) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory json = vm.readFile(path);
return IBoltManagerV1(vm.parseJsonAddress(json, ".bolt.manager"));
}

function _readConfig(
string memory path
) public view returns (OperatorConfig memory) {
Expand Down
107 changes: 87 additions & 20 deletions testnets/holesky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ The opt-in process requires the following steps:
Run the provided Forge script to register a Symbiotic operator:

```bash
forge script script/holesky/validators/RegisterSymbioticOperator.s.sol --rpc-url $HOLESKY_RPC -vvvv --broadcast
forge script script/holesky/operators/RegisterSymbioticOperator.s.sol --rpc-url $HOLESKY_RPC -vvvv --broadcast
```

If all goes well, your Symbiotic operator was registered into Bolt.
Expand All @@ -524,31 +524,93 @@ If all goes well, your Symbiotic operator was registered into Bolt.
> The supported strategies can be found in
> [`deployments.json`](../../bolt-contracts/config/holesky/deployments.json).
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:
If you're not registered as an operator in EigenLayer yet, you need to do so by
following [the official
guide](https://docs.eigenlayer.xyz/eigenlayer/operator-guides/operator-introduction).
This requires installing the EigenLayer CLI and opt into the protocol by
registering via the
[`DelegationManager.registerAsOperator`](https://docs.eigenlayer.xyz/eigenlayer/operator-guides/operator-installation)
function.

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).
After that you need to deposit into a supported EigenLayer
strategy using
[`StrategyManager.depositIntoStrategy`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/testnet-holesky/src/contracts/core/StrategyManager.sol#L303-L322).
This will add the deposit into the collateral of the operator so that Bolt can
read it. Note that you need to deposit a minimum of `1 ether` of the strategies
underlying token in order to opt in.

2. You can then use the same account to deposit into a supported EigenLayer
strategy using
[`StrategyManager.depositIntoStrategy`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/testnet-holesky/src/contracts/core/StrategyManager.sol#L303-L322).
This will add the deposit into the collateral of the operator so that Bolt can
read it. Note that you need to deposit a minimum of `1 ether` of the strategies
underlying token in order to opt in.
We've provided a script to facilitate the procedure. If you want to use it,
please set the operator private key to an `OPERATOR_SK` environment variable.

First, you need to first configure the deposit details in this JSON
file:

```bash
$EDITOR ./config/holesky/operators/eigenlayer/depositIntoStrategy.json
```

Then you can run the following Forge script:

```bash
forge script script/holesky/operators/RegisterEigenLayerOperator.s.sol \
--sig "S01_depositIntoStrategy()" \
--rpc-url $HOLESKY_RPC \
-vvvv \
--broadcast
```

**Internal Steps**

Set the operator private key to an `OPERATOR_SK` environment variable, and then
run the following Forge script from the `bolt-contracts` directory:
After having deposited collateral into a strategy you need to register into the
Bolt AVS. We've provided a script to facilitate the procedure. If you want to
use it, please set follow these steps:

1. configure the operator details in this JSON file

```bash
$EDITOR ./config/holesky/operators/eigenlayer/registerIntoBoltAVS.json
```

In there you'll need to set the the following fields:

- `rpc` -- the RPC URL of your operator which supports the Commitments API
- `salt` -- an unique 32 bytes value to avoid replay attacks. To generate it on
both Linux and MacOS you can run:

```bash
echo -n "0x"; head -c 32 /dev/urandom | hexdump -e '32/1 "%02x" "\n"'
```

- `expiry` -- the timestamp of the signature expiry in seconds. To generate it
on both Linux and MacOS run the following command, replacing
`<EXPIRY_TIMESTAMP>` with the desired timestamp:

```bash
echo -n "0x"; printf "%064x\n" <EXPIRY_TIMESTAMP>
```

2. set the operator private key to an `OPERATOR_SK` environment
variable;
3. run the following Forge script from the `bolt-contracts`
directory:

```bash
forge script script/holesky/validators/RegisterEigenLayerOperator.s.sol --rpc-url $HOLESKY_RPC -vvvv --broadcast
forge script script/holesky/operators/RegisterEigenLayerOperator.s.sol \
--sig "S02_registerIntoBoltAVS" \
--rpc-url $HOLESKY_RPC \
-vvvv \
--broadcast
```

If all goes well, your EigenLayer operator was registered into Bolt.
To check if your operator is correctly registered, set the operator public key
in the `OPERATOR_PK` environment variable and run the following script:

```bash
forge script script/holesky/operators/RegisterEigenLayerOperator.s.sol \
--sig "S03_checkOperatorRegistration" \
--rpc-url $HOLESKY_RPC \
-vvvv
```

# Reference

Expand All @@ -559,13 +621,14 @@ sidecar. You can see them in your terminal by running the Bolt sidecar binary
with the `--help` flag:

```
Command-line options for the Bolt sidecar
Usage: bolt-sidecar [OPTIONS] --validator-indexes <VALIDATOR_INDEXES> --engine-jwt-hex <ENGINE_JWT_HEX> --fee-recipient <FEE_RECIPIENT> --builder-private-key <BUILDER_PRIVATE_KEY> --commitment-private-key <COMMITMENT_PRIVATE_KEY> <--constraint-private-key <CONSTRAINT_PRIVATE_KEY>|--commit-boost-signer-url <COMMIT_BOOST_SIGNER_URL>|--keystore-password <KEYSTORE_PASSWORD>|--keystore-secrets-path <KEYSTORE_SECRETS_PATH>>
Options:
--port <PORT>
Port to listen on for incoming JSON-RPC requests of the Commitments API. This port should be open on your firewall in order to receive external requests!
Port to listen on for incoming JSON-RPC requests of the Commitments API. This port should be open on your firewall in order to receive external requests!
[env: BOLT_SIDECAR_PORT=]
[default: 8017]
Expand Down Expand Up @@ -601,8 +664,11 @@ Options:
[default: 18550]
--validator-indexes <VALIDATOR_INDEXES>
Validator indexes of connected validators that the sidecar should accept commitments on behalf of. Accepted values: - a comma-separated list of indexes (e.g. "1,2,3,4") - a contiguous range of indexes (e.g. "1..4") - a mix of the
above (e.g. "1,2..4,6..8")
Validator indexes of connected validators that the sidecar should accept commitments on behalf of.
Accepted values:
- a comma-separated list of indexes (e.g. "1,2,3,4")
- a contiguous range of indexes (e.g. "1..4")
- a mix of the above (e.g. "1,2..4,6..8")
[env: BOLT_SIDECAR_VALIDATOR_INDEXES=]
Expand Down Expand Up @@ -711,6 +777,7 @@ Options:
-h, --help
Print help (see a summary with '-h')
```
## Delegations and signing options for Native and Docker Compose Mode
Expand Down

0 comments on commit 295a56a

Please sign in to comment.