@aztec/cli 3.0.0-nightly.20250930 → 3.0.0-nightly.20251002

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 (36) hide show
  1. package/dest/cmds/devnet/bootstrap_network.js +1 -1
  2. package/dest/cmds/infrastructure/setup_l2_contract.js +2 -2
  3. package/dest/cmds/l1/deploy_l1_contracts.d.ts +1 -1
  4. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
  5. package/dest/cmds/l1/deploy_l1_contracts.js +2 -2
  6. package/dest/cmds/l1/index.d.ts.map +1 -1
  7. package/dest/cmds/l1/index.js +2 -2
  8. package/dest/config/cached_fetch.d.ts +18 -0
  9. package/dest/config/cached_fetch.d.ts.map +1 -0
  10. package/dest/config/cached_fetch.js +54 -0
  11. package/dest/config/chain_l2_config.d.ts +7 -4
  12. package/dest/config/chain_l2_config.d.ts.map +1 -1
  13. package/dest/config/chain_l2_config.js +107 -63
  14. package/dest/config/enrich_env.d.ts +4 -0
  15. package/dest/config/enrich_env.d.ts.map +1 -0
  16. package/dest/config/enrich_env.js +12 -0
  17. package/dest/config/index.d.ts +2 -0
  18. package/dest/config/index.d.ts.map +1 -1
  19. package/dest/config/index.js +2 -0
  20. package/dest/config/network_config.d.ts +19 -0
  21. package/dest/config/network_config.d.ts.map +1 -0
  22. package/dest/config/network_config.js +84 -0
  23. package/dest/utils/aztec.d.ts +1 -1
  24. package/dest/utils/aztec.d.ts.map +1 -1
  25. package/dest/utils/aztec.js +2 -1
  26. package/package.json +24 -24
  27. package/src/cmds/devnet/bootstrap_network.ts +1 -1
  28. package/src/cmds/infrastructure/setup_l2_contract.ts +2 -2
  29. package/src/cmds/l1/deploy_l1_contracts.ts +2 -0
  30. package/src/cmds/l1/index.ts +2 -0
  31. package/src/config/cached_fetch.ts +67 -0
  32. package/src/config/chain_l2_config.ts +128 -69
  33. package/src/config/enrich_env.ts +15 -0
  34. package/src/config/index.ts +2 -0
  35. package/src/config/network_config.ts +108 -0
  36. package/src/utils/aztec.ts +2 -0
@@ -19,7 +19,7 @@ export async function bootstrapNetwork(nodeUrl, l1Urls, l1ChainId, l1PrivateKey,
19
19
  // so all we need to do is register them to our pxe.
20
20
  const [accountData] = await getInitialTestAccountsData();
21
21
  const accountManager = await wallet.createSchnorrAccount(accountData.secret, accountData.salt, accountData.signingKey);
22
- const defaultAccountAddress = accountManager.getAddress();
22
+ const defaultAccountAddress = accountManager.address;
23
23
  const l1Client = createExtendedL1Client(l1Urls, l1PrivateKey ? privateKeyToAccount(l1PrivateKey) : // Note that this account needs to be funded on L1 !
24
24
  mnemonicToAccount(l1Mnemonic, {
25
25
  addressIndex
@@ -16,14 +16,14 @@ export async function setupL2Contracts(nodeUrl, testAccounts, json, log) {
16
16
  if (testAccounts) {
17
17
  log('setupL2Contracts: Deploying test accounts...');
18
18
  const initialAccountsData = await getInitialTestAccountsData();
19
- deployedAccountManagers = await deployFundedSchnorrAccounts(wallet, initialAccountsData, waitOpts);
19
+ deployedAccountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccountsData, waitOpts);
20
20
  }
21
21
  if (json) {
22
22
  const toPrint = {
23
23
  ...ProtocolContractAddress
24
24
  };
25
25
  deployedAccountManagers.forEach((a, i)=>{
26
- toPrint[`testAccount${i}`] = a.getAddress();
26
+ toPrint[`testAccount${i}`] = a.address;
27
27
  });
28
28
  log(JSON.stringify(toPrint, null, 2));
29
29
  }
@@ -1,4 +1,4 @@
1
1
  import { type EthAddress } from '@aztec/aztec.js';
2
2
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
- export declare function deployL1Contracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, testAccounts: boolean, sponsoredFPC: boolean, acceleratedTestDeployments: boolean, json: boolean, createVerificationJson: string | false, initialValidators: EthAddress[], realVerifier: boolean, log: LogFn, debugLogger: Logger): Promise<void>;
3
+ export declare function deployL1Contracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, testAccounts: boolean, sponsoredFPC: boolean, acceleratedTestDeployments: boolean, json: boolean, createVerificationJson: string | false, initialValidators: EthAddress[], realVerifier: boolean, existingToken: EthAddress | undefined, log: LogFn, debugLogger: Logger): Promise<void>;
4
4
  //# sourceMappingURL=deploy_l1_contracts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy_l1_contracts.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/deploy_l1_contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAM,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,0BAA0B,EAAE,OAAO,EACnC,IAAI,EAAE,OAAO,EACb,sBAAsB,EAAE,MAAM,GAAG,KAAK,EACtC,iBAAiB,EAAE,UAAU,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,iBA6DpB"}
1
+ {"version":3,"file":"deploy_l1_contracts.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/deploy_l1_contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAM,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAM3D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,0BAA0B,EAAE,OAAO,EACnC,IAAI,EAAE,OAAO,EACb,sBAAsB,EAAE,MAAM,GAAG,KAAK,EACtC,iBAAiB,EAAE,UAAU,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,aAAa,EAAE,UAAU,GAAG,SAAS,EACrC,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,iBA8DpB"}
@@ -5,7 +5,7 @@ import { SecretValue } from '@aztec/foundation/config';
5
5
  import { getGenesisValues } from '@aztec/world-state/testing';
6
6
  import { deployAztecContracts } from '../../utils/aztec.js';
7
7
  import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
8
- export async function deployL1Contracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, testAccounts, sponsoredFPC, acceleratedTestDeployments, json, createVerificationJson, initialValidators, realVerifier, log, debugLogger) {
8
+ export async function deployL1Contracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, testAccounts, sponsoredFPC, acceleratedTestDeployments, json, createVerificationJson, initialValidators, realVerifier, existingToken, log, debugLogger) {
9
9
  const config = getL1ContractsConfigEnvVars();
10
10
  const initialAccounts = testAccounts ? await getInitialTestAccountsData() : [];
11
11
  const sponsoredFPCAddress = sponsoredFPC ? await getSponsoredFPCAddress() : [];
@@ -16,7 +16,7 @@ export async function deployL1Contracts(rpcUrls, chainId, privateKey, mnemonic,
16
16
  withdrawer: a,
17
17
  bn254SecretKey: new SecretValue(Fr.random().toBigInt())
18
18
  }));
