@aztec/cli 2.0.3 → 2.1.0-rc.1

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.
@@ -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 getInitialTestAccounts() : [];
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
+ }
@@ -9,9 +9,6 @@ export type L2ChainConfig = L1ContractsConfig & Pick<P2PConfig, 'txPoolDeleteTxs
9
9
  sponsoredFPC: boolean;
10
10
  p2pEnabled: boolean;
11
11
  p2pBootstrapNodes: string[];
12
- registryAddress: string;
13
- slashFactoryAddress: string;
14
- feeAssetHandlerAddress: string;
15
12
  seqMinTxsPerBlock: number;
16
13
  seqMaxTxsPerBlock: number;
17
14
  realProofs: boolean;
@@ -22,11 +19,17 @@ export type L2ChainConfig = L1ContractsConfig & Pick<P2PConfig, 'txPoolDeleteTxs
22
19
  publicIncludeMetrics?: string[];
23
20
  publicMetricsCollectorUrl?: string;
24
21
  publicMetricsCollectFrom?: string[];
22
+ dbMapSizeKb: number;
23
+ archiverStoreMapSizeKb: number;
24
+ noteHashTreeMapSizeKb: number;
25
+ nullifierTreeMapSizeKb: number;
26
+ publicDataTreeMapSizeKb: number;
25
27
  sentinelEnabled: boolean;
26
28
  };
27
29
  export declare const stagingIgnitionL2ChainConfig: L2ChainConfig;
28
30
  export declare const stagingPublicL2ChainConfig: L2ChainConfig;
29
31
  export declare const testnetL2ChainConfig: L2ChainConfig;
32
+ export declare const ignitionL2ChainConfig: L2ChainConfig;
30
33
  export declare function getBootnodes(networkName: NetworkNames, cacheDir?: string): Promise<any>;
31
34
  export declare function getL2ChainConfig(networkName: NetworkNames, cacheDir?: string): Promise<L2ChainConfig | undefined>;
