Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contracts): script to register validators #302

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bolt-contracts/config/holesky/register_validators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"boltValidators": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
"maxCommittedGasLimit": 10000000,
"authorizedOperator": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
"pubkeys": [
{
"x": [1, 2],
"y": [3, 4]
},
{
"x": [5, 6],
"y": [7, 8]
}
]
}
49 changes: 49 additions & 0 deletions bolt-contracts/script/holesky/validators/RegisterValidators.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {IBoltValidatorsV1} from "../../../src/interfaces/IBoltValidatorsV1.sol";
import {BLS12381} from "../../../src/lib/bls/BLS12381.sol";

import {Script, console} from "forge-std/Script.sol";

/// @notice Script to register Ethereum validators to Bolt
/// @dev this script reads from the config file in /config/holesky/register_validators.json
contract RegisterValidators is Script {
struct RegisterValidatorsConfig {
address boltValidators;
uint128 maxCommittedGasLimit;
address authorizedOperator;
BLS12381.G1Point[] pubkeys;
}

function run() public {
address controller = msg.sender;

console.log("Registering validators to Bolt");
console.log("Controller address: ", controller);

RegisterValidatorsConfig memory config = parseConfig();

vm.startBroadcast(controller);
IBoltValidatorsV1(config.boltValidators).batchRegisterValidatorsUnsafe(
config.pubkeys, config.maxCommittedGasLimit, config.authorizedOperator
);
vm.stopBroadcast();

console.log("Validators registered successfully");
}

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

config.boltValidators = vm.parseJsonAddress(json, ".boltValidators");
config.authorizedOperator = vm.parseJsonAddress(json, ".authorizedOperator");
config.maxCommittedGasLimit = uint128(vm.parseJsonUint(json, ".maxCommittedGasLimit"));

bytes memory pubkeysRaw = vm.parseJson(json, ".pubkeys");
BLS12381.G1Point[] memory pubkeys = abi.decode(pubkeysRaw, (BLS12381.G1Point[]));
config.pubkeys = pubkeys;
}
}
Loading