19
- const { l1ContractAddresses } = await deployAztecContracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, initialValidatorOperators, genesisArchiveRoot, fundingNeeded, acceleratedTestDeployments, config, realVerifier, createVerificationJson, debugLogger);
19
+ const { l1ContractAddresses } = await deployAztecContracts(rpcUrls, chainId, privateKey, mnemonic, mnemonicIndex, salt, initialValidatorOperators, genesisArchiveRoot, fundingNeeded, acceleratedTestDeployments, config, existingToken, realVerifier, createVerificationJson, debugLogger);
20
20
  if (json) {
21
21
  log(JSON.stringify(Object.fromEntries(Object.entries(l1ContractAddresses).map(([k, v])=>[
22
22
  k,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAa3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAghB/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/l1/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAa3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAkhB/E"}
@@ -8,10 +8,10 @@ const l1RpcUrlsOption = new Option('--l1-rpc-urls <string>', 'List of Ethereum h
8
8
  ]).makeOptionMandatory(true).argParser((arg)=>arg.split(',').map((url)=>url.trim()));
9
9
  const networkOption = new Option('--network <string>', 'Network to execute against').env('NETWORK');
10
10
  export function injectCommands(program, log, debugLogger) {
11
- program.command('deploy-l1-contracts').description('Deploys all necessary Ethereum contracts for Aztec.').addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('--validators <string>', 'Comma separated list of validators').option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', (arg)=>parseInt(arg), 0).addOption(l1ChainIdOption).option('--salt <number>', 'The optional salt to use in deployment', (arg)=>parseInt(arg)).option('--json', 'Output the contract addresses in JSON format').option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts').option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract').option('--accelerated-test-deployments', 'Fire and forget deployment transactions, use in testing only', false).option('--real-verifier', 'Deploy the real verifier', false).option('--create-verification-json [path]', 'Create JSON file for etherscan contract verification', false).action(async (options)=>{
11
+ program.command('deploy-l1-contracts').description('Deploys all necessary Ethereum contracts for Aztec.').addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('--validators <string>', 'Comma separated list of validators').option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', 'test test test test test test test test test test test junk').option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', (arg)=>parseInt(arg), 0).addOption(l1ChainIdOption).option('--salt <number>', 'The optional salt to use in deployment', (arg)=>parseInt(arg)).option('--json', 'Output the contract addresses in JSON format').option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts').option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract').option('--accelerated-test-deployments', 'Fire and forget deployment transactions, use in testing only', false).option('--real-verifier', 'Deploy the real verifier', false).option('--existing-token <address>', 'Use an existing ERC20 for both fee and staking', parseEthereumAddress).option('--create-verification-json [path]', 'Create JSON file for etherscan contract verification', false).action(async (options)=>{
12
12
  const { deployL1Contracts } = await import('./deploy_l1_contracts.js');
13
13
  const initialValidators = options.validators?.split(',').map((validator)=>EthAddress.fromString(validator)) || [];
14
- await deployL1Contracts(options.l1RpcUrls, options.l1ChainId, options.privateKey, options.mnemonic, options.mnemonicIndex, options.salt, options.testAccounts, options.sponsoredFpc, options.acceleratedTestDeployments, options.json, options.createVerificationJson, initialValidators, options.realVerifier, log, debugLogger);
14
+ await deployL1Contracts(options.l1RpcUrls, options.l1ChainId, options.privateKey, options.mnemonic, options.mnemonicIndex, options.salt, options.testAccounts, options.sponsoredFpc, options.acceleratedTestDeployments, options.json, options.createVerificationJson, initialValidators, options.realVerifier, options.existingToken, log, debugLogger);
15
15
  });
16
16
  program.command('deploy-new-rollup').description('Deploys a new rollup contract and adds it to the registry (if you are the owner).').requiredOption('-r, --registry-address <string>', 'The address of the registry contract', parseEthereumAddress).addOption(l1RpcUrlsOption).option('-pk, --private-key <string>', 'The private key to use for deployment', PRIVATE_KEY).option('--validators <string>', 'Comma separated list of validators').option('-m, --mnemonic <string>', 'The mnemonic to use in deployment', MNEMONIC ?? 'test test test test test test test test test test test junk').option('-i, --mnemonic-index <number>', 'The index of the mnemonic to use in deployment', (arg)=>parseInt(arg), 0).addOption(l1ChainIdOption).option('--salt <number>', 'The optional salt to use in deployment', (arg)=>parseInt(arg)).option('--json', 'Output the contract addresses in JSON format').option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts').option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract').option('--real-verifier', 'Deploy the real verifier', false).action(async (options)=>{
17
17
  const { deployNewRollup } = await import('./deploy_new_rollup.js');
@@ -0,0 +1,18 @@
1
+ export interface CachedFetchOptions {
2
+ /** Cache duration in milliseconds */
3
+ cacheDurationMs: number;
4
+ /** The cache file */
5
+ cacheFile?: string;
6
+ }
7
+ /**
8
+ * Fetches data from a URL with file-based caching support.
9
+ * This utility can be used by both remote config and bootnodes fetching.
10
+ *
11
+ * @param url - The URL to fetch from
12
+ * @param networkName - Network name for cache directory structure
13
+ * @param options - Caching and error handling options
14
+ * @param cacheDir - Optional cache directory (defaults to no caching)
15
+ * @returns The fetched and parsed JSON data, or undefined if fetch fails and throwOnError is false
16
+ */
17
+ export declare function cachedFetch<T = any>(url: string, options: CachedFetchOptions, fetch?: typeof globalThis.fetch, log?: import("@aztec/aztec.js").Logger): Promise<T | undefined>;
18
+ //# sourceMappingURL=cached_fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cached_fetch.d.ts","sourceRoot":"","sources":["../../src/config/cached_fetch.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,GAAG,EACvC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,EAC3B,KAAK,0BAAmB,EACxB,GAAG,mCAA+B,GACjC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAuCxB"}
@@ -0,0 +1,54 @@
1
+ import { createLogger } from '@aztec/aztec.js';
2
+ import { mkdir, readFile, stat, writeFile } from 'fs/promises';
3
+ import { dirname } from 'path';
4
+ /**
5
+ * Fetches data from a URL with file-based caching support.
6
+ * This utility can be used by both remote config and bootnodes fetching.
7
+ *
8
+ * @param url - The URL to fetch from
9
+ * @param networkName - Network name for cache directory structure
10
+ * @param options - Caching and error handling options
11
+ * @param cacheDir - Optional cache directory (defaults to no caching)
12
+ * @returns The fetched and parsed JSON data, or undefined if fetch fails and throwOnError is false
13
+ */ export async function cachedFetch(url, options, fetch = globalThis.fetch, log = createLogger('cached_fetch')) {
14
+ const { cacheDurationMs, cacheFile } = options;
15
+ // Try to read from cache first
16
+ try {
17
+ if (cacheFile) {
18
+ const info = await stat(cacheFile);
19
+ if (info.mtimeMs + cacheDurationMs > Date.now()) {
20
+ const cachedData = JSON.parse(await readFile(cacheFile, 'utf-8'));
21
+ return cachedData;
22
+ }
23
+ }
24
+ } catch {
25
+ log.trace('Failed to read data from cache');
26
+ }
27
+ try {
28
+ const response = await fetch(url);
29
+ if (!response.ok) {
30
+ log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
31
+ return undefined;
32
+ }
33
+ const data = await response.json();
34
+ try {
35
+ if (cacheFile) {
36
+ await mkdir(dirname(cacheFile), {
37
+ recursive: true
38
+ });
39
+ await writeFile(cacheFile, JSON.stringify(data), 'utf-8');
40
+ }
41
+ } catch (err) {
42
+ log.warn('Failed to cache data on disk: ' + cacheFile, {
43
+ cacheFile,
44
+ err
45
+ });
46
+ }
47
+ return data;
48
+ } catch (err) {
49
+ log.warn(`Failed to fetch from ${url}`, {
50
+ err
51
+ });
52
+ return undefined;
53
+ }
54
+ }
@@ -8,24 +8,27 @@ export type L2ChainConfig = L1ContractsConfig & Omit<SlasherConfig, 'slashValida
8
8
  sponsoredFPC: boolean;
9
9
  p2pEnabled: boolean;
10
10
  p2pBootstrapNodes: string[];
11
- registryAddress: string;
12
- slashFactoryAddress: string;
13
- feeAssetHandlerAddress: string;
14
11
  seqMinTxsPerBlock: number;
15
12
  seqMaxTxsPerBlock: number;
16
13
  realProofs: boolean;
17
- snapshotsUrl: string;
14
+ snapshotsUrls: string[];
18
15
  autoUpdate: SharedNodeConfig['autoUpdate'];
19
16
  autoUpdateUrl?: string;
20
17
  maxTxPoolSize: number;
21
18
  publicIncludeMetrics?: string[];
22
19
  publicMetricsCollectorUrl?: string;
23
20
  publicMetricsCollectFrom?: string[];
21
+ dbMapSizeKb: number;
22
+ archiverStoreMapSizeKb: number;
23
+ noteHashTreeMapSizeKb: number;
24
+ nullifierTreeMapSizeKb: number;
25
+ publicDataTreeMapSizeKb: number;
24
26
  sentinelEnabled: boolean;
25
27
  };
26
28
  export declare const stagingIgnitionL2ChainConfig: L2ChainConfig;
27
29
  export declare const stagingPublicL2ChainConfig: L2ChainConfig;
28
30
  export declare const testnetL2ChainConfig: L2ChainConfig;
31
+ export declare const ignitionL2ChainConfig: L2ChainConfig;
29
32
  export declare function getBootnodes(networkName: NetworkNames, cacheDir?: string): Promise<any>;
30
33
  export declare function getL2ChainConfig(networkName: NetworkNames, cacheDir?: string): Promise<L2ChainConfig | undefined>;
31
34
  export declare function enrichEnvironmentWithChainConfig(networkName: NetworkNames): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AASrE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,IAAI,CAAC,aAAa,EAAE,sBAAsB,GAAG,uBAAuB,CAAC,GAAG;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpC,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAuCJ,eAAO,MAAM,4BAA4B,EAAE,aA+E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAmDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAqDlC,CAAC;AAIF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,gBAgC9E;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAkBpC;AAuBD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBA0F/E"}
1
+ {"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAarE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,IAAI,CAAC,aAAa,EAAE,sBAAsB,GAAG,uBAAuB,CAAC,GAAG;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IAIpC,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uBAAuB,EAAE,MAAM,CAAC;IAGhC,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AA+CJ,eAAO,MAAM,4BAA4B,EAAE,aA8E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAkDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAoDlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aAgFnC,CAAC;AAIF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,gBAQ9E;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAoBpC;AAMD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBA4F/E"}
@@ -1,11 +1,14 @@
1
1
  import { DefaultL1ContractsConfig } from '@aztec/ethereum';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
- import { mkdir, readFile, stat, writeFile } from 'fs/promises';
4
- import path, { dirname, join } from 'path';
3
+ import path, { join } from 'path';
5
4
  import publicIncludeMetrics from '../../public_include_metric_prefixes.json' with {
6
5
  type: 'json'
7
6
  };
7
+ import { cachedFetch } from './cached_fetch.js';
8
+ import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
8
9
  const SNAPSHOT_URL = 'https://pub-f4a8c34d4bb7441ebf8f48d904512180.r2.dev/snapshots';
10
+ const defaultDBMapSizeKb = 128 * 1_024 * 1_024; // 128 GB
11
+ const tbMapSizeKb = 1_024 * 1_024 * 1_024; // 1 TB
9
12
  const DefaultSlashConfig = {
10
13
  /** Tally-style slashing */ slasherFlavor: 'tally',
11
14
  /** Allow one round for vetoing */ slashingExecutionDelayInRounds: 1,
@@ -34,19 +37,25 @@ const DefaultSlashConfig = {
34
37
  sentinelEnabled: true,
35
38
  slashExecuteRoundsLookBack: 4
36
39
  };
40
+ const DefaultNetworkDBMapSizeConfig = {
41
+ dbMapSizeKb: defaultDBMapSizeKb,
42
+ archiverStoreMapSizeKb: tbMapSizeKb,
43
+ noteHashTreeMapSizeKb: tbMapSizeKb,
44
+ nullifierTreeMapSizeKb: tbMapSizeKb,
45
+ publicDataTreeMapSizeKb: tbMapSizeKb
46
+ };
37
47
  export const stagingIgnitionL2ChainConfig = {
38
48
  l1ChainId: 11155111,
39
49
  testAccounts: false,
40
50
  sponsoredFPC: false,
41
51
  p2pEnabled: true,
42
52
  p2pBootstrapNodes: [],
43
- registryAddress: '0x5f85fa0f40bc4b5ccd53c9f34258aa55d25cdde8',
44
- slashFactoryAddress: '0x257db2ca1471b7f76f414d2997404bfbe916c8c9',
45
- feeAssetHandlerAddress: '0x67d645b0a3e053605ea861d7e8909be6669812c4',
46
53
  seqMinTxsPerBlock: 0,
47
54
  seqMaxTxsPerBlock: 0,
48
55
  realProofs: true,
49
- snapshotsUrl: `${SNAPSHOT_URL}/staging-ignition/`,
56
+ snapshotsUrls: [
57
+ `${SNAPSHOT_URL}/staging-ignition/`
58
+ ],
50
59
  autoUpdate: 'config-and-version',
51
60
  autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/staging-ignition.json',
52
61
  maxTxPoolSize: 100_000_000,
@@ -97,7 +106,8 @@ export const stagingIgnitionL2ChainConfig = {
97
106
  slashOffenseExpirationRounds: 8,
98
107
  sentinelEnabled: true,
99
108
  slashingDisableDuration: 5 * 24 * 60 * 60,
100
- slashExecuteRoundsLookBack: 4
109
+ slashExecuteRoundsLookBack: 4,
110
+ ...DefaultNetworkDBMapSizeConfig
101
111
  };
102
112
  export const stagingPublicL2ChainConfig = {
103
113
  l1ChainId: 11155111,
@@ -105,13 +115,12 @@ export const stagingPublicL2ChainConfig = {
105
115
  sponsoredFPC: true,
106
116
  p2pEnabled: true,
107
117
  p2pBootstrapNodes: [],
108
- registryAddress: '0x2e48addca360da61e4d6c21ff2b1961af56eb83b',
109
- slashFactoryAddress: '0xe19410632fd00695bc5a08dd82044b7b26317742',
110
- feeAssetHandlerAddress: '0xb46dc3d91f849999330b6dd93473fa29fc45b076',
111
118
  seqMinTxsPerBlock: 0,
112
119
  seqMaxTxsPerBlock: 20,
113
120
  realProofs: true,
114
- snapshotsUrl: `${SNAPSHOT_URL}/staging-public/`,
121
+ snapshotsUrls: [
122
+ `${SNAPSHOT_URL}/staging-public/`
123
+ ],
115
124
  autoUpdate: 'config-and-version',
116
125
  autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/staging-public.json',
117
126
  publicIncludeMetrics,
@@ -135,7 +144,8 @@ export const stagingPublicL2ChainConfig = {
135
144
  /** The mana target for the rollup */ manaTarget: DefaultL1ContractsConfig.manaTarget,
136
145
  /** The proving cost per mana */ provingCostPerMana: DefaultL1ContractsConfig.provingCostPerMana,
137
146
  /** Exit delay for stakers */ exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
138
- ...DefaultSlashConfig
147
+ ...DefaultSlashConfig,
148
+ ...DefaultNetworkDBMapSizeConfig
139
149
  };
140
150
  export const testnetL2ChainConfig = {
141
151
  l1ChainId: 11155111,
@@ -143,13 +153,12 @@ export const testnetL2ChainConfig = {
143
153
  sponsoredFPC: true,
144
154
  p2pEnabled: true,
145
155
  p2pBootstrapNodes: [],
146
- registryAddress: '0xcfe61b2574984326679cd15c6566fbd4a724f3b4',
147
- slashFactoryAddress: '0x58dc5b14f9d3085c9106f5b8208a1026f94614f0',
148
- feeAssetHandlerAddress: '0x7abdec6e68ae27c37feb6a77371382a109ec4763',
149
156
  seqMinTxsPerBlock: 0,
150
157
  seqMaxTxsPerBlock: 20,
151
158
  realProofs: true,
152
- snapshotsUrl: `${SNAPSHOT_URL}/testnet/`,
159
+ snapshotsUrls: [
160
+ `${SNAPSHOT_URL}/testnet/`
161
+ ],
153
162
  autoUpdate: 'config-and-version',
154
163
  autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/testnet.json',
155
164
  maxTxPoolSize: 100_000_000,
@@ -175,38 +184,82 @@ export const testnetL2ChainConfig = {
175
184
  /** Exit delay for stakers */ exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
176
185
  ...DefaultSlashConfig,
177
186
  slashPrunePenalty: 0n,
178
- slashDataWithholdingPenalty: 0n
187
+ slashDataWithholdingPenalty: 0n,
188
+ ...DefaultNetworkDBMapSizeConfig
189
+ };
190
+ export const ignitionL2ChainConfig = {
191
+ l1ChainId: 1,
192
+ testAccounts: false,
193
+ sponsoredFPC: false,
194
+ p2pEnabled: true,
195
+ p2pBootstrapNodes: [],
196
+ seqMinTxsPerBlock: 0,
197
+ seqMaxTxsPerBlock: 0,
198
+ realProofs: true,
199
+ snapshotsUrls: [
200
+ 'https://storage.googleapis.com/aztec-testnet/snapshots/ignition/'
201
+ ],
202
+ autoUpdate: 'notify',
203
+ autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/ignition.json',
204
+ maxTxPoolSize: 100_000_000,
205
+ publicIncludeMetrics,
206
+ publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
207
+ publicMetricsCollectFrom: [
208
+ 'sequencer'
209
+ ],
210
+ /** How many seconds an L1 slot lasts. */ ethereumSlotDuration: 12,
211
+ /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 72,
212
+ /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
213
+ /** The target validator committee size. */ aztecTargetCommitteeSize: 24,
214
+ /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
215
+ /** How many sequencers must agree with a slash for it to be executed. */ slashingQuorum: 65,
216
+ /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: 2,
217
+ localEjectionThreshold: 196_000n * 10n ** 18n,
218
+ slashingDisableDuration: 5 * 24 * 60 * 60,
219
+ slashingRoundSizeInEpochs: 4,
220
+ slashingLifetimeInRounds: 40,
221
+ slashingExecutionDelayInRounds: 28,
222
+ slashAmountSmall: 2_000n * 10n ** 18n,
223
+ slashAmountMedium: 10_000n * 10n ** 18n,
224
+ slashAmountLarge: 50_000n * 10n ** 18n,
225
+ slashingOffsetInRounds: 2,
226
+ slasherFlavor: 'tally',
227
+ slashingVetoer: EthAddress.ZERO,
228
+ /** The mana target for the rollup */ manaTarget: 0n,
229
+ exitDelaySeconds: 5 * 24 * 60 * 60,
230
+ /** The proving cost per mana */ provingCostPerMana: 0n,
231
+ ejectionThreshold: 100_000n * 10n ** 18n,
232
+ activationThreshold: 200_000n * 10n ** 18n,
233
+ governanceProposerRoundSize: 300,
234
+ governanceProposerQuorum: 151,
235
+ // Node slashing config
236
+ // TODO TMNT-330
237
+ slashMinPenaltyPercentage: 0.5,
238
+ slashMaxPenaltyPercentage: 2.0,
239
+ slashInactivityTargetPercentage: 0.7,
240
+ slashInactivityConsecutiveEpochThreshold: 2,
241
+ slashInactivityPenalty: 2_000n * 10n ** 18n,
242
+ slashPrunePenalty: 0n,
243
+ slashDataWithholdingPenalty: 0n,
244
+ slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
245
+ slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
246
+ slashUnknownPenalty: 2_000n * 10n ** 18n,
247
+ slashBroadcastedInvalidBlockPenalty: 0n,
248
+ slashMaxPayloadSize: 50,
249
+ slashGracePeriodL2Slots: 32 * 4,
250
+ slashOffenseExpirationRounds: 8,
251
+ sentinelEnabled: true,
252
+ slashExecuteRoundsLookBack: 4,
253
+ ...DefaultNetworkDBMapSizeConfig
179
254
  };
180
255
  const BOOTNODE_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour;
181
256
  export async function getBootnodes(networkName, cacheDir) {
182
- const cacheFile = cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined;
183
- try {
184
- if (cacheFile) {
185
- const info = await stat(cacheFile);
186
- if (info.mtimeMs + BOOTNODE_CACHE_DURATION_MS > Date.now()) {
187
- return JSON.parse(await readFile(cacheFile, 'utf-8'))['bootnodes'];
188
- }
189
- }
190
- } catch {
191
- // no-op. Get the remote-file
192
- }
193
257
  const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
194
- const response = await fetch(url);
195
- if (!response.ok) {
196
- throw new Error(`Failed to fetch basic contract addresses from ${url}. Check you are using a correct network name.`);
197
- }
198
- const json = await response.json();
199
- try {
200
- if (cacheFile) {
201
- await mkdir(dirname(cacheFile), {
202
- recursive: true
203
- });
204
- await writeFile(cacheFile, JSON.stringify(json), 'utf-8');
205
- }
206
- } catch {
207
- // no-op
208
- }
209
- return json['bootnodes'];
258
+ const data = await cachedFetch(url, {
259
+ cacheDurationMs: BOOTNODE_CACHE_DURATION_MS,
260
+ cacheFile: cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined
261
+ });
262
+ return data?.bootnodes;
210
263
  }
211
264
  export async function getL2ChainConfig(networkName, cacheDir) {
212
265
  let config;
@@ -222,6 +275,10 @@ export async function getL2ChainConfig(networkName, cacheDir) {
222
275
  config = {
223
276
  ...stagingIgnitionL2ChainConfig
224
277
  };
278
+ } else if (networkName === 'ignition') {
279
+ config = {
280
+ ...ignitionL2ChainConfig
281
+ };
225
282
  }
226
283
  if (!config) {
227
284
  return undefined;
@@ -233,21 +290,6 @@ export async function getL2ChainConfig(networkName, cacheDir) {
233
290
  }
234
291
  return config;
235
292
  }
236
- function enrichVar(envVar, value) {
237
- // Don't override
238
- if (process.env[envVar] || value === undefined) {
239
- return;
240
- }
241
- process.env[envVar] = value;
242
- }
243
- function enrichEthAddressVar(envVar, value) {
244
- // EthAddress doesn't like being given empty strings
245
- if (value === '') {
246
- enrichVar(envVar, EthAddress.ZERO.toString());
247
- return;
248
- }
249
- enrichVar(envVar, value);
250
- }
251
293
  function getDefaultDataDir(networkName) {
252
294
  return path.join(process.env.HOME || '~', '.aztec', networkName, 'data');
253
295
  }
@@ -270,8 +312,13 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
270
312
  enrichVar('SEQ_MAX_TX_PER_BLOCK', config.seqMaxTxsPerBlock.toString());
271
313
  enrichVar('PROVER_REAL_PROOFS', config.realProofs.toString());
272
314
  enrichVar('PXE_PROVER_ENABLED', config.realProofs.toString());
273
- enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
315
+ enrichVar('SYNC_SNAPSHOTS_URLS', config.snapshotsUrls.join(','));
274
316
  enrichVar('P2P_MAX_TX_POOL_SIZE', config.maxTxPoolSize.toString());
317
+ enrichVar('DATA_STORE_MAP_SIZE_KB', config.dbMapSizeKb.toString());
318
+ enrichVar('ARCHIVER_STORE_MAP_SIZE_KB', config.archiverStoreMapSizeKb.toString());
319
+ enrichVar('NOTE_HASH_TREE_MAP_SIZE_KB', config.noteHashTreeMapSizeKb.toString());
320
+ enrichVar('NULLIFIER_TREE_MAP_SIZE_KB', config.nullifierTreeMapSizeKb.toString());
321
+ enrichVar('PUBLIC_DATA_TREE_MAP_SIZE_KB', config.publicDataTreeMapSizeKb.toString());
275
322
  if (config.autoUpdate) {
276
323
  enrichVar('AUTO_UPDATE', config.autoUpdate?.toString());
277
324
  }
@@ -287,9 +334,6 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
287
334
  if (config.publicMetricsCollectFrom) {
288
335
  enrichVar('PUBLIC_OTEL_COLLECT_FROM', config.publicMetricsCollectFrom.join(','));
289
336
  }
290
- enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', config.registryAddress);
291
- enrichEthAddressVar('SLASH_FACTORY_CONTRACT_ADDRESS', config.slashFactoryAddress);
292
- enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', config.feeAssetHandlerAddress);
293
337
  // Deployment stuff
294
338
  enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
295
339
  enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
@@ -0,0 +1,4 @@
1
+ import type { EnvVar } from '@aztec/foundation/config';
2
+ export declare function enrichVar(envVar: EnvVar, value: string | undefined): void;
3
+ export declare function enrichEthAddressVar(envVar: EnvVar, value: string): void;
4
+ //# sourceMappingURL=enrich_env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrich_env.d.ts","sourceRoot":"","sources":["../../src/config/enrich_env.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,QAMlE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAGhE"}
@@ -0,0 +1,12 @@
1
+ import { EthAddress } from '@aztec/aztec.js';
2
+ export function enrichVar(envVar, value) {
3
+ // Don't override
4
+ if (process.env[envVar] || value === undefined) {
5
+ return;
6
+ }
7
+ process.env[envVar] = value;
8
+ }
9
+ export function enrichEthAddressVar(envVar, value) {
10
+ // EthAddress doesn't like being given empty strings
11
+ enrichVar(envVar, value || EthAddress.ZERO.toString());
12
+ }
@@ -1,3 +1,5 @@
1
+ export * from './cached_fetch.js';
1
2
  export * from './chain_l2_config.js';
2
3
  export * from './get_l1_config.js';
4
+ export * from './network_config.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
@@ -1,2 +1,4 @@
1
+ export * from './cached_fetch.js';
1
2
  export * from './chain_l2_config.js';
2
3
  export * from './get_l1_config.js';
4
+ export * from './network_config.js';
@@ -0,0 +1,19 @@
1
+ import { type NetworkConfig, type NetworkNames } from '@aztec/foundation/config';
2
+ /**
3
+ * Fetches remote network configuration from GitHub with caching support.
4
+ * Uses the reusable cachedFetch utility.
5
+ *
6
+ * @param networkName - The network name to fetch config for
7
+ * @param cacheDir - Optional cache directory for storing fetched config
8
+ * @returns Remote configuration for the specified network, or undefined if not found/error
9
+ */
10
+ export declare function getNetworkConfig(networkName: NetworkNames, cacheDir?: string): Promise<NetworkConfig | undefined>;
11
+ /**
12
+ * Enriches environment variables with remote network configuration.
13
+ * This function is called before node config initialization to set env vars
14
+ * from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
15
+ *
16
+ * @param networkName - The network name to fetch remote config for
17
+ */
18
+ export declare function enrichEnvironmentWithNetworkConfig(networkName: NetworkNames): Promise<void>;
19
+ //# sourceMappingURL=network_config.d.ts.map
@@ -0,0 +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,iBA0BjF"}
@@ -0,0 +1,84 @@
1
+ import { NetworkConfigMapSchema } from '@aztec/foundation/config';
2
+ import { readFile } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import { cachedFetch } from './cached_fetch.js';
5
+ import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
6
+ const DEFAULT_CONFIG_URL = 'https://raw.githubusercontent.com/AztecProtocol/networks/refs/heads/main/network_config.json';
7
+ const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
8
+ /**
9
+ * Fetches remote network configuration from GitHub with caching support.
10
+ * Uses the reusable cachedFetch utility.
11
+ *
12
+ * @param networkName - The network name to fetch config for
13
+ * @param cacheDir - Optional cache directory for storing fetched config
14
+ * @returns Remote configuration for the specified network, or undefined if not found/error
15
+ */ export async function getNetworkConfig(networkName, cacheDir) {
16
+ let url;
17
+ const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
18
+ if (!configLocation) {
19
+ return undefined;
20
+ }
21
+ try {
22
+ if (configLocation.includes('://')) {
23
+ url = new URL(configLocation);
24
+ } else {
25
+ url = new URL(`file://${configLocation}`);
26
+ }
27
+ } catch {
28
+ /* no-op */ }
29
+ if (!url) {
30
+ return undefined;
31
+ }
32
+ try {
33
+ let rawConfig;
34
+ if (url.protocol === 'http:' || url.protocol === 'https:') {
35
+ rawConfig = await cachedFetch(url.href, {
36
+ cacheDurationMs: NETWORK_CONFIG_CACHE_DURATION_MS,
37
+ cacheFile: cacheDir ? join(cacheDir, networkName, 'network_config.json') : undefined
38
+ });
39
+ } else if (url.protocol === 'file:') {
40
+ rawConfig = JSON.parse(await readFile(url.pathname, 'utf-8'));
41
+ } else {
42
+ throw new Error('Unsupported Aztec network config protocol: ' + url.href);
43
+ }
44
+ if (!rawConfig) {
45
+ return undefined;
46
+ }
47
+ const networkConfigMap = NetworkConfigMapSchema.parse(rawConfig);
48
+ if (networkName in networkConfigMap) {
49
+ return networkConfigMap[networkName];
50
+ } else {
51
+ return undefined;
52
+ }
53
+ } catch {
54
+ return undefined;
55
+ }
56
+ }
57
+ /**
58
+ * Enriches environment variables with remote network configuration.
59
+ * This function is called before node config initialization to set env vars
60
+ * from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
61
+ *
62
+ * @param networkName - The network name to fetch remote config for
63
+ */ export async function enrichEnvironmentWithNetworkConfig(networkName) {
64
+ if (networkName === 'local') {
65
+ return; // No remote config for local development
66
+ }
67
+ const cacheDir = process.env.DATA_DIRECTORY ? join(process.env.DATA_DIRECTORY, 'cache') : undefined;
68
+ const networkConfig = await getNetworkConfig(networkName, cacheDir);
69
+ if (!networkConfig) {
70
+ return;
71
+ }
72
+ enrichVar('BOOTSTRAP_NODES', networkConfig.bootnodes.join(','));
73
+ enrichVar('L1_CHAIN_ID', String(networkConfig.l1ChainId));
74
+ // Snapshot synch only supports a single source. Take the first
75
+ // See A-101 for more details
76
+ const firstSource = networkConfig[0];
77
+ if (firstSource) {
78
+ enrichVar('SYNC_SNAPSHOTS_URL', networkConfig.snapshots.join(','));
79
+ }
80
+ enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', networkConfig.registryAddress.toString());
81
+ if (networkConfig.feeAssetHandlerAddress) {
82
+ enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', networkConfig.feeAssetHandlerAddress.toString());
83
+ }
84
+ }
@@ -18,7 +18,7 @@ export declare function getFunctionAbi(artifact: ContractArtifact, fnName: strin
18
18
  * @param privateKey - The private key to be used in contract deployment.
19
19
  * @param mnemonic - The mnemonic to be used in contract deployment.
20
20
  */
21
- export declare function deployAztecContracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, initialValidators: Operator[], genesisArchiveRoot: Fr, feeJuicePortalInitialBalance: bigint, acceleratedTestDeployments: boolean, config: L1ContractsConfig, realVerifier: boolean, createVerificationJson: string | false, debugLogger: Logger): Promise<DeployL1ContractsReturnType>;
21
+ export declare function deployAztecContracts(rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, initialValidators: Operator[], genesisArchiveRoot: Fr, feeJuicePortalInitialBalance: bigint, acceleratedTestDeployments: boolean, config: L1ContractsConfig, existingToken: EthAddress | undefined, realVerifier: boolean, createVerificationJson: string | false, debugLogger: Logger): Promise<DeployL1ContractsReturnType>;
22
22
  export declare function deployNewRollupContracts(registryAddress: EthAddress, rpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mnemonicIndex: number, salt: number | undefined, initialValidators: Operator[], genesisArchiveRoot: Fr, feeJuicePortalInitialBalance: bigint, config: L1ContractsConfig, realVerifier: boolean, logger: Logger): Promise<{
23
23
  rollup: RollupContract;
24
24
  slashFactoryAddress: EthAddress;