@aztec/cli 0.0.1-commit.96dac018d → 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.
Files changed (51) hide show
  1. package/dest/cmds/aztec_node/block_number.js +1 -1
  2. package/dest/cmds/aztec_node/get_logs.d.ts +30 -4
  3. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -1
  4. package/dest/cmds/aztec_node/get_logs.js +39 -29
  5. package/dest/cmds/aztec_node/get_node_info.d.ts +1 -1
  6. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -1
  7. package/dest/cmds/aztec_node/get_node_info.js +0 -2
  8. package/dest/cmds/aztec_node/index.d.ts +1 -1
  9. package/dest/cmds/aztec_node/index.d.ts.map +1 -1
  10. package/dest/cmds/aztec_node/index.js +13 -3
  11. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +1 -1
  12. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -1
  13. package/dest/cmds/l1/deploy_l1_contracts_cmd.js +0 -1
  14. package/dest/cmds/l1/deploy_new_rollup.d.ts +1 -1
  15. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  16. package/dest/cmds/l1/deploy_new_rollup.js +2 -4
  17. package/dest/cmds/l1/update_l1_validators.d.ts +1 -1
  18. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  19. package/dest/cmds/l1/update_l1_validators.js +0 -1
  20. package/dest/config/cached_fetch.d.ts +19 -10
  21. package/dest/config/cached_fetch.d.ts.map +1 -1
  22. package/dest/config/cached_fetch.js +110 -32
  23. package/dest/config/generated/networks.d.ts +55 -45
  24. package/dest/config/generated/networks.d.ts.map +1 -1
  25. package/dest/config/generated/networks.js +56 -46
  26. package/dest/config/network_config.d.ts +1 -1
  27. package/dest/config/network_config.d.ts.map +1 -1
  28. package/dest/config/network_config.js +6 -2
  29. package/dest/utils/aztec.d.ts +1 -2
  30. package/dest/utils/aztec.d.ts.map +1 -1
  31. package/dest/utils/aztec.js +2 -3
  32. package/dest/utils/commands.d.ts +14 -6
  33. package/dest/utils/commands.d.ts.map +1 -1
  34. package/dest/utils/commands.js +19 -9
  35. package/dest/utils/inspect.d.ts +1 -1
  36. package/dest/utils/inspect.d.ts.map +1 -1
  37. package/dest/utils/inspect.js +6 -5
  38. package/package.json +30 -30
  39. package/src/cmds/aztec_node/block_number.ts +1 -1
  40. package/src/cmds/aztec_node/get_logs.ts +70 -38
  41. package/src/cmds/aztec_node/get_node_info.ts +0 -2
  42. package/src/cmds/aztec_node/index.ts +13 -8
  43. package/src/cmds/l1/deploy_l1_contracts_cmd.ts +0 -1
  44. package/src/cmds/l1/deploy_new_rollup.ts +1 -3
  45. package/src/cmds/l1/update_l1_validators.ts +0 -1
  46. package/src/config/cached_fetch.ts +119 -31
  47. package/src/config/generated/networks.ts +54 -44
  48. package/src/config/network_config.ts +6 -2
  49. package/src/utils/aztec.ts +12 -18
  50. package/src/utils/commands.ts +22 -9
  51. package/src/utils/inspect.ts +4 -5
@@ -3,11 +3,12 @@ import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { PublicKeys } from '@aztec/stdlib/keys';
6
- import { LogId } from '@aztec/stdlib/logs/log-id';
6
+ import { LogCursor, Tag } from '@aztec/stdlib/logs';
7
7
  import { TxHash } from '@aztec/stdlib/tx/tx-hash';
8
8
  import { CommanderError, InvalidArgumentError, Option } from 'commander';
9
9
  import { lookup } from 'dns/promises';
10
10
  import { rename, writeFile } from 'fs/promises';
