@aztec/aztec 0.0.1-commit.88e6f9396 → 0.0.1-commit.8c0b8ff

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 (48) hide show
  1. package/dest/cli/aztec_start_action.d.ts +1 -1
  2. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  3. package/dest/cli/aztec_start_action.js +11 -1
  4. package/dest/cli/aztec_start_options.d.ts +1 -1
  5. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  6. package/dest/cli/aztec_start_options.js +8 -1
  7. package/dest/cli/cmds/compile.d.ts +1 -1
  8. package/dest/cli/cmds/compile.d.ts.map +1 -1
  9. package/dest/cli/cmds/compile.js +2 -0
  10. package/dest/cli/cmds/start_archiver.d.ts +2 -2
  11. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  12. package/dest/cli/cmds/start_archiver.js +1 -1
  13. package/dest/cli/cmds/start_node.d.ts +1 -1
  14. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  15. package/dest/cli/cmds/start_node.js +3 -15
  16. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  17. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  18. package/dest/cli/cmds/start_prover_agent.js +3 -15
  19. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  20. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  21. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  22. package/dest/cli/cmds/utils/needs_recompile.d.ts +1 -1
  23. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -1
  24. package/dest/cli/cmds/utils/needs_recompile.js +9 -53
  25. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  26. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  27. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +41 -0
  28. package/dest/cli/util.js +3 -3
  29. package/dest/testing/anvil_test_watcher.d.ts +1 -1
  30. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  31. package/dest/testing/anvil_test_watcher.js +36 -10
  32. package/dest/testing/cheat_codes.d.ts +11 -15
  33. package/dest/testing/cheat_codes.d.ts.map +1 -1
  34. package/dest/testing/cheat_codes.js +34 -32
  35. package/package.json +34 -33
  36. package/scripts/aztec.sh +2 -1
  37. package/src/cli/aztec_start_action.ts +5 -1
  38. package/src/cli/aztec_start_options.ts +8 -1
  39. package/src/cli/cmds/compile.ts +3 -0
  40. package/src/cli/cmds/start_archiver.ts +1 -1
  41. package/src/cli/cmds/start_node.ts +7 -7
  42. package/src/cli/cmds/start_prover_agent.ts +3 -6
  43. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  44. package/src/cli/cmds/utils/needs_recompile.ts +8 -61
  45. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
  46. package/src/cli/util.ts +2 -2
  47. package/src/testing/anvil_test_watcher.ts +33 -10
  48. package/src/testing/cheat_codes.ts +42 -36
@@ -101,14 +101,25 @@ import { getAddress, getContract } from 'viem';
101
101
  if (!this.dateProvider) {
102
102
  return;
103
103
  }
104
- const l1Time = await this.cheatcodes.timestamp() * 1000;
104
+ const l1Time = await this.cheatcodes.lastBlockTimestamp() * 1000;
105
105
  const wallTime = this.dateProvider.now();
106
106
  if (l1Time > wallTime) {
107
107
  this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
108
108
  this.dateProvider.setTime(l1Time);
109
109
  } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
110
- this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
111
- await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
110
+ // Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
111
+ // `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
112
+ // `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
113
+ // a second apart and one of them is then rejected by anvil as non-monotonic.
114
+ const wallSec = Math.floor(wallTime / 1000);
115
+ const targetSlot = await this.rollup.read.getSlotAt([
116
+ BigInt(wallSec)
117
+ ]);
118
+ const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([
119
+ targetSlot
120
+ ]));
121
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
122
+ await this.warpToTimestamp(targetTimestamp);
112
123
  }
113
124
  }
114
125
  async warpTimeIfNeeded() {
@@ -124,8 +135,9 @@ import { getAddress, getContract } from 'viem';
124
135
  ]));
125
136
  if (BigInt(currentSlot) === checkpointLog.slotNumber) {
126
137
  // The current slot has been filled, we should jump to the next slot.
127
- await this.warpToTimestamp(nextSlotTimestamp);
128
- this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
138
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
139
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
140
+ }
129
141
  return;
