@aztec/cli 3.0.0-canary.a9708bd → 3.0.0-manual.20251030

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +1 -427
  2. package/dest/cmds/aztec_node/block_number.d.ts +3 -0
  3. package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
  4. package/dest/cmds/aztec_node/block_number.js +10 -0
  5. package/dest/cmds/aztec_node/get_block.d.ts +3 -0
  6. package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
  7. package/dest/cmds/aztec_node/get_block.js +9 -0
  8. package/dest/cmds/aztec_node/get_current_base_fee.d.ts +3 -0
  9. package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +1 -0
  10. package/dest/cmds/aztec_node/get_current_base_fee.js +7 -0
  11. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
  12. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
  13. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
  14. package/dest/cmds/aztec_node/get_logs.d.ts +6 -0
  15. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
  16. package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
  17. package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
  18. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
  19. package/dest/cmds/{pxe → aztec_node}/get_node_info.js +3 -8
  20. package/dest/cmds/aztec_node/index.d.ts.map +1 -0
  21. package/dest/cmds/aztec_node/index.js +28 -0
  22. package/dest/cmds/infrastructure/index.d.ts +2 -2
  23. package/dest/cmds/infrastructure/index.d.ts.map +1 -1
  24. package/dest/cmds/infrastructure/index.js +7 -8
  25. package/dest/cmds/infrastructure/sequencers.d.ts +2 -3
  26. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  27. package/dest/cmds/infrastructure/sequencers.js +4 -3
  28. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
  29. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
  30. package/dest/cmds/infrastructure/setup_l2_contract.js +10 -25
  31. package/dest/cmds/l1/advance_epoch.d.ts +1 -1
  32. package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
  33. package/dest/cmds/l1/advance_epoch.js +6 -5
  34. package/dest/cmds/l1/assume_proven_through.d.ts +1 -1
  35. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  36. package/dest/cmds/l1/assume_proven_through.js +7 -6
  37. package/dest/cmds/l1/bridge_erc20.d.ts +1 -1
  38. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
  39. package/dest/cmds/l1/bridge_erc20.js +1 -1
  40. package/dest/cmds/l1/deploy_l1_contracts.d.ts +2 -2
  41. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
  42. package/dest/cmds/l1/deploy_l1_contracts.js +5 -5
  43. package/dest/cmds/l1/deploy_new_rollup.d.ts +1 -1
  44. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  45. package/dest/cmds/l1/deploy_new_rollup.js +4 -4
  46. package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
  47. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
  48. package/dest/cmds/l1/index.d.ts.map +1 -1
  49. package/dest/cmds/l1/index.js +18 -34
  50. package/dest/cmds/l1/update_l1_validators.d.ts +5 -0
  51. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  52. package/dest/cmds/l1/update_l1_validators.js +67 -6
  53. package/dest/cmds/misc/generate_secret_and_hash.js +1 -1
  54. package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
  55. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
  56. package/dest/cmds/misc/generate_secret_key.js +1 -1
  57. package/dest/config/cached_fetch.d.ts +18 -0
  58. package/dest/config/cached_fetch.d.ts.map +1 -0
  59. package/dest/config/cached_fetch.js +54 -0
  60. package/dest/config/chain_l2_config.d.ts +39 -0
  61. package/dest/config/chain_l2_config.d.ts.map +1 -0
  62. package/dest/config/chain_l2_config.js +452 -0
  63. package/dest/config/enrich_env.d.ts +4 -0
  64. package/dest/config/enrich_env.d.ts.map +1 -0
  65. package/dest/config/enrich_env.js +12 -0
  66. package/dest/config/get_l1_config.d.ts +8 -0
  67. package/dest/config/get_l1_config.d.ts.map +1 -0
  68. package/dest/config/get_l1_config.js +22 -0
  69. package/dest/config/index.d.ts +5 -0
  70. package/dest/config/index.d.ts.map +1 -0
  71. package/dest/config/index.js +4 -0
  72. package/dest/config/network_config.d.ts +19 -0
  73. package/dest/config/network_config.d.ts.map +1 -0
  74. package/dest/config/network_config.js +79 -0
  75. package/dest/utils/aztec.d.ts +3 -9
  76. package/dest/utils/aztec.d.ts.map +1 -1
  77. package/dest/utils/aztec.js +8 -32
  78. package/dest/utils/commands.d.ts +6 -7
  79. package/dest/utils/commands.d.ts.map +1 -1
  80. package/dest/utils/commands.js +5 -6
  81. package/dest/utils/inspect.d.ts +3 -10
  82. package/dest/utils/inspect.d.ts.map +1 -1
  83. package/dest/utils/inspect.js +13 -95
  84. package/dest/utils/setup_contracts.d.ts +1 -3
  85. package/dest/utils/setup_contracts.d.ts.map +1 -1
  86. package/dest/utils/setup_contracts.js +2 -22
  87. package/package.json +28 -25
  88. package/src/cmds/aztec_node/block_number.ts +9 -0
  89. package/src/cmds/aztec_node/get_block.ts +10 -0
  90. package/src/cmds/aztec_node/get_current_base_fee.ts +9 -0
  91. package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
  92. package/src/cmds/{pxe → aztec_node}/get_logs.ts +8 -7
  93. package/src/cmds/{pxe → aztec_node}/get_node_info.ts +5 -16
  94. package/src/cmds/aztec_node/index.ts +87 -0
  95. package/src/cmds/infrastructure/index.ts +7 -17
  96. package/src/cmds/infrastructure/sequencers.ts +6 -6
  97. package/src/cmds/infrastructure/setup_l2_contract.ts +13 -30
  98. package/src/cmds/l1/advance_epoch.ts +6 -5
  99. package/src/cmds/l1/assume_proven_through.ts +7 -6
  100. package/src/cmds/l1/bridge_erc20.ts +3 -1
  101. package/src/cmds/l1/deploy_l1_contracts.ts +6 -3
  102. package/src/cmds/l1/deploy_new_rollup.ts +4 -2
  103. package/src/cmds/l1/get_l1_addresses.ts +1 -1
  104. package/src/cmds/l1/index.ts +25 -53
  105. package/src/cmds/l1/update_l1_validators.ts +81 -6
  106. package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
  107. package/src/cmds/misc/generate_secret_key.ts +1 -1
  108. package/src/config/cached_fetch.ts +67 -0
  109. package/src/config/chain_l2_config.ts +597 -0
  110. package/src/config/enrich_env.ts +15 -0
  111. package/src/config/get_l1_config.ts +28 -0
  112. package/src/config/index.ts +4 -0
  113. package/src/config/network_config.ts +102 -0
  114. package/src/utils/aztec.ts +8 -40
  115. package/src/utils/commands.ts +8 -10
  116. package/src/utils/inspect.ts +18 -111
  117. package/src/utils/setup_contracts.ts +4 -43
  118. package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
  119. package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
  120. package/dest/cmds/devnet/bootstrap_network.js +0 -216
  121. package/dest/cmds/devnet/faucet.d.ts +0 -4
  122. package/dest/cmds/devnet/faucet.d.ts.map +0 -1
  123. package/dest/cmds/devnet/faucet.js +0 -26
  124. package/dest/cmds/devnet/index.d.ts.map +0 -1
  125. package/dest/cmds/devnet/index.js +0 -14
  126. package/dest/cmds/pxe/add_contract.d.ts +0 -5
  127. package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
  128. package/dest/cmds/pxe/add_contract.js +0 -29
  129. package/dest/cmds/pxe/block_number.d.ts +0 -3
  130. package/dest/cmds/pxe/block_number.d.ts.map +0 -1
  131. package/dest/cmds/pxe/block_number.js +0 -10
  132. package/dest/cmds/pxe/get_account.d.ts +0 -4
  133. package/dest/cmds/pxe/get_account.d.ts.map +0 -1
  134. package/dest/cmds/pxe/get_account.js +0 -10
  135. package/dest/cmds/pxe/get_accounts.d.ts +0 -3
  136. package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
  137. package/dest/cmds/pxe/get_accounts.js +0 -25
  138. package/dest/cmds/pxe/get_block.d.ts +0 -3
  139. package/dest/cmds/pxe/get_block.d.ts.map +0 -1
  140. package/dest/cmds/pxe/get_block.js +0 -9
  141. package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
  142. package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
  143. package/dest/cmds/pxe/get_contract_data.js +0 -31
  144. package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
  145. package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
  146. package/dest/cmds/pxe/get_current_base_fee.js +0 -7
  147. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
  148. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
  149. package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
  150. package/dest/cmds/pxe/get_logs.d.ts +0 -4
  151. package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
  152. package/dest/cmds/pxe/get_node_info.d.ts +0 -3
  153. package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
  154. package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
  155. package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
  156. package/dest/cmds/pxe/get_pxe_info.js +0 -11
  157. package/dest/cmds/pxe/index.d.ts +0 -4
  158. package/dest/cmds/pxe/index.d.ts.map +0 -1
  159. package/dest/cmds/pxe/index.js +0 -55
  160. package/src/cmds/devnet/bootstrap_network.ts +0 -321
  161. package/src/cmds/devnet/faucet.ts +0 -33
  162. package/src/cmds/devnet/index.ts +0 -60
  163. package/src/cmds/pxe/add_contract.ts +0 -41
  164. package/src/cmds/pxe/block_number.ts +0 -9
  165. package/src/cmds/pxe/get_account.ts +0 -16
  166. package/src/cmds/pxe/get_accounts.ts +0 -35
  167. package/src/cmds/pxe/get_block.ts +0 -10
  168. package/src/cmds/pxe/get_contract_data.ts +0 -51
  169. package/src/cmds/pxe/get_current_base_fee.ts +0 -9
  170. package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
  171. package/src/cmds/pxe/get_pxe_info.ts +0 -13
  172. package/src/cmds/pxe/index.ts +0 -170
  173. /package/dest/cmds/{devnet → aztec_node}/index.d.ts +0 -0