11
+ export { LogCursor };
11
12
  /**
12
13
  * If we can successfully resolve 'host.docker.internal', then we are running in a container, and we should treat
13
14
  * localhost as being host.docker.internal.
@@ -166,15 +167,24 @@ export function parseBigint(bigint) {
166
167
  return parseAztecAddress(address);
167
168
  }
168
169
  /**
169
- * Parses an optional log ID string into a LogId object.
170
- *
171
- * @param logId - The log ID string to parse.
172
- * @returns The parsed LogId object, or undefined if the log ID is missing or empty.
173
- */ export function parseOptionalLogId(logId) {
174
- if (!logId) {
175
- return undefined;
170
+ * Parses an optional `<blockNumber>-<txIndexWithinBlock>-<logIndexWithinTx>` triple into a {@link LogCursor},
171
+ * used as the `--after-log` argument of `get-logs` to resume pagination strictly after a previously-seen log.
172
+ * Thin wrapper over {@link LogCursor.parseOptional} that surfaces parse errors as commander's
173
+ * {@link InvalidArgumentError}.
174
+ */ export function parseOptionalLogCursor(value) {
175
+ try {
176
+ return LogCursor.parseOptional(value);
177
+ } catch (err) {
178
+ throw new InvalidArgumentError(err instanceof Error ? err.message : String(err));
176
179
  }
177
- return LogId.fromString(logId);
180
+ }
181
+ /**
182
+ * Parses a log tag from a string. Tags are field-element values; we delegate to the {@link parseField} parser.
183
+ *
184
+ * @param tag - A hex string, integer, or boolean string representing the tag.
185
+ * @returns A {@link Tag} wrapping the parsed field.
186
+ */ export function parseTag(tag) {
187
+ return new Tag(parseField(tag));
178
188
  }
179
189
  /**
180
190
  * Parses a selector from a string.
@@ -8,4 +8,4 @@ export declare function inspectBlock(aztecNode: AztecNode, blockNumber: BlockNum
8
8
  export declare function inspectTx(aztecNode: AztecNode, txHash: TxHash, log: LogFn, opts?: {
9
9
  includeBlockInfo?: boolean;
10
10
  }): Promise<void>;
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zcGVjdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL2luc3BlY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRS9DLHdCQUFzQixZQUFZLENBQ2hDLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFdBQVcsRUFBRSxXQUFXLEVBQ3hCLEdBQUcsRUFBRSxLQUFLLEVBQ1YsSUFBSSxHQUFFO0lBQUUsT0FBTyxDQUFDLEVBQUUsT0FBTyxDQUFBO0NBQU8saUJBMEJqQztBQUVELHdCQUFzQixTQUFTLENBQzdCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxNQUFNLEVBQ2QsR0FBRyxFQUFFLEtBQUssRUFDVixJQUFJLEdBQUU7SUFBRSxnQkFBZ0IsQ0FBQyxFQUFFLE9BQU8sQ0FBQTtDQUFPLGlCQXNFMUMifQ==
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zcGVjdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL2luc3BlY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRS9DLHdCQUFzQixZQUFZLENBQ2hDLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFdBQVcsRUFBRSxXQUFXLEVBQ3hCLEdBQUcsRUFBRSxLQUFLLEVBQ1YsSUFBSSxHQUFFO0lBQUUsT0FBTyxDQUFDLEVBQUUsT0FBTyxDQUFBO0NBQU8saUJBeUJqQztBQUVELHdCQUFzQixTQUFTLENBQzdCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxNQUFNLEVBQ2QsR0FBRyxFQUFFLEtBQUssRUFDVixJQUFJLEdBQUU7SUFBRSxnQkFBZ0IsQ0FBQyxFQUFFLE9BQU8sQ0FBQTtDQUFPLGlCQXNFMUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/utils/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,KAAK,EACV,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,iBA0BjC;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,KAAK,EACV,IAAI,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,iBAsE1C"}
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/utils/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,KAAK,EACV,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,iBAyBjC;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,KAAK,EACV,IAAI,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,iBAsE1C"}
@@ -1,25 +1,26 @@
1
1
  export async function inspectBlock(aztecNode, blockNumber, log, opts = {}) {
2
- const block = await aztecNode.getBlock(blockNumber);
2
+ const block = await aztecNode.getBlock(blockNumber, {
3
+ includeTransactions: opts.showTxs
4
+ });
3
5
  if (!block) {
4
6
  log(`No block found for block number ${blockNumber}`);
5
7
  return;
6
8
  }
7
- const blockHash = await block.hash();
8
- log(`Block ${blockNumber} (${blockHash.toString()})`);
9
+ log(`Block ${blockNumber} (${block.hash.toString()})`);
9
10
  log(` Total fees: ${block.header.totalFees.toBigInt()}`);
10
11
  log(` Total mana used: ${block.header.totalManaUsed.toBigInt()}`);
11
12
  log(` Fee per gas unit: DA=${block.header.globalVariables.gasFees.feePerDaGas} L2=${block.header.globalVariables.gasFees.feePerL2Gas}`);
12
13
  log(` Coinbase: ${block.header.globalVariables.coinbase}`);
13
14
  log(` Fee recipient: ${block.header.globalVariables.feeRecipient}`);
14
15
  log(` Timestamp: ${new Date(Number(block.header.globalVariables.timestamp) * 500)}`);
15
- if (opts.showTxs) {
16
+ if (opts.showTxs && block.body) {
16
17
  log(``);
17
18
  for (const txHash of block.body.txEffects.map((tx)=>tx.txHash)){
18
19
  await inspectTx(aztecNode, txHash, log, {
19
20
  includeBlockInfo: false
20
21
  });
21
22
  }
22
- } else {
23
+ } else if (block.body) {
23
24
  log(` Transactions: ${block.body.txEffects.length}`);
24
25
  }
25
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "0.0.1-commit.96dac018d",
3
+ "version": "0.0.1-commit.993d240",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -77,23 +77,23 @@
77
77
  ]
78
78
  },
79
79
  "dependencies": {
80
- "@aztec/accounts": "0.0.1-commit.96dac018d",
81
- "@aztec/archiver": "0.0.1-commit.96dac018d",
82
- "@aztec/aztec.js": "0.0.1-commit.96dac018d",
83
- "@aztec/constants": "0.0.1-commit.96dac018d",
84
- "@aztec/entrypoints": "0.0.1-commit.96dac018d",
85
- "@aztec/ethereum": "0.0.1-commit.96dac018d",
86
- "@aztec/foundation": "0.0.1-commit.96dac018d",
87
- "@aztec/l1-artifacts": "0.0.1-commit.96dac018d",
88
- "@aztec/node-keystore": "0.0.1-commit.96dac018d",
89
- "@aztec/node-lib": "0.0.1-commit.96dac018d",
90
- "@aztec/p2p": "0.0.1-commit.96dac018d",
91
- "@aztec/protocol-contracts": "0.0.1-commit.96dac018d",
92
- "@aztec/sequencer-client": "0.0.1-commit.96dac018d",
93
- "@aztec/slasher": "0.0.1-commit.96dac018d",
94
- "@aztec/stdlib": "0.0.1-commit.96dac018d",
95
- "@aztec/wallets": "0.0.1-commit.96dac018d",
96
- "@aztec/world-state": "0.0.1-commit.96dac018d",
80
+ "@aztec/accounts": "0.0.1-commit.993d240",
81
+ "@aztec/archiver": "0.0.1-commit.993d240",
82
+ "@aztec/aztec.js": "0.0.1-commit.993d240",
83
+ "@aztec/constants": "0.0.1-commit.993d240",
84
+ "@aztec/entrypoints": "0.0.1-commit.993d240",
85
+ "@aztec/ethereum": "0.0.1-commit.993d240",
86
+ "@aztec/foundation": "0.0.1-commit.993d240",
87
+ "@aztec/l1-artifacts": "0.0.1-commit.993d240",
88
+ "@aztec/node-keystore": "0.0.1-commit.993d240",
89
+ "@aztec/node-lib": "0.0.1-commit.993d240",
90
+ "@aztec/p2p": "0.0.1-commit.993d240",
91
+ "@aztec/protocol-contracts": "0.0.1-commit.993d240",
92
+ "@aztec/sequencer-client": "0.0.1-commit.993d240",
93
+ "@aztec/slasher": "0.0.1-commit.993d240",
94
+ "@aztec/stdlib": "0.0.1-commit.993d240",
95
+ "@aztec/wallets": "0.0.1-commit.993d240",
96
+ "@aztec/world-state": "0.0.1-commit.993d240",
97
97
  "@ethersproject/wallet": "^5.8.0",
98
98
  "@iarna/toml": "^2.2.5",
99
99
  "@libp2p/peer-id-factory": "^3.0.4",
@@ -107,9 +107,9 @@
107
107
  "viem": "npm:@aztec/viem@2.38.2"
108
108
  },
109
109
  "devDependencies": {
110
- "@aztec/aztec-node": "0.0.1-commit.96dac018d",
111
- "@aztec/kv-store": "0.0.1-commit.96dac018d",
112
- "@aztec/telemetry-client": "0.0.1-commit.96dac018d",
110
+ "@aztec/aztec-node": "0.0.1-commit.993d240",
111
+ "@aztec/kv-store": "0.0.1-commit.993d240",
112
+ "@aztec/telemetry-client": "0.0.1-commit.993d240",
113
113
  "@jest/globals": "^30.0.0",
114
114
  "@types/jest": "^30.0.0",
115
115
  "@types/lodash.chunk": "^4.2.9",
@@ -126,15 +126,15 @@
126
126
  "typescript": "^5.3.3"
127
127
  },
128
128
  "peerDependencies": {
129
- "@aztec/accounts": "0.0.1-commit.96dac018d",
130
- "@aztec/bb-prover": "0.0.1-commit.96dac018d",
131
- "@aztec/ethereum": "0.0.1-commit.96dac018d",
132
- "@aztec/l1-artifacts": "0.0.1-commit.96dac018d",
133
- "@aztec/noir-contracts.js": "0.0.1-commit.96dac018d",
134
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.96dac018d",
135
- "@aztec/noir-test-contracts.js": "0.0.1-commit.96dac018d",
136
- "@aztec/protocol-contracts": "0.0.1-commit.96dac018d",
137
- "@aztec/stdlib": "0.0.1-commit.96dac018d"
129
+ "@aztec/accounts": "0.0.1-commit.993d240",
130
+ "@aztec/bb-prover": "0.0.1-commit.993d240",
131
+ "@aztec/ethereum": "0.0.1-commit.993d240",
132
+ "@aztec/l1-artifacts": "0.0.1-commit.993d240",
133
+ "@aztec/noir-contracts.js": "0.0.1-commit.993d240",
134
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.993d240",
135
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.993d240",
136
+ "@aztec/protocol-contracts": "0.0.1-commit.993d240",
137
+ "@aztec/stdlib": "0.0.1-commit.993d240"
138
138
  },
139
139
  "files": [
140
140
  "dest",
@@ -3,7 +3,7 @@ import type { LogFn } from '@aztec/foundation/log';
3
3
 
4
4
  export async function blockNumber(nodeUrl: string, log: LogFn) {
5
5
  const aztecNode = createAztecNodeClient(nodeUrl);
6
- const [latestNum, provenNum] = await Promise.all([aztecNode.getBlockNumber(), aztecNode.getProvenBlockNumber()]);
6
+ const [latestNum, provenNum] = await Promise.all([aztecNode.getBlockNumber(), aztecNode.getBlockNumber('proven')]);
7
7
  log(`Latest block: ${latestNum}`);
8
8
  log(`Proven block: ${provenNum}`);
9
9
  }
@@ -1,22 +1,47 @@
1
1
  import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import type { LogFilter, LogId } from '@aztec/aztec.js/log';
3
2
  import { createAztecNodeClient } from '@aztec/aztec.js/node';
4
3
  import type { TxHash } from '@aztec/aztec.js/tx';
5
- import { BlockNumber } from '@aztec/foundation/branded-types';
4
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
6
5
  import type { LogFn } from '@aztec/foundation/log';
7
6
  import { sleep } from '@aztec/foundation/sleep';
7
+ import {
8
+ LogCursor,
9
+ type PublicLogsQuery,
10
+ type Tag,
11
+ logResultToHumanReadable,
12
+ queryAllPublicLogsByTags,
13
+ } from '@aztec/stdlib/logs';
8
14
 
9
- export async function getLogs(
10
- txHash: TxHash,
11
- fromBlock: BlockNumber,
12
- toBlock: BlockNumber,
13
- afterLog: LogId,
14
- contractAddress: AztecAddress,
15
- nodeUrl: string,
16
- follow: boolean,
17
- log: LogFn,
18
- ) {
19
- const node = createAztecNodeClient(nodeUrl);
15
+ /** Options for the `get-logs` CLI command. */
16
+ export type GetLogsOptions = {
17
+ /** Contract address that emitted the logs (required). */
18
+ contractAddress: AztecAddress;
19
+ /** Tag to filter logs by (required). */
20
+ tag: Tag;
21
+ /** Restrict the search to this tx hash. Mutually exclusive with `fromBlock`/`toBlock`. */
22
+ txHash?: TxHash;
23
+ /** Lower block bound, inclusive. */
24
+ fromBlock?: BlockNumber;
25
+ /** Upper block bound, exclusive. */
26
+ toBlock?: BlockNumber;
27
+ /** Log cursor to resume pagination strictly after a previously-seen log. */
28
+ afterLog?: LogCursor;
29
+ /** Node RPC URL. */
30
+ nodeUrl: string;
31
+ /** When set, polls indefinitely for new logs. Incompatible with `txHash` and `toBlock`. */
32
+ follow: boolean;
33
+ /** Log function. */
34
+ log: LogFn;
35
+ };
36
+
37
+ /**
38
+ * Fetches public logs for a (contract, tag) pair, draining all pages via the stdlib pagination helper.
39
+ * In `--follow` mode, polls indefinitely: each round drains all currently-available logs, then sleeps
40
+ * until the next poll if nothing new was found.
41
+ */
42
+ export async function getLogs(options: GetLogsOptions): Promise<void> {
43
+ const { txHash, fromBlock, toBlock, contractAddress, tag, nodeUrl, follow, log } = options;
44
+ let afterLog = options.afterLog;
20
45
 
21
46
  if (follow) {
22
47
  if (txHash) {
@@ -26,43 +51,50 @@ export async function getLogs(
26
51
  throw Error('Cannot use --follow with --to-block');
27
52
  }
28
53
  }
54
+ if (txHash !== undefined && (fromBlock !== undefined || toBlock !== undefined)) {
55
+ throw Error('Cannot combine --tx-hash with --from-block / --to-block');
56
+ }
29
57
 
30
- const filter: LogFilter = { txHash, fromBlock, toBlock, afterLog, contractAddress };
31
-
32
- const fetchLogs = async () => {
33
- const response = await node.getPublicLogs(filter);
34
- const logs = response.logs;
58
+ const node = createAztecNodeClient(nodeUrl);
35
59
 
36
- if (!logs.length) {
37
- const filterOptions = Object.entries(filter)
38
- .filter(([, value]) => value !== undefined)
39
- .map(([key, value]) => `${key}: ${value}`)
40
- .join(', ');
41
- if (!follow) {
42
- log(`No logs found for filter: {${filterOptions}}`);
43
- }
44
- } else {
45
- if (!follow && !filter.afterLog) {
46
- log('Logs found: \n');
47
- }
48
- logs.forEach(publicLog => log(publicLog.toHumanReadable()));
49
- // Set the continuation parameter for the following requests
50
- filter.afterLog = logs[logs.length - 1].id;
60
+ const drainLogs = async () => {
61
+ const query: PublicLogsQuery = {
62
+ contractAddress,
63
+ tags: [afterLog !== undefined ? { tag, afterLog } : tag],
64
+ fromBlock,
65
+ toBlock,
66
+ txHash,
67
+ };
68
+ const [logsForTag] = await queryAllPublicLogsByTags(node, query);
69
+ if (logsForTag.length > 0) {
70
+ afterLog = LogCursor.fromLog(logsForTag[logsForTag.length - 1]);
51
71
  }
52
- return response.maxLogsHit;
72
+ return logsForTag;
53
73
  };
54
74
 
55
75
  if (follow) {
56
76
  log('Fetching logs...');
57
77
  while (true) {
58
- const maxLogsHit = await fetchLogs();
59
- if (!maxLogsHit) {
78
+ const results = await drainLogs();
79
+ if (results.length === 0) {
60
80
  await sleep(1000);
81
+ } else {
82
+ results.forEach(r => log(logResultToHumanReadable(r)));
61
83
  }
62
84
  }
63
85
  } else {
64
- while (await fetchLogs()) {
65
- // Keep fetching logs until we reach the end.
86
+ const results = await drainLogs();
87
+ if (results.length === 0) {
88
+ log(
89
+ `No logs found for {contractAddress: ${contractAddress.toString()}, tag: ${tag.toString()}` +
90
+ `${txHash ? `, txHash: ${txHash.toString()}` : ''}` +
91
+ `${fromBlock !== undefined ? `, fromBlock: ${fromBlock}` : ''}` +
92
+ `${toBlock !== undefined ? `, toBlock: ${toBlock}` : ''}` +
93
+ `${afterLog ? `, afterLog: ${afterLog.toString()}` : ''}}`,
94
+ );
95
+ } else {
96
+ log('Logs found: \n');
97
+ results.forEach(r => log(logResultToHumanReadable(r)));
66
98
  }
67
99
  }
68
100
  }
@@ -23,7 +23,6 @@ export async function getNodeInfo(nodeUrl: string, json: boolean, log: LogFn, lo
23
23
  rewardDistributor: info.l1ContractAddresses.rewardDistributorAddress.toString(),
24
24
  governanceProposer: info.l1ContractAddresses.governanceProposerAddress.toString(),
25
25
  governance: info.l1ContractAddresses.governanceAddress.toString(),
26
- slashFactory: info.l1ContractAddresses.slashFactoryAddress?.toString(),
27
26
  feeAssetHandler: info.l1ContractAddresses.feeAssetHandlerAddress?.toString(),
28
27
  stakingAssetHandler: info.l1ContractAddresses.stakingAssetHandlerAddress?.toString(),
29
28
  },
@@ -51,7 +50,6 @@ export async function getNodeInfo(nodeUrl: string, json: boolean, log: LogFn, lo
51
50
  log(` RewardDistributor Address: ${info.l1ContractAddresses.rewardDistributorAddress.toString()}`);
52
51
  log(` GovernanceProposer Address: ${info.l1ContractAddresses.governanceProposerAddress.toString()}`);
53
52
  log(` Governance Address: ${info.l1ContractAddresses.governanceAddress.toString()}`);
54
- log(` SlashFactory Address: ${info.l1ContractAddresses.slashFactoryAddress?.toString()}`);
55
53
  log(` FeeAssetHandler Address: ${info.l1ContractAddresses.feeAssetHandlerAddress?.toString()}`);
56
54
  log(` StakingAssetHandler Address: ${info.l1ContractAddresses.stakingAssetHandlerAddress?.toString()}`);
57
55
  log(`L2 Contract Addresses:`);
@@ -7,10 +7,10 @@ import {
7
7
  nodeOption,
8
8
  parseAztecAddress,
9
9
  parseField,
10
- parseOptionalAztecAddress,
11
10
  parseOptionalInteger,
12
- parseOptionalLogId,
11
+ parseOptionalLogCursor,
13
12
  parseOptionalTxHash,
13
+ parseTag,
14
14
  } from '../../utils/commands.js';
15
15
 
16
16
  export function injectCommands(program: Command, log: LogFn, debugLogger: Logger) {
@@ -47,21 +47,26 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
47
47
 
48
48
  program
49
49
  .command('get-logs')
50
- .description('Gets all the public logs from an intersection of all the filter params.')
51
- .option('-tx, --tx-hash <txHash>', 'A transaction hash to get the receipt for.', parseOptionalTxHash)
50
+ .description('Gets public logs for a contract and tag, optionally restricted by block range or tx hash.')
51
+ .requiredOption('-ca, --contract-address <address>', 'Contract address that emitted the logs.', parseAztecAddress)
52
+ .requiredOption('--tag <tag>', 'Tag (Fr value) to filter logs by.', parseTag)
53
+ .option('-tx, --tx-hash <txHash>', 'A transaction hash to restrict the search to.', parseOptionalTxHash)
52
54
  .option(
53
55
  '-fb, --from-block <blockNum>',
54
56
  'Initial block number for getting logs (defaults to 1).',
55
57
  parseOptionalInteger,
56
58
  )
57
59
  .option('-tb, --to-block <blockNum>', 'Up to which block to fetch logs (defaults to latest).', parseOptionalInteger)
58
- .option('-al --after-log <logId>', 'ID of a log after which to fetch the logs.', parseOptionalLogId)
59
- .option('-ca, --contract-address <address>', 'Contract address to filter logs by.', parseOptionalAztecAddress)
60
+ .option(
61
+ '-al --after-log <cursor>',
62
+ 'Log cursor of the form <blockNumber>-<txIndexWithinBlock>-<logIndexWithinTx> to resume pagination after.',
63
+ parseOptionalLogCursor,
64
+ )
60
65
  .addOption(nodeOption)
61
66
  .option('--follow', 'If set, will keep polling for new logs until interrupted.')
62
- .action(async ({ txHash, fromBlock, toBlock, afterLog, contractAddress, aztecNodeRpcUrl: nodeUrl, follow }) => {
67
+ .action(async ({ txHash, fromBlock, toBlock, afterLog, contractAddress, tag, nodeUrl, follow }) => {
63
68
  const { getLogs } = await import('./get_logs.js');
64
- await getLogs(txHash, fromBlock, toBlock, afterLog, contractAddress, nodeUrl, follow, log);
69
+ await getLogs({ txHash, fromBlock, toBlock, afterLog, contractAddress, tag, nodeUrl, follow, log });
65
70
  });
66
71
 
67
72
  program
@@ -96,7 +96,6 @@ export async function deployL1ContractsCmd(
96
96
  log(`RewardDistributor Address: ${l1ContractAddresses.rewardDistributorAddress.toString()}`);
97
97
  log(`GovernanceProposer Address: ${l1ContractAddresses.governanceProposerAddress.toString()}`);
98
98
  log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`);
99
- log(`SlashFactory Address: ${l1ContractAddresses.slashFactoryAddress?.toString()}`);
100
99
  log(`FeeAssetHandler Address: ${l1ContractAddresses.feeAssetHandlerAddress?.toString()}`);
101
100
  log(`StakingAssetHandler Address: ${l1ContractAddresses.stakingAssetHandlerAddress?.toString()}`);
102
101
  log(`ZK Passport Verifier Address: ${l1ContractAddresses.zkPassportVerifierAddress?.toString()}`);
@@ -29,7 +29,7 @@ export async function deployNewRollup(
29
29
  const initialFundedAccounts = initialAccounts.map(a => a.address).concat(sponsoredFPCAddress);
30
30
  const { genesisArchiveRoot, fundingNeeded } = await getGenesisValues(initialFundedAccounts);
31
31
 
32
- const { rollup, slashFactoryAddress } = await deployNewRollupContracts(
32
+ const { rollup } = await deployNewRollupContracts(
33
33
  registryAddress,
34
34
  rpcUrls,
35
35
  privateKey,
@@ -51,7 +51,6 @@ export async function deployNewRollup(
51
51
  initialFundedAccounts: initialFundedAccounts.map(a => a.toString()),
52
52
  initialValidators: initialValidators.map(a => a.attester.toString()),
53
53
  genesisArchiveRoot: genesisArchiveRoot.toString(),
54
- slashFactoryAddress: slashFactoryAddress.toString(),
55
54
  },
56
55
  null,
57
56
  2,
@@ -62,6 +61,5 @@ export async function deployNewRollup(
62
61
  log(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
63
62
  log(`Initial validators: ${initialValidators.map(a => a.attester.toString()).join(', ')}`);
64
63
  log(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
65
- log(`Slash Factory Address: ${slashFactoryAddress.toString()}`);
66
64
  }
67
65
  }
@@ -38,7 +38,6 @@ export interface LoggerArgs {
38
38
  export function generateL1Account() {
39
39
  const privateKey = generatePrivateKey();
40
40
  const account = privateKeyToAccount(privateKey);
41
- account.address;
42
41
  return {
43
42
  privateKey,
44
43
  address: account.address,
@@ -1,24 +1,48 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
2
 
3
- import { mkdir, readFile, stat, writeFile } from 'fs/promises';
3
+ import { mkdir, readFile, writeFile } from 'fs/promises';
4
4
  import { dirname } from 'path';
5
5
 
6
6
  export interface CachedFetchOptions {
7
- /** Cache duration in milliseconds */
8
- cacheDurationMs: number;
9
- /** The cache file */
7
+ /** The cache file path for storing data. If not provided, no caching is performed. */
10
8
  cacheFile?: string;
9
+ /** Fallback max-age in milliseconds when server sends no Cache-Control header. Defaults to 5 minutes. */
10
+ defaultMaxAgeMs?: number;
11
+ }
12
+
13
+ /** Cache metadata stored in a sidecar .meta file alongside the data file. */
14
+ interface CacheMeta {
15
+ etag?: string;
16
+ expiresAt: number;
17
+ }
18
+
19
+ const DEFAULT_MAX_AGE_MS = 5 * 60 * 1000; // 5 minutes
20
+
21
+ /** Extracts max-age value in milliseconds from a Response's Cache-Control header. Returns undefined if not present. */
22
+ export function parseMaxAge(response: { headers: { get(name: string): string | null } }): number | undefined {
23
+ const cacheControl = response.headers.get('cache-control');
24
+ if (!cacheControl) {
25
+ return undefined;
26
+ }
27
+ const match = cacheControl.match(/max-age=(\d+)/);
28
+ if (!match) {
29
+ return undefined;
30
+ }
31
+ return parseInt(match[1], 10) * 1000;
11
32
  }
12
33
 
13
34
  /**
14
- * Fetches data from a URL with file-based caching support.
15
- * This utility can be used by both remote config and bootnodes fetching.
35
+ * Fetches data from a URL with file-based HTTP conditional caching.
36
+ *
37
+ * Data is stored as raw JSON in the cache file (same format as the server returns).
38
+ * Caching metadata (ETag, expiry) is stored in a separate sidecar `.meta` file.
39
+ * This keeps the data file human-readable and backward-compatible with older code.
16
40
  *
17
41
  * @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
42
+ * @param options - Caching options
43
+ * @param fetch - Fetch implementation (defaults to globalThis.fetch)
44
+ * @param log - Logger instance
45
+ * @returns The fetched and parsed JSON data, or undefined if fetch fails
22
46
  */
23
47
  export async function cachedFetch<T = any>(
24
48
  url: string,
@@ -26,42 +50,106 @@ export async function cachedFetch<T = any>(
26
50
  fetch = globalThis.fetch,
27
51
  log = createLogger('cached_fetch'),
28
52
  ): Promise<T | undefined> {
29
- const { cacheDurationMs, cacheFile } = options;
53
+ const { cacheFile, defaultMaxAgeMs = DEFAULT_MAX_AGE_MS } = options;
54
+
55
+ // If no cacheFile, just fetch normally without caching
56
+ if (!cacheFile) {
57
+ return fetchAndParse<T>(url, fetch, log);
58
+ }
59
+
60
+ const metaFile = cacheFile + '.meta';
30
61
 
31
- // Try to read from cache first
62
+ // Try to read metadata
63
+ let meta: CacheMeta | undefined;
32
64
  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
- }
65
+ meta = JSON.parse(await readFile(metaFile, 'utf-8'));
40
66
  } catch {
41
- log.trace('Failed to read data from cache');
67
+ log.trace('No usable cache metadata found');
42
68
  }
43
69
 
70
+ // Try to read cached data
71
+ let cachedData: T | undefined;
44
72
  try {
45
- const response = await fetch(url);
73
+ cachedData = JSON.parse(await readFile(cacheFile, 'utf-8'));
74
+ } catch {
75
+ log.trace('No usable cached data found');
76
+ }
77
+
78
+ // If metadata and data exist and cache is fresh, return directly
79
+ if (meta && cachedData !== undefined && meta.expiresAt > Date.now()) {
80
+ return cachedData;
81
+ }
82
+
83
+ // Cache is stale or missing — make a (possibly conditional) request
84
+ try {
85
+ const headers: Record<string, string> = {};
86
+ if (meta?.etag && cachedData !== undefined) {
87
+ headers['If-None-Match'] = meta.etag;
88
+ }
89
+
90
+ const response = await fetch(url, { headers });
91
+
92
+ if (response.status === 304 && cachedData !== undefined) {
93
+ // Not modified — recompute expiry from new response headers and return cached data
94
+ const maxAgeMs = parseMaxAge(response) ?? defaultMaxAgeMs;
95
+ await writeMetaFile(metaFile, { etag: meta?.etag, expiresAt: Date.now() + maxAgeMs }, log);
96
+ return cachedData;
97
+ }
98
+
46
99
  if (!response.ok) {
47
100
  log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
48
- return undefined;
101
+ return cachedData;
49
102
  }
50
103
 
51
- const data = await response.json();
104
+ // 200 — parse new data and cache it
105
+ const data = (await response.json()) as T;
106
+ const maxAgeMs = parseMaxAge(response) ?? defaultMaxAgeMs;
107
+ const etag = response.headers.get('etag') ?? undefined;
52
108
 
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
- }
109
+ await ensureDir(cacheFile, log);
110
+ await Promise.all([
111
+ writeFile(cacheFile, JSON.stringify(data), 'utf-8'),
112
+ writeFile(metaFile, JSON.stringify({ etag, expiresAt: Date.now() + maxAgeMs }), 'utf-8'),
113
+ ]);
61
114
 
62
115
  return data;
116
+ } catch (err) {
117
+ log.warn(`Failed to fetch from ${url}`, { err });
118
+ return cachedData;
119
+ }
120
+ }
121
+
122
+ async function fetchAndParse<T>(
123
+ url: string,
124
+ fetch: typeof globalThis.fetch,
125
+ log: ReturnType<typeof createLogger>,
126
+ ): Promise<T | undefined> {
127
+ try {
128
+ const response = await fetch(url);
129
+ if (!response.ok) {
130
+ log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
131
+ return undefined;
132
+ }
133
+ return (await response.json()) as T;
63
134
  } catch (err) {
64
135
  log.warn(`Failed to fetch from ${url}`, { err });
65
136
  return undefined;
66
137
  }
67
138
  }
139
+
140
+ async function ensureDir(filePath: string, log: ReturnType<typeof createLogger>) {
141
+ try {
142
+ await mkdir(dirname(filePath), { recursive: true });
143
+ } catch (err) {
144
+ log.warn('Failed to create cache directory for: ' + filePath, { err });
145
+ }
146
+ }
147
+
148
+ async function writeMetaFile(metaFile: string, meta: CacheMeta, log: ReturnType<typeof createLogger>) {
149
+ try {
150
+ await mkdir(dirname(metaFile), { recursive: true });
151
+ await writeFile(metaFile, JSON.stringify(meta), 'utf-8');
152
+ } catch (err) {
153
+ log.warn('Failed to write cache metadata: ' + metaFile, { err });
154
+ }
155
+ }