32
35
  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,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAOrE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,IAAI,CAAC,SAAS,EAAE,2BAA2B,CAAC,GAC5C,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;AAoCJ,eAAO,MAAM,4BAA4B,EAAE,aA2E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAgDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAmDlC,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,iBAyF/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,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAWrE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,IAAI,CAAC,SAAS,EAAE,2BAA2B,CAAC,GAC5C,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,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;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,aA+E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAmDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAsDlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aA+EnC,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,16 +1,20 @@
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';
9
+ const defaultDBMapSizeKb = 128 * 1_024 * 1_024; // 128 GB
10
+ const tbMapSizeKb = 1_024 * 1_024 * 1_024; // 1 TB
8
11
  const DefaultSlashConfig = {
9
12
  /** Tally-style slashing */ slasherFlavor: 'tally',
10
13
  /** Allow one round for vetoing */ slashingExecutionDelayInRounds: 1,
11
14
  /** How long for a slash payload to be executed */ slashingLifetimeInRounds: 5,
12
15
  /** Allow 2 rounds to discover faults */ slashingOffsetInRounds: 2,
13
16
  /** No slash vetoer */ slashingVetoer: EthAddress.ZERO,
17
+ /** Use default disable duration */ slashingDisableDuration: DefaultL1ContractsConfig.slashingDisableDuration,
14
18
  /** Use default slash amounts */ slashAmountSmall: DefaultL1ContractsConfig.slashAmountSmall,
15
19
  slashAmountMedium: DefaultL1ContractsConfig.slashAmountMedium,
16
20
  slashAmountLarge: DefaultL1ContractsConfig.slashAmountLarge,
@@ -25,11 +29,19 @@ const DefaultSlashConfig = {
25
29
  slashProposeInvalidAttestationsPenalty: DefaultL1ContractsConfig.slashAmountLarge,
26
30
  slashAttestDescendantOfInvalidPenalty: DefaultL1ContractsConfig.slashAmountLarge,
27
31
  slashUnknownPenalty: DefaultL1ContractsConfig.slashAmountSmall,
28
- slashBroadcastedInvalidBlockPenalty: DefaultL1ContractsConfig.slashAmountMedium,
32
+ slashBroadcastedInvalidBlockPenalty: 0n,
29
33
  slashMaxPayloadSize: 50,
30
34
  slashGracePeriodL2Slots: 32 * 2,
31
35
  slashOffenseExpirationRounds: 8,
32
- sentinelEnabled: true
36
+ sentinelEnabled: true,
37
+ slashExecuteRoundsLookBack: 4
38
+ };
39
+ const DefaultNetworkDBMapSizeConfig = {
40
+ dbMapSizeKb: defaultDBMapSizeKb,
41
+ archiverStoreMapSizeKb: tbMapSizeKb,
42
+ noteHashTreeMapSizeKb: tbMapSizeKb,
43
+ nullifierTreeMapSizeKb: tbMapSizeKb,
44
+ publicDataTreeMapSizeKb: tbMapSizeKb
33
45
  };
34
46
  export const stagingIgnitionL2ChainConfig = {
35
47
  l1ChainId: 11155111,
@@ -37,9 +49,6 @@ export const stagingIgnitionL2ChainConfig = {
37
49
  sponsoredFPC: false,
38
50
  p2pEnabled: true,
39
51
  p2pBootstrapNodes: [],
40
- registryAddress: '0x6c04b1c116ec1ea0f918e3cc91e87b0af3e23b73',
41
- slashFactoryAddress: '',
42
- feeAssetHandlerAddress: '',
43
52
  seqMinTxsPerBlock: 0,
44
53
  seqMaxTxsPerBlock: 0,
45
54
  realProofs: true,
@@ -57,11 +66,13 @@ export const stagingIgnitionL2ChainConfig = {
57
66
  /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 72,
58
67
  /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
59
68
  /** The target validator committee size. */ aztecTargetCommitteeSize: 24,
69
+ /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: 2,
60
70
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
61
71
  /** How many sequencers must agree with a slash for it to be executed. */ slashingQuorum: 65,
62
72
  slashingRoundSizeInEpochs: 4,
63
73
  slashingLifetimeInRounds: 40,
64
74
  slashingExecutionDelayInRounds: 28,
75
+ slashingDisableDuration: 5 * 24 * 60 * 60,
65
76
  slashAmountSmall: 2_000n * 10n ** 18n,
66
77
  slashAmountMedium: 10_000n * 10n ** 18n,
67
78
  slashAmountLarge: 50_000n * 10n ** 18n,
@@ -73,6 +84,7 @@ export const stagingIgnitionL2ChainConfig = {
73
84
  /** The proving cost per mana */ provingCostPerMana: 0n,
74
85
  ejectionThreshold: 100_000n * 10n ** 18n,
75
86
  activationThreshold: 200_000n * 10n ** 18n,
87
+ localEjectionThreshold: 196_000n * 10n ** 18n,
76
88
  governanceProposerRoundSize: 300,
77
89
  governanceProposerQuorum: 151,
78
90
  // Node slashing config
@@ -87,11 +99,13 @@ export const stagingIgnitionL2ChainConfig = {
87
99
  slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
88
100
  slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
89
101
  slashUnknownPenalty: 2_000n * 10n ** 18n,
90
- slashBroadcastedInvalidBlockPenalty: 10_000n * 10n ** 18n,
102
+ slashBroadcastedInvalidBlockPenalty: 0n,
91
103
  slashMaxPayloadSize: 50,
92
104
  slashGracePeriodL2Slots: 32 * 4,
93
105
  slashOffenseExpirationRounds: 8,
94
- sentinelEnabled: true
106
+ sentinelEnabled: true,
107
+ slashExecuteRoundsLookBack: 4,
108
+ ...DefaultNetworkDBMapSizeConfig
95
109
  };
96
110
  export const stagingPublicL2ChainConfig = {
97
111
  l1ChainId: 11155111,
@@ -99,9 +113,6 @@ export const stagingPublicL2ChainConfig = {
99
113
  sponsoredFPC: true,
100
114
  p2pEnabled: true,
101
115
  p2pBootstrapNodes: [],
102
- registryAddress: '0x2e48addca360da61e4d6c21ff2b1961af56eb83b',
103
- slashFactoryAddress: '0xe19410632fd00695bc5a08dd82044b7b26317742',
104
- feeAssetHandlerAddress: '0xb46dc3d91f849999330b6dd93473fa29fc45b076',
105
116
  seqMinTxsPerBlock: 0,
106
117
  seqMaxTxsPerBlock: 20,
107
118
  realProofs: true,
@@ -120,6 +131,8 @@ export const stagingPublicL2ChainConfig = {
120
131
  /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 36,
121
132
  /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
122
133
  /** The target validator committee size. */ aztecTargetCommitteeSize: 48,
134
+ /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: DefaultL1ContractsConfig.lagInEpochs,
135
+ /** The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup */ localEjectionThreshold: DefaultL1ContractsConfig.localEjectionThreshold,
123
136
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
124
137
  /** The deposit amount for a validator */ activationThreshold: DefaultL1ContractsConfig.activationThreshold,
125
138
  /** The minimum stake for a validator. */ ejectionThreshold: DefaultL1ContractsConfig.ejectionThreshold,
@@ -128,7 +141,8 @@ export const stagingPublicL2ChainConfig = {
128
141
  /** The mana target for the rollup */ manaTarget: DefaultL1ContractsConfig.manaTarget,
129
142
  /** The proving cost per mana */ provingCostPerMana: DefaultL1ContractsConfig.provingCostPerMana,
130
143
  /** Exit delay for stakers */ exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
131
- ...DefaultSlashConfig
144
+ ...DefaultSlashConfig,
145
+ ...DefaultNetworkDBMapSizeConfig
132
146
  };
133
147
  export const testnetL2ChainConfig = {
134
148
  l1ChainId: 11155111,
@@ -136,9 +150,6 @@ export const testnetL2ChainConfig = {
136
150
  sponsoredFPC: true,
137
151
  p2pEnabled: true,
138
152
  p2pBootstrapNodes: [],
139
- registryAddress: '0xc2f24280f5c7f4897370dfdeb30f79ded14f1c81',
140
- slashFactoryAddress: '0x76291684ae928d6e5bcff348e36917f4cc532db8',
141
- feeAssetHandlerAddress: '0x50513c3713ffd33301e85f30d86ab764df421fe9',
142
153
  seqMinTxsPerBlock: 0,
143
154
  seqMaxTxsPerBlock: 20,
144
155
  realProofs: true,
@@ -157,9 +168,11 @@ export const testnetL2ChainConfig = {
157
168
  /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 36,
158
169
  /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
159
170
  /** The target validator committee size. */ aztecTargetCommitteeSize: 48,
171
+ /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: 2,
160
172
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
161
173
  /** The deposit amount for a validator */ activationThreshold: DefaultL1ContractsConfig.activationThreshold,
162
174
  /** The minimum stake for a validator. */ ejectionThreshold: DefaultL1ContractsConfig.ejectionThreshold,
175
+ /** The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup */ localEjectionThreshold: DefaultL1ContractsConfig.localEjectionThreshold,
163
176
  /** The slashing round size */ slashingRoundSizeInEpochs: DefaultL1ContractsConfig.slashingRoundSizeInEpochs,
164
177
  /** Governance proposing round size */ governanceProposerRoundSize: DefaultL1ContractsConfig.governanceProposerRoundSize,
165
178
  /** The mana target for the rollup */ manaTarget: DefaultL1ContractsConfig.manaTarget,
@@ -168,38 +181,81 @@ export const testnetL2ChainConfig = {
168
181
  ...DefaultSlashConfig,
169
182
  slashPrunePenalty: 0n,
170
183
  slashDataWithholdingPenalty: 0n,
171
- slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium
184
+ slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium,
185
+ ...DefaultNetworkDBMapSizeConfig
186
+ };
187
+ export const ignitionL2ChainConfig = {
188
+ l1ChainId: 1,
189
+ testAccounts: false,
190
+ sponsoredFPC: false,
191
+ p2pEnabled: true,
192
+ p2pBootstrapNodes: [],
193
+ seqMinTxsPerBlock: 0,
194
+ seqMaxTxsPerBlock: 0,
195
+ realProofs: true,
196
+ snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/ignition/',
197
+ autoUpdate: 'notify',
198
+ autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/ignition.json',
199
+ maxTxPoolSize: 100_000_000,
200
+ publicIncludeMetrics,
201
+ publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
202
+ publicMetricsCollectFrom: [
203
+ 'sequencer'
204
+ ],
205
+ txPoolDeleteTxsAfterReorg: false,
206
+ /** How many seconds an L1 slot lasts. */ ethereumSlotDuration: 12,
207
+ /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 72,
208
+ /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
209
+ /** The target validator committee size. */ aztecTargetCommitteeSize: 24,
210
+ /** The number of epochs to lag behind the current epoch for validator selection. */ lagInEpochs: 2,
211
+ /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
212
+ /** How many sequencers must agree with a slash for it to be executed. */ slashingQuorum: 65,
213
+ slashingRoundSizeInEpochs: 4,
214
+ slashingLifetimeInRounds: 40,
215
+ slashingExecutionDelayInRounds: 28,
216
+ slashingDisableDuration: 5 * 24 * 60 * 60,
217
+ slashAmountSmall: 2_000n * 10n ** 18n,
218
+ slashAmountMedium: 10_000n * 10n ** 18n,
219
+ slashAmountLarge: 50_000n * 10n ** 18n,
220
+ slashingOffsetInRounds: 2,
221
+ slasherFlavor: 'tally',
222
+ slashingVetoer: EthAddress.ZERO,
223
+ /** The mana target for the rollup */ manaTarget: 0n,
224
+ exitDelaySeconds: 5 * 24 * 60 * 60,
225
+ /** The proving cost per mana */ provingCostPerMana: 0n,
226
+ ejectionThreshold: 100_000n * 10n ** 18n,
227
+ activationThreshold: 200_000n * 10n ** 18n,
228
+ localEjectionThreshold: 196_000n * 10n ** 18n,
229
+ governanceProposerRoundSize: 300,
230
+ governanceProposerQuorum: 151,
231
+ // Node slashing config
232
+ // TODO TMNT-330
233
+ slashMinPenaltyPercentage: 0.5,
234
+ slashMaxPenaltyPercentage: 2.0,
235
+ slashInactivityTargetPercentage: 0.7,
236
+ slashInactivityConsecutiveEpochThreshold: 2,
237
+ slashInactivityPenalty: 2_000n * 10n ** 18n,
238
+ slashPrunePenalty: 0n,
239
+ slashDataWithholdingPenalty: 0n,
240
+ slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
241
+ slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
242
+ slashUnknownPenalty: 2_000n * 10n ** 18n,
243
+ slashBroadcastedInvalidBlockPenalty: 0n,
244
+ slashMaxPayloadSize: 50,
245
+ slashGracePeriodL2Slots: 32 * 4,
246
+ slashOffenseExpirationRounds: 8,
247
+ sentinelEnabled: true,
248
+ slashExecuteRoundsLookBack: 4,
249
+ ...DefaultNetworkDBMapSizeConfig
172
250
  };
173
251
  const BOOTNODE_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour;
174
252
  export async function getBootnodes(networkName, cacheDir) {
175
- const cacheFile = cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined;
176
- try {
177
- if (cacheFile) {
178
- const info = await stat(cacheFile);
179
- if (info.mtimeMs + BOOTNODE_CACHE_DURATION_MS > Date.now()) {
180
- return JSON.parse(await readFile(cacheFile, 'utf-8'))['bootnodes'];
181
- }
182
- }
183
- } catch {
184
- // no-op. Get the remote-file
185
- }
186
253
  const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
187
- const response = await fetch(url);
188
- if (!response.ok) {
189
- throw new Error(`Failed to fetch basic contract addresses from ${url}. Check you are using a correct network name.`);
190
- }
191
- const json = await response.json();
192
- try {
193
- if (cacheFile) {
194
- await mkdir(dirname(cacheFile), {
195
- recursive: true
196
- });
197
- await writeFile(cacheFile, JSON.stringify(json), 'utf-8');
198
- }
199
- } catch {
200
- // no-op
201
- }
202
- return json['bootnodes'];
254
+ const data = await cachedFetch(url, {
255
+ cacheDurationMs: BOOTNODE_CACHE_DURATION_MS,
256
+ cacheFile: cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined
257
+ });
258
+ return data?.bootnodes;
203
259
  }
204
260
  export async function getL2ChainConfig(networkName, cacheDir) {
205
261
  let config;
@@ -215,6 +271,10 @@ export async function getL2ChainConfig(networkName, cacheDir) {
215
271
  config = {
216
272
  ...stagingIgnitionL2ChainConfig
217
273
  };
274
+ } else if (networkName === 'ignition') {
275
+ config = {
276
+ ...ignitionL2ChainConfig
277
+ };
218
278
  }
219
279
  if (!config) {
220
280
  return undefined;
@@ -226,21 +286,6 @@ export async function getL2ChainConfig(networkName, cacheDir) {
226
286
  }
227
287
  return config;
228
288
  }
229
- function enrichVar(envVar, value) {
230
- // Don't override
231
- if (process.env[envVar] || value === undefined) {
232
- return;
233
- }
234
- process.env[envVar] = value;
235
- }
236
- function enrichEthAddressVar(envVar, value) {
237
- // EthAddress doesn't like being given empty strings
238
- if (value === '') {
239
- enrichVar(envVar, EthAddress.ZERO.toString());
240
- return;
241
- }
242
- enrichVar(envVar, value);
243
- }
244
289
  function getDefaultDataDir(networkName) {
245
290
  return path.join(process.env.HOME || '~', '.aztec', networkName, 'data');
246
291
  }
@@ -265,6 +310,11 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
265
310
  enrichVar('PXE_PROVER_ENABLED', config.realProofs.toString());
266
311
  enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
267
312
  enrichVar('P2P_MAX_TX_POOL_SIZE', config.maxTxPoolSize.toString());
313
+ enrichVar('DATA_STORE_MAP_SIZE_KB', config.dbMapSizeKb.toString());
314
+ enrichVar('ARCHIVER_STORE_MAP_SIZE_KB', config.archiverStoreMapSizeKb.toString());
315
+ enrichVar('NOTE_HASH_TREE_MAP_SIZE_KB', config.noteHashTreeMapSizeKb.toString());
316
+ enrichVar('NULLIFIER_TREE_MAP_SIZE_KB', config.nullifierTreeMapSizeKb.toString());
317
+ enrichVar('PUBLIC_DATA_TREE_MAP_SIZE_KB', config.publicDataTreeMapSizeKb.toString());
268
318
  if (config.autoUpdate) {
269
319
  enrichVar('AUTO_UPDATE', config.autoUpdate?.toString());
270
320
  }
@@ -280,9 +330,6 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
280
330
  if (config.publicMetricsCollectFrom) {
281
331
  enrichVar('PUBLIC_OTEL_COLLECT_FROM', config.publicMetricsCollectFrom.join(','));
282
332
  }
283
- enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', config.registryAddress);
284
- enrichEthAddressVar('SLASH_FACTORY_CONTRACT_ADDRESS', config.slashFactoryAddress);
285
- enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', config.feeAssetHandlerAddress);
286
333
  // Deployment stuff
287
334
  enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
288
335
  enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
@@ -291,6 +338,7 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
291
338
  enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
292
339
  enrichVar('AZTEC_ACTIVATION_THRESHOLD', config.activationThreshold.toString());
293
340
  enrichVar('AZTEC_EJECTION_THRESHOLD', config.ejectionThreshold.toString());
341
+ enrichVar('AZTEC_LOCAL_EJECTION_THRESHOLD', config.localEjectionThreshold.toString());
294
342
  enrichVar('AZTEC_SLASHING_QUORUM', config.slashingQuorum?.toString());
295
343
  enrichVar('AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS', config.slashingRoundSizeInEpochs.toString());
296
344
  enrichVar('AZTEC_GOVERNANCE_PROPOSER_QUORUM', config.governanceProposerQuorum?.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,iBAoBjF"}
@@ -0,0 +1,79 @@
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
+ enrichVar('SYNC_SNAPSHOTS_URL', networkConfig.snapshots.join(','));
75
+ enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', networkConfig.registryAddress.toString());
76
+ if (networkConfig.feeAssetHandlerAddress) {
77
+ enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', networkConfig.feeAssetHandlerAddress.toString());
78
+ }
79
+ }