@aztec/cli 3.0.0-nightly.20251118 → 3.0.0-nightly.20251120

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.
Files changed (30) hide show
  1. package/dest/cmds/validator_keys/add.d.ts.map +1 -1
  2. package/dest/cmds/validator_keys/add.js +19 -3
  3. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -1
  4. package/dest/cmds/validator_keys/generate_bls_keypair.js +2 -1
  5. package/dest/cmds/validator_keys/index.d.ts.map +1 -1
  6. package/dest/cmds/validator_keys/index.js +4 -3
  7. package/dest/cmds/validator_keys/new.d.ts +2 -1
  8. package/dest/cmds/validator_keys/new.d.ts.map +1 -1
  9. package/dest/cmds/validator_keys/new.js +24 -26
  10. package/dest/cmds/validator_keys/shared.d.ts +2 -0
  11. package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
  12. package/dest/cmds/validator_keys/shared.js +26 -8
  13. package/dest/cmds/validator_keys/staker.d.ts.map +1 -1
  14. package/dest/cmds/validator_keys/staker.js +12 -11
  15. package/dest/cmds/validator_keys/utils.d.ts +25 -0
  16. package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
  17. package/dest/cmds/validator_keys/utils.js +52 -0
  18. package/dest/config/network_config.d.ts +1 -1
  19. package/dest/config/network_config.d.ts.map +1 -1
  20. package/dest/config/network_config.js +18 -4
  21. package/package.json +30 -29
  22. package/public_include_metric_prefixes.json +1 -0
  23. package/src/cmds/validator_keys/add.ts +20 -4
  24. package/src/cmds/validator_keys/generate_bls_keypair.ts +2 -1
  25. package/src/cmds/validator_keys/index.ts +33 -17
  26. package/src/cmds/validator_keys/new.ts +35 -34
  27. package/src/cmds/validator_keys/shared.ts +27 -8
  28. package/src/cmds/validator_keys/staker.ts +14 -12
  29. package/src/cmds/validator_keys/utils.ts +80 -0
  30. package/src/config/network_config.ts +25 -4
@@ -1 +1 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/add.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAU5D,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAElE,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,KAAK,iBAyFpG"}
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/add.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAW5D,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAElE,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,KAAK,iBAwGpG"}
@@ -3,8 +3,15 @@ import { wordlist } from '@scure/bip39/wordlists/english.js';
3
3
  import { dirname, isAbsolute, join } from 'path';
4
4
  import { generateMnemonic } from 'viem/accounts';
5
5
  import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
