@aztec/aztec 0.0.0-test.0 → 0.0.1-commit.001888fc

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 (194) hide show
  1. package/README.md +1 -1
  2. package/dest/bin/index.d.ts +1 -1
  3. package/dest/bin/index.js +28 -13
  4. package/dest/cli/admin_api_key_store.d.ts +45 -0
  5. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  6. package/dest/cli/admin_api_key_store.js +98 -0
  7. package/dest/cli/aztec_start_action.d.ts +1 -1
  8. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  9. package/dest/cli/aztec_start_action.js +89 -44
  10. package/dest/cli/aztec_start_options.d.ts +5 -3
  11. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  12. package/dest/cli/aztec_start_options.js +157 -220
  13. package/dest/cli/cli.d.ts +1 -1
  14. package/dest/cli/cli.d.ts.map +1 -1
  15. package/dest/cli/cli.js +11 -7
  16. package/dest/cli/cmds/compile.d.ts +4 -0
  17. package/dest/cli/cmds/compile.d.ts.map +1 -0
  18. package/dest/cli/cmds/compile.js +166 -0
  19. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  20. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  21. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  22. package/dest/cli/cmds/profile.d.ts +4 -0
  23. package/dest/cli/cmds/profile.d.ts.map +1 -0
  24. package/dest/cli/cmds/profile.js +8 -0
  25. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  26. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  27. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  28. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  29. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  30. package/dest/cli/cmds/profile_gates.js +58 -0
  31. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  32. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  33. package/dest/cli/cmds/profile_utils.js +50 -0
  34. package/dest/cli/cmds/standby.d.ts +32 -0
  35. package/dest/cli/cmds/standby.d.ts.map +1 -0
  36. package/dest/cli/cmds/standby.js +97 -0
  37. package/dest/cli/cmds/start_archiver.d.ts +2 -2
  38. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  39. package/dest/cli/cmds/start_archiver.js +25 -19
  40. package/dest/cli/cmds/start_bot.d.ts +4 -7
  41. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  42. package/dest/cli/cmds/start_bot.js +29 -14
  43. package/dest/cli/cmds/start_node.d.ts +3 -2
  44. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  45. package/dest/cli/cmds/start_node.js +128 -85
  46. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  47. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  48. package/dest/cli/cmds/start_p2p_bootstrap.js +10 -6
  49. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  50. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  51. package/dest/cli/cmds/start_prover_agent.js +35 -6
  52. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  53. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  54. package/dest/cli/cmds/start_prover_broker.js +17 -5
  55. package/dest/cli/cmds/start_txe.d.ts +1 -1
  56. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  57. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/artifacts.js +24 -0
  59. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  60. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  61. package/dest/cli/cmds/utils/needs_recompile.js +134 -0
  62. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  63. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  64. package/dest/cli/cmds/utils/spawn.js +16 -0
  65. package/dest/cli/index.d.ts +1 -1
  66. package/dest/cli/preload_crs.d.ts +3 -0
  67. package/dest/cli/preload_crs.d.ts.map +1 -0
  68. package/dest/cli/preload_crs.js +6 -0
  69. package/dest/cli/util.d.ts +37 -17
  70. package/dest/cli/util.d.ts.map +1 -1
  71. package/dest/cli/util.js +165 -31
  72. package/dest/cli/versioning.d.ts +1 -1
  73. package/dest/cli/versioning.js +3 -3
  74. package/dest/examples/token.d.ts +1 -1
  75. package/dest/examples/token.js +31 -18
  76. package/dest/examples/util.d.ts +5 -6
  77. package/dest/examples/util.d.ts.map +1 -1
  78. package/dest/examples/util.js +5 -6
  79. package/dest/index.d.ts +2 -2
  80. package/dest/index.d.ts.map +1 -1
  81. package/dest/index.js +1 -1
  82. package/dest/local-network/banana_fpc.d.ts +10 -0
  83. package/dest/local-network/banana_fpc.d.ts.map +1 -0
  84. package/dest/{sandbox → local-network}/banana_fpc.js +23 -25
  85. package/dest/local-network/index.d.ts +4 -0
  86. package/dest/local-network/index.d.ts.map +1 -0
  87. package/dest/local-network/index.js +3 -0
  88. package/dest/local-network/local-network.d.ts +73 -0
  89. package/dest/local-network/local-network.d.ts.map +1 -0
  90. package/dest/local-network/local-network.js +226 -0
  91. package/dest/local-network/sponsored_fpc.d.ts +5 -0
  92. package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
  93. package/dest/local-network/sponsored_fpc.js +18 -0
  94. package/dest/mnemonic.d.ts +1 -1
  95. package/dest/splash.d.ts +1 -1
  96. package/dest/testing/anvil_test_watcher.d.ts +42 -0
  97. package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
  98. package/dest/testing/anvil_test_watcher.js +181 -0
  99. package/dest/testing/cheat_codes.d.ts +43 -0
  100. package/dest/testing/cheat_codes.d.ts.map +1 -0
  101. package/dest/testing/cheat_codes.js +62 -0
  102. package/dest/testing/epoch_test_settler.d.ts +19 -0
  103. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  104. package/dest/testing/epoch_test_settler.js +61 -0
  105. package/dest/testing/index.d.ts +6 -0
  106. package/dest/testing/index.d.ts.map +1 -0
  107. package/dest/testing/index.js +5 -0
  108. package/dest/testing/token_allowed_setup.d.ts +7 -0
  109. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  110. package/dest/testing/token_allowed_setup.js +20 -0
  111. package/package.json +55 -45
  112. package/scripts/add_crate.sh +102 -0
  113. package/scripts/aztec.sh +69 -0
  114. package/scripts/init.sh +39 -0
  115. package/scripts/new.sh +83 -0
  116. package/scripts/setup_workspace.sh +68 -0
  117. package/src/bin/index.ts +33 -13
  118. package/src/cli/admin_api_key_store.ts +128 -0
  119. package/src/cli/aztec_start_action.ts +87 -41
  120. package/src/cli/aztec_start_options.ts +176 -218
  121. package/src/cli/cli.ts +19 -11
  122. package/src/cli/cmds/compile.ts +191 -0
  123. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  124. package/src/cli/cmds/profile.ts +25 -0
  125. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  126. package/src/cli/cmds/profile_gates.ts +68 -0
  127. package/src/cli/cmds/profile_utils.ts +58 -0
  128. package/src/cli/cmds/standby.ts +132 -0
  129. package/src/cli/cmds/start_archiver.ts +16 -21
  130. package/src/cli/cmds/start_bot.ts +40 -14
  131. package/src/cli/cmds/start_node.ts +146 -91
  132. package/src/cli/cmds/start_p2p_bootstrap.ts +14 -6
  133. package/src/cli/cmds/start_prover_agent.ts +26 -14
  134. package/src/cli/cmds/start_prover_broker.ts +28 -4
  135. package/src/cli/cmds/utils/artifacts.ts +44 -0
  136. package/src/cli/cmds/utils/needs_recompile.ts +151 -0
  137. package/src/cli/cmds/utils/spawn.ts +16 -0
  138. package/src/cli/preload_crs.ts +7 -0
  139. package/src/cli/util.ts +186 -50
  140. package/src/cli/versioning.ts +3 -3
  141. package/src/examples/token.ts +23 -19
  142. package/src/examples/util.ts +6 -8
  143. package/src/index.ts +5 -6
  144. package/src/{sandbox → local-network}/banana_fpc.ts +28 -29
  145. package/src/local-network/index.ts +7 -0
  146. package/src/local-network/local-network.ts +277 -0
  147. package/src/local-network/sponsored_fpc.ts +26 -0
  148. package/src/testing/anvil_test_watcher.ts +210 -0
  149. package/src/testing/cheat_codes.ts +79 -0
  150. package/src/testing/epoch_test_settler.ts +70 -0
  151. package/src/testing/index.ts +5 -0
  152. package/src/testing/token_allowed_setup.ts +19 -0
  153. package/dest/cli/chain_l2_config.d.ts +0 -19
  154. package/dest/cli/chain_l2_config.d.ts.map +0 -1
  155. package/dest/cli/chain_l2_config.js +0 -56
  156. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  157. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  158. package/dest/cli/cmds/start_blob_sink.js +0 -17
  159. package/dest/cli/cmds/start_faucet.d.ts +0 -4
  160. package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
  161. package/dest/cli/cmds/start_faucet.js +0 -20
  162. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  163. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  164. package/dest/cli/cmds/start_prover_node.js +0 -110
  165. package/dest/cli/cmds/start_pxe.d.ts +0 -16
  166. package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
  167. package/dest/cli/cmds/start_pxe.js +0 -95
  168. package/dest/cli/get_l1_config.d.ts +0 -7
  169. package/dest/cli/get_l1_config.d.ts.map +0 -1
  170. package/dest/cli/get_l1_config.js +0 -13
  171. package/dest/sandbox/banana_fpc.d.ts +0 -11
  172. package/dest/sandbox/banana_fpc.d.ts.map +0 -1
  173. package/dest/sandbox/index.d.ts +0 -5
  174. package/dest/sandbox/index.d.ts.map +0 -1
  175. package/dest/sandbox/index.js +0 -4
  176. package/dest/sandbox/sandbox.d.ts +0 -76
  177. package/dest/sandbox/sandbox.d.ts.map +0 -1
  178. package/dest/sandbox/sandbox.js +0 -181
  179. package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
  180. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
  181. package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
  182. package/dest/sandbox/sponsored_fpc.d.ts +0 -6
  183. package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
  184. package/dest/sandbox/sponsored_fpc.js +0 -26
  185. package/src/cli/chain_l2_config.ts +0 -74
  186. package/src/cli/cmds/start_blob_sink.ts +0 -31
  187. package/src/cli/cmds/start_faucet.ts +0 -34
  188. package/src/cli/cmds/start_prover_node.ts +0 -121
  189. package/src/cli/cmds/start_pxe.ts +0 -129
  190. package/src/cli/get_l1_config.ts +0 -18
  191. package/src/sandbox/index.ts +0 -5
  192. package/src/sandbox/sandbox.ts +0 -229
  193. package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
  194. package/src/sandbox/sponsored_fpc.ts +0 -38
