@aztec/cli 2.1.0-rc.24 → 2.1.0-rc.28

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.
@@ -92,7 +92,6 @@ export const stagingIgnitionL2ChainConfig = {
92
92
  governanceProposerRoundSize: 300,
93
93
  governanceProposerQuorum: 151,
94
94
  // Node slashing config
95
- // TODO TMNT-330
96
95
  slashMinPenaltyPercentage: 0.5,
97
96
  slashMaxPenaltyPercentage: 2.0,
98
97
  slashInactivityTargetPercentage: 0.7,
@@ -175,25 +174,49 @@ export const testnetL2ChainConfig = {
175
174
  txPoolDeleteTxsAfterReorg: true,
176
175
  skipArchiverInitialSync: true,
177
176
  blobAllowEmptySources: true,
178
- // Deployment stuff
179
177
  /** How many seconds an L1 slot lasts. */ ethereumSlotDuration: 12,
180
- /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 36,
178
+ /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 72,
181
179
  /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
182
- /** The target validator committee size. */ aztecTargetCommitteeSize: 48,
180
+ /** The target validator committee size. */ aztecTargetCommitteeSize: 24,
183
181
  /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: 2,
184
182
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
185
- /** The deposit amount for a validator */ activationThreshold: DefaultL1ContractsConfig.activationThreshold,
186
- /** The minimum stake for a validator. */ ejectionThreshold: DefaultL1ContractsConfig.ejectionThreshold,
187
- /** The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup */ localEjectionThreshold: DefaultL1ContractsConfig.localEjectionThreshold,
188
- /** The slashing round size */ slashingRoundSizeInEpochs: DefaultL1ContractsConfig.slashingRoundSizeInEpochs,
189
- /** Governance proposing round size */ governanceProposerRoundSize: DefaultL1ContractsConfig.governanceProposerRoundSize,
183
+ // This is a diff from mainnet: we have 2-strikes you're out, rather than 3 on mainnet.
184
+ localEjectionThreshold: 198_000n * 10n ** 18n,
185
+ /** How many sequencers must agree with a slash for it to be executed. */ slashingQuorum: 65,
186
+ slashingRoundSizeInEpochs: 4,
187
+ slashingExecutionDelayInRounds: 28,
188
+ slashingLifetimeInRounds: 34,
189
+ slashingVetoer: EthAddress.fromString('0xBbB4aF368d02827945748b28CD4b2D42e4A37480'),
190
+ slashingOffsetInRounds: 2,
191
+ slashingDisableDuration: 259_200,
192
+ slasherFlavor: 'tally',
193
+ slashAmountSmall: 2_000n * 10n ** 18n,
194
+ slashAmountMedium: 2_000n * 10n ** 18n,
195
+ slashAmountLarge: 2_000n * 10n ** 18n,
190
196
  /** The mana target for the rollup */ manaTarget: 0n,
191
- /** The proving cost per mana */ provingCostPerMana: DefaultL1ContractsConfig.provingCostPerMana,
192
- /** Exit delay for stakers */ exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
193
- ...DefaultSlashConfig,
197
+ /** The proving cost per mana */ provingCostPerMana: 0n,
198
+ exitDelaySeconds: 4 * 24 * 60 * 60,
199
+ activationThreshold: 200_000n * 10n ** 18n,
200
+ ejectionThreshold: 100_000n * 10n ** 18n,
201
+ governanceProposerRoundSize: 300,
202
+ governanceProposerQuorum: 151,
203
+ // Node slashing config
204
+ slashInactivityTargetPercentage: 0.8,
205
+ slashInactivityConsecutiveEpochThreshold: 2,
206
+ slashInactivityPenalty: 2_000n * 10n ** 18n,
194
207
  slashPrunePenalty: 0n,
195
208
  slashDataWithholdingPenalty: 0n,
196
- slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium,
209
+ slashProposeInvalidAttestationsPenalty: 2_000n * 10n ** 18n,
210
+ slashAttestDescendantOfInvalidPenalty: 2_000n * 10n ** 18n,
211
+ slashUnknownPenalty: 2_000n * 10n ** 18n,
212
+ slashBroadcastedInvalidBlockPenalty: 2_000n * 10n ** 18n,
213
+ slashGracePeriodL2Slots: 1_200,
214
+ slashOffenseExpirationRounds: 8,
215
+ slashMinPenaltyPercentage: 0.5,
216
+ slashMaxPenaltyPercentage: 2.0,
217
+ slashMaxPayloadSize: 50,
218
+ slashExecuteRoundsLookBack: 4,
219
+ sentinelEnabled: true,
197
220
  ...DefaultNetworkDBMapSizeConfig
198
221
  };
199
222
  export const mainnetL2ChainConfig = {
@@ -224,43 +247,42 @@ export const mainnetL2ChainConfig = {
224
247
  /** The target validator committee size. */ aztecTargetCommitteeSize: 24,
225
248
  /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: 2,
226
249
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
250
+ localEjectionThreshold: 196_000n * 10n ** 18n,
227
251
  /** How many sequencers must agree with a slash for it to be executed. */ slashingQuorum: 65,
228
252
  slashingRoundSizeInEpochs: 4,
229
- slashingLifetimeInRounds: 40,
230
253
  slashingExecutionDelayInRounds: 28,
231
- slashingDisableDuration: 5 * 24 * 60 * 60,
232
- slashAmountSmall: 2_000n * 10n ** 18n,
233
- slashAmountMedium: 10_000n * 10n ** 18n,
234
- slashAmountLarge: 50_000n * 10n ** 18n,
254
+ slashingLifetimeInRounds: 34,
255
+ slashingVetoer: EthAddress.ZERO,
235
256
  slashingOffsetInRounds: 2,
257
+ slashingDisableDuration: 259_200,
236
258
  slasherFlavor: 'tally',
237
- slashingVetoer: EthAddress.ZERO,
259
+ slashAmountSmall: 2_000n * 10n ** 18n,
260
+ slashAmountMedium: 2_000n * 10n ** 18n,
261
+ slashAmountLarge: 2_000n * 10n ** 18n,
238
262
  /** The mana target for the rollup */ manaTarget: 0n,
239
- exitDelaySeconds: 5 * 24 * 60 * 60,
240
263
  /** The proving cost per mana */ provingCostPerMana: 0n,
241
- ejectionThreshold: 100_000n * 10n ** 18n,
264
+ exitDelaySeconds: 4 * 24 * 60 * 60,
242
265
  activationThreshold: 200_000n * 10n ** 18n,
243
- localEjectionThreshold: 196_000n * 10n ** 18n,
244
- governanceProposerRoundSize: 300,
245
- governanceProposerQuorum: 151,
266
+ ejectionThreshold: 100_000n * 10n ** 18n,
267
+ governanceProposerRoundSize: 1000,
268
+ governanceProposerQuorum: 600,
246
269
  // Node slashing config
247
- // TODO TMNT-330
248
- slashMinPenaltyPercentage: 0.5,
249
- slashMaxPenaltyPercentage: 2.0,
250
- slashInactivityTargetPercentage: 0.7,
270
+ slashInactivityTargetPercentage: 0.8,
251
271
  slashInactivityConsecutiveEpochThreshold: 2,
252
272
  slashInactivityPenalty: 2_000n * 10n ** 18n,
253
273
  slashPrunePenalty: 0n,
254
274
  slashDataWithholdingPenalty: 0n,
255
- slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
256
- slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
275
+ slashProposeInvalidAttestationsPenalty: 2_000n * 10n ** 18n,
276
+ slashAttestDescendantOfInvalidPenalty: 2_000n * 10n ** 18n,
257
277
  slashUnknownPenalty: 2_000n * 10n ** 18n,
258
- slashBroadcastedInvalidBlockPenalty: 0n,
259
- slashMaxPayloadSize: 50,
260
- slashGracePeriodL2Slots: 32 * 4,
278
+ slashBroadcastedInvalidBlockPenalty: 2_000n * 10n ** 18n,
279
+ slashGracePeriodL2Slots: 1_200,
261
280
  slashOffenseExpirationRounds: 8,
262
- sentinelEnabled: true,
281
+ slashMinPenaltyPercentage: 0.5,
282
+ slashMaxPenaltyPercentage: 2.0,
283
+ slashMaxPayloadSize: 50,
263
284
  slashExecuteRoundsLookBack: 4,
285
+ sentinelEnabled: true,
264
286
  ...DefaultNetworkDBMapSizeConfig
265
287
  };
266
288
  export function getL2ChainConfig(networkName) {
@@ -35,6 +35,15 @@ export declare function atomicUpdateFile(filePath: string, contents: string): Pr
35
35
  * @returns An Aztec address. Will throw if one can't be found in either options.
36
36
  */
37
37
  export declare function getTxSender(pxe: PXE, _from?: string): Promise<AztecAddress>;
38
+ /**
39
+ * Parses and validates a hex string. Removes leading 0x if present, checks for hex validity,
40
+ * and enforces an optional minimum length.
41
+ * @param hex - The hex string to validate.
42
+ * @param minLen - Optional minimum length (in hex characters, after stripping '0x').
43
+ * @returns The normalized hex string (without leading 0x).
44
+ * @throws InvalidArgumentError if the string is not valid hex or does not meet the minimum length.
45
+ */
46
+ export declare function parseHex(hex: string, minLen?: number): `0x${string}`;
38
47
  export declare function parseBigint(bigint: string): bigint | undefined;
39
48
  /**
40
49
  * Parses a hex encoded string to an Fr integer
@@ -84,7 +93,7 @@ export declare function parseOptionalSelector(selector: string): FunctionSelecto
84
93
  * @returns The parsed integer, or undefined if the input string is falsy.
85
94
  * @throws If the input is not a valid integer.
86
95
  */
87
- export declare function parseOptionalInteger(value: string): number | undefined;
96
+ export declare function parseOptionalInteger(value: string, min?: number, max?: number): number | undefined;
88
97
  /**
89
98
  * Parses a TxHash from a string.
90
99
  * @param txHash - A transaction hash
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/utils/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,OAAO,EAAwC,MAAM,EAAE,MAAM,WAAW,CAAC;AAIvF;;;GAGG;AACH,eAAO,MAAM,YAAY,uBAGI,CAAC;AAE9B,eAAO,MAAM,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;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAElD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAcjE"}
@@ -74,6 +74,27 @@ export const logJson = (log)=>(obj)=>log(JSON.stringify(obj, null, 2));
74
74
  }
75
75
  return from;
76
76
  }
77
+ /**
78
+ * Parses and validates a hex string. Removes leading 0x if present, checks for hex validity,
79
+ * and enforces an optional minimum length.
80
+ * @param hex - The hex string to validate.
81
+ * @param minLen - Optional minimum length (in hex characters, after stripping '0x').
82
+ * @returns The normalized hex string (without leading 0x).
83
+ * @throws InvalidArgumentError if the string is not valid hex or does not meet the minimum length.
84
+ */ // minLen is now interpreted as the minimum number of bytes (2 hex characters per byte)
85
+ export function parseHex(hex, minLen) {
86
+ const normalized = hex.startsWith('0x') ? hex.slice(2) : hex;
87
+ if (!/^[0-9a-fA-F]*$/.test(normalized)) {
88
+ throw new InvalidArgumentError('Invalid hex string');
89
+ }
90
+ if (minLen !== undefined) {
91
+ const minHexLen = minLen * 2;
92
+ if (normalized.length < minHexLen) {
93
+ throw new InvalidArgumentError(`Hex string is too short (length ${normalized.length}), minimum byte length is ${minLen} (hex chars: ${minHexLen})`);
94
+ }
95
+ }
96
+ return `0x${normalized}`;
97
+ }
77
98
  /**
78
99
  * Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
79
100
  * @param hex - A hex string
@@ -118,7 +139,7 @@ export function parseBigint(bigint) {
118
139
  try {
119
140
  return AztecAddress.fromString(address);
120
141
  } catch {
121
- throw new InvalidArgumentError(`Invalid address: ${address}`);
142
+ throw new InvalidArgumentError(`Invalid Aztec address: ${address}`);
122
143
  }
123
144
  }
124
145
  /**
@@ -130,7 +151,7 @@ export function parseBigint(bigint) {
130
151
  try {
131
152
  return EthAddress.fromString(address);
132
153
  } catch {
133
- throw new InvalidArgumentError(`Invalid address: ${address}`);
154
+ throw new InvalidArgumentError(`Invalid Ethereumaddress: ${address}`);
134
155
  }
135
156
  }
136
157
  /**
@@ -176,7 +197,7 @@ export function parseBigint(bigint) {
176
197
  * @param value - The string to parse into an integer.
177
198
  * @returns The parsed integer, or undefined if the input string is falsy.
178
199
  * @throws If the input is not a valid integer.
179
- */ export function parseOptionalInteger(value) {
200
+ */ export function parseOptionalInteger(value, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
180
201
  if (!value) {
181
202
  return undefined;
182
203
  }
@@ -184,6 +205,12 @@ export function parseBigint(bigint) {
184
205
  if (!Number.isInteger(parsed)) {
185
206
  throw new InvalidArgumentError('Invalid integer.');
186
207
  }
208
+ if (parsed < min) {
209
+ throw new InvalidArgumentError(`Value must be greater than ${min}.`);
210
+ }
211
+ if (parsed > max) {
212
+ throw new InvalidArgumentError(`Value must be less than ${max}.`);
213
+ }
187
214
  return parsed;
188
215
  }
189
216
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "2.1.0-rc.24",
3
+ "version": "2.1.0-rc.28",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -10,6 +10,7 @@
10
10
  "./pxe": "./dest/cmds/pxe/index.js",
11
11
  "./cli-utils": "./dest/utils/index.js",
12
12
  "./misc": "./dest/cmds/misc/index.js",
13
+ "./validator_keys": "./dest/cmds/validator_keys/index.js",
13
14
  "./setup-contracts": "./dest/cmds/misc/setup_contracts.js",
14
15
  "./utils": "./dest/utils/index.js",
15
16
  "./inspect": "./dest/utils/inspect.js",
@@ -70,19 +71,22 @@
70
71
  ]
71
72
  },
72
73
  "dependencies": {
73
- "@aztec/archiver": "2.1.0-rc.24",
74
- "@aztec/aztec.js": "2.1.0-rc.24",
75
- "@aztec/constants": "2.1.0-rc.24",
76
- "@aztec/entrypoints": "2.1.0-rc.24",
77
- "@aztec/ethereum": "2.1.0-rc.24",
78
- "@aztec/foundation": "2.1.0-rc.24",
79
- "@aztec/l1-artifacts": "2.1.0-rc.24",
80
- "@aztec/node-lib": "2.1.0-rc.24",
81
- "@aztec/p2p": "2.1.0-rc.24",
82
- "@aztec/stdlib": "2.1.0-rc.24",
83
- "@aztec/world-state": "2.1.0-rc.24",
74
+ "@aztec/archiver": "2.1.0-rc.28",
75
+ "@aztec/aztec.js": "2.1.0-rc.28",
76
+ "@aztec/constants": "2.1.0-rc.28",
77
+ "@aztec/entrypoints": "2.1.0-rc.28",
78
+ "@aztec/ethereum": "2.1.0-rc.28",
79
+ "@aztec/foundation": "2.1.0-rc.28",
80
+ "@aztec/l1-artifacts": "2.1.0-rc.28",
81
+ "@aztec/node-keystore": "2.1.0-rc.28",
82
+ "@aztec/node-lib": "2.1.0-rc.28",
83
+ "@aztec/p2p": "2.1.0-rc.28",
84
+ "@aztec/stdlib": "2.1.0-rc.28",
85
+ "@aztec/world-state": "2.1.0-rc.28",
86
+ "@ethersproject/wallet": "^5.8.0",
84
87
  "@iarna/toml": "^2.2.5",
85
88
  "@libp2p/peer-id-factory": "^3.0.4",
89
+ "@scure/bip39": "^2.0.1",
86
90
  "commander": "^12.1.0",
87
91
  "lodash.chunk": "^4.2.0",
88
92
  "lodash.groupby": "^4.6.0",
@@ -92,8 +96,8 @@
92
96
  "viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
93
97
  },
94
98
  "devDependencies": {
95
- "@aztec/accounts": "2.1.0-rc.24",
96
- "@aztec/protocol-contracts": "2.1.0-rc.24",
99
+ "@aztec/accounts": "2.1.0-rc.28",
100
+ "@aztec/protocol-contracts": "2.1.0-rc.28",
97
101
  "@jest/globals": "^30.0.0",
98
102
  "@types/jest": "^30.0.0",
99
103
  "@types/lodash.chunk": "^4.2.9",
@@ -109,15 +113,15 @@
109
113
  "typescript": "^5.3.3"
110
114
  },
111
115
  "peerDependencies": {
112
- "@aztec/accounts": "2.1.0-rc.24",
113
- "@aztec/bb-prover": "2.1.0-rc.24",
114
- "@aztec/ethereum": "2.1.0-rc.24",
115
- "@aztec/l1-artifacts": "2.1.0-rc.24",
116
- "@aztec/noir-contracts.js": "2.1.0-rc.24",
117
- "@aztec/noir-protocol-circuits-types": "2.1.0-rc.24",
118
- "@aztec/noir-test-contracts.js": "2.1.0-rc.24",
119
- "@aztec/protocol-contracts": "2.1.0-rc.24",
120
- "@aztec/stdlib": "2.1.0-rc.24"
116
+ "@aztec/accounts": "2.1.0-rc.28",
117
+ "@aztec/bb-prover": "2.1.0-rc.28",
118
+ "@aztec/ethereum": "2.1.0-rc.28",
119
+ "@aztec/l1-artifacts": "2.1.0-rc.28",
120
+ "@aztec/noir-contracts.js": "2.1.0-rc.28",
121
+ "@aztec/noir-protocol-circuits-types": "2.1.0-rc.28",
122
+ "@aztec/noir-test-contracts.js": "2.1.0-rc.28",
123
+ "@aztec/protocol-contracts": "2.1.0-rc.28",
124
+ "@aztec/stdlib": "2.1.0-rc.28"
121
125
  },
122
126
  "files": [
123
127
  "dest",
@@ -0,0 +1,113 @@
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import { loadKeystoreFile } from '@aztec/node-keystore/loader';
4
+ import type { KeyStore } from '@aztec/node-keystore/types';
5
+
6
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
7
+ import { dirname, isAbsolute, join } from 'path';
8
+ import { generateMnemonic } from 'viem/accounts';
9
+
10
+ import type { NewValidatorKeystoreOptions } from './new.js';
11
+ import {
12
+ buildValidatorEntries,
13
+ logValidatorSummaries,
14
+ maybePrintJson,
15
+ writeBlsBn254ToFile,
16
+ writeEthJsonV3ToFile,
17
+ writeKeystoreFile,
18
+ } from './shared.js';
19
+
20
+ export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
21
+
22
+ export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
23
+ const {
24
+ dataDir,
25
+ file,
26
+ count,
27
+ publisherCount = 0,
28
+ mnemonic,
29
+ accountIndex = 0,
30
+ addressIndex,
31
+ ikm,
32
+ blsPath,
33
+ blsOnly,
34
+ json,
35
+ feeRecipient: feeRecipientOpt,
36
+ coinbase: coinbaseOpt,
37
+ fundingAccount: fundingAccountOpt,
38
+ remoteSigner: remoteSignerOpt,
39
+ password,
40
+ outDir,
41
+ } = options;
42
+
43
+ const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
44
+ const baseAddressIndex = addressIndex ?? 0;
45
+
46
+ const keystore: KeyStore = loadKeystoreFile(existing);
47
+
48
+ if (!keystore.validators || !Array.isArray(keystore.validators)) {
49
+ throw new Error('Invalid keystore: missing validators array');
50
+ }
51
+
52
+ const first = keystore.validators[0] ?? {};
53
+ const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
54
+ if (!feeRecipient) {
55
+ throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
56
+ }
57
+ 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
+ const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
61
+ const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
62
+
63
+ // Ensure we always have a mnemonic for key derivation if none was provided
64
+ const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
65
+
66
+ // If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
67
+ const effectiveBaseAddressIndex =
68
+ addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
69
+
70
+ const { validators, summaries } = await buildValidatorEntries({
71
+ validatorCount,
72
+ publisherCount,
73
+ accountIndex,
74
+ baseAddressIndex: effectiveBaseAddressIndex,
75
+ mnemonic: mnemonicToUse,
76
+ ikm,
77
+ blsPath,
78
+ blsOnly,
79
+ feeRecipient,
80
+ coinbase,
81
+ remoteSigner,
82
+ fundingAccount,
83
+ });
84
+
85
+ keystore.validators.push(...validators);
86
+
87
+ // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
88
+ if (password !== undefined) {
89
+ const targetDir =
90
+ outDir && outDir.length > 0 ? outDir : dataDir && dataDir.length > 0 ? dataDir : dirname(existing);
91
+ await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
92
+ await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password });
93
+ }
94
+
95
+ let outputPath = existing;
96
+ if (file && file.length > 0) {
97
+ if (isAbsolute(file)) {
98
+ outputPath = file;
99
+ } else if (dataDir && dataDir.length > 0) {
100
+ outputPath = join(dataDir, file);
101
+ } else {
102
+ outputPath = join(dirname(existing), file);
103
+ }
104
+ }
105
+
106
+ await writeKeystoreFile(outputPath, keystore);
107
+
108
+ if (!json) {
109
+ log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
110
+ logValidatorSummaries(log, summaries);
111
+ }
112
+ maybePrintJson(log, !!json, keystore as unknown as Record<string, any>);
113
+ }
@@ -0,0 +1,33 @@
1
+ import { deriveBlsPrivateKey } from '@aztec/foundation/crypto';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+
4
+ import { writeFile } from 'fs/promises';
5
+
6
+ import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
7
+
8
+ export type GenerateBlsKeypairOptions = {
9
+ mnemonic?: string;
10
+ ikm?: string;
11
+ blsPath?: string;
12
+ g2?: boolean;
13
+ compressed?: boolean;
14
+ json?: boolean;
15
+ out?: string;
16
+ };
17
+
18
+ export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
19
+ const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
20
+ const path = withValidatorIndex(blsPath ?? 'm/12381/3600/0/0/0', 0);
21
+ const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
22
+ const pub = await computeBlsPublicKeyCompressed(priv);
23
+ const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
24
+ if (out) {
25
+ await writeFile(out, JSON.stringify(result, null, 2), { encoding: 'utf-8' });
26
+ if (!json) {
27
+ log(`Wrote BLS keypair to ${out}`);
28
+ }
29
+ }
30
+ if (json || !out) {
31
+ log(JSON.stringify(result, null, 2));
32
+ }
33
+ }
@@ -0,0 +1,96 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+
3
+ import { Command } from 'commander';
4
+
5
+ import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
6
+
7
+ export function injectCommands(program: Command, log: LogFn) {
8
+ const group = program
9
+ .command('validator-keys')
10
+ .aliases(['valKeys'])
11
+ .description('Manage validator keystores for node operators');
12
+
13
+ group
14
+ .command('new')
15
+ .summary('Generate a new validator keystore JSON')
16
+ .description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts')
17
+ .option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore')
18
+ .option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)')
19
+ .option('--count <N>', 'Number of validators to generate', parseOptionalInteger)
20
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', value =>
21
+ parseOptionalInteger(value, 0),
22
+ )
23
+ .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
24
+ .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('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress)
28
+ .option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress)
29
+ .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
30
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
31
+ .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
32
+ .option('--bls-only', 'Generate only BLS keys')
33
+ .option(
34
+ '--password <str>',
35
+ 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
36
+ )
37
+ .option('--out-dir <dir>', 'Output directory for generated keystore file(s)')
38
+ .option('--json', 'Echo resulting JSON to stdout')
39
+ .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
40
+ .action(async options => {
41
+ const { newValidatorKeystore } = await import('./new.js');
42
+ await newValidatorKeystore(options, log);
43
+ });
44
+
45
+ group
46
+ .command('add')
47
+ .summary('Augment an existing validator keystore JSON')
48
+ .description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new')
49
+ .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 1)', value =>
54
+ parseOptionalInteger(value, 0),
55
+ )
56
+ .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
57
+ .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('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress)
61
+ .option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress)
62
+ .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
63
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
64
+ .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
65
+ .option('--bls-only', 'Generate only BLS keys')
66
+ .option('--empty', 'Generate an empty skeleton without keys')
67
+ .option(
68
+ '--password <str>',
69
+ 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
70
+ )
71
+ .option('--out-dir <dir>', 'Output directory for generated keystore file(s)')
72
+ .option('--json', 'Echo resulting JSON to stdout')
73
+ .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
74
+ .action(async (existing: string, options) => {
75
+ const { addValidatorKeys } = await import('./add.js');
76
+ await addValidatorKeys(existing, options, log);
77
+ });
78
+
79
+ // top-level convenience: aztec generate-bls-keypair
80
+ program
81
+ .command('generate-bls-keypair')
82
+ .description('Generate a BLS keypair with convenience flags')
83
+ .option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation')
84
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
85
+ .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
86
+ .option('--g2', 'Derive on G2 subgroup')
87
+ .option('--compressed', 'Output compressed public key')
88
+ .option('--json', 'Print JSON output to stdout')
89
+ .option('--out <file>', 'Write output to file')
90
+ .action(async options => {
91
+ const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
92
+ await generateBlsKeypair(options, log);
93
+ });
94
+
95
+ return program;
96
+ }