@aztec/cli 3.0.0-devnet.2 → 3.0.0-devnet.20251212
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_base_fee.d.ts +1 -1
- 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/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 +3 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/l1/advance_epoch.d.ts +1 -1
- package/dest/cmds/l1/assume_proven_through.d.ts +1 -1
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +2 -1
- 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/create_l1_account.d.ts +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.js +1 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -2
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +1 -1
- 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 +2 -1
- package/dest/cmds/l1/get_l1_balance.d.ts +1 -1
- package/dest/cmds/l1/get_l1_balance.js +1 -1
- 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 -1
- 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 +29 -29
- 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 +6 -6
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +7 -3
- 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/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 +5 -0
- package/dest/cmds/validator_keys/add.d.ts.map +1 -0
- package/dest/cmds/validator_keys/add.js +83 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.js +27 -0
- package/dest/cmds/validator_keys/index.d.ts +4 -0
- package/dest/cmds/validator_keys/index.d.ts.map +1 -0
- package/dest/cmds/validator_keys/index.js +32 -0
- package/dest/cmds/validator_keys/new.d.ts +29 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +132 -0
- package/dest/cmds/validator_keys/shared.d.ts +68 -0
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
- package/dest/cmds/validator_keys/shared.js +274 -0
- 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 +208 -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 +14 -10
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +128 -67
- package/dest/config/enrich_env.d.ts +1 -1
- 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 +6 -3
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +58 -28
- package/dest/utils/aztec.d.ts +5 -3
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +6 -3
- package/dest/utils/commands.d.ts +12 -3
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +30 -3
- 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/setup_contracts.d.ts +1 -1
- package/package.json +37 -28
- package/public_include_metric_prefixes.json +1 -0
- package/src/cmds/aztec_node/get_block.ts +2 -1
- package/src/cmds/aztec_node/get_logs.ts +3 -2
- package/src/cmds/contracts/inspect_contract.ts +4 -11
- package/src/cmds/infrastructure/index.ts +0 -1
- package/src/cmds/infrastructure/sequencers.ts +3 -2
- package/src/cmds/l1/assume_proven_through.ts +4 -1
- package/src/cmds/l1/bridge_erc20.ts +2 -1
- package/src/cmds/l1/deploy_l1_contracts.ts +1 -1
- package/src/cmds/l1/deploy_new_rollup.ts +2 -1
- package/src/cmds/l1/get_l1_addresses.ts +3 -1
- package/src/cmds/l1/get_l1_balance.ts +1 -1
- package/src/cmds/l1/governance_utils.ts +3 -8
- package/src/cmds/l1/prover_stats.ts +38 -30
- package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
- package/src/cmds/l1/update_l1_validators.ts +7 -12
- package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
- package/src/cmds/misc/update/npm.ts +1 -1
- package/src/cmds/validator_keys/add.ts +123 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +34 -0
- package/src/cmds/validator_keys/index.ts +142 -0
- package/src/cmds/validator_keys/new.ts +207 -0
- package/src/cmds/validator_keys/shared.ts +326 -0
- package/src/cmds/validator_keys/staker.ts +301 -0
- package/src/cmds/validator_keys/utils.ts +80 -0
- package/src/config/chain_l2_config.ts +176 -92
- package/src/config/get_l1_config.ts +4 -1
- package/src/config/network_config.ts +67 -29
- package/src/utils/aztec.ts +9 -9
- package/src/utils/commands.ts +41 -3
- package/src/utils/encoding.ts +1 -1
- package/src/utils/inspect.ts +2 -1
|
@@ -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))),
|
|
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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { type EthPrivateKey, ethPrivateKeySchema } from '@aztec/node-keystore';
|
|
3
|
+
|
|
4
|
+
export const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
5
|
+
|
|
6
|
+
export function validateBlsPathOptions(options: {
|
|
7
|
+
count?: number;
|
|
8
|
+
publisherCount?: number;
|
|
9
|
+
accountIndex?: number;
|
|
10
|
+
addressIndex?: number;
|
|
11
|
+
blsPath?: string;
|
|
12
|
+
ikm?: string;
|
|
13
|
+
}) {
|
|
14
|
+
if (options.blsPath && options.blsPath !== defaultBlsPath) {
|
|
15
|
+
if (
|
|
16
|
+
(options.count && options.count !== 1) ||
|
|
17
|
+
(options.publisherCount && options.publisherCount > 0) ||
|
|
18
|
+
(options.accountIndex && options.accountIndex !== 0) ||
|
|
19
|
+
(options.addressIndex && options.addressIndex !== 0)
|
|
20
|
+
) {
|
|
21
|
+
throw new Error('--bls-path cannot be used with --count, --publisher-count, --account-index, or --address-index');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function validateStakerOutputOptions(options: {
|
|
27
|
+
stakerOutput?: boolean;
|
|
28
|
+
gseAddress?: EthAddress;
|
|
29
|
+
l1RpcUrls?: string[];
|
|
30
|
+
l1ChainId?: number;
|
|
31
|
+
}) {
|
|
32
|
+
if (!options.stakerOutput) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Required options for staker output
|
|
36
|
+
if (!options.gseAddress) {
|
|
37
|
+
throw new Error('--gse-address is required when using --staker-output');
|
|
38
|
+
}
|
|
39
|
+
if (!options.l1RpcUrls || options.l1RpcUrls.length === 0) {
|
|
40
|
+
throw new Error('--l1-rpc-urls is required when using --staker-output');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (options.l1ChainId === undefined) {
|
|
44
|
+
throw new Error('--l1-chain-id is required when using --staker-output');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function validateRemoteSignerOptions(options: { remoteSigner?: string; mnemonic?: string }) {
|
|
49
|
+
if (options.remoteSigner && !options.mnemonic) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
'Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.',
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function validatePublisherOptions(options: { publishers?: string[]; publisherCount?: number }) {
|
|
57
|
+
if (options.publisherCount && options.publisherCount > 0 && options.publishers && options.publishers.length > 0) {
|
|
58
|
+
throw new Error('--publishers and --publisher-count cannot be used together');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (options.publishers && options.publishers.length > 0) {
|
|
62
|
+
// Normalize each private key by adding 0x prefix if missing
|
|
63
|
+
const normalizedKeys: string[] = [];
|
|
64
|
+
for (const key of options.publishers) {
|
|
65
|
+
let privateKey = key.trim();
|
|
66
|
+
if (!privateKey.startsWith('0x')) {
|
|
67
|
+
privateKey = '0x' + privateKey;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
ethPrivateKeySchema.parse(privateKey);
|
|
72
|
+
normalizedKeys.push(privateKey);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new Error(`Invalid publisher private key: ${error instanceof Error ? error.message : String(error)}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Update the options with the normalized keys
|
|
78
|
+
options.publishers = normalizedKeys as EthPrivateKey[];
|
|
79
|
+
}
|
|
80
|
+
}
|