-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomExternalCallNonRestakingValidators.s.sol
More file actions
105 lines (85 loc) · 4.07 KB
/
CustomExternalCallNonRestakingValidators.s.sol
File metadata and controls
105 lines (85 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;
import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {console} from "forge-std/console.sol";
interface IInstitutionalVault {
function customExternalCall(address target, bytes calldata data, uint256 amount) external payable;
}
interface IBeaconDepositContract {
function deposit(
bytes calldata pubkey,
bytes calldata withdrawal_credentials,
bytes calldata signature,
bytes32 deposit_data_root
) external payable;
}
// forge script script/CustomExternalCallNonRestakingValidators.s.sol:CustomExternalCallNonRestakingValidators --rpc-url=$HOLESKY_RPC_URL --account institutional-deployer-testnet -vvvv --sig "run(string)" depositfilename
// This script assumes that the calldata will be executed on mainnet, so the beacon deposit contract address is hardcoded
contract CustomExternalCallNonRestakingValidators is Script {
using stdJson for string;
// That is generated using the deposit-cli -> https://deposit-cli.ethstaker.cc/landing.html
struct DepositData {
ValidatorDepositData[] validatorDepositData;
}
// Struct needs to be ordered alphabetically, see foundry docs for more info
struct ValidatorDepositData {
uint256 amount;
string deposit_cli_version;
string deposit_data_root;
string deposit_message_root;
string fork_version;
string network_name;
string pubkey;
string signature;
string withdrawal_credentials;
}
struct RolesConfiguration {
address admin;
address[] customExternalCallers;
address pufferOpsMultisig;
address vault;
address withdrawalManager;
}
bytes pubKey;
bytes withdrawalCredentials;
bytes signature;
bytes32 depositDataRoot;
uint256 amount;
function run(string calldata depositFileName) public {
// vm.startBroadcast();
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/validator_deposit_data/0x02/", depositFileName, ".json");
string memory rolesConfigurationPath = string.concat(root, "/roles-configuration.json");
console.log("Path:", path);
console.log("Roles configuration path:", rolesConfigurationPath);
string memory fileContent = vm.readFile(path);
bytes memory rawJson = vm.parseJson(fileContent);
RolesConfiguration memory accessManagerConfiguration =
abi.decode(vm.parseJson(vm.readFile(rolesConfigurationPath)), (RolesConfiguration));
ValidatorDepositData[] memory depositData = abi.decode(rawJson, (ValidatorDepositData[]));
for (uint256 i = 0; i < depositData.length; i++) {
pubKey = vm.parseBytes(depositData[i].pubkey);
withdrawalCredentials = vm.parseBytes(depositData[i].withdrawal_credentials);
signature = vm.parseBytes(depositData[i].signature);
depositDataRoot = vm.parseBytes32(depositData[i].deposit_data_root);
amount = depositData[i].amount * 10 ** 9; // The deposit data amount is in Gwei, we need to convert it to Wei
bytes memory data = abi.encodeCall(
IBeaconDepositContract.deposit, (pubKey, withdrawalCredentials, signature, depositDataRoot)
);
bytes memory customExternalCallData = abi.encodeCall(
IInstitutionalVault.customExternalCall,
// Hardcoded the beacon deposit contract address
(0x00000000219ab540356cBB839Cbe05303d7705Fa, data, amount)
);
console.log("Custom external call to the beacon deposit contract");
console.log("Vault:", accessManagerConfiguration.vault);
console.logBytes(customExternalCallData);
// TODO: Custom external call directly to the beacon deposit contract
// IInstitutionalVault(institutionalVaultProxy).customExternalCall(
// accessManagerConfiguration.vault, data, amount
// );
}
// vm.stopBroadcast();
}
}