130
142
  }
131
143
  // If we are not in local network, we don't need to warp time
@@ -152,9 +164,10 @@ import { getAddress, getContract } from 'viem';
152
164
  return;
153
165
  }
154
166
  if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
155
- await this.warpToTimestamp(nextSlotTimestamp);
167
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
168
+ this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
169
+ }
156
170
  this.unfilledSlotFirstSeen = undefined;
157
- this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
158
171
  }
159
172
  return;
160
173
  }
@@ -162,20 +175,33 @@ import { getAddress, getContract } from 'viem';
162
175
  // Fallback: warp when the dateProvider time has passed the next slot timestamp.
163
176
  const currentTimestamp = this.dateProvider?.now() ?? Date.now();
164
177
  if (currentTimestamp > nextSlotTimestamp * 1000) {
165
- await this.warpToTimestamp(nextSlotTimestamp);
166
- this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
178
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
179
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
180
+ }
167
181
  }
168
182
  } catch {
169
183
  this.logger.error('mineIfSlotFilled failed');
170
184
  }
171
185
  }
172
- async warpToTimestamp(timestamp) {
186
+ /**
187
+ * Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
188
+ * happened, false when skipped or on error. Callers use the return value to gate success logs.
189
+ */ async warpToTimestamp(timestamp) {
173
190
  try {
191
+ // Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
192
+ // watcher loops can race and pick targets a fraction of a second apart; skip here rather than
193
+ // letting the second one error out noisily.
194
+ const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
195
+ if (timestamp <= lastTimestamp) {
196
+ return false;
197
+ }
174
198
  await this.cheatcodes.warp(timestamp, {
175
199
  resetBlockInterval: true
176
200
  });
201
+ return true;
177
202
  } catch (e) {
178
203
  this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
204
+ return false;
179
205
  }
180
206
  }
181
207
  }
@@ -1,7 +1,6 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
2
  import type { DateProvider } from '@aztec/foundation/timer';
3
- import type { SequencerClient } from '@aztec/sequencer-client';
4
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
5
4
  /**
6
5
  * A class that provides utility functions for interacting with the chain.
7
6
  * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
@@ -13,6 +12,7 @@ export declare class CheatCodes {
13
12
  eth: EthCheatCodes;
14
13
  /** Cheat codes for the Aztec Rollup contract on L1. */
15
14
  rollup: RollupCheatCodes;
15
+ private logger;
16
16
  constructor(
17
17
  /** Cheat codes for L1.*/
18
18
  eth: EthCheatCodes,
@@ -21,23 +21,19 @@ export declare class CheatCodes {
21
21
  static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes>;
22
22
  /**
23
23
  * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
24
- * the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
25
- * by the slot number, which advances in fixed intervals.
26
- * This is useful for testing time-dependent contract behavior.
27
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
28
- * @param node - The Aztec node used to query if a new block has been mined.
24
+ * the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
25
+ * the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
26
+ * @param node - The Aztec node used to force an empty block to be mined.
29
27
  * @param targetTimestamp - The target timestamp to warp to (in seconds)
30
28
  */
31
- warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number): Promise<void>;
29
+ warpL2TimeAtLeastTo(node: AztecNodeDebug, targetTimestamp: bigint | number): Promise<void>;
32
30
  /**
33
31
  * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
34
- * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
35
- * number, which advances in fixed intervals.
36
- * This is useful for testing time-dependent contract behavior.
37
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
38
- * @param node - The Aztec node used to query if a new block has been mined.
32
+ * least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
33
+ * extended to the start of the next slot so that `mineBlock()` succeeds.
34
+ * @param node - The Aztec node used to force an empty block to be mined.
39
35
  * @param duration - The duration to advance time by (in seconds)
40
36
  */
41
- warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number): Promise<void>;
37
+ warpL2TimeAtLeastBy(node: AztecNodeDebug, duration: bigint | number): Promise<void>;
42
38
  }
