@aztec/cli 0.0.1-commit.24de95ac → 0.0.1-commit.27d773e65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dest/cmds/aztec_node/block_number.d.ts +1 -1
- package/dest/cmds/aztec_node/get_block.d.ts +1 -1
- package/dest/cmds/aztec_node/get_block.d.ts.map +1 -1
- package/dest/cmds/aztec_node/get_block.js +2 -1
- package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
- package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
- package/dest/cmds/aztec_node/{get_current_base_fee.js → get_current_min_fee.js} +2 -2
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +1 -1
- package/dest/cmds/aztec_node/get_logs.d.ts +3 -2
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -1
- package/dest/cmds/aztec_node/get_node_info.d.ts +1 -1
- package/dest/cmds/aztec_node/index.d.ts +1 -1
- package/dest/cmds/aztec_node/index.js +3 -3
- package/dest/cmds/contracts/index.d.ts +1 -1
- package/dest/cmds/contracts/inspect_contract.d.ts +1 -1
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +4 -10
- package/dest/cmds/contracts/parse_parameter_struct.d.ts +1 -1
- package/dest/cmds/infrastructure/index.d.ts +1 -1
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +0 -1
- package/dest/cmds/infrastructure/sequencers.d.ts +1 -2
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +11 -4
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +4 -3
- package/dest/cmds/l1/advance_epoch.d.ts +1 -1
- package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +3 -4
- package/dest/cmds/l1/bridge_erc20.d.ts +1 -1
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +2 -1
- package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
- package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
- package/dest/cmds/l1/compute_genesis_values.js +17 -0
- package/dest/cmds/l1/create_l1_account.d.ts +1 -1
- package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +4 -0
- package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -0
- package/dest/cmds/l1/{deploy_l1_contracts.js → deploy_l1_contracts_cmd.js} +39 -4
- package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -4
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +3 -3
- package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
- package/dest/cmds/l1/get_l1_addresses.js +5 -2
- package/dest/cmds/l1/get_l1_balance.d.ts +1 -1
- package/dest/cmds/l1/get_l1_balance.js +4 -2
- package/dest/cmds/l1/governance_utils.d.ts +5 -5
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +3 -1
- package/dest/cmds/l1/index.d.ts +1 -2
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +17 -10
- package/dest/cmds/l1/prover_stats.d.ts +1 -1
- package/dest/cmds/l1/prover_stats.d.ts.map +1 -1
- package/dest/cmds/l1/prover_stats.js +32 -30
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +2 -2
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -1
- package/dest/cmds/l1/trigger_seed_snapshot.js +2 -1
- package/dest/cmds/l1/update_l1_validators.d.ts +7 -7
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +58 -19
- package/dest/cmds/misc/compute_selector.d.ts +1 -1
- package/dest/cmds/misc/example_contracts.d.ts +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +1 -1
- package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +1 -1
- package/dest/cmds/misc/index.d.ts +1 -1
- package/dest/cmds/misc/index.d.ts.map +1 -1
- package/dest/cmds/misc/index.js +1 -1
- package/dest/cmds/misc/update/common.d.ts +1 -1
- package/dest/cmds/misc/update/github.d.ts +1 -1
- package/dest/cmds/misc/update/noir.d.ts +1 -1
- package/dest/cmds/misc/update/npm.d.ts +1 -1
- package/dest/cmds/misc/update/npm.js +1 -1
- package/dest/cmds/misc/update/utils.d.ts +1 -1
- package/dest/cmds/misc/update.d.ts +1 -1
- package/dest/cmds/validator_keys/add.d.ts +1 -1
- package/dest/cmds/validator_keys/add.d.ts.map +1 -1
- package/dest/cmds/validator_keys/add.js +20 -7
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +1 -1
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -1
- package/dest/cmds/validator_keys/generate_bls_keypair.js +3 -2
- package/dest/cmds/validator_keys/index.d.ts +1 -1
- package/dest/cmds/validator_keys/index.d.ts.map +1 -1
- package/dest/cmds/validator_keys/index.js +16 -4
- package/dest/cmds/validator_keys/new.d.ts +7 -4
- package/dest/cmds/validator_keys/new.d.ts.map +1 -1
- package/dest/cmds/validator_keys/new.js +90 -16
- package/dest/cmds/validator_keys/shared.d.ts +4 -4
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
- package/dest/cmds/validator_keys/shared.js +31 -28
- package/dest/cmds/validator_keys/staker.d.ts +38 -0
- package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
- package/dest/cmds/validator_keys/staker.js +210 -0
- package/dest/cmds/validator_keys/utils.d.ts +25 -0
- package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
- package/dest/cmds/validator_keys/utils.js +52 -0
- package/dest/config/cached_fetch.d.ts +1 -1
- package/dest/config/chain_l2_config.d.ts +13 -38
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +35 -463
- package/dest/config/enrich_env.d.ts +1 -1
- package/dest/config/generated/networks.d.ts +222 -0
- package/dest/config/generated/networks.d.ts.map +1 -0
- package/dest/config/generated/networks.js +223 -0
- package/dest/config/get_l1_config.d.ts +3 -2
- package/dest/config/get_l1_config.d.ts.map +1 -1
- package/dest/config/get_l1_config.js +3 -1
- package/dest/config/index.d.ts +1 -1
- package/dest/config/network_config.d.ts +7 -4
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +65 -29
- package/dest/utils/aztec.d.ts +7 -13
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +19 -40
- package/dest/utils/commands.d.ts +8 -7
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +6 -5
- package/dest/utils/encoding.d.ts +1 -1
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +1 -1
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/inspect.d.ts +3 -2
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +4 -1
- package/dest/utils/setup_contracts.d.ts +1 -1
- package/package.json +44 -31
- package/public_include_metric_prefixes.json +1 -0
- package/src/cmds/aztec_node/get_block.ts +2 -1
- package/src/cmds/aztec_node/{get_current_base_fee.ts → get_current_min_fee.ts} +2 -2
- package/src/cmds/aztec_node/get_logs.ts +3 -2
- package/src/cmds/aztec_node/index.ts +3 -3
- package/src/cmds/contracts/inspect_contract.ts +4 -11
- package/src/cmds/infrastructure/index.ts +0 -1
- package/src/cmds/infrastructure/sequencers.ts +7 -5
- package/src/cmds/infrastructure/setup_l2_contract.ts +5 -4
- package/src/cmds/l1/assume_proven_through.ts +4 -4
- package/src/cmds/l1/bridge_erc20.ts +2 -1
- package/src/cmds/l1/compute_genesis_values.ts +29 -0
- package/src/cmds/l1/{deploy_l1_contracts.ts → deploy_l1_contracts_cmd.ts} +39 -22
- package/src/cmds/l1/deploy_new_rollup.ts +4 -9
- package/src/cmds/l1/get_l1_addresses.ts +4 -2
- package/src/cmds/l1/get_l1_balance.ts +2 -2
- package/src/cmds/l1/governance_utils.ts +3 -8
- package/src/cmds/l1/index.ts +30 -21
- package/src/cmds/l1/prover_stats.ts +42 -31
- package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
- package/src/cmds/l1/update_l1_validators.ts +52 -31
- package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
- package/src/cmds/misc/index.ts +1 -1
- package/src/cmds/misc/update/npm.ts +1 -1
- package/src/cmds/validator_keys/add.ts +20 -10
- package/src/cmds/validator_keys/generate_bls_keypair.ts +3 -2
- package/src/cmds/validator_keys/index.ts +67 -21
- package/src/cmds/validator_keys/new.ts +110 -23
- package/src/cmds/validator_keys/shared.ts +32 -27
- package/src/cmds/validator_keys/staker.ts +301 -0
- package/src/cmds/validator_keys/utils.ts +81 -0
- package/src/config/chain_l2_config.ts +36 -604
- package/src/config/generated/networks.ts +227 -0
- package/src/config/get_l1_config.ts +4 -1
- package/src/config/network_config.ts +75 -30
- package/src/utils/aztec.ts +24 -83
- package/src/utils/commands.ts +6 -5
- package/src/utils/encoding.ts +1 -1
- package/src/utils/inspect.ts +6 -2
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts +0 -3
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +0 -1
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +0 -4
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +0 -1
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { GSEContract } from '@aztec/ethereum/contracts';
|
|
1
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
7
|
|
|
5
8
|
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
6
|
-
import {
|
|
9
|
+
import { writeFile } from 'fs/promises';
|
|
10
|
+
import { basename, dirname, join } from 'path';
|
|
11
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
7
12
|
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
8
13
|
|
|
9
14
|
import {
|
|
@@ -15,12 +20,20 @@ import {
|
|
|
15
20
|
writeEthJsonV3ToFile,
|
|
16
21
|
writeKeystoreFile,
|
|
17
22
|
} from './shared.js';
|
|
23
|
+
import { processAttesterAccounts } from './staker.js';
|
|
24
|
+
import {
|
|
25
|
+
validateBlsPathOptions,
|
|
26
|
+
validatePublisherOptions,
|
|
27
|
+
validateRemoteSignerOptions,
|
|
28
|
+
validateStakerOutputOptions,
|
|
29
|
+
} from './utils.js';
|
|
18
30
|
|
|
19
31
|
export type NewValidatorKeystoreOptions = {
|
|
20
32
|
dataDir?: string;
|
|
21
33
|
file?: string;
|
|
22
34
|
count?: number;
|
|
23
35
|
publisherCount?: number;
|
|
36
|
+
publishers?: string[];
|
|
24
37
|
mnemonic?: string;
|
|
25
38
|
passphrase?: string;
|
|
26
39
|
accountIndex?: number;
|
|
@@ -28,68 +41,85 @@ export type NewValidatorKeystoreOptions = {
|
|
|
28
41
|
separatePublisher?: boolean;
|
|
29
42
|
ikm?: string;
|
|
30
43
|
blsPath?: string;
|
|
31
|
-
blsOnly?: boolean;
|
|
32
44
|
password?: string;
|
|
33
|
-
|
|
45
|
+
encryptedKeystoreDir?: string;
|
|
34
46
|
json?: boolean;
|
|
35
47
|
feeRecipient: AztecAddress;
|
|
36
48
|
coinbase?: EthAddress;
|
|
37
49
|
remoteSigner?: string;
|
|
38
|
-
|
|
50
|
+
stakerOutput?: boolean;
|
|
51
|
+
gseAddress?: EthAddress;
|
|
52
|
+
l1RpcUrls?: string[];
|
|
53
|
+
l1ChainId?: number;
|
|
39
54
|
};
|
|
40
55
|
|
|
41
56
|
export async function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn) {
|
|
57
|
+
// validate bls-path inputs before proceeding with key generation
|
|
58
|
+
validateBlsPathOptions(options);
|
|
59
|
+
// validate staker output options before proceeding with key generation
|
|
60
|
+
validateStakerOutputOptions(options);
|
|
61
|
+
// validate publisher options
|
|
62
|
+
validatePublisherOptions(options);
|
|
63
|
+
// validate remote signer options
|
|
64
|
+
validateRemoteSignerOptions(options);
|
|
65
|
+
|
|
42
66
|
const {
|
|
43
67
|
dataDir,
|
|
44
68
|
file,
|
|
45
69
|
count,
|
|
46
70
|
publisherCount = 0,
|
|
71
|
+
publishers,
|
|
47
72
|
json,
|
|
48
73
|
coinbase,
|
|
49
74
|
accountIndex = 0,
|
|
50
75
|
addressIndex = 0,
|
|
51
76
|
feeRecipient,
|
|
52
77
|
remoteSigner,
|
|
53
|
-
fundingAccount,
|
|
54
|
-
blsOnly,
|
|
55
78
|
blsPath,
|
|
56
79
|
ikm,
|
|
57
80
|
mnemonic: _mnemonic,
|
|
58
81
|
password,
|
|
59
|
-
|
|
82
|
+
encryptedKeystoreDir,
|
|
83
|
+
stakerOutput,
|
|
84
|
+
gseAddress,
|
|
85
|
+
l1RpcUrls,
|
|
86
|
+
l1ChainId,
|
|
60
87
|
} = options;
|
|
61
88
|
|
|
62
|
-
if (remoteSigner && !_mnemonic) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
'Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.',
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
89
|
const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
|
|
69
90
|
|
|
91
|
+
if (!_mnemonic && !json) {
|
|
92
|
+
log('No mnemonic provided, generating new one...');
|
|
93
|
+
log(`Using new mnemonic:`);
|
|
94
|
+
log('');
|
|
95
|
+
log(mnemonic);
|
|
96
|
+
log('');
|
|
97
|
+
}
|
|
98
|
+
|
|
70
99
|
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
71
100
|
const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
|
|
101
|
+
const keystoreOutDir = dirname(outputPath);
|
|
72
102
|
|
|
73
103
|
const { validators, summaries } = await buildValidatorEntries({
|
|
74
104
|
validatorCount,
|
|
75
105
|
publisherCount,
|
|
106
|
+
publishers,
|
|
76
107
|
accountIndex,
|
|
77
108
|
baseAddressIndex: addressIndex,
|
|
78
109
|
mnemonic,
|
|
79
110
|
ikm,
|
|
80
111
|
blsPath,
|
|
81
|
-
blsOnly,
|
|
82
112
|
feeRecipient,
|
|
83
113
|
coinbase,
|
|
84
114
|
remoteSigner,
|
|
85
|
-
fundingAccount,
|
|
86
115
|
});
|
|
87
116
|
|
|
88
117
|
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
89
118
|
if (password !== undefined) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
await
|
|
119
|
+
const encryptedKeystoreOutDir =
|
|
120
|
+
encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : keystoreOutDir;
|
|
121
|
+
await writeEthJsonV3ToFile(validators, { outDir: encryptedKeystoreOutDir, password });
|
|
122
|
+
await writeBlsBn254ToFile(validators, { outDir: encryptedKeystoreOutDir, password });
|
|
93
123
|
}
|
|
94
124
|
|
|
95
125
|
const keystore = {
|
|
@@ -99,15 +129,66 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
|
|
|
99
129
|
|
|
100
130
|
await writeKeystoreFile(outputPath, keystore);
|
|
101
131
|
|
|
102
|
-
|
|
103
|
-
|
|
132
|
+
// Generate staker outputs if requested
|
|
133
|
+
const allStakerOutputs: any[] = [];
|
|
134
|
+
if (stakerOutput && gseAddress && l1RpcUrls && l1ChainId !== undefined) {
|
|
135
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
136
|
+
const publicClient = createPublicClient({
|
|
137
|
+
chain: chain.chainInfo,
|
|
138
|
+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
139
|
+
});
|
|
140
|
+
const gse = new GSEContract(publicClient, gseAddress);
|
|
141
|
+
|
|
142
|
+
// Extract keystore base name without extension for unique staker output filenames
|
|
143
|
+
const keystoreBaseName = basename(outputPath, '.json');
|
|
144
|
+
|
|
145
|
+
// Process each validator
|
|
146
|
+
for (let i = 0; i < validators.length; i++) {
|
|
147
|
+
const validator = validators[i];
|
|
148
|
+
const outputs = await processAttesterAccounts(validator.attester, gse, password);
|
|
149
|
+
|
|
150
|
+
// Collect all staker outputs
|
|
151
|
+
for (let j = 0; j < outputs.length; j++) {
|
|
152
|
+
allStakerOutputs.push(outputs[j]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Write a single JSON file with all staker outputs
|
|
157
|
+
if (allStakerOutputs.length > 0) {
|
|
158
|
+
const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_staker_output.json`);
|
|
159
|
+
await writeFile(stakerOutputPath, prettyPrintJSON(allStakerOutputs), 'utf-8');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const outputData = !_mnemonic ? { ...keystore, generatedMnemonic: mnemonic } : keystore;
|
|
164
|
+
|
|
165
|
+
// Handle JSON output
|
|
166
|
+
if (json) {
|
|
167
|
+
if (stakerOutput && allStakerOutputs.length > 0) {
|
|
168
|
+
const combinedOutput = {
|
|
169
|
+
keystore: outputData,
|
|
170
|
+
staker: allStakerOutputs,
|
|
171
|
+
};
|
|
172
|
+
maybePrintJson(log, json, combinedOutput as unknown as Record<string, any>);
|
|
173
|
+
} else {
|
|
174
|
+
maybePrintJson(log, json, outputData as unknown as Record<string, any>);
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
104
177
|
log(`Wrote validator keystore to ${outputPath}`);
|
|
178
|
+
if (stakerOutput && allStakerOutputs.length > 0) {
|
|
179
|
+
const keystoreBaseName = basename(outputPath, '.json');
|
|
180
|
+
const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_staker_output.json`);
|
|
181
|
+
log(`Wrote staker output for ${allStakerOutputs.length} validator(s) to ${stakerOutputPath}`);
|
|
182
|
+
log('');
|
|
183
|
+
}
|
|
105
184
|
}
|
|
106
185
|
|
|
107
|
-
//
|
|
108
|
-
|
|
186
|
+
// print a concise summary of public keys (addresses and BLS pubkeys) if no --json options was selected
|
|
187
|
+
if (!json) {
|
|
188
|
+
logValidatorSummaries(log, summaries);
|
|
189
|
+
}
|
|
109
190
|
|
|
110
|
-
if (
|
|
191
|
+
if (mnemonic && remoteSigner && !json) {
|
|
111
192
|
for (let i = 0; i < validatorCount; i++) {
|
|
112
193
|
const addrIdx = addressIndex + i;
|
|
113
194
|
const acct = mnemonicToAccount(mnemonic, {
|
|
@@ -117,4 +198,10 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
|
|
|
117
198
|
log(`attester address: ${acct.address} remoteSignerUrl: ${remoteSigner}`);
|
|
118
199
|
}
|
|
119
200
|
}
|
|
201
|
+
|
|
202
|
+
// Log staker outputs if not in JSON mode
|
|
203
|
+
if (!json && stakerOutput && allStakerOutputs.length > 0) {
|
|
204
|
+
log('\nStaker outputs:');
|
|
205
|
+
log(prettyPrintJSON(allStakerOutputs));
|
|
206
|
+
}
|
|
120
207
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
|
|
3
3
|
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
4
|
+
import { computeBn254G1PublicKeyCompressed } from '@aztec/foundation/crypto/bn254';
|
|
4
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
6
7
|
import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
|
|
@@ -13,27 +14,42 @@ import { homedir } from 'os';
|
|
|
13
14
|
import { dirname, isAbsolute, join } from 'path';
|
|
14
15
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
15
16
|
|
|
17
|
+
import { defaultBlsPath } from './utils.js';
|
|
18
|
+
|
|
16
19
|
export type ValidatorSummary = { attesterEth?: string; attesterBls?: string; publisherEth?: string[] };
|
|
17
20
|
|
|
18
21
|
export type BuildValidatorsInput = {
|
|
19
22
|
validatorCount: number;
|
|
20
23
|
publisherCount?: number;
|
|
24
|
+
publishers?: string[];
|
|
21
25
|
accountIndex: number;
|
|
22
26
|
baseAddressIndex: number;
|
|
23
27
|
mnemonic: string;
|
|
24
28
|
ikm?: string;
|
|
25
29
|
blsPath?: string;
|
|
26
|
-
blsOnly?: boolean;
|
|
27
30
|
feeRecipient: AztecAddress;
|
|
28
31
|
coinbase?: EthAddress;
|
|
29
32
|
remoteSigner?: string;
|
|
30
|
-
fundingAccount?: EthAddress;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
export function withValidatorIndex(path: string,
|
|
35
|
+
export function withValidatorIndex(path: string, accountIndex: number = 0, addressIndex: number = 0) {
|
|
36
|
+
// NOTE: The legacy BLS CLI is to allow users who generated keys in 2.1.4 to be able to use the same command
|
|
37
|
+
// to re-generate their keys. In 2.1.5 we switched how we append addresses to the path so this is to maintain backwards compatibility.
|
|
38
|
+
const useLegacyBlsCli = ['true', '1', 'yes', 'y'].includes(process.env.LEGACY_BLS_CLI ?? '');
|
|
39
|
+
|
|
40
|
+
const defaultBlsPathParts = defaultBlsPath.split('/');
|
|
41
|
+
|
|
34
42
|
const parts = path.split('/');
|
|
35
|
-
if (parts.length
|
|
36
|
-
|
|
43
|
+
if (parts.length == defaultBlsPathParts.length && parts.every((part, index) => part === defaultBlsPathParts[index])) {
|
|
44
|
+
if (useLegacyBlsCli) {
|
|
45
|
+
// In 2.1.4, we were using address-index in parts[3] and did NOT use account-index, check lines 32 & 84
|
|
46
|
+
// https://github.com/AztecProtocol/aztec-packages/blob/v2.1.4/yarn-project/cli/src/cmds/validator_keys/shared.ts
|
|
47
|
+
|
|
48
|
+
parts[3] = String(addressIndex);
|
|
49
|
+
} else {
|
|
50
|
+
parts[3] = String(accountIndex);
|
|
51
|
+
parts[5] = String(addressIndex);
|
|
52
|
+
}
|
|
37
53
|
return parts.join('/');
|
|
38
54
|
}
|
|
39
55
|
return path;
|
|
@@ -64,42 +80,37 @@ export async function buildValidatorEntries(input: BuildValidatorsInput) {
|
|
|
64
80
|
const {
|
|
65
81
|
validatorCount,
|
|
66
82
|
publisherCount = 0,
|
|
83
|
+
publishers,
|
|
67
84
|
accountIndex,
|
|
68
85
|
baseAddressIndex,
|
|
69
86
|
mnemonic,
|
|
70
87
|
ikm,
|
|
71
88
|
blsPath,
|
|
72
|
-
blsOnly,
|
|
73
89
|
feeRecipient,
|
|
74
90
|
coinbase,
|
|
75
91
|
remoteSigner,
|
|
76
|
-
fundingAccount,
|
|
77
92
|
} = input;
|
|
78
93
|
|
|
79
|
-
const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
80
94
|
const summaries: ValidatorSummary[] = [];
|
|
81
95
|
|
|
82
96
|
const validators = await Promise.all(
|
|
83
97
|
Array.from({ length: validatorCount }, async (_unused, i) => {
|
|
84
98
|
const addressIndex = baseAddressIndex + i;
|
|
85
99
|
const basePath = blsPath ?? defaultBlsPath;
|
|
86
|
-
const perValidatorPath = withValidatorIndex(basePath, addressIndex);
|
|
100
|
+
const perValidatorPath = withValidatorIndex(basePath, accountIndex, addressIndex);
|
|
87
101
|
|
|
88
|
-
const blsPrivKey =
|
|
102
|
+
const blsPrivKey = ikm || mnemonic ? deriveBlsPrivateKey(mnemonic, ikm, perValidatorPath) : undefined;
|
|
89
103
|
const blsPubCompressed = blsPrivKey ? await computeBlsPublicKeyCompressed(blsPrivKey) : undefined;
|
|
90
104
|
|
|
91
|
-
if (blsOnly) {
|
|
92
|
-
const attester = { bls: blsPrivKey! };
|
|
93
|
-
summaries.push({ attesterBls: blsPubCompressed });
|
|
94
|
-
return { attester, feeRecipient } as ValidatorKeyStore;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
105
|
const ethAttester = deriveEthAttester(mnemonic, accountIndex, addressIndex, remoteSigner);
|
|
98
106
|
const attester = blsPrivKey ? { eth: ethAttester, bls: blsPrivKey } : ethAttester;
|
|
99
107
|
|
|
100
108
|
let publisherField: EthAccount | EthPrivateKey | (EthAccount | EthPrivateKey)[] | undefined;
|
|
101
109
|
const publisherAddresses: string[] = [];
|
|
102
|
-
if (
|
|
110
|
+
if (publishers && publishers.length > 0) {
|
|
111
|
+
publisherAddresses.push(...publishers);
|
|
112
|
+
publisherField = publishers.length === 1 ? (publishers[0] as EthPrivateKey) : (publishers as EthPrivateKey[]);
|
|
113
|
+
} else if (publisherCount > 0) {
|
|
103
114
|
const publishersBaseIndex = baseAddressIndex + validatorCount + i * publisherCount;
|
|
104
115
|
const publisherAccounts = Array.from({ length: publisherCount }, (_unused2, j) => {
|
|
105
116
|
const publisherAddressIndex = publishersBaseIndex + j;
|
|
@@ -130,8 +141,7 @@ export async function buildValidatorEntries(input: BuildValidatorsInput) {
|
|
|
130
141
|
attester,
|
|
131
142
|
...(publisherField !== undefined ? { publisher: publisherField } : {}),
|
|
132
143
|
feeRecipient,
|
|
133
|
-
coinbase,
|
|
134
|
-
fundingAccount,
|
|
144
|
+
coinbase: coinbase ?? attesterEthAddress,
|
|
135
145
|
} as ValidatorKeyStore;
|
|
136
146
|
}),
|
|
137
147
|
);
|
|
@@ -229,7 +239,7 @@ export async function writeBn254BlsKeystore(
|
|
|
229
239
|
/** Replace plaintext BLS keys in validators with { path, password } pointing to BN254 keystore files. */
|
|
230
240
|
export async function writeBlsBn254ToFile(
|
|
231
241
|
validators: ValidatorKeyStore[],
|
|
232
|
-
options: { outDir: string; password: string },
|
|
242
|
+
options: { outDir: string; password: string; blsPath?: string },
|
|
233
243
|
): Promise<void> {
|
|
234
244
|
for (let i = 0; i < validators.length; i++) {
|
|
235
245
|
const v = validators[i];
|
|
@@ -245,7 +255,7 @@ export async function writeBlsBn254ToFile(
|
|
|
245
255
|
}
|
|
246
256
|
|
|
247
257
|
const pub = await computeBlsPublicKeyCompressed(blsKey);
|
|
248
|
-
const path =
|
|
258
|
+
const path = options.blsPath ?? defaultBlsPath;
|
|
249
259
|
const fileBase = `${String(i + 1)}_${pub.slice(2, 18)}`;
|
|
250
260
|
const keystorePath = await writeBn254BlsKeystore(options.outDir, fileBase, options.password, blsKey, pub, path);
|
|
251
261
|
|
|
@@ -312,10 +322,5 @@ export async function writeEthJsonV3ToFile(
|
|
|
312
322
|
(v as any).publisher = await maybeEncryptEth(pub, `publisher_${i + 1}`);
|
|
313
323
|
}
|
|
314
324
|
}
|
|
315
|
-
|
|
316
|
-
// Optional fundingAccount within validator
|
|
317
|
-
if ('fundingAccount' in v) {
|
|
318
|
-
(v as any).fundingAccount = await maybeEncryptEth((v as any).fundingAccount, `funding_${i + 1}`);
|
|
319
|
-
}
|
|
320
325
|
}
|
|
321
326
|
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { GSEContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import { decryptBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
5
|
+
import { computeBn254G1PublicKey, computeBn254G2PublicKey } from '@aztec/foundation/crypto/bn254';
|
|
6
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
9
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
10
|
+
import type {
|
|
11
|
+
AttesterAccount,
|
|
12
|
+
AttesterAccounts,
|
|
13
|
+
BLSAccount,
|
|
14
|
+
EncryptedKeyFileConfig,
|
|
15
|
+
EthAccount,
|
|
16
|
+
MnemonicConfig,
|
|
17
|
+
} from '@aztec/node-keystore/types';
|
|
18
|
+
|
|
19
|
+
import { Wallet } from '@ethersproject/wallet';
|
|
20
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
21
|
+
import { basename, dirname, join } from 'path';
|
|
22
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
23
|
+
import { privateKeyToAddress } from 'viem/accounts';
|
|
24
|
+
|
|
25
|
+
export type StakerOptions = {
|
|
26
|
+
from: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
output?: string;
|
|
29
|
+
gseAddress: EthAddress;
|
|
30
|
+
l1RpcUrls: string[];
|
|
31
|
+
l1ChainId: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type StakerOutput = {
|
|
35
|
+
attester: string;
|
|
36
|
+
publicKeyG1: {
|
|
37
|
+
x: string;
|
|
38
|
+
y: string;
|
|
39
|
+
};
|
|
40
|
+
publicKeyG2: {
|
|
41
|
+
x0: string;
|
|
42
|
+
x1: string;
|
|
43
|
+
y0: string;
|
|
44
|
+
y1: string;
|
|
45
|
+
};
|
|
46
|
+
proofOfPossession: {
|
|
47
|
+
x: string;
|
|
48
|
+
y: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Check if an object is a MnemonicConfig
|
|
54
|
+
*/
|
|
55
|
+
function isMnemonicConfig(obj: unknown): obj is MnemonicConfig {
|
|
56
|
+
return typeof obj === 'object' && obj !== null && 'mnemonic' in obj;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Check if a value is an encrypted keystore file config
|
|
61
|
+
*/
|
|
62
|
+
function isEncryptedKeyFileConfig(value: unknown): value is EncryptedKeyFileConfig {
|
|
63
|
+
return typeof value === 'object' && value !== null && 'path' in value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if a BLSAccount is a private key string (not an encrypted keystore file)
|
|
68
|
+
*/
|
|
69
|
+
function isBlsPrivateKey(bls: unknown): bls is string {
|
|
70
|
+
return typeof bls === 'string' && bls.startsWith('0x');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Check if an EthAccount is a private key string (66 chars: 0x + 64 hex)
|
|
75
|
+
*/
|
|
76
|
+
function isEthPrivateKey(eth: unknown): eth is string {
|
|
77
|
+
return typeof eth === 'string' && eth.startsWith('0x') && eth.length === 66;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check if a string is an Ethereum address (42 chars: 0x + 40 hex)
|
|
82
|
+
*/
|
|
83
|
+
function isEthAddress(value: unknown): value is string {
|
|
84
|
+
return typeof value === 'string' && /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Decrypt a BLS private key from an encrypted keystore file
|
|
89
|
+
*/
|
|
90
|
+
function decryptBlsKey(bls: BLSAccount, password?: string): string | undefined {
|
|
91
|
+
if (isBlsPrivateKey(bls)) {
|
|
92
|
+
return bls;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (isEncryptedKeyFileConfig(bls)) {
|
|
96
|
+
if (!password && !bls.password) {
|
|
97
|
+
return undefined; // Can't decrypt without password
|
|
98
|
+
}
|
|
99
|
+
const pwd = password ?? bls.password!;
|
|
100
|
+
return decryptBn254Keystore(bls.path, pwd);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Decrypt an Ethereum private key from an encrypted keystore file
|
|
108
|
+
*/
|
|
109
|
+
async function decryptEthKey(eth: EthAccount, password?: string): Promise<string | undefined> {
|
|
110
|
+
if (isEthPrivateKey(eth)) {
|
|
111
|
+
return eth;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (isEncryptedKeyFileConfig(eth)) {
|
|
115
|
+
if (!password && !eth.password) {
|
|
116
|
+
return undefined; // Can't decrypt without password
|
|
117
|
+
}
|
|
118
|
+
const pwd = password ?? eth.password!;
|
|
119
|
+
const json = readFileSync(eth.path, 'utf-8');
|
|
120
|
+
const wallet = await Wallet.fromEncryptedJson(json, pwd);
|
|
121
|
+
return wallet.privateKey as string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Extract Ethereum address from an EthAccount (or private key)
|
|
129
|
+
*/
|
|
130
|
+
async function getEthAddress(eth: EthAccount | string, password?: string): Promise<EthAddress | undefined> {
|
|
131
|
+
// Case 1: It's a private key string - derive the address
|
|
132
|
+
if (isEthPrivateKey(eth)) {
|
|
133
|
+
return privateKeyToAddress(eth as `0x${string}`) as unknown as EthAddress;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Case 2: It's just an address string directly (EthRemoteSignerAccount can be just EthAddress)
|
|
137
|
+
if (isEthAddress(eth)) {
|
|
138
|
+
return eth as unknown as EthAddress;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Case 3: It's an object with an address property (remote signer config)
|
|
142
|
+
if (typeof eth === 'object' && eth !== null && 'address' in eth) {
|
|
143
|
+
return (eth as any).address as EthAddress;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Case 4: It's an encrypted keystore file - decrypt and derive address
|
|
147
|
+
if (isEncryptedKeyFileConfig(eth)) {
|
|
148
|
+
const privateKey = await decryptEthKey(eth, password);
|
|
149
|
+
if (privateKey) {
|
|
150
|
+
return privateKeyToAddress(privateKey as `0x${string}`) as unknown as EthAddress;
|
|
151
|
+
}
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Extract BLS private key and Ethereum address from an AttesterAccount
|
|
160
|
+
*/
|
|
161
|
+
async function extractAttesterInfo(
|
|
162
|
+
attester: AttesterAccount,
|
|
163
|
+
password?: string,
|
|
164
|
+
): Promise<{ blsPrivateKey?: string; ethAddress?: EthAddress }> {
|
|
165
|
+
// Case 1: attester is { eth: EthAccount, bls?: BLSAccount }
|
|
166
|
+
if (typeof attester === 'object' && attester !== null && 'eth' in attester) {
|
|
167
|
+
const ethAddress = await getEthAddress(attester.eth, password);
|
|
168
|
+
const blsPrivateKey = attester.bls ? decryptBlsKey(attester.bls, password) : undefined;
|
|
169
|
+
return { blsPrivateKey, ethAddress };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Case 2: attester is just an EthAccount directly (no BLS key)
|
|
173
|
+
return {
|
|
174
|
+
blsPrivateKey: undefined,
|
|
175
|
+
ethAddress: await getEthAddress(attester as EthAccount, password),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Process a single attester entry and output staking JSON
|
|
181
|
+
*/
|
|
182
|
+
async function processAttester(
|
|
183
|
+
attester: AttesterAccount,
|
|
184
|
+
gse: GSEContract,
|
|
185
|
+
password?: string,
|
|
186
|
+
): Promise<StakerOutput | undefined> {
|
|
187
|
+
const { blsPrivateKey, ethAddress } = await extractAttesterInfo(attester, password);
|
|
188
|
+
|
|
189
|
+
// Skip if no BLS private key or no Ethereum address
|
|
190
|
+
if (!blsPrivateKey || !ethAddress) {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Derive G1 and G2 public keys
|
|
195
|
+
const g1PublicKey = await computeBn254G1PublicKey(blsPrivateKey);
|
|
196
|
+
const g2PublicKey = await computeBn254G2PublicKey(blsPrivateKey);
|
|
197
|
+
|
|
198
|
+
// Generate proof of possession
|
|
199
|
+
const bn254SecretKeyFieldElement = Fr.fromString(blsPrivateKey);
|
|
200
|
+
const registrationTuple = await gse.makeRegistrationTuple(bn254SecretKeyFieldElement.toBigInt());
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
attester: String(ethAddress),
|
|
204
|
+
publicKeyG1: {
|
|
205
|
+
x: '0x' + g1PublicKey.x.toString(16).padStart(64, '0'),
|
|
206
|
+
y: '0x' + g1PublicKey.y.toString(16).padStart(64, '0'),
|
|
207
|
+
},
|
|
208
|
+
publicKeyG2: {
|
|
209
|
+
x0: '0x' + g2PublicKey.x.c0.toString(16).padStart(64, '0'),
|
|
210
|
+
x1: '0x' + g2PublicKey.x.c1.toString(16).padStart(64, '0'),
|
|
211
|
+
y0: '0x' + g2PublicKey.y.c0.toString(16).padStart(64, '0'),
|
|
212
|
+
y1: '0x' + g2PublicKey.y.c1.toString(16).padStart(64, '0'),
|
|
213
|
+
},
|
|
214
|
+
proofOfPossession: {
|
|
215
|
+
x: '0x' + registrationTuple.proofOfPossession.x.toString(16),
|
|
216
|
+
y: '0x' + registrationTuple.proofOfPossession.y.toString(16),
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Process AttesterAccounts (which can be a single attester, array, or mnemonic)
|
|
223
|
+
*/
|
|
224
|
+
export async function processAttesterAccounts(
|
|
225
|
+
attesterAccounts: AttesterAccounts,
|
|
226
|
+
gse: GSEContract,
|
|
227
|
+
password?: string,
|
|
228
|
+
): Promise<StakerOutput[]> {
|
|
229
|
+
// Skip mnemonic configs
|
|
230
|
+
if (isMnemonicConfig(attesterAccounts)) {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Handle array of attesters
|
|
235
|
+
if (Array.isArray(attesterAccounts)) {
|
|
236
|
+
const results: StakerOutput[] = [];
|
|
237
|
+
for (const attester of attesterAccounts) {
|
|
238
|
+
const result = await processAttester(attester, gse, password);
|
|
239
|
+
if (result) {
|
|
240
|
+
results.push(result);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return results;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Handle single attester
|
|
247
|
+
const result = await processAttester(attesterAccounts, gse, password);
|
|
248
|
+
return result ? [result] : [];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Main staker command function
|
|
253
|
+
*/
|
|
254
|
+
export async function generateStakerJson(options: StakerOptions, log: LogFn): Promise<void> {
|
|
255
|
+
const { from, password, gseAddress, l1RpcUrls, l1ChainId, output } = options;
|
|
256
|
+
|
|
257
|
+
// Load the keystore file
|
|
258
|
+
const keystore = loadKeystoreFile(from);
|
|
259
|
+
|
|
260
|
+
if (!gseAddress) {
|
|
261
|
+
throw new Error('GSE contract address is required');
|
|
262
|
+
}
|
|
263
|
+
log(`Calling GSE contract ${gseAddress} on chain ${l1ChainId}, using ${l1RpcUrls.join(', ')} to get staker outputs`);
|
|
264
|
+
|
|
265
|
+
if (!keystore.validators || keystore.validators.length === 0) {
|
|
266
|
+
log('No validators found in keystore');
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const allOutputs: StakerOutput[] = [];
|
|
271
|
+
|
|
272
|
+
// L1 client for proof of possession
|
|
273
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
274
|
+
const publicClient = createPublicClient({
|
|
275
|
+
chain: chain.chainInfo,
|
|
276
|
+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
277
|
+
});
|
|
278
|
+
const gse = new GSEContract(publicClient, gseAddress);
|
|
279
|
+
|
|
280
|
+
const keystoreBaseName = basename(from, '.json');
|
|
281
|
+
const outputDir = output ? output : dirname(from);
|
|
282
|
+
|
|
283
|
+
for (let i = 0; i < keystore.validators.length; i++) {
|
|
284
|
+
const validator = keystore.validators[i];
|
|
285
|
+
const outputs = await processAttesterAccounts(validator.attester, gse, password);
|
|
286
|
+
|
|
287
|
+
for (let j = 0; j < outputs.length; j++) {
|
|
288
|
+
allOutputs.push(outputs[j]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (allOutputs.length === 0) {
|
|
293
|
+
log('No attesters with BLS keys found (skipping mnemonics and encrypted keystores without password)');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Write a single JSON file with all staker outputs
|
|
298
|
+
const stakerOutputPath = join(outputDir, `${keystoreBaseName}_staker_output.json`);
|
|
299
|
+
writeFileSync(stakerOutputPath, prettyPrintJSON(allOutputs), 'utf-8');
|
|
300
|
+
log(`Wrote staker output for ${allOutputs.length} validator(s) to ${stakerOutputPath}`);
|
|
301
|
+
}
|