Skip to content

Commit

Permalink
chore: update script
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Oct 18, 2024
1 parent 8c2efe9 commit 4693478
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions bolt-contracts/script/holesky/validators/RegisterValidators.s.sol
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {IBoltValidatorsV1} from "../interfaces/IBoltValidatorsV1.sol";
import {BLS12381} from "../lib/bls/BLS12381.sol";
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;
string[] pubkeys;
BLS12381.G1Point[] pubkeys;
}

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

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

RegisterValidatorsConfig memory config = parseConfig(configPath);
RegisterValidatorsConfig memory config = parseConfig();

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

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

function parseConfig(
string configPath
) public view returns (RegisterValidatorsConfig memory config) {
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);
Expand All @@ -48,7 +45,9 @@ contract RegisterValidators is Script {
string[] memory pubkeysRaw = vm.parseJsonStringArray(json, "pubkeys");
BLS12381.G1Point[] memory pubkeys = new BLS12381.G1Point[](pubkeysRaw.length);
for (uint256 i = 0; i < pubkeysRaw.length; i++) {
pubkeys[i] = BLS12381.G1Point(vm.parseJsonBytes(json, pubkeysRaw[i]));
uint256[2] memory x = [uint256(0), uint256(0)];
uint256[2] memory y = [uint256(0), uint256(0)];
pubkeys[i] = BLS12381.G1Point(x, y);
}
config.pubkeys = pubkeys;
}
Expand Down

0 comments on commit 4693478

Please sign in to comment.