6
+ import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
6
7
  export async function addValidatorKeys(existing, options, log) {
7
- const { dataDir, file, count, publisherCount = 0, mnemonic, accountIndex = 0, addressIndex, ikm, blsPath, json, feeRecipient: feeRecipientOpt, coinbase: coinbaseOpt, fundingAccount: fundingAccountOpt, remoteSigner: remoteSignerOpt, password, outDir } = options;
8
+ // validate bls-path inputs before proceeding with key generation
9
+ validateBlsPathOptions(options);
10
+ // validate publisher options
11
+ validatePublisherOptions(options);
12
+ // validate remote signer options
13
+ validateRemoteSignerOptions(options);
14
+ const { dataDir, file, count, publisherCount = 0, publishers, mnemonic, accountIndex = 0, addressIndex, ikm, blsPath, json, feeRecipient: feeRecipientOpt, coinbase: coinbaseOpt, fundingAccount: fundingAccountOpt, remoteSigner: remoteSignerOpt, password, encryptedKeystoreDir } = options;
8
15
  const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
9
16
  const baseAddressIndex = addressIndex ?? 0;
10
17
  const keystore = loadKeystoreFile(existing);
@@ -27,6 +34,7 @@ export async function addValidatorKeys(existing, options, log) {
27
34
  const { validators, summaries } = await buildValidatorEntries({
28
35
  validatorCount,
29
36
  publisherCount,
37
+ publishers,
30
38
  accountIndex,
31
39
  baseAddressIndex: effectiveBaseAddressIndex,
32
40
  mnemonic: mnemonicToUse,
@@ -40,14 +48,22 @@ export async function addValidatorKeys(existing, options, log) {
40
48
  keystore.validators.push(...validators);
41
49
  // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
42
50
  if (password !== undefined) {
43
- const targetDir = outDir && outDir.length > 0 ? outDir : dataDir && dataDir.length > 0 ? dataDir : dirname(existing);
51
+ let targetDir;
52
+ if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
53
+ targetDir = encryptedKeystoreDir;
54
+ } else if (dataDir && dataDir.length > 0) {
55
+ targetDir = dataDir;
56
+ } else {
57
+ targetDir = dirname(existing);
58
+ }
44
59
  await writeEthJsonV3ToFile(keystore.validators, {
45
60
  outDir: targetDir,
46
61
  password
47
62
  });
48
63
  await writeBlsBn254ToFile(keystore.validators, {
49
64
  outDir: targetDir,
50
- password
65
+ password,
66
+ blsPath
51
67
  });
52
68
  }
53
69
  let outputPath = existing;
@@ -1 +1 @@
1
- {"version":3,"file":"generate_bls_keypair.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/generate_bls_keypair.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,KAAK,iBAetF"}
1
+ {"version":3,"file":"generate_bls_keypair.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/generate_bls_keypair.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAOnD,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,KAAK,iBAetF"}
@@ -1,9 +1,10 @@
1
1
  import { deriveBlsPrivateKey } from '@aztec/foundation/crypto';
2
2
  import { writeFile } from 'fs/promises';
3
3
  import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
4
+ import { defaultBlsPath } from './utils.js';
4
5
  export async function generateBlsKeypair(options, log) {
5
6
  const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
6
- const path = withValidatorIndex(blsPath ?? 'm/12381/3600/0/0/0', 0);
7
+ const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
7
8
  const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
8
9
  const pub = await computeBlsPublicKeyCompressed(priv);
9
10
  const result = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WAqH1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WAoI1D"}
@@ -1,14 +1,15 @@
1
1
  import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
2
+ import { defaultBlsPath } from './utils.js';
2
3
  export function injectCommands(program, log) {
3
4
  const group = program.command('validator-keys').aliases([
4
5
  'valKeys',
5
6
  'valkeys'
6
7
  ]).description('Manage validator keystores for node operators');
7
- group.command('new').summary('Generate a new validator keystore JSON').description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts').option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore').option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)').option('--count <N>', 'Number of validators to generate', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--out-dir <dir>', 'Output directory for generated keystore file(s)').option('--json', 'Echo resulting JSON to stdout').option('--staker-output', 'Generate staker output JSON files for each attester').option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', (value)=>value.split(',')).option('-c, --l1-chain-id <number>', 'L1 chain ID (required with --staker-output)', (value)=>parseInt(value), 31337).requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (options)=>{
8
+ group.command('new').summary('Generate a new validator keystore JSON').description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts').option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore').option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)').option('--count <N>', 'Number of validators to generate', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries').option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', (value)=>value.split(',')).option('-c, --l1-chain-id <number>', 'L1 chain ID (required with --staker-output)', (value)=>parseInt(value), 31337).requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (options)=>{
8
9
  const { newValidatorKeystore } = await import('./new.js');
9
10
  await newValidatorKeystore(options, log);
10
11
  });
11
- group.command('add').summary('Augment an existing validator keystore JSON').description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new').argument('<existing>', 'Path to existing keystore JSON').option('--data-dir <path>', 'Directory where keystore(s) live').option('--file <name>', 'Override output file name').option('--count <N>', 'Number of validators to add', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--empty', 'Generate an empty skeleton without keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--out-dir <dir>', 'Output directory for generated keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (existing, options)=>{
12
+ group.command('add').summary('Augment an existing validator keystore JSON').description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new').argument('<existing>', 'Path to existing keystore JSON').option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)').option('--file <name>', 'Override output file name. (default: key<N>.json)').option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--empty', 'Generate an empty skeleton without keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (existing, options)=>{
12
13
  const { addValidatorKeys } = await import('./add.js');
13
14
  await addValidatorKeys(existing, options, log);
14
15
  });
@@ -19,7 +20,7 @@ export function injectCommands(program, log) {
19
20
  await generateStakerJson(options, log);
20
21
  });
21
22
  // top-level convenience: aztec generate-bls-keypair