@@ -0,0 +1,42 @@
1
+ import { EthCheatCodes } from '@aztec/ethereum/test';
2
+ import type { ViemClient } from '@aztec/ethereum/types';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import type { TestDateProvider } from '@aztec/foundation/timer';
5
+ /**
6
+ * Represents a watcher for a rollup contract.
7
+ *
8
+ * It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
9
+ * it will periodically check if the current slot have already been filled, e.g., there was an L2
10
+ * block within the slot. And if so, it will time travel into the next slot.
11
+ */
12
+ export declare class AnvilTestWatcher {
13
+ private cheatcodes;
14
+ private dateProvider?;
15
+ private isLocalNetwork;
16
+ private rollup;
17
+ private rollupCheatCodes;
18
+ private l2SlotDuration;
19
+ private filledRunningPromise?;
20
+ private syncDateProviderPromise?;
21
+ private markingAsProvenRunningPromise?;
22
+ private logger;
23
+ private isMarkingAsProven;
24
+ private getPendingTxCount?;
25
+ private isSequencerBuilding?;
26
+ private unfilledSlotFirstSeen?;
27
+ constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
28
+ setIsMarkingAsProven(isMarkingAsProven: boolean): void;
29
+ setisLocalNetwork(isLocalNetwork: boolean): void;
30
+ /** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
31
+ setGetPendingTxCount(fn: () => Promise<number>): void;
32
+ /** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
33
+ setIsSequencerBuilding(fn: () => boolean): void;
34
+ start(): Promise<void>;
35
+ stop(): Promise<void>;
36
+ trigger(): Promise<void>;
37
+ markAsProven(): Promise<void>;
38
+ syncDateProviderToL1IfBehind(): Promise<void>;
39
+ warpTimeIfNeeded(): Promise<void>;
40
+ private warpToTimestamp;
41
+ }
42
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW52aWxfdGVzdF93YXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9hbnZpbF90ZXN0X3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBb0IsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUV4RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBS2hFOzs7Ozs7R0FNRztBQUNILHFCQUFhLGdCQUFnQjtJQXlCekIsT0FBTyxDQUFDLFVBQVU7SUFHbEIsT0FBTyxDQUFDLFlBQVksQ0FBQztJQTNCdkIsT0FBTyxDQUFDLGNBQWMsQ0FBa0I7SUFFeEMsT0FBTyxDQUFDLE1BQU0sQ0FBc0Q7SUFDcEUsT0FBTyxDQUFDLGdCQUFnQixDQUFtQjtJQUMzQyxPQUFPLENBQUMsY0FBYyxDQUFVO0lBRWhDLE9BQU8sQ0FBQyxvQkFBb0Is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ereum/test';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import { RunningPromise } from '@aztec/foundation/running-promise';
5
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
6
+ import { getAddress, getContract } from 'viem';
7
+ /**
8
+ * Represents a watcher for a rollup contract.
9
+ *
10
+ * It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
11
+ * it will periodically check if the current slot have already been filled, e.g., there was an L2
12
+ * block within the slot. And if so, it will time travel into the next slot.
13
+ */ export class AnvilTestWatcher {
14
+ cheatcodes;
15
+ dateProvider;
16
+ isLocalNetwork;
17
+ rollup;
18
+ rollupCheatCodes;
19
+ l2SlotDuration;
20
+ filledRunningPromise;
21
+ syncDateProviderPromise;
22
+ markingAsProvenRunningPromise;
23
+ logger;
24
+ isMarkingAsProven;
25
+ // Optional callback to check if there are pending txs in the mempool.
26
+ getPendingTxCount;
27
+ // Optional callback to check if the sequencer is actively building a block.
28
+ isSequencerBuilding;
29
+ // Tracks when we first observed the current unfilled slot with pending txs (real wall time).
30
+ unfilledSlotFirstSeen;
31
+ constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
32
+ this.cheatcodes = cheatcodes;
33
+ this.dateProvider = dateProvider;
34
+ this.isLocalNetwork = false;
35
+ this.logger = createLogger(`aztecjs:utils:watcher`);
36
+ this.isMarkingAsProven = true;
37
+ this.rollup = getContract({
38
+ address: getAddress(rollupAddress.toString()),
39
+ abi: RollupAbi,
40
+ client: l1Client
41
+ });
42
+ this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
43
+ rollupAddress
44
+ });
45
+ this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
46
+ }
47
+ setIsMarkingAsProven(isMarkingAsProven) {
48
+ this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
49
+ this.isMarkingAsProven = isMarkingAsProven;
50
+ }
51
+ setisLocalNetwork(isLocalNetwork) {
52
+ this.isLocalNetwork = isLocalNetwork;
53
+ }
54
+ /** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */ setGetPendingTxCount(fn) {
55
+ this.getPendingTxCount = fn;
56
+ }
57
+ /** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */ setIsSequencerBuilding(fn) {
58
+ this.isSequencerBuilding = fn;
59
+ }
60
+ async start() {
61
+ if (this.filledRunningPromise) {
62
+ throw new Error('Watcher already watching for filled slot');
63
+ }
64
+ const config = await this.rollupCheatCodes.getConfig();
65
+ this.l2SlotDuration = config.slotDuration;
66
+ // If auto mining is not supported (e.g., we are on a real network), then we
67
+ // will simple do nothing. But if on an anvil or the like, this make sure that
68
+ // the local network and tests don't break because time is frozen and we never get to
69
+ // the next slot.
70
+ const isAutoMining = await this.cheatcodes.isAutoMining();
71
+ if (isAutoMining) {
72
+ this.filledRunningPromise = new RunningPromise(()=>this.warpTimeIfNeeded(), this.logger, 200);
73
+ this.filledRunningPromise.start();
74
+ this.syncDateProviderPromise = new RunningPromise(()=>this.syncDateProviderToL1IfBehind(), this.logger, 200);
75
+ this.syncDateProviderPromise.start();
76
+ this.markingAsProvenRunningPromise = new RunningPromise(()=>this.markAsProven(), this.logger, 200);
77
+ this.markingAsProvenRunningPromise.start();
78
+ this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
79
+ } else {
80
+ this.logger.info(`Watcher not started because not auto mining`);
81
+ }
82
+ }
83
+ async stop() {
84
+ await this.filledRunningPromise?.stop();
85
+ await this.syncDateProviderPromise?.stop();
86
+ await this.markingAsProvenRunningPromise?.stop();
87
+ }
88
+ async trigger() {
89
+ await this.filledRunningPromise?.trigger();
90
+ await this.syncDateProviderPromise?.trigger();
91
+ await this.markingAsProvenRunningPromise?.trigger();
92
+ }
93
+ async markAsProven() {
94
+ if (!this.isMarkingAsProven) {
95
+ return;
96
+ }
97
+ await this.rollupCheatCodes.markAsProven();
98
+ }
99
+ async syncDateProviderToL1IfBehind() {
100
+ // this doesn't apply to the local network, because we don't have a date provider in the local network
101
+ if (!this.dateProvider) {
102
+ return;
103
+ }
104
+ const l1Time = await this.cheatcodes.timestamp() * 1000;
105
+ const wallTime = this.dateProvider.now();
106
+ if (l1Time > wallTime) {
107
+ this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
108
+ this.dateProvider.setTime(l1Time);
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));
112
+ }
113
+ }
114
+ async warpTimeIfNeeded() {
115
+ try {
116
+ const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
117
+ const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
118
+ const checkpointLog = await this.rollup.read.getCheckpoint([
119
+ pendingCheckpointNumber
120
+ ]);
121
+ const nextSlot = SlotNumber(currentSlot + 1);
122
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([
123
+ BigInt(nextSlot)
124
+ ]));
125
+ if (BigInt(currentSlot) === checkpointLog.slotNumber) {
126
+ // 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`);
129
+ return;
130
+ }
131
+ // If we are not in local network, we don't need to warp time
132
+ if (!this.isLocalNetwork) {
133
+ return;
134
+ }
135
+ // If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
136
+ // sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
137
+ // the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
138
+ // to avoid invalidating its in-progress work.
139
+ if (this.getPendingTxCount) {
140
+ const pendingTxs = await this.getPendingTxCount();
141
+ if (pendingTxs > 0) {
142
+ if (this.isSequencerBuilding?.()) {
143
+ this.unfilledSlotFirstSeen = undefined;
144
+ return;
145
+ }
146
+ const realNow = Date.now();
147
+ if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
148
+ this.unfilledSlotFirstSeen = {
149
+ slot: currentSlot,
150
+ realTime: realNow
151
+ };
152
+ return;
153
+ }
154
+ if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
155
+ await this.warpToTimestamp(nextSlotTimestamp);
156
+ this.unfilledSlotFirstSeen = undefined;
157
+ this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
158
+ }
159
+ return;
160
+ }
161
+ }
162
+ // Fallback: warp when the dateProvider time has passed the next slot timestamp.
163
+ const currentTimestamp = this.dateProvider?.now() ?? Date.now();
164
+ if (currentTimestamp > nextSlotTimestamp * 1000) {
165
+ await this.warpToTimestamp(nextSlotTimestamp);
166
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
167
+ }
168
+ } catch {
169
+ this.logger.error('mineIfSlotFilled failed');
170
+ }
171
+ }
172
+ async warpToTimestamp(timestamp) {
173
+ try {
174
+ await this.cheatcodes.warp(timestamp, {
175
+ resetBlockInterval: true
176
+ });
177
+ } catch (e) {
178
+ this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
179
+ }
180
+ }
181
+ }
@@ -0,0 +1,43 @@
1
+ import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
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';
5
+ /**
6
+ * A class that provides utility functions for interacting with the chain.
7
+ * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
8
+ * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
9
+ * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
10
+ */
11
+ export declare class CheatCodes {
12
+ /** Cheat codes for L1.*/
13
+ eth: EthCheatCodes;
14
+ /** Cheat codes for the Aztec Rollup contract on L1. */
15
+ rollup: RollupCheatCodes;
16
+ constructor(
17
+ /** Cheat codes for L1.*/
18
+ eth: EthCheatCodes,
19
+ /** Cheat codes for the Aztec Rollup contract on L1. */
20
+ rollup: RollupCheatCodes);
21
+ static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes>;
22
+ /**
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.
29
+ * @param targetTimestamp - The target timestamp to warp to (in seconds)
30
+ */
31
+ warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number): Promise<void>;
32
+ /**
33
+ * 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.
39
+ * @param duration - The duration to advance time by (in seconds)
40
+ */
41
+ warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number): Promise<void>;
42
+ }
43
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlYXRfY29kZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2NoZWF0X2NvZGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQ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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"}
@@ -0,0 +1,62 @@
1
+ import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { retryUntil } from '@aztec/foundation/retry';
3
+ /**
4
+ * A class that provides utility functions for interacting with the chain.
5
+ * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
6
+ * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
7
+ * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
8
+ */ export class CheatCodes {
9
+ eth;
10
+ rollup;
11
+ constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup){
12
+ this.eth = eth;
13
+ this.rollup = rollup;
14
+ }
15
+ static async create(rpcUrls, node, dateProvider) {
16
+ const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
17
+ const rollupCheatCodes = new RollupCheatCodes(ethCheatCodes, await node.getNodeInfo().then((n)=>n.l1ContractAddresses));
18
+ return new CheatCodes(ethCheatCodes, rollupCheatCodes);
19
+ }
20
+ /**
21
+ * 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.
27
+ * @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, {
32
+ resetBlockInterval: true
33
+ });
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
+ }
49
+ /**
50
+ * 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.
56
+ * @param duration - The duration to advance time by (in seconds)
57
+ */ async warpL2TimeAtLeastBy(sequencerClient, node, duration) {
58
+ const currentTimestamp = await this.eth.timestamp();
59
+ const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
60
+ await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
61
+ }
62
+ }
@@ -0,0 +1,19 @@
1
+ import { type EthCheatCodes } from '@aztec/ethereum/test';
2
+ import { type EpochNumber } from '@aztec/foundation/branded-types';
3
+ import type { Logger } from '@aztec/foundation/log';
4
+ import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
5
+ export declare class EpochTestSettler {
6
+ private l2BlockSource;
7
+ private log;
8
+ private options;
9
+ private rollupCheatCodes;
10
+ private epochMonitor?;
11
+ constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l2BlockSource: L2BlockSource, log: Logger, options: {
12
+ pollingIntervalMs: number;
13
+ provingDelayMs?: number;
14
+ });
15
+ start(): Promise<void>;
16
+ stop(): Promise<void>;
17
+ handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean>;
18
+ }
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfdGVzdF9zZXR0bGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9lcG9jaF90ZXN0X3NldHRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssYUFBYSxFQUFvQixNQUFNLHNCQUFzQixDQUFDO0FBQzVFLE9BQU8sRUFBRSxLQUFLLFdBQVcsRUFBYyxNQUFNLGlDQUFpQyxDQUFDO0FBQy9FLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUdyRSxxQkFBYSxnQkFBZ0I7SUFPek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AAE,MAAM,EACX,OAAO,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,EAGxE;IAEK,KAAK,kBAIV;IAEK,IAAI,kBAET;IAEK,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAoClE;CACF"}
@@ -0,0 +1,61 @@
1
+ import { RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { EpochMonitor } from '@aztec/prover-node';
4
+ import { computeEpochOutHash } from '@aztec/stdlib/messaging';
5
+ export class EpochTestSettler {
6
+ l2BlockSource;
7
+ log;
8
+ options;
9
+ rollupCheatCodes;
10
+ epochMonitor;
11
+ constructor(cheatcodes, rollupAddress, l2BlockSource, log, options){
12
+ this.l2BlockSource = l2BlockSource;
13
+ this.log = log;
14
+ this.options = options;
15
+ this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, {
16
+ rollupAddress
17
+ });
18
+ }
19
+ async start() {
20
+ const { epochDuration } = await this.rollupCheatCodes.getConfig();
21
+ this.epochMonitor = new EpochMonitor(this.l2BlockSource, {
22
+ epochDuration: Number(epochDuration)
23
+ }, this.options);
24
+ this.epochMonitor.start(this);
25
+ }
26
+ async stop() {
27
+ await this.epochMonitor?.stop();
28
+ }
29
+ async handleEpochReadyToProve(epoch) {
30
+ const checkpointedBlocks = await this.l2BlockSource.getCheckpointedBlocksForEpoch(epoch);
31
+ const blocks = checkpointedBlocks.map((b)=>b.block);
32
+ this.log.info(`Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`, {
33
+ blocks: blocks.map((b)=>b.toBlockInfo())
34
+ });
35
+ const messagesInEpoch = [];
36
+ let previousSlotNumber = SlotNumber.ZERO;
37
+ let checkpointIndex = -1;
38
+ for (const block of blocks){
39
+ const slotNumber = block.header.globalVariables.slotNumber;
40
+ if (slotNumber !== previousSlotNumber) {
41
+ checkpointIndex++;
42
+ messagesInEpoch[checkpointIndex] = [];
43
+ previousSlotNumber = slotNumber;
44
+ }
45
+ messagesInEpoch[checkpointIndex].push(block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs));
46
+ }
47
+ const outHash = computeEpochOutHash(messagesInEpoch);
48
+ if (!outHash.isZero()) {
49
+ await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
50
+ } else {
51
+ this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
52
+ }
53
+ const lastCheckpoint = checkpointedBlocks.at(-1)?.checkpointNumber;
54
+ if (lastCheckpoint !== undefined) {
55
+ await this.rollupCheatCodes.markAsProven(lastCheckpoint);
56
+ } else {
57
+ this.log.warn(`No checkpoint found for epoch ${epoch}`);
58
+ }
59
+ return true;
60
+ }
61
+ }
@@ -0,0 +1,6 @@
1
+ export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
+ export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ export { CheatCodes } from './cheat_codes.js';
4
+ export { EpochTestSettler } from './epoch_test_settler.js';
5
+ export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzNELE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDOUMsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDM0QsT0FBTyxFQUFFLDZCQUE2QixFQUFFLE1BQU0sMEJBQTBCLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
+ export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ export { CheatCodes } from './cheat_codes.js';
4
+ export { EpochTestSettler } from './epoch_test_settler.js';
5
+ export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
@@ -0,0 +1,7 @@
1
+ import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
2
+ /**
3
+ * Returns Token-specific allowlist entries needed for FPC-based fee payments.
4
+ * These are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
5
+ */
6
+ export declare function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]>;
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9rZW5fYWxsb3dlZF9zZXR1cC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3RpbmcvdG9rZW5fYWxsb3dlZF9zZXR1cC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUV0RTs7O0dBR0c7QUFDSCx3QkFBc0IsNkJBQTZCLElBQUksT0FBTyxDQUFDLGNBQWMsRUFBRSxDQUFDLENBUy9FIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token_allowed_setup.d.ts","sourceRoot":"","sources":["../../src/testing/token_allowed_setup.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;;GAGG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAS/E"}
@@ -0,0 +1,20 @@
1
+ import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
2
+ import { buildAllowedElement } from '@aztec/p2p/msg_validators';
3
+ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
4
+ /**
5
+ * Returns Token-specific allowlist entries needed for FPC-based fee payments.
6
+ * These are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
7
+ */ export async function getTokenAllowedSetupFunctions() {
8
+ const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
9
+ const target = {
10
+ classId: tokenClassId
11
+ };
12
+ return Promise.all([
13
+ // Token: needed for private transfers via FPC (transfer_to_public enqueues this)
14
+ buildAllowedElement(TokenContractArtifact, target, '_increase_public_balance', {
15
+ onlySelf: true
16
+ }),
17
+ // Token: needed for public transfers via FPC (fee_entrypoint_public enqueues this)
18
+ buildAllowedElement(TokenContractArtifact, target, 'transfer_in_public')
19
+ ]);
20
+ }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.0.0-test.0",
3
+ "version": "0.0.1-commit.001888fc",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": "./dest/index.js"
6
+ ".": "./dest/index.js",
7
+ "./testing": "./dest/testing/index.js"
7
8
  },
