@aztec/cli 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
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/cmds/aztec_node/block_number.js +1 -1
- package/dest/cmds/aztec_node/get_logs.d.ts +30 -4
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -1
- package/dest/cmds/aztec_node/get_logs.js +39 -29
- package/dest/cmds/aztec_node/get_node_info.d.ts +1 -1
- package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -1
- package/dest/cmds/aztec_node/get_node_info.js +0 -2
- package/dest/cmds/aztec_node/index.d.ts +1 -1
- package/dest/cmds/aztec_node/index.d.ts.map +1 -1
- package/dest/cmds/aztec_node/index.js +13 -3
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +4 -3
- package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +3 -5
- package/dest/cmds/l1/compute_genesis_values.d.ts +4 -0
- package/dest/cmds/l1/compute_genesis_values.d.ts.map +1 -0
- package/dest/cmds/l1/compute_genesis_values.js +17 -0
- package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +1 -1
- package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_l1_contracts_cmd.js +0 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts +1 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +2 -4
- package/dest/cmds/l1/index.d.ts +1 -1
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +7 -2
- package/dest/cmds/l1/update_l1_validators.d.ts +3 -3
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +52 -18
- package/dest/config/cached_fetch.d.ts +19 -10
- package/dest/config/cached_fetch.d.ts.map +1 -1
- package/dest/config/cached_fetch.js +110 -32
- package/dest/config/chain_l2_config.d.ts +12 -39
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +35 -512
- package/dest/config/generated/networks.d.ts +221 -0
- package/dest/config/generated/networks.d.ts.map +1 -0
- package/dest/config/generated/networks.js +222 -0
- package/dest/config/network_config.d.ts +2 -2
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +7 -3
- package/dest/utils/aztec.d.ts +1 -2
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +2 -3
- package/dest/utils/commands.d.ts +14 -6
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +19 -9
- package/dest/utils/inspect.d.ts +1 -1
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +10 -6
- package/package.json +35 -30
- package/src/cmds/aztec_node/block_number.ts +1 -1
- package/src/cmds/aztec_node/get_logs.ts +70 -38
- package/src/cmds/aztec_node/get_node_info.ts +0 -2
- package/src/cmds/aztec_node/index.ts +13 -8
- package/src/cmds/infrastructure/setup_l2_contract.ts +5 -4
- package/src/cmds/l1/assume_proven_through.ts +4 -7
- package/src/cmds/l1/compute_genesis_values.ts +29 -0
- package/src/cmds/l1/deploy_l1_contracts_cmd.ts +0 -1
- package/src/cmds/l1/deploy_new_rollup.ts +1 -3
- package/src/cmds/l1/index.ts +23 -4
- package/src/cmds/l1/update_l1_validators.ts +46 -21
- package/src/config/cached_fetch.ts +119 -31
- package/src/config/chain_l2_config.ts +35 -670
- package/src/config/generated/networks.ts +226 -0
- package/src/config/network_config.ts +7 -3
- package/src/utils/aztec.ts +12 -18
- package/src/utils/commands.ts +22 -9
- package/src/utils/inspect.ts +8 -6
|
@@ -2,24 +2,22 @@ import { createEthereumChain, isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
|
2
2
|
import { createExtendedL1Client, getPublicClient } from '@aztec/ethereum/client';
|
|
3
3
|
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
4
4
|
import { GSEContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
-
import {
|
|
5
|
+
import { createL1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
6
6
|
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
7
7
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
8
|
-
import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
8
|
+
import { RollupAbi, StakingAssetHandlerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
9
9
|
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
10
|
-
import { encodeFunctionData, formatEther, getContract } from 'viem';
|
|
10
|
+
import { encodeFunctionData, formatEther, getContract, maxUint256 } from 'viem';
|
|
11
11
|
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
12
|
-
import { addLeadingHex } from '../../utils/aztec.js';
|
|
13
12
|
export function generateL1Account() {
|
|
14
13
|
const privateKey = generatePrivateKey();
|
|
15
14
|
const account = privateKeyToAccount(privateKey);
|
|
16
|
-
account.address;
|
|
17
15
|
return {
|
|
18
16
|
privateKey,
|
|
19
17
|
address: account.address
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
|
-
export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, attesterAddress,
|
|
20
|
+
export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, attesterAddress, withdrawerAddress, stakingAssetHandlerAddress, proofParams, blsSecretKey, log, debugLogger }) {
|
|
23
21
|
const dualLog = makeDualLog(log, debugLogger);
|
|
24
22
|
const account = getAccount(privateKey, mnemonic);
|
|
25
23
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
@@ -39,28 +37,64 @@ export async function addL1Validator({ rpcUrls, chainId, privateKey, mnemonic, a
|
|
|
39
37
|
const gseAddress = await rollup.read.getGSE();
|
|
40
38
|
const gse = new GSEContract(l1Client, gseAddress);
|
|
41
39
|
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
42
|
-
const l1TxUtils =
|
|
40
|
+
const l1TxUtils = createL1TxUtils(l1Client, {
|
|
43
41
|
logger: debugLogger
|
|
44
42
|
});
|
|
45
43
|
const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
// Step 1: Claim STK tokens from the faucet
|
|
45
|
+
dualLog(`Claiming STK tokens from faucet`);
|
|
46
|
+
const { receipt: claimReceipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
48
47
|
to: stakingAssetHandlerAddress.toString(),
|
|
49
48
|
data: encodeFunctionData({
|
|
50
49
|
abi: StakingAssetHandlerAbi,
|
|
51
|
-
functionName: '
|
|
50
|
+
functionName: 'claim',
|
|
51
|
+
args: [
|
|
52
|
+
proofParamsObj.toViem()
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
abi: StakingAssetHandlerAbi
|
|
56
|
+
});
|
|
57
|
+
dualLog(`Claim transaction hash: ${claimReceipt.transactionHash}`);
|
|
58
|
+
await l1Client.waitForTransactionReceipt({
|
|
59
|
+
hash: claimReceipt.transactionHash
|
|
60
|
+
});
|
|
61
|
+
// Step 2: Approve the rollup to spend STK tokens
|
|
62
|
+
const stakingAssetAddress = await stakingAssetHandler.read.STAKING_ASSET();
|
|
63
|
+
dualLog(`Approving rollup to spend STK tokens`);
|
|
64
|
+
const { receipt: approveReceipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
65
|
+
to: stakingAssetAddress,
|
|
66
|
+
data: encodeFunctionData({
|
|
67
|
+
abi: TestERC20Abi,
|
|
68
|
+
functionName: 'approve',
|
|
69
|
+
args: [
|
|
70
|
+
rollupAddress,
|
|
71
|
+
maxUint256
|
|
72
|
+
]
|
|
73
|
+
}),
|
|
74
|
+
abi: TestERC20Abi
|
|
75
|
+
});
|
|
76
|
+
await l1Client.waitForTransactionReceipt({
|
|
77
|
+
hash: approveReceipt.transactionHash
|
|
78
|
+
});
|
|
79
|
+
// Step 3: Deposit into the rollup to register as a validator
|
|
80
|
+
dualLog(`Depositing into rollup to register validator`);
|
|
81
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
82
|
+
to: rollupAddress,
|
|
83
|
+
data: encodeFunctionData({
|
|
84
|
+
abi: RollupAbi,
|
|
85
|
+
functionName: 'deposit',
|
|
52
86
|
args: [
|
|
53
87
|
attesterAddress.toString(),
|
|
54
|
-
|
|
55
|
-
proofParamsObj.toViem(),
|
|
88
|
+
withdrawerAddress.toString(),
|
|
56
89
|
registrationTuple.publicKeyInG1,
|
|
57
90
|
registrationTuple.publicKeyInG2,
|
|
58
|
-
registrationTuple.proofOfPossession
|
|
91
|
+
registrationTuple.proofOfPossession,
|
|
92
|
+
false
|
|
59
93
|
]
|
|
60
94
|
}),
|
|
61
|
-
abi:
|
|
95
|
+
abi: RollupAbi
|
|
62
96
|
});
|
|
63
|
-
dualLog(`
|
|
97
|
+
dualLog(`Deposit transaction hash: ${receipt.transactionHash}`);
|
|
64
98
|
await l1Client.waitForTransactionReceipt({
|
|
65
99
|
hash: receipt.transactionHash
|
|
66
100
|
});
|
|
@@ -95,7 +129,7 @@ export async function addL1ValidatorViaRollup({ rpcUrls, chainId, privateKey, mn
|
|
|
95
129
|
const gseAddress = await rollup.read.getGSE();
|
|
96
130
|
const gse = new GSEContract(l1Client, gseAddress);
|
|
97
131
|
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
98
|
-
const l1TxUtils =
|
|
132
|
+
const l1TxUtils = createL1TxUtils(l1Client, {
|
|
99
133
|
logger: debugLogger
|
|
100
134
|
});
|
|
101
135
|
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
@@ -137,7 +171,7 @@ export async function removeL1Validator({ rpcUrls, chainId, privateKey, mnemonic
|
|
|
137
171
|
const account = getAccount(privateKey, mnemonic);
|
|
138
172
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
139
173
|
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
140
|
-
const l1TxUtils =
|
|
174
|
+
const l1TxUtils = createL1TxUtils(l1Client, {
|
|
141
175
|
logger: debugLogger
|
|
142
176
|
});
|
|
143
177
|
dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
|
|
@@ -159,7 +193,7 @@ export async function pruneRollup({ rpcUrls, chainId, privateKey, mnemonic, roll
|
|
|
159
193
|
const account = getAccount(privateKey, mnemonic);
|
|
160
194
|
const chain = createEthereumChain(rpcUrls, chainId);
|
|
161
195
|
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
162
|
-
const l1TxUtils =
|
|
196
|
+
const l1TxUtils = createL1TxUtils(l1Client, {
|
|
163
197
|
logger: debugLogger
|
|
164
198
|
});
|
|
165
199
|
dualLog(`Trying prune`);
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
export interface CachedFetchOptions {
|
|
2
|
-
/**
|
|
3
|
-
cacheDurationMs: number;
|
|
4
|
-
/** The cache file */
|
|
2
|
+
/** The cache file path for storing data. If not provided, no caching is performed. */
|
|
5
3
|
cacheFile?: string;
|
|
4
|
+
/** Fallback max-age in milliseconds when server sends no Cache-Control header. Defaults to 5 minutes. */
|
|
5
|
+
defaultMaxAgeMs?: number;
|
|
6
6
|
}
|
|
7
|
+
/** Extracts max-age value in milliseconds from a Response's Cache-Control header. Returns undefined if not present. */
|
|
8
|
+
export declare function parseMaxAge(response: {
|
|
9
|
+
headers: {
|
|
10
|
+
get(name: string): string | null;
|
|
11
|
+
};
|
|
12
|
+
}): number | undefined;
|
|
7
13
|
/**
|
|
8
|
-
* Fetches data from a URL with file-based caching
|
|
9
|
-
*
|
|
14
|
+
* Fetches data from a URL with file-based HTTP conditional caching.
|
|
15
|
+
*
|
|
16
|
+
* Data is stored as raw JSON in the cache file (same format as the server returns).
|
|
17
|
+
* Caching metadata (ETag, expiry) is stored in a separate sidecar `.meta` file.
|
|
18
|
+
* This keeps the data file human-readable and backward-compatible with older code.
|
|
10
19
|
*
|
|
11
20
|
* @param url - The URL to fetch from
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @returns The fetched and parsed JSON data, or undefined if fetch fails
|
|
21
|
+
* @param options - Caching options
|
|
22
|
+
* @param fetch - Fetch implementation (defaults to globalThis.fetch)
|
|
23
|
+
* @param log - Logger instance
|
|
24
|
+
* @returns The fetched and parsed JSON data, or undefined if fetch fails
|
|
16
25
|
*/
|
|
17
26
|
export declare function cachedFetch<T = any>(url: string, options: CachedFetchOptions, fetch?: typeof globalThis.fetch, log?: import("@aztec/aztec.js/log").Logger): Promise<T | undefined>;
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FjaGVkX2ZldGNoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL2NhY2hlZF9mZXRjaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxNQUFNLFdBQVcsa0JBQWtCO0lBQ2pDLHNGQUFzRjtJQUN0RixTQUFTLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDbkIseUdBQXlHO0lBQ3pHLGVBQWUsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUMxQjtBQVVELHVIQUF1SDtBQUN2SCx3QkFBZ0IsV0FBVyxDQUFDLFFBQVEsRUFBRTtJQUFFLE9BQU8sRUFBRTtRQUFFLEdBQUcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxHQUFHLE1BQU0sR0FBRyxJQUFJLENBQUE7S0FBRSxDQUFBO0NBQUUsR0FBRyxNQUFNLEdBQUcsU0FBUyxDQVUzRztBQUVEOzs7Ozs7Ozs7Ozs7R0FZRztBQUNILHdCQUFzQixXQUFXLENBQUMsQ0FBQyxHQUFHLEdBQUcsRUFDdkMsR0FBRyxFQUFFLE1BQU0sRUFDWCxPQUFPLEVBQUUsa0JBQWtCLEVBQzNCLEtBQUssMEJBQW1CLEVBQ3hCLEdBQUcsdUNBQStCLEdBQ2pDLE9BQU8sQ0FBQyxDQUFDLEdBQUcsU0FBUyxDQUFDLENBb0V4QiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cached_fetch.d.ts","sourceRoot":"","sources":["../../src/config/cached_fetch.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,
|
|
1
|
+
{"version":3,"file":"cached_fetch.d.ts","sourceRoot":"","sources":["../../src/config/cached_fetch.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yGAAyG;IACzG,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAUD,uHAAuH;AACvH,wBAAgB,WAAW,CAAC,QAAQ,EAAE;IAAE,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAU3G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,GAAG,EACvC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,EAC3B,KAAK,0BAAmB,EACxB,GAAG,uCAA+B,GACjC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAoExB"}
|
|
@@ -1,50 +1,105 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
-
import { mkdir, readFile,
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
3
3
|
import { dirname } from 'path';
|
|
4
|
+
const DEFAULT_MAX_AGE_MS = 5 * 60 * 1000; // 5 minutes
|
|
5
|
+
/** Extracts max-age value in milliseconds from a Response's Cache-Control header. Returns undefined if not present. */ export function parseMaxAge(response) {
|
|
6
|
+
const cacheControl = response.headers.get('cache-control');
|
|
7
|
+
if (!cacheControl) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const match = cacheControl.match(/max-age=(\d+)/);
|
|
11
|
+
if (!match) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return parseInt(match[1], 10) * 1000;
|
|
15
|
+
}
|
|
4
16
|
/**
|
|
5
|
-
* Fetches data from a URL with file-based caching
|
|
6
|
-
*
|
|
17
|
+
* Fetches data from a URL with file-based HTTP conditional caching.
|
|
18
|
+
*
|
|
19
|
+
* Data is stored as raw JSON in the cache file (same format as the server returns).
|
|
20
|
+
* Caching metadata (ETag, expiry) is stored in a separate sidecar `.meta` file.
|
|
21
|
+
* This keeps the data file human-readable and backward-compatible with older code.
|
|
7
22
|
*
|
|
8
23
|
* @param url - The URL to fetch from
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @returns The fetched and parsed JSON data, or undefined if fetch fails
|
|
24
|
+
* @param options - Caching options
|
|
25
|
+
* @param fetch - Fetch implementation (defaults to globalThis.fetch)
|
|
26
|
+
* @param log - Logger instance
|
|
27
|
+
* @returns The fetched and parsed JSON data, or undefined if fetch fails
|
|
13
28
|
*/ export async function cachedFetch(url, options, fetch = globalThis.fetch, log = createLogger('cached_fetch')) {
|
|
14
|
-
const {
|
|
15
|
-
//
|
|
29
|
+
const { cacheFile, defaultMaxAgeMs = DEFAULT_MAX_AGE_MS } = options;
|
|
30
|
+
// If no cacheFile, just fetch normally without caching
|
|
31
|
+
if (!cacheFile) {
|
|
32
|
+
return fetchAndParse(url, fetch, log);
|
|
33
|
+
}
|
|
34
|
+
const metaFile = cacheFile + '.meta';
|
|
35
|
+
// Try to read metadata
|
|
36
|
+
let meta;
|
|
16
37
|
try {
|
|
17
|
-
|
|
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
|
-
}
|
|
38
|
+
meta = JSON.parse(await readFile(metaFile, 'utf-8'));
|
|
24
39
|
} catch {
|
|
25
|
-
log.trace('
|
|
40
|
+
log.trace('No usable cache metadata found');
|
|
26
41
|
}
|
|
42
|
+
// Try to read cached data
|
|
43
|
+
let cachedData;
|
|
27
44
|
try {
|
|
28
|
-
|
|
45
|
+
cachedData = JSON.parse(await readFile(cacheFile, 'utf-8'));
|
|
46
|
+
} catch {
|
|
47
|
+
log.trace('No usable cached data found');
|
|
48
|
+
}
|
|
49
|
+
// If metadata and data exist and cache is fresh, return directly
|
|
50
|
+
if (meta && cachedData !== undefined && meta.expiresAt > Date.now()) {
|
|
51
|
+
return cachedData;
|
|
52
|
+
}
|
|
53
|
+
// Cache is stale or missing — make a (possibly conditional) request
|
|
54
|
+
try {
|
|
55
|
+
const headers = {};
|
|
56
|
+
if (meta?.etag && cachedData !== undefined) {
|
|
57
|
+
headers['If-None-Match'] = meta.etag;
|
|
58
|
+
}
|
|
59
|
+
const response = await fetch(url, {
|
|
60
|
+
headers
|
|
61
|
+
});
|
|
62
|
+
if (response.status === 304 && cachedData !== undefined) {
|
|
63
|
+
// Not modified — recompute expiry from new response headers and return cached data
|
|
64
|
+
const maxAgeMs = parseMaxAge(response) ?? defaultMaxAgeMs;
|
|
65
|
+
await writeMetaFile(metaFile, {
|
|
66
|
+
etag: meta?.etag,
|
|
67
|
+
expiresAt: Date.now() + maxAgeMs
|
|
68
|
+
}, log);
|
|
69
|
+
return cachedData;
|
|
70
|
+
}
|
|
29
71
|
if (!response.ok) {
|
|
30
72
|
log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
|
|
31
|
-
return
|
|
73
|
+
return cachedData;
|
|
32
74
|
}
|
|
75
|
+
// 200 — parse new data and cache it
|
|
33
76
|
const data = await response.json();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
err
|
|
45
|
-
});
|
|
46
|
-
}
|
|
77
|
+
const maxAgeMs = parseMaxAge(response) ?? defaultMaxAgeMs;
|
|
78
|
+
const etag = response.headers.get('etag') ?? undefined;
|
|
79
|
+
await ensureDir(cacheFile, log);
|
|
80
|
+
await Promise.all([
|
|
81
|
+
writeFile(cacheFile, JSON.stringify(data), 'utf-8'),
|
|
82
|
+
writeFile(metaFile, JSON.stringify({
|
|
83
|
+
etag,
|
|
84
|
+
expiresAt: Date.now() + maxAgeMs
|
|
85
|
+
}), 'utf-8')
|
|
86
|
+
]);
|
|
47
87
|
return data;
|
|
88
|
+
} catch (err) {
|
|
89
|
+
log.warn(`Failed to fetch from ${url}`, {
|
|
90
|
+
err
|
|
91
|
+
});
|
|
92
|
+
return cachedData;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function fetchAndParse(url, fetch, log) {
|
|
96
|
+
try {
|
|
97
|
+
const response = await fetch(url);
|
|
98
|
+
if (!response.ok) {
|
|
99
|
+
log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
return await response.json();
|
|
48
103
|
} catch (err) {
|
|
49
104
|
log.warn(`Failed to fetch from ${url}`, {
|
|
50
105
|
err
|
|
@@ -52,3 +107,26 @@ import { dirname } from 'path';
|
|
|
52
107
|
return undefined;
|
|
53
108
|
}
|
|
54
109
|
}
|
|
110
|
+
async function ensureDir(filePath, log) {
|
|
111
|
+
try {
|
|
112
|
+
await mkdir(dirname(filePath), {
|
|
113
|
+
recursive: true
|
|
114
|
+
});
|
|
115
|
+
} catch (err) {
|
|
116
|
+
log.warn('Failed to create cache directory for: ' + filePath, {
|
|
117
|
+
err
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function writeMetaFile(metaFile, meta, log) {
|
|
122
|
+
try {
|
|
123
|
+
await mkdir(dirname(metaFile), {
|
|
124
|
+
recursive: true
|
|
125
|
+
});
|
|
126
|
+
await writeFile(metaFile, JSON.stringify(meta), 'utf-8');
|
|
127
|
+
} catch (err) {
|
|
128
|
+
log.warn('Failed to write cache metadata: ' + metaFile, {
|
|
129
|
+
err
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -1,41 +1,14 @@
|
|
|
1
|
-
import { type L1ContractsConfig } from '@aztec/ethereum/config';
|
|
2
|
-
import type { L1TxUtilsConfig } from '@aztec/ethereum/l1-tx-utils/config';
|
|
3
1
|
import type { NetworkNames } from '@aztec/foundation/config';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
autoUpdate: SharedNodeConfig['autoUpdate'];
|
|
16
|
-
autoUpdateUrl?: string;
|
|
17
|
-
maxPendingTxCount: number;
|
|
18
|
-
publicMetricsOptOut: boolean;
|
|
19
|
-
publicIncludeMetrics?: string[];
|
|
20
|
-
publicMetricsCollectorUrl?: string;
|
|
21
|
-
publicMetricsCollectFrom?: string[];
|
|
22
|
-
skipArchiverInitialSync?: boolean;
|
|
23
|
-
blobAllowEmptySources?: boolean;
|
|
24
|
-
dataStoreMapSizeKb: number;
|
|
25
|
-
archiverStoreMapSizeKb: number;
|
|
26
|
-
noteHashTreeMapSizeKb: number;
|
|
27
|
-
nullifierTreeMapSizeKb: number;
|
|
28
|
-
publicDataTreeMapSizeKb: number;
|
|
29
|
-
sentinelEnabled: boolean;
|
|
30
|
-
disableTransactions: boolean;
|
|
31
|
-
};
|
|
32
|
-
export declare const stagingIgnitionL2ChainConfig: L2ChainConfig;
|
|
33
|
-
export declare const stagingPublicL2ChainConfig: L2ChainConfig;
|
|
34
|
-
export declare const nextNetL2ChainConfig: L2ChainConfig;
|
|
35
|
-
export declare const testnetL2ChainConfig: L2ChainConfig;
|
|
36
|
-
export declare const mainnetL2ChainConfig: L2ChainConfig;
|
|
37
|
-
export declare const devnetL2ChainConfig: L2ChainConfig;
|
|
38
|
-
export declare function getL2ChainConfig(networkName: NetworkNames): L2ChainConfig | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Sets up environment for the given network.
|
|
4
|
+
*
|
|
5
|
+
* For 'local' network: returns early, using hardcoded defaults from DefaultL1ContractsConfig
|
|
6
|
+
* and DefaultSlasherConfig (which match the 'defaults' section of defaults.yml).
|
|
7
|
+
*
|
|
8
|
+
* For deployed networks: applies network configuration from generated defaults.yml,
|
|
9
|
+
* merging base defaults with network-specific overrides.
|
|
10
|
+
*
|
|
11
|
+
* @param networkName - The network name
|
|
12
|
+
*/
|
|
39
13
|
export declare function enrichEnvironmentWithChainName(networkName: NetworkNames): void;
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhaW5fbDJfY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL2NoYWluX2wyX2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQTRCLEtBQUssaUJBQWlCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUMxRixPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQztBQUMxRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwwQkFBMEIsQ0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maWxlIjoiY2hhaW5fbDJfY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL2NoYWluX2wyX2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQTBCN0Q7Ozs7Ozs7Ozs7R0FVRztBQUNILHdCQUFnQiw4QkFBOEIsQ0FBQyxXQUFXLEVBQUUsWUFBWSxRQXFCdkUifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/config/chain_l2_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AA0B7D;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,YAAY,QAqBvE"}
|