22
- program.command('generate-bls-keypair').description('Generate a BLS keypair with convenience flags').option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--g2', 'Derive on G2 subgroup').option('--compressed', 'Output compressed public key').option('--json', 'Print JSON output to stdout').option('--out <file>', 'Write output to file').action(async (options)=>{
23
+ program.command('generate-bls-keypair').description('Generate a BLS keypair with convenience flags').option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--g2', 'Derive on G2 subgroup').option('--compressed', 'Output compressed public key').option('--json', 'Print JSON output to stdout').option('--out <file>', 'Write output to file').action(async (options)=>{
23
24
  const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
24
25
  await generateBlsKeypair(options, log);
25
26
  });
@@ -6,6 +6,7 @@ export type NewValidatorKeystoreOptions = {
6
6
  file?: string;
7
7
  count?: number;
8
8
  publisherCount?: number;
9
+ publishers?: string[];
9
10
  mnemonic?: string;
10
11
  passphrase?: string;
11
12
  accountIndex?: number;
@@ -14,7 +15,7 @@ export type NewValidatorKeystoreOptions = {
14
15
  ikm?: string;
15
16
  blsPath?: string;
16
17
  password?: string;
17
- outDir?: string;
18
+ encryptedKeystoreDir?: string;
18
19
  json?: boolean;
19
20
  feeRecipient: AztecAddress;
20
21
  coinbase?: EthAddress;
@@ -1 +1 @@
1
- {"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator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AU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAyBhE,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,KAAK,iBAyJ1F"}
@@ -7,23 +7,17 @@ import { createPublicClient, fallback, http } from 'viem';
7
7
  import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
8
8
  import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
9
9
  import { processAttesterAccounts } from './staker.js';
10
+ import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions, validateStakerOutputOptions } from './utils.js';
10
11
  export async function newValidatorKeystore(options, log) {
11
- const { dataDir, file, count, publisherCount = 0, json, coinbase, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, fundingAccount, blsPath, ikm, mnemonic: _mnemonic, password, outDir, stakerOutput, gseAddress, l1RpcUrls, l1ChainId } = options;
12
- // Validate staker output requirements
13
- if (stakerOutput) {
14
- if (!gseAddress) {
15
- throw new Error('--gse-address is required when using --staker-output');
16
- }
17
- if (!l1RpcUrls || l1RpcUrls.length === 0) {
18
- throw new Error('--l1-rpc-urls is required when using --staker-output');
19
- }
20
- if (l1ChainId === undefined) {
21
- throw new Error('--l1-chain-id is required when using --staker-output');
22
- }
23
- }
24
- if (remoteSigner && !_mnemonic) {
25
- throw new Error('Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.');
26
- }
12
+ // validate bls-path inputs before proceeding with key generation
13
+ validateBlsPathOptions(options);
14
+ // validate staker output options before proceeding with key generation
15
+ validateStakerOutputOptions(options);
16
+ // validate publisher options
17
+ validatePublisherOptions(options);
18
+ // validate remote signer options
19
+ validateRemoteSignerOptions(options);
20
+ const { dataDir, file, count, publisherCount = 0, publishers, json, coinbase, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, fundingAccount, blsPath, ikm, mnemonic: _mnemonic, password, encryptedKeystoreDir, stakerOutput, gseAddress, l1RpcUrls, l1ChainId } = options;
27
21
  const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
28
22
  if (!_mnemonic && !json) {
29
23
  log('No mnemonic provided, generating new one...');
@@ -34,9 +28,11 @@ export async function newValidatorKeystore(options, log) {
34
28
  }
35
29
  const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
36
30
  const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
31
+ const keystoreOutDir = dirname(outputPath);
37
32
  const { validators, summaries } = await buildValidatorEntries({
38
33
  validatorCount,
39
34
  publisherCount,
35
+ publishers,
40
36
  accountIndex,
41
37
  baseAddressIndex: addressIndex,
42
38
  mnemonic,
@@ -49,13 +45,13 @@ export async function newValidatorKeystore(options, log) {
49
45
  });
50
46
  // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
51
47
  if (password !== undefined) {
52
- const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
48
+ const encryptedKeystoreOutDir = encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : keystoreOutDir;
53
49
  await writeEthJsonV3ToFile(validators, {
54
- outDir: keystoreOutDir,
50
+ outDir: encryptedKeystoreOutDir,
55
51
  password
56
52
  });
57
53
  await writeBlsBn254ToFile(validators, {
58
- outDir: keystoreOutDir,
54
+ outDir: encryptedKeystoreOutDir,
59
55
  password
60
56
  });
61
57
  }
@@ -73,21 +69,22 @@ export async function newValidatorKeystore(options, log) {
73
69
  transport: fallback(l1RpcUrls.map((url)=>http(url)))
74
70
  });
75
71
  const gse = new GSEContract(publicClient, gseAddress);
76
- const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
77
72
  // Extract keystore base name without extension for unique staker output filenames
78
73
  const keystoreBaseName = basename(outputPath, '.json');
79
74
  // Process each validator
80
75
  for(let i = 0; i < validators.length; i++){
81
76
  const validator = validators[i];
82
77
  const outputs = await processAttesterAccounts(validator.attester, gse, password);
83
- // Save each attester's staker output
78
+ // Collect all staker outputs
84
79
  for(let j = 0; j < outputs.length; j++){
85
- const attesterIndex = i + 1;
86
- const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_attester${attesterIndex}_staker_output.json`);
87
- await writeFile(stakerOutputPath, prettyPrintJSON(outputs[j]), 'utf-8');
88
80
  allStakerOutputs.push(outputs[j]);
89
81
  }
90
82
  }
83
+ // Write a single JSON file with all staker outputs
84
+ if (allStakerOutputs.length > 0) {
85
+ const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_staker_output.json`);
86
+ await writeFile(stakerOutputPath, prettyPrintJSON(allStakerOutputs), 'utf-8');
87
+ }
91
88
  }
92
89
  const outputData = !_mnemonic ? {
93
90
  ...keystore,
@@ -107,8 +104,9 @@ export async function newValidatorKeystore(options, log) {
107
104
  } else {
108
105
  log(`Wrote validator keystore to ${outputPath}`);
109
106
  if (stakerOutput && allStakerOutputs.length > 0) {
110
- const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
111
- log(`Wrote ${allStakerOutputs.length} staker output file(s) to ${keystoreOutDir}`);
107
+ const keystoreBaseName = basename(outputPath, '.json');
108
+ const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_staker_output.json`);
109
+ log(`Wrote staker output for ${allStakerOutputs.length} validator(s) to ${stakerOutputPath}`);
112
110
  log('');
113
111
  }
114
112
  }
@@ -10,6 +10,7 @@ export type ValidatorSummary = {
10
10
  export type BuildValidatorsInput = {
11
11
  validatorCount: number;
12
12
  publisherCount?: number;
13
+ publishers?: string[];
13
14
  accountIndex: number;
14
15
  baseAddressIndex: number;
15
16
  mnemonic: string;
@@ -56,6 +57,7 @@ export declare function writeBn254BlsKeystore(outDir: string, fileNameBase: stri
56
57
  export declare function writeBlsBn254ToFile(validators: ValidatorKeyStore[], options: {
57
58
  outDir: string;
58
59
  password: string;
60
+ blsPath?: string;
59
61
  }): Promise<void>;
60
62
  /** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */
61
63
  export declare function writeEthJsonV3Keystore(outDir: string, fileNameBase: string, password: string, privateKeyHex: string): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KA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C,OAAO,CAAC,IAAI,CAAC,CA2Cf"}
@@ -7,11 +7,27 @@ import { access, writeFile } from 'fs/promises';
7
7
  import { homedir } from 'os';
8
8
  import { dirname, isAbsolute, join } from 'path';
9
9
  import { mnemonicToAccount } from 'viem/accounts';
10
+ import { defaultBlsPath } from './utils.js';
10
11
  export function withValidatorIndex(path, accountIndex = 0, addressIndex = 0) {
12
+ // NOTE: The legacy BLS CLI is to allow users who generated keys in 2.1.4 to be able to use the same command
13
+ // 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.
14
+ const useLegacyBlsCli = [
15
+ 'true',
16
+ '1',
17
+ 'yes',
18
+ 'y'
19
+ ].includes(process.env.LEGACY_BLS_CLI ?? '');
20
+ const defaultBlsPathParts = defaultBlsPath.split('/');
11
21
  const parts = path.split('/');
12
- if (parts.length == 6 && parts[0] === 'm' && parts[1] === '12381' && parts[2] === '3600') {
13
- parts[3] = String(accountIndex);
14
- parts[5] = String(addressIndex);
22
+ if (parts.length == defaultBlsPathParts.length && parts.every((part, index)=>part === defaultBlsPathParts[index])) {
23
+ if (useLegacyBlsCli) {
24
+ // In 2.1.4, we were using address-index in parts[3] and did NOT use account-index, check lines 32 & 84
25
+ // https://github.com/AztecProtocol/aztec-packages/blob/v2.1.4/yarn-project/cli/src/cmds/validator_keys/shared.ts
26
+ parts[3] = String(addressIndex);
27
+ } else {
28
+ parts[3] = String(accountIndex);
29
+ parts[5] = String(addressIndex);
30
+ }
15
31
  return parts.join('/');
16
32
  }
17
33
  return path;
@@ -34,8 +50,7 @@ export function deriveEthAttester(mnemonic, baseAccountIndex, addressIndex, remo
34
50
  } : '0x' + Buffer.from(acct.getHdKey().privateKey).toString('hex');
35
51
  }
36
52
  export async function buildValidatorEntries(input) {
37
- const { validatorCount, publisherCount = 0, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, feeRecipient, coinbase, remoteSigner, fundingAccount } = input;
38
- const defaultBlsPath = 'm/12381/3600/0/0/0';
53
+ const { validatorCount, publisherCount = 0, publishers, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, feeRecipient, coinbase, remoteSigner, fundingAccount } = input;
39
54
  const summaries = [];
40
55
  const validators = await Promise.all(Array.from({
41
56
  length: validatorCount
@@ -52,7 +67,10 @@ export async function buildValidatorEntries(input) {
52
67
  } : ethAttester;
53
68
  let publisherField;
54
69
  const publisherAddresses = [];
55
- if (publisherCount > 0) {
70
+ if (publishers && publishers.length > 0) {
71
+ publisherAddresses.push(...publishers);
72
+ publisherField = publishers.length === 1 ? publishers[0] : publishers;
73
+ } else if (publisherCount > 0) {
56
74
  const publishersBaseIndex = baseAddressIndex + validatorCount + i * publisherCount;
57
75
  const publisherAccounts = Array.from({
58
76
  length: publisherCount
@@ -86,7 +104,7 @@ export async function buildValidatorEntries(input) {
86
104
  publisher: publisherField
87
105
  } : {},
88
106
  feeRecipient,
89
- coinbase,
107
+ coinbase: coinbase ?? attesterEthAddress,
90
108
  fundingAccount
91
109
  };
92
110
  }));
@@ -191,7 +209,7 @@ export function maybePrintJson(log, jsonFlag, obj) {
191
209
  continue;
192
210
  }
193
211
  const pub = await computeBlsPublicKeyCompressed(blsKey);
194
- const path = 'm/12381/3600/0/0/0';
212
+ const path = options.blsPath ?? defaultBlsPath;
195
213
  const fileBase = `${String(i + 1)}_${pub.slice(2, 18)}`;
196
214
  const keystorePath = await writeBn254BlsKeystore(options.outDir, fileBase, options.password, blsKey, pub, path);
197
215
  if (typeof att === 'object') {
@@ -1 +1 @@
1
- {"version":3,"file":"staker.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/staker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAuB,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAEV,gBAAgB,EAKjB,MAAM,4BA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AA4B,CAAC;AAQpC,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,WAAW,EAAE;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,iBAAiB,EAAE;QACjB,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH,CAAC;AA2KF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,WAAW,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CA+C1F"}
@@ -6,6 +6,7 @@ import { Fr } from '@aztec/foundation/fields';
6
6
  import { loadKeystoreFile } from '@aztec/node-keystore/loader';
7
7
  import { Wallet } from '@ethersproject/wallet';
8
8
  import { readFileSync, writeFileSync } from 'fs';
9
+ import { basename, dirname, join } from 'path';
9
10
  import { createPublicClient, fallback, http } from 'viem';
10
11
  import { privateKeyToAddress } from 'viem/accounts';
11
12
  /**
@@ -186,21 +187,21 @@ import { privateKeyToAddress } from 'viem/accounts';
186
187
  transport: fallback(l1RpcUrls.map((url)=>http(url)))
187
188
  });
188
189
  const gse = new GSEContract(publicClient, gseAddress);
189
- // Process each validator
190
- for (const validator of keystore.validators){
190
+ const keystoreBaseName = basename(from, '.json');
191
+ const outputDir = output ? output : dirname(from);
192
+ for(let i = 0; i < keystore.validators.length; i++){
193
+ const validator = keystore.validators[i];
191
194
  const outputs = await processAttesterAccounts(validator.attester, gse, password);
192
- allOutputs.push(...outputs);
195
+ for(let j = 0; j < outputs.length; j++){
196
+ allOutputs.push(outputs[j]);
197
+ }
193
198
  }
194
199
  if (allOutputs.length === 0) {
195
200
  log('No attesters with BLS keys found (skipping mnemonics and encrypted keystores without password)');
196
201
  return;
197
202
  }
198
- const jsonOutput = prettyPrintJSON(allOutputs);
199
- // Write to file if output is specified, otherwise log to stdout
200
- if (output) {
201
- writeFileSync(output, jsonOutput, 'utf-8');
202
- log(`Wrote staking data to ${output}`);
203
- } else {
204
- log(jsonOutput);
205
- }
203
+ // Write a single JSON file with all staker outputs
204
+ const stakerOutputPath = join(outputDir, `${keystoreBaseName}_staker_output.json`);
205
+ writeFileSync(stakerOutputPath, prettyPrintJSON(allOutputs), 'utf-8');
206
+ log(`Wrote staker output for ${allOutputs.length} validator(s) to ${stakerOutputPath}`);
206
207
  }
@@ -0,0 +1,25 @@
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ export declare const defaultBlsPath = "m/12381/3600/0/0/0";
3
+ export declare function validateBlsPathOptions(options: {
4
+ count?: number;
5
+ publisherCount?: number;
6
+ accountIndex?: number;
7
+ addressIndex?: number;
8
+ blsPath?: string;
9
+ ikm?: string;
10
+ }): void;
11
+ export declare function validateStakerOutputOptions(options: {
12
+ stakerOutput?: boolean;
13
+ gseAddress?: EthAddress;
14
+ l1RpcUrls?: string[];
15
+ l1ChainId?: number;
16
+ }): void;
17
+ export declare function validateRemoteSignerOptions(options: {
18
+ remoteSigner?: string;
19
+ mnemonic?: string;
20
+ }): void;
21
+ export declare function validatePublisherOptions(options: {
22
+ publishers?: string[];
23
+ publisherCount?: number;
24
+ }): void;
25
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,QAWA;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,QAeA;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,QAMhG;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,QAwBnG"}
@@ -0,0 +1,52 @@
1
+ import { ethPrivateKeySchema } from '@aztec/node-keystore';
2
+ export const defaultBlsPath = 'm/12381/3600/0/0/0';
3
+ export function validateBlsPathOptions(options) {
4
+ if (options.blsPath && options.blsPath !== defaultBlsPath) {
5
+ if (options.count && options.count !== 1 || options.publisherCount && options.publisherCount > 0 || options.accountIndex && options.accountIndex !== 0 || options.addressIndex && options.addressIndex !== 0) {
6
+ throw new Error('--bls-path cannot be used with --count, --publisher-count, --account-index, or --address-index');
7
+ }
8
+ }
9
+ }
10
+ export function validateStakerOutputOptions(options) {
11
+ if (!options.stakerOutput) {
12
+ return;
13
+ }
14
+ // Required options for staker output
15
+ if (!options.gseAddress) {
16
+ throw new Error('--gse-address is required when using --staker-output');
17
+ }
18
+ if (!options.l1RpcUrls || options.l1RpcUrls.length === 0) {
19
+ throw new Error('--l1-rpc-urls is required when using --staker-output');
20
+ }
21
+ if (options.l1ChainId === undefined) {
22
+ throw new Error('--l1-chain-id is required when using --staker-output');
23
+ }
24
+ }
25
+ export function validateRemoteSignerOptions(options) {
26
+ if (options.remoteSigner && !options.mnemonic) {
27
+ throw new Error('Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.');
28
+ }
29
+ }
30
+ export function validatePublisherOptions(options) {
31
+ if (options.publisherCount && options.publisherCount > 0 && options.publishers && options.publishers.length > 0) {
32
+ throw new Error('--publishers and --publisher-count cannot be used together');
33
+ }
34
+ if (options.publishers && options.publishers.length > 0) {
35
+ // Normalize each private key by adding 0x prefix if missing
36
+ const normalizedKeys = [];
37
+ for (const key of options.publishers){
38
+ let privateKey = key.trim();
39
+ if (!privateKey.startsWith('0x')) {
40
+ privateKey = '0x' + privateKey;
41
+ }
42
+ try {
43
+ ethPrivateKeySchema.parse(privateKey);
44
+ normalizedKeys.push(privateKey);
45
+ } catch (error) {
46
+ throw new Error(`Invalid publisher private key: ${error instanceof Error ? error.message : String(error)}`);
47
+ }
48
+ }
49
+ // Update the options with the normalized keys
50
+ options.publishers = normalizedKeys;
51
+ }
52
+ }
@@ -1,7 +1,7 @@
1
1
  import { type NetworkConfig, type NetworkNames } from '@aztec/foundation/config';
2
2
  /**
3
3
  * Fetches remote network configuration from GitHub with caching support.
4
- * Uses the reusable cachedFetch utility.
4
+ * Uses the reusable cachedFetch utility. Falls back to metadata.aztec.network if the default URL fails.
5
5
  *
6
6
  * @param networkName - The network name to fetch config for
7
7
  * @param cacheDir - Optional cache directory for storing fetched config
@@ -1 +1 @@
1
- {"version":3,"file":"network_config.d.ts","sourceRoot":"","sources":["../../src/config/network_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA0B,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAYzG;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAiDpC;AAED;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,WAAW,EAAE,YAAY,iBAoBjF"}
1
+ {"version":3,"file":"network_config.d.ts","sourceRoot":"","sources":["../../src/config/network_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA0B,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAazG;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAapC;AA0DD;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,WAAW,EAAE,YAAY,iBAoBjF"}
@@ -4,20 +4,34 @@ import { join } from 'path';
4
4
  import { cachedFetch } from './cached_fetch.js';
5
5
  import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
6
6
  const DEFAULT_CONFIG_URL = 'https://raw.githubusercontent.com/AztecProtocol/networks/refs/heads/main/network_config.json';
7
+ const FALLBACK_CONFIG_URL = 'https://metadata.aztec.network/network_config.json';
7
8
  const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
8
9
  /**
9
10
  * Fetches remote network configuration from GitHub with caching support.
10
- * Uses the reusable cachedFetch utility.
11
+ * Uses the reusable cachedFetch utility. Falls back to metadata.aztec.network if the default URL fails.
11
12
  *
12
13
  * @param networkName - The network name to fetch config for
13
14
  * @param cacheDir - Optional cache directory for storing fetched config
14
15
  * @returns Remote configuration for the specified network, or undefined if not found/error
15
16
  */ export async function getNetworkConfig(networkName, cacheDir) {
16
- let url;
17
+ // Try with the primary URL (env var or default)
17
18
  const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
18
- if (!configLocation) {
19
- return undefined;
19
+ // First try the primary config location
20
+ let config = await fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir);
21
+ // If primary fails and we were using the default URL, try the fallback
22
+ if (!config && configLocation === DEFAULT_CONFIG_URL) {
23
+ config = await fetchNetworkConfigFromUrl(FALLBACK_CONFIG_URL, networkName, cacheDir);
20
24
  }
25
+ return config;
26
+ }
27
+ /**
28
+ * Helper function to fetch network config from a specific URL.
29
+ * @param configLocation - The URL or file path to fetch from
30
+ * @param networkName - The network name to fetch config for
31
+ * @param cacheDir - Optional cache directory for storing fetched config
32
+ * @returns Remote configuration for the specified network, or undefined if not found/error
33
+ */ async function fetchNetworkConfigFromUrl(configLocation, networkName, cacheDir) {
34
+ let url;
21
35
  try {
22
36
  if (configLocation.includes('://')) {
23
37
  url = new URL(configLocation);