8
- "bin": "./dest/bin/index.js",
9
+ "bin": "./scripts/aztec.sh",
9
10
  "typedocOptions": {
10
11
  "entryPoints": [
11
12
  "./src/index.ts"
@@ -14,14 +15,12 @@
14
15
  "tsconfig": "./tsconfig.json"
15
16
  },
16
17
  "scripts": {
17
- "build": "yarn clean && tsc -b",
18
+ "build": "yarn clean && ../scripts/tsc.sh",
18
19
  "start": "node --no-warnings ./dest/bin",
19
20
  "start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
20
- "start:sandbox": "ETHEREUM_HOSTS=http://0.0.0.0:8545/ && yarn start start --sandbox",
21
+ "start:local-network": "ETHEREUM_HOSTS=http://0.0.0.0:8545/ && yarn start start --local-network",
21
22
  "clean": "rm -rf ./dest .tsbuildinfo",
22
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
23
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
24
- "build:dev": "tsc -b --watch",
23
+ "build:dev": "../scripts/tsc.sh --watch",
25
24
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
26
25
  "run:example:token": "LOG_LEVEL='verbose' node ./dest/examples/token.js"
27
26
  },
@@ -29,55 +28,62 @@
29
28
  "../package.common.json"
30
29
  ],
31
30
  "dependencies": {
32
- "@aztec/accounts": "0.0.0-test.0",
33
- "@aztec/archiver": "0.0.0-test.0",
34
- "@aztec/aztec-faucet": "0.0.0-test.0",
35
- "@aztec/aztec-node": "0.0.0-test.0",
36
- "@aztec/aztec.js": "0.0.0-test.0",
37
- "@aztec/bb-prover": "0.0.0-test.0",
38
- "@aztec/blob-sink": "0.0.0-test.0",
39
- "@aztec/bot": "0.0.0-test.0",
40
- "@aztec/builder": "0.0.0-test.0",
41
- "@aztec/cli": "0.0.0-test.0",
42
- "@aztec/cli-wallet": "0.0.0-test.0",
43
- "@aztec/constants": "0.0.0-test.0",
44
- "@aztec/entrypoints": "0.0.0-test.0",
45
- "@aztec/ethereum": "0.0.0-test.0",
46
- "@aztec/foundation": "0.0.0-test.0",
47
- "@aztec/kv-store": "0.0.0-test.0",
48
- "@aztec/noir-contracts.js": "0.0.0-test.0",
49
- "@aztec/noir-protocol-circuits-types": "0.0.0-test.0",
50
- "@aztec/p2p": "0.0.0-test.0",
51
- "@aztec/p2p-bootstrap": "0.0.0-test.0",
52
- "@aztec/protocol-contracts": "0.0.0-test.0",
53
- "@aztec/prover-client": "0.0.0-test.0",
54
- "@aztec/prover-node": "0.0.0-test.0",
55
- "@aztec/pxe": "0.0.0-test.0",
56
- "@aztec/stdlib": "0.0.0-test.0",
57
- "@aztec/telemetry-client": "0.0.0-test.0",
58
- "@aztec/txe": "0.0.0-test.0",
59
- "@aztec/world-state": "0.0.0-test.0",
31
+ "@aztec/accounts": "0.0.1-commit.001888fc",
32
+ "@aztec/archiver": "0.0.1-commit.001888fc",
33
+ "@aztec/aztec-node": "0.0.1-commit.001888fc",
34
+ "@aztec/aztec.js": "0.0.1-commit.001888fc",
35
+ "@aztec/bb-prover": "0.0.1-commit.001888fc",
36
+ "@aztec/bb.js": "0.0.1-commit.001888fc",
37
+ "@aztec/blob-client": "0.0.1-commit.001888fc",
38
+ "@aztec/bot": "0.0.1-commit.001888fc",
39
+ "@aztec/builder": "0.0.1-commit.001888fc",
40
+ "@aztec/cli": "0.0.1-commit.001888fc",
41
+ "@aztec/constants": "0.0.1-commit.001888fc",
42
+ "@aztec/entrypoints": "0.0.1-commit.001888fc",
43
+ "@aztec/ethereum": "0.0.1-commit.001888fc",
44
+ "@aztec/foundation": "0.0.1-commit.001888fc",
45
+ "@aztec/kv-store": "0.0.1-commit.001888fc",
46
+ "@aztec/l1-artifacts": "0.0.1-commit.001888fc",
47
+ "@aztec/node-lib": "0.0.1-commit.001888fc",
48
+ "@aztec/noir-contracts.js": "0.0.1-commit.001888fc",
49
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.001888fc",
50
+ "@aztec/p2p": "0.0.1-commit.001888fc",
51
+ "@aztec/p2p-bootstrap": "0.0.1-commit.001888fc",
52
+ "@aztec/protocol-contracts": "0.0.1-commit.001888fc",
53
+ "@aztec/prover-client": "0.0.1-commit.001888fc",
54
+ "@aztec/prover-node": "0.0.1-commit.001888fc",
55
+ "@aztec/pxe": "0.0.1-commit.001888fc",
56
+ "@aztec/sequencer-client": "0.0.1-commit.001888fc",
57
+ "@aztec/stdlib": "0.0.1-commit.001888fc",
58
+ "@aztec/telemetry-client": "0.0.1-commit.001888fc",
59
+ "@aztec/txe": "0.0.1-commit.001888fc",
60
+ "@aztec/validator-ha-signer": "0.0.1-commit.001888fc",
61
+ "@aztec/wallets": "0.0.1-commit.001888fc",
62
+ "@aztec/world-state": "0.0.1-commit.001888fc",
63
+ "@iarna/toml": "^2.2.5",
60
64
  "@types/chalk": "^2.2.0",
61
65
  "abitype": "^0.8.11",
62
66
  "chalk": "^5.3.0",
63
67
  "commander": "^12.1.0",
64
- "koa": "^2.14.2",
65
- "koa-router": "^12.0.0",
66
- "viem": "2.22.8"
68
+ "koa": "^2.16.1",
69
+ "koa-router": "^13.1.1",
70
+ "viem": "npm:@aztec/viem@2.38.2"
67
71
  },
