@aztec/cli 0.0.1-commit.24de95ac → 0.0.1-commit.2e2504e2
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.js +1 -1
- 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 +54 -15
- 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 +33 -463
- package/dest/config/enrich_env.d.ts +1 -1
- package/dest/config/generated/networks.d.ts +205 -0
- package/dest/config/generated/networks.d.ts.map +1 -0
- package/dest/config/generated/networks.js +206 -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 +1 -1
- 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 +22 -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 +48 -27
- 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 +34 -604
- package/src/config/generated/networks.ts +210 -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,25 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createL1TxUtilsFromViemWallet,
|
|
7
|
-
getL1ContractsConfigEnvVars,
|
|
8
|
-
getPublicClient,
|
|
9
|
-
isAnvilTestChain,
|
|
10
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { createEthereumChain, isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { createExtendedL1Client, getPublicClient } from '@aztec/ethereum/client';
|
|
3
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
4
|
+
import { GSEContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { createL1TxUtilsFromViemWallet } from '@aztec/ethereum/l1-tx-utils';
|
|
11
6
|
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
12
7
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
13
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
14
9
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
15
|
-
import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
10
|
+
import { RollupAbi, StakingAssetHandlerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
16
11
|
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
17
12
|
|
|
18
|
-
import { encodeFunctionData, formatEther, getContract } from 'viem';
|
|
13
|
+
import { encodeFunctionData, formatEther, getContract, maxUint256 } from 'viem';
|
|
19
14
|
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
20
15
|
|
|
21
|
-
import { addLeadingHex } from '../../utils/aztec.js';
|
|
22
|
-
|
|
23
16
|
export interface RollupCommandArgs {
|
|
24
17
|
rpcUrls: string[];
|
|
25
18
|
chainId: number;
|
|
@@ -58,8 +51,8 @@ export async function addL1Validator({
|
|
|
58
51
|
privateKey,
|
|
59
52
|
mnemonic,
|
|
60
53
|
attesterAddress,
|
|
54
|
+
withdrawerAddress,
|
|
61
55
|
stakingAssetHandlerAddress,
|
|
62
|
-
merkleProof,
|
|
63
56
|
proofParams,
|
|
64
57
|
blsSecretKey,
|
|
65
58
|
log,
|
|
@@ -68,8 +61,8 @@ export async function addL1Validator({
|
|
|
68
61
|
LoggerArgs & {
|
|
69
62
|
blsSecretKey: bigint; // scalar field element of BN254
|
|
70
63
|
attesterAddress: EthAddress;
|
|
64
|
+
withdrawerAddress: EthAddress;
|
|
71
65
|
proofParams: Buffer;
|
|
72
|
-
merkleProof: string[];
|
|
73
66
|
}) {
|
|
74
67
|
const dualLog = makeDualLog(log, debugLogger);
|
|
75
68
|
const account = getAccount(privateKey, mnemonic);
|
|
@@ -92,33 +85,61 @@ export async function addL1Validator({
|
|
|
92
85
|
});
|
|
93
86
|
|
|
94
87
|
const gseAddress = await rollup.read.getGSE();
|
|
95
|
-
|
|
96
88
|
const gse = new GSEContract(l1Client, gseAddress);
|
|
97
|
-
|
|
98
89
|
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
99
90
|
|
|
100
91
|
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
101
92
|
const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
|
|
102
|
-
const merkleProofArray = merkleProof.map(proof => addLeadingHex(proof));
|
|
103
93
|
|
|
104
|
-
|
|
94
|
+
// Step 1: Claim STK tokens from the faucet
|
|
95
|
+
dualLog(`Claiming STK tokens from faucet`);
|
|
96
|
+
const { receipt: claimReceipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
105
97
|
to: stakingAssetHandlerAddress.toString(),
|
|
106
98
|
data: encodeFunctionData({
|
|
107
99
|
abi: StakingAssetHandlerAbi,
|
|
108
|
-
functionName: '
|
|
100
|
+
functionName: 'claim',
|
|
101
|
+
args: [proofParamsObj.toViem()],
|
|
102
|
+
}),
|
|
103
|
+
abi: StakingAssetHandlerAbi,
|
|
104
|
+
});
|
|
105
|
+
dualLog(`Claim transaction hash: ${claimReceipt.transactionHash}`);
|
|
106
|
+
await l1Client.waitForTransactionReceipt({ hash: claimReceipt.transactionHash });
|
|
107
|
+
|
|
108
|
+
// Step 2: Approve the rollup to spend STK tokens
|
|
109
|
+
const stakingAssetAddress = await stakingAssetHandler.read.STAKING_ASSET();
|
|
110
|
+
dualLog(`Approving rollup to spend STK tokens`);
|
|
111
|
+
const { receipt: approveReceipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
112
|
+
to: stakingAssetAddress,
|
|
113
|
+
data: encodeFunctionData({
|
|
114
|
+
abi: TestERC20Abi,
|
|
115
|
+
functionName: 'approve',
|
|
116
|
+
args: [rollupAddress, maxUint256],
|
|
117
|
+
}),
|
|
118
|
+
abi: TestERC20Abi,
|
|
119
|
+
});
|
|
120
|
+
await l1Client.waitForTransactionReceipt({ hash: approveReceipt.transactionHash });
|
|
121
|
+
|
|
122
|
+
// Step 3: Deposit into the rollup to register as a validator
|
|
123
|
+
dualLog(`Depositing into rollup to register validator`);
|
|
124
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
125
|
+
to: rollupAddress,
|
|
126
|
+
data: encodeFunctionData({
|
|
127
|
+
abi: RollupAbi,
|
|
128
|
+
functionName: 'deposit',
|
|
109
129
|
args: [
|
|
110
130
|
attesterAddress.toString(),
|
|
111
|
-
|
|
112
|
-
proofParamsObj.toViem(),
|
|
131
|
+
withdrawerAddress.toString(),
|
|
113
132
|
registrationTuple.publicKeyInG1,
|
|
114
133
|
registrationTuple.publicKeyInG2,
|
|
115
134
|
registrationTuple.proofOfPossession,
|
|
135
|
+
false, // moveWithLatestRollup
|
|
116
136
|
],
|
|
117
137
|
}),
|
|
118
|
-
abi:
|
|
138
|
+
abi: RollupAbi,
|
|
119
139
|
});
|
|
120
|
-
dualLog(`
|
|
140
|
+
dualLog(`Deposit transaction hash: ${receipt.transactionHash}`);
|
|
121
141
|
await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
|
|
142
|
+
|
|
122
143
|
if (isAnvilTestChain(chainId)) {
|
|
123
144
|
dualLog(`Funding validator on L1`);
|
|
124
145
|
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
|
|
@@ -299,9 +320,9 @@ export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: Roll
|
|
|
299
320
|
const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
|
|
300
321
|
const rollup = new RollupContract(publicClient, rollupAddress);
|
|
301
322
|
|
|
302
|
-
const pendingNum = await rollup.
|
|
323
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
303
324
|
log(`Pending block num: ${pendingNum}`);
|
|
304
|
-
const provenNum = await rollup.
|
|
325
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
305
326
|
log(`Proven block num: ${provenNum}`);
|
|
306
327
|
const validators = await rollup.getAttesters();
|
|
307
328
|
log(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
5
|
export async function generateSecretAndHash(log: LogFn) {
|
package/src/cmds/misc/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
-
import { printENR } from '@aztec/p2p/enr';
|
|
3
2
|
|
|
4
3
|
import type { Command } from 'commander';
|
|
5
4
|
|
|
@@ -49,6 +48,7 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
49
48
|
.description('Decodes and ENR record')
|
|
50
49
|
.argument('<enr>', 'The encoded ENR string')
|
|
51
50
|
.action(async (enr: string) => {
|
|
51
|
+
const { printENR } = await import('@aztec/p2p/enr');
|
|
52
52
|
await printENR(enr, log);
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -9,7 +9,7 @@ import { type SemVer, parse } from 'semver';
|
|
|
9
9
|
import type { DependencyChanges } from './common.js';
|
|
10
10
|
import { atomicUpdateFile } from './utils.js';
|
|
11
11
|
|
|
12
|
-
const deprecatedNpmPackages = new Set<string>(['@aztec/cli', '@aztec/aztec-
|
|
12
|
+
const deprecatedNpmPackages = new Set<string>(['@aztec/cli', '@aztec/aztec-local-network']);
|
|
13
13
|
const npmDeprecationMessage = `
|
|
14
14
|
The following packages have been deprecated and will no longer be updated on the npm registry:
|
|
15
15
|
${Array.from(deprecatedNpmPackages)
|
|
@@ -16,28 +16,35 @@ import {
|
|
|
16
16
|
writeEthJsonV3ToFile,
|
|
17
17
|
writeKeystoreFile,
|
|
18
18
|
} from './shared.js';
|
|
19
|
+
import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
|
|
19
20
|
|
|
20
21
|
export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
|
|
21
22
|
|
|
22
23
|
export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
|
|
24
|
+
// validate bls-path inputs before proceeding with key generation
|
|
25
|
+
validateBlsPathOptions(options);
|
|
26
|
+
// validate publisher options
|
|
27
|
+
validatePublisherOptions(options);
|
|
28
|
+
// validate remote signer options
|
|
29
|
+
validateRemoteSignerOptions(options);
|
|
30
|
+
|
|
23
31
|
const {
|
|
24
32
|
dataDir,
|
|
25
33
|
file,
|
|
26
34
|
count,
|
|
27
35
|
publisherCount = 0,
|
|
36
|
+
publishers,
|
|
28
37
|
mnemonic,
|
|
29
38
|
accountIndex = 0,
|
|
30
39
|
addressIndex,
|
|
31
40
|
ikm,
|
|
32
41
|
blsPath,
|
|
33
|
-
blsOnly,
|
|
34
42
|
json,
|
|
35
43
|
feeRecipient: feeRecipientOpt,
|
|
36
44
|
coinbase: coinbaseOpt,
|
|
37
|
-
fundingAccount: fundingAccountOpt,
|
|
38
45
|
remoteSigner: remoteSignerOpt,
|
|
39
46
|
password,
|
|
40
|
-
|
|
47
|
+
encryptedKeystoreDir,
|
|
41
48
|
} = options;
|
|
42
49
|
|
|
43
50
|
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
@@ -55,8 +62,6 @@ export async function addValidatorKeys(existing: string, options: AddValidatorKe
|
|
|
55
62
|
throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
|
|
56
63
|
}
|
|
57
64
|
const coinbase = (coinbaseOpt as EthAddress | undefined) ?? (first.coinbase as EthAddress | undefined);
|
|
58
|
-
const fundingAccount =
|
|
59
|
-
(fundingAccountOpt as EthAddress | undefined) ?? (first.fundingAccount as EthAddress | undefined);
|
|
60
65
|
const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
|
|
61
66
|
const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
|
|
62
67
|
|
|
@@ -70,26 +75,31 @@ export async function addValidatorKeys(existing: string, options: AddValidatorKe
|
|
|
70
75
|
const { validators, summaries } = await buildValidatorEntries({
|
|
71
76
|
validatorCount,
|
|
72
77
|
publisherCount,
|
|
78
|
+
publishers,
|
|
73
79
|
accountIndex,
|
|
74
80
|
baseAddressIndex: effectiveBaseAddressIndex,
|
|
75
81
|
mnemonic: mnemonicToUse,
|
|
76
82
|
ikm,
|
|
77
83
|
blsPath,
|
|
78
|
-
blsOnly,
|
|
79
84
|
feeRecipient,
|
|
80
85
|
coinbase,
|
|
81
86
|
remoteSigner,
|
|
82
|
-
fundingAccount,
|
|
83
87
|
});
|
|
84
88
|
|
|
85
89
|
keystore.validators.push(...validators);
|
|
86
90
|
|
|
87
91
|
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
88
92
|
if (password !== undefined) {
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
let targetDir: string;
|
|
94
|
+
if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
|
|
95
|
+
targetDir = encryptedKeystoreDir;
|
|
96
|
+
} else if (dataDir && dataDir.length > 0) {
|
|
97
|
+
targetDir = dataDir;
|
|
98
|
+
} else {
|
|
99
|
+
targetDir = dirname(existing);
|
|
100
|
+
}
|
|
91
101
|
await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
|
|
92
|
-
await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password });
|
|
102
|
+
await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password, blsPath });
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
let outputPath = existing;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto';
|
|
1
|
+
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
3
|
|
|
4
4
|
import { writeFile } from 'fs/promises';
|
|
5
5
|
|
|
6
6
|
import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
|
|
7
|
+
import { defaultBlsPath } from './utils.js';
|
|
7
8
|
|
|
8
9
|
export type GenerateBlsKeypairOptions = {
|
|
9
10
|
mnemonic?: string;
|
|
@@ -17,7 +18,7 @@ export type GenerateBlsKeypairOptions = {
|
|
|
17
18
|
|
|
18
19
|
export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
|
|
19
20
|
const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
|
|
20
|
-
const path = withValidatorIndex(blsPath ??
|
|
21
|
+
const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
|
|
21
22
|
const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
|
|
22
23
|
const pub = await computeBlsPublicKeyCompressed(priv);
|
|
23
24
|
const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
|
|
@@ -3,11 +3,12 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
|
|
5
5
|
import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
|
|
6
|
+
import { defaultBlsPath } from './utils.js';
|
|
6
7
|
|
|
7
8
|
export function injectCommands(program: Command, log: LogFn) {
|
|
8
9
|
const group = program
|
|
9
10
|
.command('validator-keys')
|
|
10
|
-
.aliases(['valKeys'])
|
|
11
|
+
.aliases(['valKeys', 'valkeys'])
|
|
11
12
|
.description('Manage validator keystores for node operators');
|
|
12
13
|
|
|
13
14
|
group
|
|
@@ -17,28 +18,47 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
17
18
|
.option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore')
|
|
18
19
|
.option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)')
|
|
19
20
|
.option('--count <N>', 'Number of validators to generate', parseOptionalInteger)
|
|
20
|
-
.option('--publisher-count <N>', 'Number of publisher accounts per validator (default
|
|
21
|
+
.option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
|
|
21
22
|
parseOptionalInteger(value, 0),
|
|
22
23
|
)
|
|
24
|
+
.option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
|
|
25
|
+
value.split(',').map((key: string) => key.trim()),
|
|
26
|
+
)
|
|
23
27
|
.option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
|
|
24
28
|
.option('--passphrase <str>', 'Optional passphrase for mnemonic')
|
|
25
|
-
.option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger)
|
|
26
|
-
.option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger)
|
|
27
|
-
.option(
|
|
28
|
-
|
|
29
|
+
.option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
|
|
30
|
+
.option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
|
|
31
|
+
.option(
|
|
32
|
+
'--coinbase <address>',
|
|
33
|
+
'Coinbase ETH address to use when proposing. Defaults to attester address.',
|
|
34
|
+
parseEthereumAddress,
|
|
35
|
+
)
|
|
36
|
+
// TODO: add funding account back in when implemented
|
|
37
|
+
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
29
38
|
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
|
|
30
39
|
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
31
|
-
.option('--bls-path <path>',
|
|
32
|
-
.option('--bls-only', 'Generate only BLS keys')
|
|
40
|
+
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
33
41
|
.option(
|
|
34
42
|
'--password <str>',
|
|
35
43
|
'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
|
|
36
44
|
)
|
|
37
|
-
.option('--
|
|
45
|
+
.option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
|
|
38
46
|
.option('--json', 'Echo resulting JSON to stdout')
|
|
47
|
+
.option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries')
|
|
48
|
+
.option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress)
|
|
49
|
+
.option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', value =>
|
|
50
|
+
value.split(','),
|
|
51
|
+
)
|
|
52
|
+
.option(
|
|
53
|
+
'-c, --l1-chain-id <number>',
|
|
54
|
+
'L1 chain ID (required with --staker-output)',
|
|
55
|
+
value => parseInt(value),
|
|
56
|
+
31337,
|
|
57
|
+
)
|
|
39
58
|
.requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
|
|
40
59
|
.action(async options => {
|
|
41
60
|
const { newValidatorKeystore } = await import('./new.js');
|
|
61
|
+
|
|
42
62
|
await newValidatorKeystore(options, log);
|
|
43
63
|
});
|
|
44
64
|
|
|
@@ -47,28 +67,35 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
47
67
|
.summary('Augment an existing validator keystore JSON')
|
|
48
68
|
.description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new')
|
|
49
69
|
.argument('<existing>', 'Path to existing keystore JSON')
|
|
50
|
-
.option('--data-dir <path>', 'Directory where keystore(s) live')
|
|
51
|
-
.option('--file <name>', 'Override output file name')
|
|
52
|
-
.option('--count <N>', 'Number of validators to add', parseOptionalInteger)
|
|
53
|
-
.option('--publisher-count <N>', 'Number of publisher accounts per validator (default
|
|
70
|
+
.option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)')
|
|
71
|
+
.option('--file <name>', 'Override output file name. (default: key<N>.json)')
|
|
72
|
+
.option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger)
|
|
73
|
+
.option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
|
|
54
74
|
parseOptionalInteger(value, 0),
|
|
55
75
|
)
|
|
76
|
+
.option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
|
|
77
|
+
value.split(',').map((key: string) => key.trim()),
|
|
78
|
+
)
|
|
56
79
|
.option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
|
|
57
80
|
.option('--passphrase <str>', 'Optional passphrase for mnemonic')
|
|
58
|
-
.option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger)
|
|
59
|
-
.option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger)
|
|
60
|
-
.option(
|
|
61
|
-
|
|
81
|
+
.option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
|
|
82
|
+
.option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
|
|
83
|
+
.option(
|
|
84
|
+
'--coinbase <address>',
|
|
85
|
+
'Coinbase ETH address to use when proposing. Defaults to attester address.',
|
|
86
|
+
parseEthereumAddress,
|
|
87
|
+
)
|
|
88
|
+
// TODO: add funding account back in when implemented
|
|
89
|
+
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
62
90
|
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
|
|
63
91
|
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
64
|
-
.option('--bls-path <path>',
|
|
65
|
-
.option('--bls-only', 'Generate only BLS keys')
|
|
92
|
+
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
66
93
|
.option('--empty', 'Generate an empty skeleton without keys')
|
|
67
94
|
.option(
|
|
68
95
|
'--password <str>',
|
|
69
96
|
'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
|
|
70
97
|
)
|
|
71
|
-
.option('--
|
|
98
|
+
.option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
|
|
72
99
|
.option('--json', 'Echo resulting JSON to stdout')
|
|
73
100
|
.requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
|
|
74
101
|
.action(async (existing: string, options) => {
|
|
@@ -76,13 +103,32 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
76
103
|
await addValidatorKeys(existing, options, log);
|
|
77
104
|
});
|
|
78
105
|
|
|
106
|
+
group
|
|
107
|
+
.command('staker')
|
|
108
|
+
.summary('Generate staking JSON from keystore')
|
|
109
|
+
.description(
|
|
110
|
+
'Reads a validator keystore and outputs staking data with BLS public keys for each attester (skips mnemonics)',
|
|
111
|
+
)
|
|
112
|
+
.requiredOption('--from <keystore>', 'Path to keystore JSON file')
|
|
113
|
+
.option('--password <password>', 'Password for decrypting encrypted keystores (if not specified in keystore file)')
|
|
114
|
+
.requiredOption('--gse-address <address>', 'GSE contract address', parseEthereumAddress)
|
|
115
|
+
.option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated)', value => value.split(','), [
|
|
116
|
+
'http://localhost:8545',
|
|
117
|
+
])
|
|
118
|
+
.option('-c, --l1-chain-id <number>', 'L1 chain ID', value => parseInt(value), 31337)
|
|
119
|
+
.option('--output <file>', 'Output file path (if not specified, JSON is written to stdout)')
|
|
120
|
+
.action(async options => {
|
|
121
|
+
const { generateStakerJson } = await import('./staker.js');
|
|
122
|
+
await generateStakerJson(options, log);
|
|
123
|
+
});
|
|
124
|
+
|
|
79
125
|
// top-level convenience: aztec generate-bls-keypair
|
|
80
126
|
program
|
|
81
127
|
.command('generate-bls-keypair')
|
|
82
128
|
.description('Generate a BLS keypair with convenience flags')
|
|
83
129
|
.option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation')
|
|
84
130
|
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
85
|
-
.option('--bls-path <path>',
|
|
131
|
+
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
86
132
|
.option('--g2', 'Derive on G2 subgroup')
|
|
87
133
|
.option('--compressed', 'Output compressed public key')
|
|
88
134
|
.option('--json', 'Print JSON output to stdout')
|
|
@@ -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
|
}
|