@@ -11,6 +11,7 @@ import {
11
11
  import { EthCheatCodes } from '@aztec/ethereum/test';
12
12
  import type { EthAddress } from '@aztec/foundation/eth-address';
13
13
  import type { LogFn, Logger } from '@aztec/foundation/log';
14
+ import { DateProvider } from '@aztec/foundation/timer';
14
15
  import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
15
16
  import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
16
17
 
@@ -96,7 +97,7 @@ export async function addL1Validator({
96
97
 
97
98
  const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
98
99
 
99
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, debugLogger);
100
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
100
101
  const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
101
102
  const merkleProofArray = merkleProof.map(proof => addLeadingHex(proof));
102
103
 
@@ -120,7 +121,81 @@ export async function addL1Validator({
120
121
  await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
121
122
  if (isAnvilTestChain(chainId)) {
122
123
  dualLog(`Funding validator on L1`);
123
- const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
124
+ const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
125
+ await cheatCodes.setBalance(attesterAddress, 10n ** 20n);
126
+ } else {
127
+ const balance = await l1Client.getBalance({ address: attesterAddress.toString() });
128
+ dualLog(`Validator balance: ${formatEther(balance)} ETH`);
129
+ if (balance === 0n) {
130
+ dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
131
+ }
132
+ }
133
+ }
134
+
135
+ export async function addL1ValidatorViaRollup({
136
+ rpcUrls,
137
+ chainId,
138
+ privateKey,
139
+ mnemonic,
140
+ attesterAddress,
141
+ withdrawerAddress,
142
+ blsSecretKey,
143
+ moveWithLatestRollup,
144
+ rollupAddress,
145
+ log,
146
+ debugLogger,
147
+ }: RollupCommandArgs &
148
+ LoggerArgs & {
149
+ blsSecretKey: bigint; // scalar field element of BN254
150
+ attesterAddress: EthAddress;
151
+ moveWithLatestRollup: boolean;
152
+ }) {
153
+ const dualLog = makeDualLog(log, debugLogger);
154
+ const account = getAccount(privateKey, mnemonic);
155
+ const chain = createEthereumChain(rpcUrls, chainId);
156
+ const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
157
+
158
+ dualLog(`Adding validator ${attesterAddress} to rollup ${rollupAddress.toString()} via direct deposit`);
159
+
160
+ if (!withdrawerAddress) {
161
+ throw new Error(`Withdrawer address required`);
162
+ }
163
+
164
+ const rollup = getContract({
165
+ address: rollupAddress.toString(),
166
+ abi: RollupAbi,
167
+ client: l1Client,
168
+ });
169
+
170
+ const gseAddress = await rollup.read.getGSE();
171
+
172
+ const gse = new GSEContract(l1Client, gseAddress);
173
+
174
+ const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
175
+
176
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
177
+
178
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
179
+ to: rollupAddress.toString(),
180
+ data: encodeFunctionData({
181
+ abi: RollupAbi,
182
+ functionName: 'deposit',
183
+ args: [
184
+ attesterAddress.toString(),
185
+ withdrawerAddress.toString(),
186
+ registrationTuple.publicKeyInG1,
187
+ registrationTuple.publicKeyInG2,
188
+ registrationTuple.proofOfPossession,
189
+ moveWithLatestRollup,
190
+ ],
191
+ }),
192
+ abi: StakingAssetHandlerAbi,
193
+ });
194
+ dualLog(`Transaction hash: ${receipt.transactionHash}`);
195
+ await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
196
+ if (isAnvilTestChain(chainId)) {
197
+ dualLog(`Funding validator on L1`);
198
+ const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
124
199
  await cheatCodes.setBalance(attesterAddress, 10n ** 20n);
125
200
  } else {
126
201
  const balance = await l1Client.getBalance({ address: attesterAddress.toString() });
@@ -145,7 +220,7 @@ export async function removeL1Validator({
145
220
  const account = getAccount(privateKey, mnemonic);
146
221
  const chain = createEthereumChain(rpcUrls, chainId);
147
222
  const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
148
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, debugLogger);
223
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
149
224
 
150
225
  dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
151
226
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
@@ -172,7 +247,7 @@ export async function pruneRollup({
172
247
  const account = getAccount(privateKey, mnemonic);
173
248
  const chain = createEthereumChain(rpcUrls, chainId);
174
249
  const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
175
- const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, debugLogger);
250
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
176
251
 
177
252
  dualLog(`Trying prune`);
178
253
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
@@ -201,7 +276,7 @@ export async function fastForwardEpochs({
201
276
  client: publicClient,
202
277
  });
203
278
 
204
- const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
279
+ const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
205
280
  const currentSlot = await rollup.read.getCurrentSlot();
206
281
  const l2SlotsInEpoch = await rollup.read.getEpochDuration();
207
282
  const timestamp = await rollup.read.getTimestampForSlot([currentSlot + l2SlotsInEpoch * numEpochs]);
@@ -234,7 +309,7 @@ export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: Roll
234
309
  log(`Committee: ${committee?.map(v => v.toString()).join(', ')}`);
235
310
  const archive = await rollup.archive();
236
311
  log(`Archive: ${archive}`);
237
- const epochNum = await rollup.getEpochNumber();
312
+ const epochNum = await rollup.getCurrentEpochNumber();
238
313
  log(`Current epoch: ${epochNum}`);
239
314
  const slot = await rollup.getSlotNumber();
240
315
  log(`Current slot: ${slot}`);
@@ -1,4 +1,4 @@
1
- import { computeSecretHash } from '@aztec/aztec.js';
1
+ import { computeSecretHash } from '@aztec/aztec.js/crypto';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import type { LogFn } from '@aztec/foundation/log';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/aztec.js';
1
+ import { Fr } from '@aztec/aztec.js/fields';
2
2
 
3
3
  export function generateSecretKey() {
4
4
  return { secretKey: Fr.random() };
@@ -0,0 +1,67 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
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
+ }