43
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoi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0FBQyxJQUFJLEVBQUUsY0FBYyxFQUFFLFFBQVEsRUFBRSxNQUFNLEdBQUcsTUFBTSxpQkFReEU7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"cheat_codes.d.ts","sourceRoot":"","sources":["../../src/testing/cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE;;;;;GAKG;AACH,qBAAa,UAAU;IAEnB,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;IAJjC;IACE,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB,EAC7B;IAEJ,OAAa,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAOvG;IAED;;;;;;;;OAQG;IACG,mBAAmB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,iBAuB5G;IAED;;;;;;;;OAQG;IACG,mBAAmB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,iBAIrG;CACF"}
1
+ {"version":3,"file":"cheat_codes.d.ts","sourceRoot":"","sources":["../../src/testing/cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjF;;;;;GAKG;AACH,qBAAa,UAAU;IAInB,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;IANjC,OAAO,CAAC,MAAM,CAAuC;IAErD;IACE,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB,EAC7B;IAEJ,OAAa,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAOvG;IAED;;;;;;OAMG;IACG,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,iBA4B/E;IAED;;;;;;OAMG;IACG,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,iBAQxE;CACF"}
@@ -1,5 +1,6 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
- import { retryUntil } from '@aztec/foundation/retry';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { createLogger } from '@aztec/foundation/log';
3
4
  /**
4
5
  * A class that provides utility functions for interacting with the chain.
5
6
  * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
@@ -8,9 +9,11 @@ import { retryUntil } from '@aztec/foundation/retry';
8
9
  */ export class CheatCodes {
9
10
  eth;
10
11
  rollup;
12
+ logger;
11
13
  constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup){
12
14
  this.eth = eth;
13
15
  this.rollup = rollup;
16
+ this.logger = createLogger('aztecjs:cheat_codes');
14
17
  }
15
18
  static async create(rpcUrls, node, dateProvider) {
16
19
  const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
@@ -19,44 +22,43 @@ import { retryUntil } from '@aztec/foundation/retry';
19
22
  }
20
23
  /**
21
24
  * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
22
- * the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
23
- * by the slot number, which advances in fixed intervals.
24
- * This is useful for testing time-dependent contract behavior.
25
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
26
- * @param node - The Aztec node used to query if a new block has been mined.
25
+ * the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
26
+ * the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
27
+ * @param node - The Aztec node used to force an empty block to be mined.
27
28
  * @param targetTimestamp - The target timestamp to warp to (in seconds)
28
- */ async warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp) {
29
- const currentL2BlockNumber = await node.getBlockNumber();
30
- // We warp the L1 timestamp
31
- await this.eth.warp(targetTimestamp, {
29
+ */ async warpL2TimeAtLeastTo(node, targetTimestamp) {
30
+ const targetBigInt = BigInt(targetTimestamp);
31
+ const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
32
+ if (targetBigInt <= currentTimestamp) {
33
+ throw new Error(`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`);
34
+ }
35
+ const currentSlot = await this.rollup.getSlot();
36
+ const targetSlot = await this.rollup.getSlotAt(targetBigInt);
37
+ let effectiveTimestamp = targetBigInt;
38
+ if (targetSlot <= currentSlot) {
39
+ // Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
40
+ const nextSlot = SlotNumber(currentSlot + 1);
41
+ const nextSlotTimestamp = await this.rollup.getTimestampForSlot(nextSlot);
42
+ this.logger.warn(`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} falls in current slot ${currentSlot}. ` + `Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`);
43
+ effectiveTimestamp = nextSlotTimestamp;
44
+ }
45
+ await this.eth.warp(effectiveTimestamp, {
32
46
  resetBlockInterval: true
33
47
  });
34
- // Wait until an L2 block is mined
35
- const sequencer = sequencerClient.getSequencer();
36
- const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
37
- sequencer.updateConfig({
38
- minTxsPerBlock: 0
39
- });
40
- await retryUntil(async ()=>{
41
- const newL2BlockNumber = await node.getBlockNumber();
42
- return newL2BlockNumber > currentL2BlockNumber;
43
- }, 'new block after warping L2 time', 36, 1);
44
- // Restore original minTxsPerBlock
45
- sequencer.updateConfig({
46
- minTxsPerBlock
47
- });
48
+ await node.mineBlock();
48
49
  }
49
50
  /**
50
51
  * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
51
- * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
52
- * number, which advances in fixed intervals.
53
- * This is useful for testing time-dependent contract behavior.
54
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
55
- * @param node - The Aztec node used to query if a new block has been mined.
52
+ * least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
53
+ * extended to the start of the next slot so that `mineBlock()` succeeds.
54
+ * @param node - The Aztec node used to force an empty block to be mined.
56
55
  * @param duration - The duration to advance time by (in seconds)
57
- */ async warpL2TimeAtLeastBy(sequencerClient, node, duration) {
58
- const currentTimestamp = await this.eth.timestamp();
56
+ */ async warpL2TimeAtLeastBy(node, duration) {
57
+ if (BigInt(duration) <= 0n) {
58
+ throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
59
+ }
60
+ const currentTimestamp = await this.eth.lastBlockTimestamp();
59
61
  const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
60
- await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
62
+ await this.warpL2TimeAtLeastTo(node, targetTimestamp);
61
63
  }
62
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.0.1-commit.88e6f9396",
3
+ "version": "0.0.1-commit.8c0b8ff",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -28,38 +28,39 @@
28
28
  "../package.common.json"
29
29
  ],
30
30
  "dependencies": {
31
- "@aztec/accounts": "0.0.1-commit.88e6f9396",
32
- "@aztec/archiver": "0.0.1-commit.88e6f9396",
33
- "@aztec/aztec-node": "0.0.1-commit.88e6f9396",
34
- "@aztec/aztec.js": "0.0.1-commit.88e6f9396",
35
- "@aztec/bb-prover": "0.0.1-commit.88e6f9396",
36
- "@aztec/bb.js": "0.0.1-commit.88e6f9396",
37
- "@aztec/blob-client": "0.0.1-commit.88e6f9396",
38
- "@aztec/bot": "0.0.1-commit.88e6f9396",
39
- "@aztec/builder": "0.0.1-commit.88e6f9396",
40
- "@aztec/cli": "0.0.1-commit.88e6f9396",
41
- "@aztec/constants": "0.0.1-commit.88e6f9396",
42
- "@aztec/entrypoints": "0.0.1-commit.88e6f9396",
43
- "@aztec/ethereum": "0.0.1-commit.88e6f9396",
44
- "@aztec/foundation": "0.0.1-commit.88e6f9396",
45
- "@aztec/kv-store": "0.0.1-commit.88e6f9396",
46
- "@aztec/l1-artifacts": "0.0.1-commit.88e6f9396",
47
- "@aztec/node-lib": "0.0.1-commit.88e6f9396",
48
- "@aztec/noir-contracts.js": "0.0.1-commit.88e6f9396",
49
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.88e6f9396",
50
- "@aztec/p2p": "0.0.1-commit.88e6f9396",
51
- "@aztec/p2p-bootstrap": "0.0.1-commit.88e6f9396",
52
- "@aztec/protocol-contracts": "0.0.1-commit.88e6f9396",
53
- "@aztec/prover-client": "0.0.1-commit.88e6f9396",
54
- "@aztec/prover-node": "0.0.1-commit.88e6f9396",
55
- "@aztec/pxe": "0.0.1-commit.88e6f9396",
56
- "@aztec/sequencer-client": "0.0.1-commit.88e6f9396",
57
- "@aztec/stdlib": "0.0.1-commit.88e6f9396",
58
- "@aztec/telemetry-client": "0.0.1-commit.88e6f9396",
59
- "@aztec/txe": "0.0.1-commit.88e6f9396",
60
- "@aztec/validator-ha-signer": "0.0.1-commit.88e6f9396",
61
- "@aztec/wallets": "0.0.1-commit.88e6f9396",
62
- "@aztec/world-state": "0.0.1-commit.88e6f9396",
31
+ "@aztec/accounts": "0.0.1-commit.8c0b8ff",
32
+ "@aztec/archiver": "0.0.1-commit.8c0b8ff",
33
+ "@aztec/aztec-faucet": "0.0.1-commit.8c0b8ff",
34
+ "@aztec/aztec-node": "0.0.1-commit.8c0b8ff",
35
+ "@aztec/aztec.js": "0.0.1-commit.8c0b8ff",
36
+ "@aztec/bb-prover": "0.0.1-commit.8c0b8ff",
37
+ "@aztec/bb.js": "0.0.1-commit.8c0b8ff",
38
+ "@aztec/blob-client": "0.0.1-commit.8c0b8ff",
39
+ "@aztec/bot": "0.0.1-commit.8c0b8ff",
40
+ "@aztec/builder": "0.0.1-commit.8c0b8ff",
41
+ "@aztec/cli": "0.0.1-commit.8c0b8ff",
42
+ "@aztec/constants": "0.0.1-commit.8c0b8ff",
43
+ "@aztec/entrypoints": "0.0.1-commit.8c0b8ff",
44
+ "@aztec/ethereum": "0.0.1-commit.8c0b8ff",
45
+ "@aztec/foundation": "0.0.1-commit.8c0b8ff",
46
+ "@aztec/kv-store": "0.0.1-commit.8c0b8ff",
47
+ "@aztec/l1-artifacts": "0.0.1-commit.8c0b8ff",
48
+ "@aztec/node-lib": "0.0.1-commit.8c0b8ff",
49
+ "@aztec/noir-contracts.js": "0.0.1-commit.8c0b8ff",
50
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.8c0b8ff",
51
+ "@aztec/p2p": "0.0.1-commit.8c0b8ff",
52
+ "@aztec/p2p-bootstrap": "0.0.1-commit.8c0b8ff",
53
+ "@aztec/protocol-contracts": "0.0.1-commit.8c0b8ff",
54
+ "@aztec/prover-client": "0.0.1-commit.8c0b8ff",
55
+ "@aztec/prover-node": "0.0.1-commit.8c0b8ff",
56
+ "@aztec/pxe": "0.0.1-commit.8c0b8ff",
57
+ "@aztec/sequencer-client": "0.0.1-commit.8c0b8ff",
58
+ "@aztec/stdlib": "0.0.1-commit.8c0b8ff",
59
+ "@aztec/telemetry-client": "0.0.1-commit.8c0b8ff",
60
+ "@aztec/txe": "0.0.1-commit.8c0b8ff",
61
+ "@aztec/validator-ha-signer": "0.0.1-commit.8c0b8ff",
62
+ "@aztec/wallets": "0.0.1-commit.8c0b8ff",
63
+ "@aztec/world-state": "0.0.1-commit.8c0b8ff",
63
64
  "@iarna/toml": "^2.2.5",
64
65
  "@types/chalk": "^2.2.0",
65
66
  "abitype": "^0.8.11",
package/scripts/aztec.sh CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
+ shopt -s inherit_errexit
3
4
 
4
5
  # Re-execute using correct version if we have an .aztecrc file.
5
6
  if [ "${AZTEC_VERSIONED:-0}" -eq 0 ] && [ -f .aztecrc ] && command -v aztec-up &>/dev/null; then
@@ -49,7 +50,7 @@ case $cmd in
49
50
  export ETHEREUM_HOSTS=${ETHEREUM_HOSTS:-"http://127.0.0.1:${ANVIL_PORT}"}
50
51
 
51
52
  anvil --version
52
- anvil --silent --port "$ANVIL_PORT" &
53
+ anvil --silent &
53
54
  anvil_pid=$!
54
55
  trap 'kill $anvil_pid &>/dev/null' EXIT
55
56
  fi
@@ -7,7 +7,7 @@ import {
7
7
  } from '@aztec/foundation/json-rpc/server';
8
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
9
9
  import type { ChainConfig } from '@aztec/stdlib/config';
10
- import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
10
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
11
11
  import { getPackageVersion } from '@aztec/stdlib/update-checker';
12
12
  import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
13
13
  import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
@@ -51,6 +51,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
51
51
  signalHandlers.push(stop);
52
52
  services.node = [node, AztecNodeApiSchema];
53
53
  adminServices.node = [node, AztecNodeAdminApiSchema];
54
+ services.nodeDebug = [node, AztecNodeDebugApiSchema];
54
55
  } else {
55
56
  // Route --prover-node through startNode
56
57
  if (options.proverNode && !options.node) {
@@ -61,6 +62,9 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
61
62
  const { startNode } = await import('./cmds/start_node.js');
62
63
  const networkName = getActiveNetworkName(options.network);
63
64
  ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
65
+ if (options.nodeDebug && services.node) {
66
+ services.nodeDebug = [services.node[0], AztecNodeDebugApiSchema];
67
+ }
64
68
  } else if (options.bot) {
65
69
  const { startBot } = await import('./cmds/start_bot.js');
66
70
  await startBot(options, signalHandlers, services, userLog);
@@ -12,6 +12,7 @@ import {
12
12
  isBooleanConfigValue,
13
13
  omitConfigMappings,
14
14
  } from '@aztec/foundation/config';
15
+ import { dataConfigMappings } from '@aztec/kv-store/config';
15
16
  import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
16
17
  import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
17
18
  import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
@@ -19,7 +20,6 @@ import { proverNodeConfigMappings } from '@aztec/prover-node/config';
19
20
  import { allPxeConfigMappings } from '@aztec/pxe/config';
20
21
  import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
21
22
  import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
22
- import { dataConfigMappings } from '@aztec/stdlib/kv-store';
23
23
  import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
24
24
  import { worldStateConfigMappings } from '@aztec/world-state/config';
25
25
 
@@ -165,6 +165,13 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
165
165
  env: 'AZTEC_RESET_ADMIN_API_KEY',
166
166
  parseVal: val => val === 'true' || val === '1',
167
167
  },
168
+ {
169
+ flag: '--node-debug',
170
+ description: 'Expose debug endpoints (e.g. mineBlock) on the main RPC port',
171
+ defaultValue: false,
172
+ env: 'AZTEC_NODE_DEBUG',
173
+ parseVal: val => val === undefined || val === 'true' || val === '1',
174
+ },
168
175
  {
169
176
  flag: '--api-prefix <value>',
170
177
  description: 'Prefix for API routes on any service that is started',
@@ -9,6 +9,7 @@ import { join } from 'path';
9
9
  import { readArtifactFiles } from './utils/artifacts.js';
10
10
  import { needsRecompile } from './utils/needs_recompile.js';
11
11
  import { run } from './utils/spawn.js';
12
+ import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
12
13
 
13
14
  /** Returns paths to contract artifacts in the target directory. */
14
15
  async function collectContractArtifacts(): Promise<string[]> {
@@ -139,6 +140,8 @@ async function checkNoTestsInContracts(nargo: string, log: LogFn): Promise<void>
139
140
 
140
141
  /** Compiles Aztec Noir contracts and postprocesses artifacts. */
141
142
  async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
143
+ await warnIfAztecVersionMismatch(log);
144
+
142
145
  if (!(await needsRecompile())) {
143
146
  log('No source changes detected, skipping compilation.');
144
147
  return;
@@ -3,8 +3,8 @@ import { createLogger } from '@aztec/aztec.js/log';
3
3
  import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
4
  import { getL1Config } from '@aztec/cli/config';
5
5
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
6
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
6
7
  import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
7
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
8
8
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
9
9
 
10
10
  import { extractRelevantOptions } from '../util.js';
@@ -9,7 +9,11 @@ import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
9
9
  import type { LogFn } from '@aztec/foundation/log';
10
10
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
11
11
  import { protocolContractsHash } from '@aztec/protocol-contracts';
12
- import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
12
+ import {
13
+ ProvingJobConsumerSchema,
14
+ createProvingJobBrokerClient,
15
+ proverBrokerBackoff,
16
+ } from '@aztec/prover-client/broker';
13
17
  import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
14
18
  import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
15
19
  import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
@@ -65,12 +69,8 @@ export async function startNode(
65
69
  if (nodeConfig.proverBrokerUrl) {
66
70
  // at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
67
71
  // set a lower connection limit such that we don't overload the server
68
- // Keep retrying up to 30s
69
- const fetch = makeTracedFetch(
70
- [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
71
- false,
72
- makeUndiciFetch(new Agent({ connections: 100 })),
73
- );
72
+ // Retry indefinitely until the epoch proving times out and the chain reorgs
73
+ const fetch = makeTracedFetch(proverBrokerBackoff, false, makeUndiciFetch(new Agent({ connections: 100 })));
74
74
  broker = createProvingJobBrokerClient(nodeConfig.proverBrokerUrl, getVersions(nodeConfig), fetch);
75
75
  } else if (options.proverBroker) {
76
76
  ({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
@@ -9,6 +9,7 @@ import {
9
9
  createProofStore,
10
10
  createProvingJobBrokerClient,
11
11
  proverAgentConfigMappings,
12
+ proverBrokerBackoff,
12
13
  } from '@aztec/prover-client/broker';
13
14
  import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
14
15
  import { ProverAgentApiSchema } from '@aztec/stdlib/interfaces/server';
@@ -45,12 +46,8 @@ export async function startProverAgent(
45
46
 
46
47
  await preloadCrsDataForServerSideProving(config, userLog);
47
48
 
48
- const fetch = makeTracedFetch(
49
- // retry connections every 3s, up to 30s before giving up
50
- [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
51
- false,
52
- makeUndiciFetch(new Agent({ connections: 10 })),
53
- );
49
+ // Retry indefinitely until the epoch proving times out and the chain reorgs
50
+ const fetch = makeTracedFetch(proverBrokerBackoff, false, makeUndiciFetch(new Agent({ connections: 10 })));
54
51
  const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
55
52
 
56
53
  const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
@@ -0,0 +1,118 @@
1
+ import TOML from '@iarna/toml';
2
+ import { existsSync } from 'fs';
3
+ import { mkdir, readFile, stat } from 'fs/promises';
4
+ import { homedir } from 'os';
5
+ import { dirname, join, resolve } from 'path';
6
+
7
+ import { run } from './spawn.js';
8
+
9
+ /**
10
+ * Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
11
+ * files.
12
+ *
13
+ * When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
14
+ * (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
15
+ *
16
+ * When `skipGitDeps` is true, git-based deps are ignored entirely.
17
+ */
18
+ export async function collectCrateDirs(startCrateDir: string, opts?: { skipGitDeps?: boolean }): Promise<string[]> {
19
+ const { skipGitDeps = false } = opts ?? {};
20
+ const visited = new Set<string>();
21
+
22
+ async function visit(crateDir: string): Promise<void> {
23
+ const absDir = resolve(crateDir);
24
+ if (visited.has(absDir)) {
25
+ return;
26
+ }
27
+ visited.add(absDir);
28
+
29
+ const tomlPath = join(absDir, 'Nargo.toml');
30
+ const content = await readFile(tomlPath, 'utf-8').catch(() => {
31
+ throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
32
+ });
33
+
34
+ const parsed = TOML.parse(content) as Record<string, any>;
35
+ const members = (parsed.workspace as Record<string, any>)?.members as string[] | undefined;
36
+
37
+ // A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
38
+ if (Array.isArray(members)) {
39
+ // The crate is a workspace root and has members defined so we visit the members
40
+ for (const member of members) {
41
+ await visit(resolve(absDir, member));
42
+ }
43
+ } else {
44
+ // Single crate — follow its deps
45
+ const deps = (parsed.dependencies as Record<string, any>) ?? {};
46
+ for (const dep of Object.values(deps)) {
47
+ if (!dep || typeof dep !== 'object') {
48
+ continue;
49
+ }
50
+ if (typeof dep.path === 'string') {
51
+ // Dependency contains "path" hence it's a local dependency. We just check it's a real directory and then we
52
+ // recursively search through it
53
+ const depPath = resolve(absDir, dep.path);
54
+ const s = await stat(depPath);
55
+ if (!s.isDirectory()) {
56
+ throw new Error(
57
+ `Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`,
58
+ );
59
+ }
60
+ await visit(depPath);
61
+ } else if (!skipGitDeps && typeof dep.git === 'string' && typeof dep.tag === 'string') {
62
+ // Dependency contains "git" hence it's a git dependency. We ensure it has been fetched and fetch it if
63
+ // it's not the case and then we recursively search through it.
64
+ await fetchAndVisit(dep.git, dep.tag, dep.directory);
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ async function fetchAndVisit(gitUrl: string, tag: string, directory?: string): Promise<void> {
71
+ // `directory` is set when the dep lives in a subdirectory of a repository, e.g.:
72
+ // aztec = { git = "https://github.com/AztecProtocol/aztec-packages", tag = "v0.82.0",
73
+ // directory = "noir-projects/aztec-nr/aztec" }
74
+ // In that case nargo clones the whole repo and the crate root is <cachePath>/<directory>.
75
+ const cachePath = nargoGitDepPath(gitUrl, tag);
76
+ const crateDir = directory ? join(cachePath, directory) : cachePath;
77
+ await ensureGitDepCached(gitUrl, tag, cachePath);
78
+ await visit(crateDir);
79
+ }
80
+
81
+ await visit(startCrateDir);
82
+ return [...visited];
83
+ }
84
+
85
+ /**
86
+ * Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
87
+ * Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
88
+ * e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
89
+ *
90
+ * Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
91
+ */
92
+ export function nargoGitDepPath(gitUrl: string, tag: string): string {
93
+ const url = new URL(gitUrl);
94
+ const domain = url.hostname;
95
+ const repoPath = url.pathname.replace(/^\//, '');
96
+ return join(process.env.HOME ?? homedir(), 'nargo', domain, repoPath, tag);
97
+ }
98
+
99
+ /**
100
+ * Ensures a git dep is present in the nargo cache, cloning it if it isn't. Mirrors nargo's `clone_git_repo`.
101
+ * If cloning fails (e.g. no network), throws with a message suggesting `nargo check` to prime the cache.
102
+ *
103
+ * Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
104
+ */
105
+ async function ensureGitDepCached(gitUrl: string, tag: string, cachePath: string): Promise<void> {
106
+ if (existsSync(cachePath)) {
107
+ return;
108
+ }
109
+ await mkdir(dirname(cachePath), { recursive: true });
110
+ try {
111
+ await run('git', ['-c', 'advice.detachedHead=false', 'clone', '--depth', '1', '--branch', tag, gitUrl, cachePath]);
112
+ } catch (err: any) {
113
+ throw new Error(
114
+ `Failed to fetch git dependency ${gitUrl}@${tag}: ${err?.message ?? err}.\n` +
115
+ `Try running \`nargo check\` first to prime the dependency cache.`,
116
+ );
117
+ }
118
+ }