68
72
  "files": [
69
73
  "dest",
74
+ "scripts",
70
75
  "src",
71
76
  "!*.test.*"
72
77
  ],
73
78
  "types": "./dest/index.d.ts",
74
79
  "devDependencies": {
75
- "@jest/globals": "^29.5.0",
76
- "@types/jest": "^29.5.0",
77
- "@types/koa": "^2.13.6",
78
- "jest": "^29.5.0",
80
+ "@jest/globals": "^30.0.0",
81
+ "@types/jest": "^30.0.0",
82
+ "@types/koa": "^2.15.0",
83
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
84
+ "jest": "^30.0.0",
79
85
  "ts-node": "^10.9.1",
80
- "typescript": "^5.0.4"
86
+ "typescript": "^5.3.3"
81
87
  },
82
88
  "jest": {
83
89
  "moduleNameMapper": {
@@ -110,9 +116,13 @@
110
116
  "testTimeout": 120000,
111
117
  "setupFiles": [
112
118
  "../../foundation/src/jest/setup.mjs"
119
+ ],
120
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
121
+ "setupFilesAfterEnv": [
122
+ "../../foundation/src/jest/setupAfterEnv.mjs"
113
123
  ]
114
124
  },
115
125
  "engines": {
116
- "node": ">=18"
126
+ "node": ">=20.10"
117
127
  }
118
128
  }