@aztec/cli 2.0.3-rc.17 → 2.0.3-rc.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config/cached_fetch.d.ts +18 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +54 -0
- package/dest/config/chain_l2_config.d.ts +6 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +101 -50
- package/dest/config/enrich_env.d.ts +4 -0
- package/dest/config/enrich_env.d.ts.map +1 -0
- package/dest/config/enrich_env.js +12 -0
- package/dest/config/index.d.ts +2 -0
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +2 -0
- package/dest/config/network_config.d.ts +19 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +79 -0
- package/package.json +23 -23
- package/src/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +125 -50
- package/src/config/enrich_env.ts +15 -0
- package/src/config/index.ts +2 -0
- package/src/config/network_config.ts +102 -0
|
@@ -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
|
+
}
|
|
@@ -22,11 +22,17 @@ export type L2ChainConfig = L1ContractsConfig & Pick<P2PConfig, 'txPoolDeleteTxs
|
|
|
22
22
|
publicIncludeMetrics?: string[];
|
|
23
23
|
publicMetricsCollectorUrl?: string;
|
|
24
24
|
publicMetricsCollectFrom?: string[];
|
|
25
|
+
dbMapSizeKb: number;
|
|
26
|
+
archiverStoreMapSizeKb: number;
|
|
27
|
+
noteHashTreeMapSizeKb: number;
|
|
28
|
+
nullifierTreeMapSizeKb: number;
|
|
29
|
+
publicDataTreeMapSizeKb: number;
|
|
25
30
|
sentinelEnabled: boolean;
|
|
26
31
|
};
|
|
27
32
|
export declare const stagingIgnitionL2ChainConfig: L2ChainConfig;
|
|
28
33
|
export declare const stagingPublicL2ChainConfig: L2ChainConfig;
|
|
29
34
|
export declare const testnetL2ChainConfig: L2ChainConfig;
|
|
35
|
+
export declare const ignitionL2ChainConfig: L2ChainConfig;
|
|
30
36
|
export declare function getBootnodes(networkName: NetworkNames, cacheDir?: string): Promise<any>;
|
|
31
37
|
export declare function getL2ChainConfig(networkName: NetworkNames, cacheDir?: string): Promise<L2ChainConfig | undefined>;
|
|
32
38
|
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;
|
|
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,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;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;AA6CJ,eAAO,MAAM,4BAA4B,EAAE,aA8E1C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAkDxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAqDlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aA8EnC,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,iBA+F/E"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import
|
|
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,
|
|
@@ -25,11 +28,19 @@ const DefaultSlashConfig = {
|
|
|
25
28
|
slashProposeInvalidAttestationsPenalty: DefaultL1ContractsConfig.slashAmountLarge,
|
|
26
29
|
slashAttestDescendantOfInvalidPenalty: DefaultL1ContractsConfig.slashAmountLarge,
|
|
27
30
|
slashUnknownPenalty: DefaultL1ContractsConfig.slashAmountSmall,
|
|
28
|
-
slashBroadcastedInvalidBlockPenalty:
|
|
31
|
+
slashBroadcastedInvalidBlockPenalty: 0n,
|
|
29
32
|
slashMaxPayloadSize: 50,
|
|
30
33
|
slashGracePeriodL2Slots: 32 * 2,
|
|
31
34
|
slashOffenseExpirationRounds: 8,
|
|
32
|
-
sentinelEnabled: true
|
|
35
|
+
sentinelEnabled: true,
|
|
36
|
+
slashExecuteRoundsLookBack: 4
|
|
37
|
+
};
|
|
38
|
+
const DefaultNetworkDBMapSizeConfig = {
|
|
39
|
+
dbMapSizeKb: defaultDBMapSizeKb,
|
|
40
|
+
archiverStoreMapSizeKb: tbMapSizeKb,
|
|
41
|
+
noteHashTreeMapSizeKb: tbMapSizeKb,
|
|
42
|
+
nullifierTreeMapSizeKb: tbMapSizeKb,
|
|
43
|
+
publicDataTreeMapSizeKb: tbMapSizeKb
|
|
33
44
|
};
|
|
34
45
|
export const stagingIgnitionL2ChainConfig = {
|
|
35
46
|
l1ChainId: 11155111,
|
|
@@ -87,11 +98,13 @@ export const stagingIgnitionL2ChainConfig = {
|
|
|
87
98
|
slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
|
|
88
99
|
slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
|
|
89
100
|
slashUnknownPenalty: 2_000n * 10n ** 18n,
|
|
90
|
-
slashBroadcastedInvalidBlockPenalty:
|
|
101
|
+
slashBroadcastedInvalidBlockPenalty: 0n,
|
|
91
102
|
slashMaxPayloadSize: 50,
|
|
92
103
|
slashGracePeriodL2Slots: 32 * 4,
|
|
93
104
|
slashOffenseExpirationRounds: 8,
|
|
94
|
-
sentinelEnabled: true
|
|
105
|
+
sentinelEnabled: true,
|
|
106
|
+
slashExecuteRoundsLookBack: 4,
|
|
107
|
+
...DefaultNetworkDBMapSizeConfig
|
|
95
108
|
};
|
|
96
109
|
export const stagingPublicL2ChainConfig = {
|
|
97
110
|
l1ChainId: 11155111,
|
|
@@ -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,
|
|
@@ -168,38 +182,81 @@ export const testnetL2ChainConfig = {
|
|
|
168
182
|
...DefaultSlashConfig,
|
|
169
183
|
slashPrunePenalty: 0n,
|
|
170
184
|
slashDataWithholdingPenalty: 0n,
|
|
171
|
-
slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium
|
|
185
|
+
slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium,
|
|
186
|
+
...DefaultNetworkDBMapSizeConfig
|
|
187
|
+
};
|
|
188
|
+
export const ignitionL2ChainConfig = {
|
|
189
|
+
l1ChainId: 1,
|
|
190
|
+
testAccounts: false,
|
|
191
|
+
sponsoredFPC: false,
|
|
192
|
+
p2pEnabled: true,
|
|
193
|
+
p2pBootstrapNodes: [],
|
|
194
|
+
registryAddress: '',
|
|
195
|
+
slashFactoryAddress: '',
|
|
196
|
+
feeAssetHandlerAddress: '',
|
|
197
|
+
seqMinTxsPerBlock: 0,
|
|
198
|
+
seqMaxTxsPerBlock: 0,
|
|
199
|
+
realProofs: true,
|
|
200
|
+
snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/ignition/',
|
|
201
|
+
autoUpdate: 'notify',
|
|
202
|
+
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/ignition.json',
|
|
203
|
+
maxTxPoolSize: 100_000_000,
|
|
204
|
+
publicIncludeMetrics,
|
|
205
|
+
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
|
|
206
|
+
publicMetricsCollectFrom: [
|
|
207
|
+
'sequencer'
|
|
208
|
+
],
|
|
209
|
+
txPoolDeleteTxsAfterReorg: false,
|
|
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
|
+
slashingRoundSizeInEpochs: 4,
|
|
217
|
+
slashingLifetimeInRounds: 40,
|
|
218
|
+
slashingExecutionDelayInRounds: 28,
|
|
219
|
+
slashAmountSmall: 2_000n * 10n ** 18n,
|
|
220
|
+
slashAmountMedium: 10_000n * 10n ** 18n,
|
|
221
|
+
slashAmountLarge: 50_000n * 10n ** 18n,
|
|
222
|
+
slashingOffsetInRounds: 2,
|
|
223
|
+
slasherFlavor: 'tally',
|
|
224
|
+
slashingVetoer: EthAddress.ZERO,
|
|
225
|
+
/** The mana target for the rollup */ manaTarget: 0n,
|
|
226
|
+
exitDelaySeconds: 5 * 24 * 60 * 60,
|
|
227
|
+
/** The proving cost per mana */ provingCostPerMana: 0n,
|
|
228
|
+
ejectionThreshold: 100_000n * 10n ** 18n,
|
|
229
|
+
activationThreshold: 200_000n * 10n ** 18n,
|
|
230
|
+
governanceProposerRoundSize: 300,
|
|
231
|
+
governanceProposerQuorum: 151,
|
|
232
|
+
// Node slashing config
|
|
233
|
+
// TODO TMNT-330
|
|
234
|
+
slashMinPenaltyPercentage: 0.5,
|
|
235
|
+
slashMaxPenaltyPercentage: 2.0,
|
|
236
|
+
slashInactivityTargetPercentage: 0.7,
|
|
237
|
+
slashInactivityConsecutiveEpochThreshold: 2,
|
|
238
|
+
slashInactivityPenalty: 2_000n * 10n ** 18n,
|
|
239
|
+
slashPrunePenalty: 0n,
|
|
240
|
+
slashDataWithholdingPenalty: 0n,
|
|
241
|
+
slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
|
|
242
|
+
slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
|
|
243
|
+
slashUnknownPenalty: 2_000n * 10n ** 18n,
|
|
244
|
+
slashBroadcastedInvalidBlockPenalty: 0n,
|
|
245
|
+
slashMaxPayloadSize: 50,
|
|
246
|
+
slashGracePeriodL2Slots: 32 * 4,
|
|
247
|
+
slashOffenseExpirationRounds: 8,
|
|
248
|
+
sentinelEnabled: true,
|
|
249
|
+
slashExecuteRoundsLookBack: 4,
|
|
250
|
+
...DefaultNetworkDBMapSizeConfig
|
|
172
251
|
};
|
|
173
252
|
const BOOTNODE_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour;
|
|
174
253
|
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
254
|
const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
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'];
|
|
255
|
+
const data = await cachedFetch(url, {
|
|
256
|
+
cacheDurationMs: BOOTNODE_CACHE_DURATION_MS,
|
|
257
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined
|
|
258
|
+
});
|
|
259
|
+
return data?.bootnodes;
|
|
203
260
|
}
|
|
204
261
|
export async function getL2ChainConfig(networkName, cacheDir) {
|
|
205
262
|
let config;
|
|
@@ -215,6 +272,10 @@ export async function getL2ChainConfig(networkName, cacheDir) {
|
|
|
215
272
|
config = {
|
|
216
273
|
...stagingIgnitionL2ChainConfig
|
|
217
274
|
};
|
|
275
|
+
} else if (networkName === 'ignition') {
|
|
276
|
+
config = {
|
|
277
|
+
...ignitionL2ChainConfig
|
|
278
|
+
};
|
|
218
279
|
}
|
|
219
280
|
if (!config) {
|
|
220
281
|
return undefined;
|
|
@@ -226,21 +287,6 @@ export async function getL2ChainConfig(networkName, cacheDir) {
|
|
|
226
287
|
}
|
|
227
288
|
return config;
|
|
228
289
|
}
|
|
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
290
|
function getDefaultDataDir(networkName) {
|
|
245
291
|
return path.join(process.env.HOME || '~', '.aztec', networkName, 'data');
|
|
246
292
|
}
|
|
@@ -265,6 +311,11 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
|
|
|
265
311
|
enrichVar('PXE_PROVER_ENABLED', config.realProofs.toString());
|
|
266
312
|
enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
|
|
267
313
|
enrichVar('P2P_MAX_TX_POOL_SIZE', config.maxTxPoolSize.toString());
|
|
314
|
+
enrichVar('DATA_STORE_MAP_SIZE_KB', config.dbMapSizeKb.toString());
|
|
315
|
+
enrichVar('ARCHIVER_STORE_MAP_SIZE_KB', config.archiverStoreMapSizeKb.toString());
|
|
316
|
+
enrichVar('NOTE_HASH_TREE_MAP_SIZE_KB', config.noteHashTreeMapSizeKb.toString());
|
|
317
|
+
enrichVar('NULLIFIER_TREE_MAP_SIZE_KB', config.nullifierTreeMapSizeKb.toString());
|
|
318
|
+
enrichVar('PUBLIC_DATA_TREE_MAP_SIZE_KB', config.publicDataTreeMapSizeKb.toString());
|
|
268
319
|
if (config.autoUpdate) {
|
|
269
320
|
enrichVar('AUTO_UPDATE', config.autoUpdate?.toString());
|
|
270
321
|
}
|
|
@@ -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
|
+
}
|
package/dest/config/index.d.ts
CHANGED
|
@@ -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"}
|
package/dest/config/index.js
CHANGED
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli",
|
|
3
|
-
"version": "2.0.3-rc.
|
|
3
|
+
"version": "2.0.3-rc.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./contracts": "./dest/cmds/contracts/index.js",
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@aztec/archiver": "2.0.3-rc.
|
|
74
|
-
"@aztec/aztec.js": "2.0.3-rc.
|
|
75
|
-
"@aztec/constants": "2.0.3-rc.
|
|
76
|
-
"@aztec/entrypoints": "2.0.3-rc.
|
|
77
|
-
"@aztec/ethereum": "2.0.3-rc.
|
|
78
|
-
"@aztec/foundation": "2.0.3-rc.
|
|
79
|
-
"@aztec/l1-artifacts": "2.0.3-rc.
|
|
80
|
-
"@aztec/node-lib": "2.0.3-rc.
|
|
81
|
-
"@aztec/p2p": "2.0.3-rc.
|
|
82
|
-
"@aztec/stdlib": "2.0.3-rc.
|
|
83
|
-
"@aztec/world-state": "2.0.3-rc.
|
|
73
|
+
"@aztec/archiver": "2.0.3-rc.19",
|
|
74
|
+
"@aztec/aztec.js": "2.0.3-rc.19",
|
|
75
|
+
"@aztec/constants": "2.0.3-rc.19",
|
|
76
|
+
"@aztec/entrypoints": "2.0.3-rc.19",
|
|
77
|
+
"@aztec/ethereum": "2.0.3-rc.19",
|
|
78
|
+
"@aztec/foundation": "2.0.3-rc.19",
|
|
79
|
+
"@aztec/l1-artifacts": "2.0.3-rc.19",
|
|
80
|
+
"@aztec/node-lib": "2.0.3-rc.19",
|
|
81
|
+
"@aztec/p2p": "2.0.3-rc.19",
|
|
82
|
+
"@aztec/stdlib": "2.0.3-rc.19",
|
|
83
|
+
"@aztec/world-state": "2.0.3-rc.19",
|
|
84
84
|
"@iarna/toml": "^2.2.5",
|
|
85
85
|
"@libp2p/peer-id-factory": "^3.0.4",
|
|
86
86
|
"commander": "^12.1.0",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"viem": "2.23.7"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@aztec/accounts": "2.0.3-rc.
|
|
96
|
-
"@aztec/protocol-contracts": "2.0.3-rc.
|
|
95
|
+
"@aztec/accounts": "2.0.3-rc.19",
|
|
96
|
+
"@aztec/protocol-contracts": "2.0.3-rc.19",
|
|
97
97
|
"@jest/globals": "^30.0.0",
|
|
98
98
|
"@types/jest": "^30.0.0",
|
|
99
99
|
"@types/lodash.chunk": "^4.2.9",
|
|
@@ -109,15 +109,15 @@
|
|
|
109
109
|
"typescript": "^5.3.3"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
|
-
"@aztec/accounts": "2.0.3-rc.
|
|
113
|
-
"@aztec/bb-prover": "2.0.3-rc.
|
|
114
|
-
"@aztec/ethereum": "2.0.3-rc.
|
|
115
|
-
"@aztec/l1-artifacts": "2.0.3-rc.
|
|
116
|
-
"@aztec/noir-contracts.js": "2.0.3-rc.
|
|
117
|
-
"@aztec/noir-protocol-circuits-types": "2.0.3-rc.
|
|
118
|
-
"@aztec/noir-test-contracts.js": "2.0.3-rc.
|
|
119
|
-
"@aztec/protocol-contracts": "2.0.3-rc.
|
|
120
|
-
"@aztec/stdlib": "2.0.3-rc.
|
|
112
|
+
"@aztec/accounts": "2.0.3-rc.19",
|
|
113
|
+
"@aztec/bb-prover": "2.0.3-rc.19",
|
|
114
|
+
"@aztec/ethereum": "2.0.3-rc.19",
|
|
115
|
+
"@aztec/l1-artifacts": "2.0.3-rc.19",
|
|
116
|
+
"@aztec/noir-contracts.js": "2.0.3-rc.19",
|
|
117
|
+
"@aztec/noir-protocol-circuits-types": "2.0.3-rc.19",
|
|
118
|
+
"@aztec/noir-test-contracts.js": "2.0.3-rc.19",
|
|
119
|
+
"@aztec/protocol-contracts": "2.0.3-rc.19",
|
|
120
|
+
"@aztec/stdlib": "2.0.3-rc.19"
|
|
121
121
|
},
|
|
122
122
|
"files": [
|
|
123
123
|
"dest",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js';
|
|
2
|
+
|
|
3
|
+
import { mkdir, readFile, stat, writeFile } from 'fs/promises';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
|
|
6
|
+
export interface CachedFetchOptions {
|
|
7
|
+
/** Cache duration in milliseconds */
|
|
8
|
+
cacheDurationMs: number;
|
|
9
|
+
/** The cache file */
|
|
10
|
+
cacheFile?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fetches data from a URL with file-based caching support.
|
|
15
|
+
* This utility can be used by both remote config and bootnodes fetching.
|
|
16
|
+
*
|
|
17
|
+
* @param url - The URL to fetch from
|
|
18
|
+
* @param networkName - Network name for cache directory structure
|
|
19
|
+
* @param options - Caching and error handling options
|
|
20
|
+
* @param cacheDir - Optional cache directory (defaults to no caching)
|
|
21
|
+
* @returns The fetched and parsed JSON data, or undefined if fetch fails and throwOnError is false
|
|
22
|
+
*/
|
|
23
|
+
export async function cachedFetch<T = any>(
|
|
24
|
+
url: string,
|
|
25
|
+
options: CachedFetchOptions,
|
|
26
|
+
fetch = globalThis.fetch,
|
|
27
|
+
log = createLogger('cached_fetch'),
|
|
28
|
+
): Promise<T | undefined> {
|
|
29
|
+
const { cacheDurationMs, cacheFile } = options;
|
|
30
|
+
|
|
31
|
+
// Try to read from cache first
|
|
32
|
+
try {
|
|
33
|
+
if (cacheFile) {
|
|
34
|
+
const info = await stat(cacheFile);
|
|
35
|
+
if (info.mtimeMs + cacheDurationMs > Date.now()) {
|
|
36
|
+
const cachedData = JSON.parse(await readFile(cacheFile, 'utf-8'));
|
|
37
|
+
return cachedData;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
log.trace('Failed to read data from cache');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(url);
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const data = await response.json();
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
if (cacheFile) {
|
|
55
|
+
await mkdir(dirname(cacheFile), { recursive: true });
|
|
56
|
+
await writeFile(cacheFile, JSON.stringify(data), 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
log.warn('Failed to cache data on disk: ' + cacheFile, { cacheFile, err });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return data;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
log.warn(`Failed to fetch from ${url}`, { err });
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -5,10 +5,14 @@ import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
|
5
5
|
import type { P2PConfig } from '@aztec/p2p/config';
|
|
6
6
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import path, { dirname, join } from 'path';
|
|
8
|
+
import path, { join } from 'path';
|
|
10
9
|
|
|
11
10
|
import publicIncludeMetrics from '../../public_include_metric_prefixes.json' with { type: 'json' };
|
|
11
|
+
import { cachedFetch } from './cached_fetch.js';
|
|
12
|
+
import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
|
|
13
|
+
|
|
14
|
+
const defaultDBMapSizeKb = 128 * 1_024 * 1_024; // 128 GB
|
|
15
|
+
const tbMapSizeKb = 1_024 * 1_024 * 1_024; // 1 TB
|
|
12
16
|
|
|
13
17
|
export type L2ChainConfig = L1ContractsConfig &
|
|
14
18
|
Pick<P2PConfig, 'txPoolDeleteTxsAfterReorg'> &
|
|
@@ -32,6 +36,14 @@ export type L2ChainConfig = L1ContractsConfig &
|
|
|
32
36
|
publicMetricsCollectorUrl?: string;
|
|
33
37
|
publicMetricsCollectFrom?: string[];
|
|
34
38
|
|
|
39
|
+
// Setting the dbMapSize provides the default for every DB in the node.
|
|
40
|
+
// Then we explicitly override the sizes for the archiver and the larger trees.
|
|
41
|
+
dbMapSizeKb: number;
|
|
42
|
+
archiverStoreMapSizeKb: number;
|
|
43
|
+
noteHashTreeMapSizeKb: number;
|
|
44
|
+
nullifierTreeMapSizeKb: number;
|
|
45
|
+
publicDataTreeMapSizeKb: number;
|
|
46
|
+
|
|
35
47
|
// Control whether sentinel is enabled or not. Needed for slashing
|
|
36
48
|
sentinelEnabled: boolean;
|
|
37
49
|
};
|
|
@@ -63,11 +75,20 @@ const DefaultSlashConfig = {
|
|
|
63
75
|
slashProposeInvalidAttestationsPenalty: DefaultL1ContractsConfig.slashAmountLarge,
|
|
64
76
|
slashAttestDescendantOfInvalidPenalty: DefaultL1ContractsConfig.slashAmountLarge,
|
|
65
77
|
slashUnknownPenalty: DefaultL1ContractsConfig.slashAmountSmall,
|
|
66
|
-
slashBroadcastedInvalidBlockPenalty: DefaultL1ContractsConfig.
|
|
78
|
+
slashBroadcastedInvalidBlockPenalty: 0n, // DefaultL1ContractsConfig.slashAmountSmall // Disabled until further testing
|
|
67
79
|
slashMaxPayloadSize: 50,
|
|
68
80
|
slashGracePeriodL2Slots: 32 * 2, // Two epochs from genesis
|
|
69
81
|
slashOffenseExpirationRounds: 8,
|
|
70
82
|
sentinelEnabled: true,
|
|
83
|
+
slashExecuteRoundsLookBack: 4,
|
|
84
|
+
} satisfies Partial<L2ChainConfig>;
|
|
85
|
+
|
|
86
|
+
const DefaultNetworkDBMapSizeConfig = {
|
|
87
|
+
dbMapSizeKb: defaultDBMapSizeKb,
|
|
88
|
+
archiverStoreMapSizeKb: tbMapSizeKb,
|
|
89
|
+
noteHashTreeMapSizeKb: tbMapSizeKb,
|
|
90
|
+
nullifierTreeMapSizeKb: tbMapSizeKb,
|
|
91
|
+
publicDataTreeMapSizeKb: tbMapSizeKb,
|
|
71
92
|
} satisfies Partial<L2ChainConfig>;
|
|
72
93
|
|
|
73
94
|
export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
|
|
@@ -140,11 +161,14 @@ export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
|
|
|
140
161
|
slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
|
|
141
162
|
slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
|
|
142
163
|
slashUnknownPenalty: 2_000n * 10n ** 18n,
|
|
143
|
-
slashBroadcastedInvalidBlockPenalty: 10_000n * 10n ** 18n,
|
|
164
|
+
slashBroadcastedInvalidBlockPenalty: 0n, // 10_000n * 10n ** 18n, Disabled for now until further testing
|
|
144
165
|
slashMaxPayloadSize: 50,
|
|
145
166
|
slashGracePeriodL2Slots: 32 * 4, // One round from genesis
|
|
146
167
|
slashOffenseExpirationRounds: 8,
|
|
147
168
|
sentinelEnabled: true,
|
|
169
|
+
slashExecuteRoundsLookBack: 4,
|
|
170
|
+
|
|
171
|
+
...DefaultNetworkDBMapSizeConfig,
|
|
148
172
|
};
|
|
149
173
|
|
|
150
174
|
export const stagingPublicL2ChainConfig: L2ChainConfig = {
|
|
@@ -195,6 +219,8 @@ export const stagingPublicL2ChainConfig: L2ChainConfig = {
|
|
|
195
219
|
exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
|
|
196
220
|
|
|
197
221
|
...DefaultSlashConfig,
|
|
222
|
+
|
|
223
|
+
...DefaultNetworkDBMapSizeConfig,
|
|
198
224
|
};
|
|
199
225
|
|
|
200
226
|
export const testnetL2ChainConfig: L2ChainConfig = {
|
|
@@ -248,42 +274,100 @@ export const testnetL2ChainConfig: L2ChainConfig = {
|
|
|
248
274
|
slashPrunePenalty: 0n,
|
|
249
275
|
slashDataWithholdingPenalty: 0n,
|
|
250
276
|
slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium,
|
|
277
|
+
|
|
278
|
+
...DefaultNetworkDBMapSizeConfig,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export const ignitionL2ChainConfig: L2ChainConfig = {
|
|
282
|
+
l1ChainId: 1,
|
|
283
|
+
testAccounts: false,
|
|
284
|
+
sponsoredFPC: false,
|
|
285
|
+
p2pEnabled: true,
|
|
286
|
+
p2pBootstrapNodes: [],
|
|
287
|
+
registryAddress: '',
|
|
288
|
+
slashFactoryAddress: '',
|
|
289
|
+
feeAssetHandlerAddress: '',
|
|
290
|
+
seqMinTxsPerBlock: 0,
|
|
291
|
+
seqMaxTxsPerBlock: 0,
|
|
292
|
+
realProofs: true,
|
|
293
|
+
snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/ignition/',
|
|
294
|
+
autoUpdate: 'notify',
|
|
295
|
+
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/ignition.json',
|
|
296
|
+
maxTxPoolSize: 100_000_000, // 100MB
|
|
297
|
+
publicIncludeMetrics,
|
|
298
|
+
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
|
|
299
|
+
publicMetricsCollectFrom: ['sequencer'],
|
|
300
|
+
txPoolDeleteTxsAfterReorg: false,
|
|
301
|
+
|
|
302
|
+
/** How many seconds an L1 slot lasts. */
|
|
303
|
+
ethereumSlotDuration: 12,
|
|
304
|
+
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
|
|
305
|
+
aztecSlotDuration: 72,
|
|
306
|
+
/** How many L2 slots an epoch lasts. */
|
|
307
|
+
aztecEpochDuration: 32,
|
|
308
|
+
/** The target validator committee size. */
|
|
309
|
+
aztecTargetCommitteeSize: 24,
|
|
310
|
+
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
311
|
+
aztecProofSubmissionEpochs: 1,
|
|
312
|
+
/** How many sequencers must agree with a slash for it to be executed. */
|
|
313
|
+
slashingQuorum: 65,
|
|
314
|
+
|
|
315
|
+
slashingRoundSizeInEpochs: 4,
|
|
316
|
+
slashingLifetimeInRounds: 40,
|
|
317
|
+
slashingExecutionDelayInRounds: 28,
|
|
318
|
+
slashAmountSmall: 2_000n * 10n ** 18n,
|
|
319
|
+
slashAmountMedium: 10_000n * 10n ** 18n,
|
|
320
|
+
slashAmountLarge: 50_000n * 10n ** 18n,
|
|
321
|
+
slashingOffsetInRounds: 2,
|
|
322
|
+
slasherFlavor: 'tally',
|
|
323
|
+
slashingVetoer: EthAddress.ZERO, // TODO TMNT-329
|
|
324
|
+
|
|
325
|
+
/** The mana target for the rollup */
|
|
326
|
+
manaTarget: 0n,
|
|
327
|
+
|
|
328
|
+
exitDelaySeconds: 5 * 24 * 60 * 60,
|
|
329
|
+
|
|
330
|
+
/** The proving cost per mana */
|
|
331
|
+
provingCostPerMana: 0n,
|
|
332
|
+
|
|
333
|
+
ejectionThreshold: 100_000n * 10n ** 18n,
|
|
334
|
+
activationThreshold: 200_000n * 10n ** 18n,
|
|
335
|
+
|
|
336
|
+
governanceProposerRoundSize: 300, // TODO TMNT-322
|
|
337
|
+
governanceProposerQuorum: 151, // TODO TMNT-322
|
|
338
|
+
|
|
339
|
+
// Node slashing config
|
|
340
|
+
// TODO TMNT-330
|
|
341
|
+
slashMinPenaltyPercentage: 0.5,
|
|
342
|
+
slashMaxPenaltyPercentage: 2.0,
|
|
343
|
+
slashInactivityTargetPercentage: 0.7,
|
|
344
|
+
slashInactivityConsecutiveEpochThreshold: 2,
|
|
345
|
+
slashInactivityPenalty: 2_000n * 10n ** 18n,
|
|
346
|
+
slashPrunePenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for prune offenses right now
|
|
347
|
+
slashDataWithholdingPenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for data withholding offenses right now
|
|
348
|
+
slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
|
|
349
|
+
slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
|
|
350
|
+
slashUnknownPenalty: 2_000n * 10n ** 18n,
|
|
351
|
+
slashBroadcastedInvalidBlockPenalty: 0n, // 10_000n * 10n ** 18n, Disabled for now until further testing
|
|
352
|
+
slashMaxPayloadSize: 50,
|
|
353
|
+
slashGracePeriodL2Slots: 32 * 4, // One round from genesis
|
|
354
|
+
slashOffenseExpirationRounds: 8,
|
|
355
|
+
sentinelEnabled: true,
|
|
356
|
+
slashExecuteRoundsLookBack: 4,
|
|
357
|
+
|
|
358
|
+
...DefaultNetworkDBMapSizeConfig,
|
|
251
359
|
};
|
|
252
360
|
|
|
253
361
|
const BOOTNODE_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour;
|
|
254
362
|
|
|
255
363
|
export async function getBootnodes(networkName: NetworkNames, cacheDir?: string) {
|
|
256
|
-
const cacheFile = cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined;
|
|
257
|
-
try {
|
|
258
|
-
if (cacheFile) {
|
|
259
|
-
const info = await stat(cacheFile);
|
|
260
|
-
if (info.mtimeMs + BOOTNODE_CACHE_DURATION_MS > Date.now()) {
|
|
261
|
-
return JSON.parse(await readFile(cacheFile, 'utf-8'))['bootnodes'];
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
} catch {
|
|
265
|
-
// no-op. Get the remote-file
|
|
266
|
-
}
|
|
267
|
-
|
|
268
364
|
const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
const json = await response.json();
|
|
276
|
-
|
|
277
|
-
try {
|
|
278
|
-
if (cacheFile) {
|
|
279
|
-
await mkdir(dirname(cacheFile), { recursive: true });
|
|
280
|
-
await writeFile(cacheFile, JSON.stringify(json), 'utf-8');
|
|
281
|
-
}
|
|
282
|
-
} catch {
|
|
283
|
-
// no-op
|
|
284
|
-
}
|
|
365
|
+
const data = await cachedFetch(url, {
|
|
366
|
+
cacheDurationMs: BOOTNODE_CACHE_DURATION_MS,
|
|
367
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'bootnodes.json') : undefined,
|
|
368
|
+
});
|
|
285
369
|
|
|
286
|
-
return
|
|
370
|
+
return data?.bootnodes;
|
|
287
371
|
}
|
|
288
372
|
|
|
289
373
|
export async function getL2ChainConfig(
|
|
@@ -297,6 +381,8 @@ export async function getL2ChainConfig(
|
|
|
297
381
|
config = { ...testnetL2ChainConfig };
|
|
298
382
|
} else if (networkName === 'staging-ignition') {
|
|
299
383
|
config = { ...stagingIgnitionL2ChainConfig };
|
|
384
|
+
} else if (networkName === 'ignition') {
|
|
385
|
+
config = { ...ignitionL2ChainConfig };
|
|
300
386
|
}
|
|
301
387
|
if (!config) {
|
|
302
388
|
return undefined;
|
|
@@ -309,23 +395,6 @@ export async function getL2ChainConfig(
|
|
|
309
395
|
return config;
|
|
310
396
|
}
|
|
311
397
|
|
|
312
|
-
function enrichVar(envVar: EnvVar, value: string | undefined) {
|
|
313
|
-
// Don't override
|
|
314
|
-
if (process.env[envVar] || value === undefined) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
process.env[envVar] = value;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function enrichEthAddressVar(envVar: EnvVar, value: string) {
|
|
321
|
-
// EthAddress doesn't like being given empty strings
|
|
322
|
-
if (value === '') {
|
|
323
|
-
enrichVar(envVar, EthAddress.ZERO.toString());
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
enrichVar(envVar, value);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
398
|
function getDefaultDataDir(networkName: NetworkNames): string {
|
|
330
399
|
return path.join(process.env.HOME || '~', '.aztec', networkName, 'data');
|
|
331
400
|
}
|
|
@@ -355,6 +424,12 @@ export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames
|
|
|
355
424
|
enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
|
|
356
425
|
enrichVar('P2P_MAX_TX_POOL_SIZE', config.maxTxPoolSize.toString());
|
|
357
426
|
|
|
427
|
+
enrichVar('DATA_STORE_MAP_SIZE_KB', config.dbMapSizeKb.toString());
|
|
428
|
+
enrichVar('ARCHIVER_STORE_MAP_SIZE_KB', config.archiverStoreMapSizeKb.toString());
|
|
429
|
+
enrichVar('NOTE_HASH_TREE_MAP_SIZE_KB', config.noteHashTreeMapSizeKb.toString());
|
|
430
|
+
enrichVar('NULLIFIER_TREE_MAP_SIZE_KB', config.nullifierTreeMapSizeKb.toString());
|
|
431
|
+
enrichVar('PUBLIC_DATA_TREE_MAP_SIZE_KB', config.publicDataTreeMapSizeKb.toString());
|
|
432
|
+
|
|
358
433
|
if (config.autoUpdate) {
|
|
359
434
|
enrichVar('AUTO_UPDATE', config.autoUpdate?.toString());
|
|
360
435
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { EnvVar } from '@aztec/foundation/config';
|
|
3
|
+
|
|
4
|
+
export function enrichVar(envVar: EnvVar, value: string | undefined) {
|
|
5
|
+
// Don't override
|
|
6
|
+
if (process.env[envVar] || value === undefined) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
process.env[envVar] = value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function enrichEthAddressVar(envVar: EnvVar, value: string) {
|
|
13
|
+
// EthAddress doesn't like being given empty strings
|
|
14
|
+
enrichVar(envVar, value || EthAddress.ZERO.toString());
|
|
15
|
+
}
|
package/src/config/index.ts
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type NetworkConfig, NetworkConfigMapSchema, type NetworkNames } from '@aztec/foundation/config';
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { cachedFetch } from './cached_fetch.js';
|
|
7
|
+
import { enrichEthAddressVar, enrichVar } from './enrich_env.js';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_CONFIG_URL =
|
|
10
|
+
'https://raw.githubusercontent.com/AztecProtocol/networks/refs/heads/main/network_config.json';
|
|
11
|
+
const NETWORK_CONFIG_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fetches remote network configuration from GitHub with caching support.
|
|
15
|
+
* Uses the reusable cachedFetch utility.
|
|
16
|
+
*
|
|
17
|
+
* @param networkName - The network name to fetch config for
|
|
18
|
+
* @param cacheDir - Optional cache directory for storing fetched config
|
|
19
|
+
* @returns Remote configuration for the specified network, or undefined if not found/error
|
|
20
|
+
*/
|
|
21
|
+
export async function getNetworkConfig(
|
|
22
|
+
networkName: NetworkNames,
|
|
23
|
+
cacheDir?: string,
|
|
24
|
+
): Promise<NetworkConfig | undefined> {
|
|
25
|
+
let url: URL | undefined;
|
|
26
|
+
const configLocation = process.env.NETWORK_CONFIG_LOCATION || DEFAULT_CONFIG_URL;
|
|
27
|
+
|
|
28
|
+
if (!configLocation) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
if (configLocation.includes('://')) {
|
|
34
|
+
url = new URL(configLocation);
|
|
35
|
+
} else {
|
|
36
|
+
url = new URL(`file://${configLocation}`);
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
/* no-op */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!url) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
let rawConfig: any;
|
|
48
|
+
|
|
49
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') {
|
|
50
|
+
rawConfig = await cachedFetch(url.href, {
|
|
51
|
+
cacheDurationMs: NETWORK_CONFIG_CACHE_DURATION_MS,
|
|
52
|
+
cacheFile: cacheDir ? join(cacheDir, networkName, 'network_config.json') : undefined,
|
|
53
|
+
});
|
|
54
|
+
} else if (url.protocol === 'file:') {
|
|
55
|
+
rawConfig = JSON.parse(await readFile(url.pathname, 'utf-8'));
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error('Unsupported Aztec network config protocol: ' + url.href);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!rawConfig) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const networkConfigMap = NetworkConfigMapSchema.parse(rawConfig);
|
|
65
|
+
if (networkName in networkConfigMap) {
|
|
66
|
+
return networkConfigMap[networkName];
|
|
67
|
+
} else {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Enriches environment variables with remote network configuration.
|
|
77
|
+
* This function is called before node config initialization to set env vars
|
|
78
|
+
* from the remote config, following the same pattern as enrichEnvironmentWithChainConfig().
|
|
79
|
+
*
|
|
80
|
+
* @param networkName - The network name to fetch remote config for
|
|
81
|
+
*/
|
|
82
|
+
export async function enrichEnvironmentWithNetworkConfig(networkName: NetworkNames) {
|
|
83
|
+
if (networkName === 'local') {
|
|
84
|
+
return; // No remote config for local development
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const cacheDir = process.env.DATA_DIRECTORY ? join(process.env.DATA_DIRECTORY, 'cache') : undefined;
|
|
88
|
+
const networkConfig = await getNetworkConfig(networkName, cacheDir);
|
|
89
|
+
|
|
90
|
+
if (!networkConfig) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
enrichVar('BOOTSTRAP_NODES', networkConfig.bootnodes.join(','));
|
|
95
|
+
enrichVar('L1_CHAIN_ID', String(networkConfig.l1ChainId));
|
|
96
|
+
enrichVar('SYNC_SNAPSHOTS_URL', networkConfig.snapshots.join(','));
|
|
97
|
+
|
|
98
|
+
enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', networkConfig.registryAddress.toString());
|
|
99
|
+
if (networkConfig.feeAssetHandlerAddress) {
|
|
100
|
+
enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', networkConfig.feeAssetHandlerAddress.toString());
|
|
101
|
+
}
|
|
102
|
+
}
|