|
| 1 | +// SPDX-License-Identifier: GPL-3.0 |
| 2 | +pragma solidity >=0.8.0 <0.9.0; |
| 3 | + |
| 4 | +import {Script} from "forge-std/Script.sol"; |
| 5 | +import {stdJson} from "forge-std/StdJson.sol"; |
| 6 | +import {console} from "forge-std/console.sol"; |
| 7 | + |
| 8 | +interface IInstitutionalVault { |
| 9 | + function startRestakingValidators( |
| 10 | + bytes[] calldata pubKeys, |
| 11 | + bytes[] calldata signatures, |
| 12 | + bytes32[] calldata depositDataRoots |
| 13 | + ) external; |
| 14 | +} |
| 15 | + |
| 16 | +// forge script script/StartRestakingValidators.s.sol:StartRestakingValidators --rpc-url=$HOLESKY_RPC_URL --account institutional-deployer-testnet -vvvv --sig "run(address,string)" 0x205A6BCF458a40E1a30a000166c793Ec54b0d9D5 example |
| 17 | +// add --broadcast to broadcast the transaction |
| 18 | +contract StartRestakingValidators is Script { |
| 19 | + using stdJson for string; |
| 20 | + |
| 21 | + // Expected file to have the format of test/validator-keys/no_restaking_validator_keys_holesky/deposit_data-1736424571.json |
| 22 | + // That is generated using the deposit-cli -> https://github.com/ethereum/staking-deposit-cli |
| 23 | + |
| 24 | + struct DepositData { |
| 25 | + ValidatorDepositData[] validatorDepositData; |
| 26 | + } |
| 27 | + |
| 28 | + // Struct needs to be ordered alphabetically, see foundry docs for more info |
| 29 | + struct ValidatorDepositData { |
| 30 | + uint256 amount; |
| 31 | + string deposit_cli_version; |
| 32 | + string deposit_data_root; |
| 33 | + string deposit_message_root; |
| 34 | + string fork_version; |
| 35 | + string network_name; |
| 36 | + string pubkey; |
| 37 | + string signature; |
| 38 | + string withdrawal_credentials; |
| 39 | + } |
| 40 | + |
| 41 | + function run(address payable institutionalVaultProxy, string calldata depositFileName) public { |
| 42 | + vm.startBroadcast(); |
| 43 | + |
| 44 | + string memory root = vm.projectRoot(); |
| 45 | + string memory path = |
| 46 | + string.concat(root, "/validator_deposit_data/restaking_validators/", depositFileName, ".json"); |
| 47 | + |
| 48 | + console.log("Path:", path); |
| 49 | + |
| 50 | + string memory fileContent = vm.readFile(path); |
| 51 | + bytes memory rawJson = vm.parseJson(fileContent); |
| 52 | + |
| 53 | + ValidatorDepositData[] memory depositData = abi.decode(rawJson, (ValidatorDepositData[])); |
| 54 | + |
| 55 | + bytes[] memory pubKeys = new bytes[](depositData.length); |
| 56 | + bytes[] memory signatures = new bytes[](depositData.length); |
| 57 | + bytes32[] memory depositDataRoots = new bytes32[](depositData.length); |
| 58 | + |
| 59 | + for (uint256 i = 0; i < depositData.length; i++) { |
| 60 | + pubKeys[i] = vm.parseBytes(depositData[i].pubkey); |
| 61 | + signatures[i] = vm.parseBytes(depositData[i].signature); |
| 62 | + depositDataRoots[i] = vm.parseBytes32(depositData[i].deposit_data_root); |
| 63 | + } |
| 64 | + |
| 65 | + IInstitutionalVault(institutionalVaultProxy).startRestakingValidators(pubKeys, signatures, depositDataRoots); |
| 66 | + |
| 67 | + vm.stopBroadcast(); |
| 68 | + } |
| 69 | +} |
0 commit comments