Skip to content

Commit

Permalink
chore(holesky): better explanation of operator config steps for EL
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Oct 24, 2024
1 parent ae72386 commit 296a87e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
"salt": "0x0000000000000000000_salt_value_0000000000000000000000000000000000",
"expiry": "0x00000000000000000_expiry_value_0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ contract RegisterEigenLayerOperator is Script {

IStrategyManager strategyManager = _readStrategyManager();

string memory json = vm.readFile("config/holesky/operators/eigenlayer/depositIntoStrategy.json");
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"));
Expand All @@ -45,24 +47,32 @@ contract RegisterEigenLayerOperator is Script {

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);
console.log("Operator RPC:", config.rpc);

bytes32 digest = avsDirectory.calculateOperatorAVSRegistrationDigestHash({
operator: operator,
avs: address(middleware),
salt: config.salt,
expiry: config.expiry
});
bytes32 digest = avsDirectory
.calculateOperatorAVSRegistrationDigestHash({
operator: operator,
avs: address(middleware),
salt: config.salt,
expiry: config.expiry
});

(uint8 v, bytes32 r, bytes32 s) = vm.sign(operatorSk, digest);
bytes memory rawSignature = abi.encodePacked(r, s, v);

ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature =
ISignatureUtils.SignatureWithSaltAndExpiry(rawSignature, config.salt, config.expiry);
ISignatureUtils.SignatureWithSaltAndExpiry
memory operatorSignature = ISignatureUtils
.SignatureWithSaltAndExpiry(
rawSignature,
config.salt,
config.expiry
);

vm.startBroadcast(operatorSk);

Expand All @@ -74,48 +84,82 @@ contract RegisterEigenLayerOperator is Script {

function S03_checkOperatorRegistration() public view {
address operatorPublicKey = vm.envAddress("OPERATOR_PK");
console.log("Checking operator registration for address", operatorPublicKey);
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) {
function _readMiddleware()
public
view
returns (BoltEigenLayerMiddlewareV1)
{
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory path = string.concat(
root,
"/config/holesky/deployments.json"
);
string memory json = vm.readFile(path);

return BoltEigenLayerMiddlewareV1(vm.parseJsonAddress(json, ".eigenLayer.middleware"));
return
BoltEigenLayerMiddlewareV1(
vm.parseJsonAddress(json, ".eigenLayer.middleware")
);
}

function _readAvsDirectory() public view returns (IAVSDirectory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory path = string.concat(
root,
"/config/holesky/deployments.json"
);
string memory json = vm.readFile(path);

return IAVSDirectory(vm.parseJsonAddress(json, ".eigenLayer.avsDirectory"));
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 path = string.concat(
root,
"/config/holesky/deployments.json"
);
string memory json = vm.readFile(path);

return IDelegationManager(vm.parseJsonAddress(json, ".eigenLayer.delegationManager"));
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 path = string.concat(
root,
"/config/holesky/deployments.json"
);
string memory json = vm.readFile(path);
return IStrategyManager(vm.parseJsonAddress(json, ".eigenLayer.strategyManager"));
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 path = string.concat(
root,
"/config/holesky/deployments.json"
);
string memory json = vm.readFile(path);
return IBoltManagerV1(vm.parseJsonAddress(json, ".bolt.manager"));
}
Expand All @@ -140,6 +184,11 @@ contract RegisterEigenLayerOperator is Script {
console.log("No expiry found in config, using UINT256_MAX");
}

return OperatorConfig({rpc: vm.parseJsonString(json, ".rpc"), salt: salt, expiry: expiry});
return
OperatorConfig({
rpc: vm.parseJsonString(json, ".rpc"),
salt: salt,
expiry: expiry
});
}
}
33 changes: 30 additions & 3 deletions testnets/holesky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,36 @@ forge script script/holesky/operators/RegisterEigenLayerOperator.s.sol \

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 the operator private key to an `OPERATOR_SK` environment
variable, and then run the following Forge script from the `bolt-contracts`
directory:
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/operators/RegisterEigenLayerOperator.s.sol \
Expand Down

0 comments on commit 296a87e

Please sign in to comment.