@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.5476d83

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 (139) hide show
  1. package/README.md +1 -1
  2. package/dest/bin/index.d.ts +1 -1
  3. package/dest/bin/index.js +20 -12
  4. package/dest/cli/aztec_start_action.d.ts +1 -1
  5. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  6. package/dest/cli/aztec_start_action.js +36 -37
  7. package/dest/cli/aztec_start_options.d.ts +5 -3
  8. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  9. package/dest/cli/aztec_start_options.js +142 -210
  10. package/dest/cli/cli.d.ts +1 -1
  11. package/dest/cli/cli.d.ts.map +1 -1
  12. package/dest/cli/cli.js +50 -1
  13. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  14. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  15. package/dest/cli/cmds/start_archiver.js +18 -10
  16. package/dest/cli/cmds/start_blob_sink.d.ts +1 -1
  17. package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -1
  18. package/dest/cli/cmds/start_blob_sink.js +17 -1
  19. package/dest/cli/cmds/start_bot.d.ts +4 -7
  20. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  21. package/dest/cli/cmds/start_bot.js +24 -13
  22. package/dest/cli/cmds/start_node.d.ts +2 -2
  23. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  24. package/dest/cli/cmds/start_node.js +67 -80
  25. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +1 -1
  26. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  27. package/dest/cli/cmds/start_p2p_bootstrap.js +9 -4
  28. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  29. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  30. package/dest/cli/cmds/start_prover_agent.js +31 -2
  31. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  32. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  33. package/dest/cli/cmds/start_prover_broker.js +9 -3
  34. package/dest/cli/cmds/start_prover_node.d.ts +1 -1
  35. package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
  36. package/dest/cli/cmds/start_prover_node.js +43 -45
  37. package/dest/cli/cmds/start_txe.d.ts +1 -1
  38. package/dest/cli/index.d.ts +1 -1
  39. package/dest/cli/preload_crs.d.ts +3 -0
  40. package/dest/cli/preload_crs.d.ts.map +1 -0
  41. package/dest/cli/preload_crs.js +6 -0
  42. package/dest/cli/release_version.d.ts +2 -0
  43. package/dest/cli/release_version.d.ts.map +1 -0
  44. package/dest/cli/release_version.js +14 -0
  45. package/dest/cli/util.d.ts +38 -7
  46. package/dest/cli/util.d.ts.map +1 -1
  47. package/dest/cli/util.js +198 -28
  48. package/dest/cli/versioning.d.ts +1 -1
  49. package/dest/cli/versioning.js +3 -3
  50. package/dest/examples/token.d.ts +1 -1
  51. package/dest/examples/token.js +31 -18
  52. package/dest/examples/util.d.ts +5 -6
  53. package/dest/examples/util.d.ts.map +1 -1
  54. package/dest/examples/util.js +5 -6
  55. package/dest/index.d.ts +2 -2
  56. package/dest/index.d.ts.map +1 -1
  57. package/dest/index.js +1 -1
  58. package/dest/local-network/banana_fpc.d.ts +10 -0
  59. package/dest/local-network/banana_fpc.d.ts.map +1 -0
  60. package/dest/{sandbox → local-network}/banana_fpc.js +19 -21
  61. package/dest/local-network/index.d.ts +4 -0
  62. package/dest/local-network/index.d.ts.map +1 -0
  63. package/dest/local-network/index.js +3 -0
  64. package/dest/local-network/local-network.d.ts +74 -0
  65. package/dest/local-network/local-network.d.ts.map +1 -0
  66. package/dest/{sandbox/sandbox.js → local-network/local-network.js} +59 -57
  67. package/dest/local-network/sponsored_fpc.d.ts +5 -0
  68. package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
  69. package/dest/local-network/sponsored_fpc.js +18 -0
  70. package/dest/mnemonic.d.ts +1 -1
  71. package/dest/splash.d.ts +1 -1
  72. package/dest/testing/anvil_test_watcher.d.ts +34 -0
  73. package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
  74. package/dest/testing/anvil_test_watcher.js +144 -0
  75. package/dest/testing/cheat_codes.d.ts +41 -0
  76. package/dest/testing/cheat_codes.d.ts.map +1 -0
  77. package/dest/testing/cheat_codes.js +62 -0
  78. package/dest/testing/index.d.ts +4 -0
  79. package/dest/testing/index.d.ts.map +1 -0
  80. package/dest/testing/index.js +3 -0
  81. package/package.json +51 -44
  82. package/src/bin/index.ts +24 -12
  83. package/src/cli/aztec_start_action.ts +32 -35
  84. package/src/cli/aztec_start_options.ts +161 -210
  85. package/src/cli/cli.ts +54 -1
  86. package/src/cli/cmds/start_archiver.ts +19 -13
  87. package/src/cli/cmds/start_blob_sink.ts +27 -1
  88. package/src/cli/cmds/start_bot.ts +35 -12
  89. package/src/cli/cmds/start_node.ts +90 -85
  90. package/src/cli/cmds/start_p2p_bootstrap.ts +12 -4
  91. package/src/cli/cmds/start_prover_agent.ts +22 -2
  92. package/src/cli/cmds/start_prover_broker.ts +23 -3
  93. package/src/cli/cmds/start_prover_node.ts +53 -50
  94. package/src/cli/preload_crs.ts +7 -0
  95. package/src/cli/release_version.ts +21 -0
  96. package/src/cli/util.ts +208 -34
  97. package/src/cli/versioning.ts +3 -3
  98. package/src/examples/token.ts +23 -19
  99. package/src/examples/util.ts +6 -8
  100. package/src/index.ts +5 -6
  101. package/src/{sandbox → local-network}/banana_fpc.ts +20 -25
  102. package/src/local-network/index.ts +7 -0
  103. package/src/{sandbox/sandbox.ts → local-network/local-network.ts} +81 -68
  104. package/src/local-network/sponsored_fpc.ts +26 -0
  105. package/src/testing/anvil_test_watcher.ts +166 -0
  106. package/src/testing/cheat_codes.ts +78 -0
  107. package/src/testing/index.ts +3 -0
  108. package/dest/cli/chain_l2_config.d.ts +0 -19
  109. package/dest/cli/chain_l2_config.d.ts.map +0 -1
  110. package/dest/cli/chain_l2_config.js +0 -56
  111. package/dest/cli/cmds/start_faucet.d.ts +0 -4
  112. package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
  113. package/dest/cli/cmds/start_faucet.js +0 -20
  114. package/dest/cli/cmds/start_pxe.d.ts +0 -16
  115. package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
  116. package/dest/cli/cmds/start_pxe.js +0 -95
  117. package/dest/cli/get_l1_config.d.ts +0 -7
  118. package/dest/cli/get_l1_config.d.ts.map +0 -1
  119. package/dest/cli/get_l1_config.js +0 -13
  120. package/dest/sandbox/banana_fpc.d.ts +0 -11
  121. package/dest/sandbox/banana_fpc.d.ts.map +0 -1
  122. package/dest/sandbox/index.d.ts +0 -5
  123. package/dest/sandbox/index.d.ts.map +0 -1
  124. package/dest/sandbox/index.js +0 -4
  125. package/dest/sandbox/sandbox.d.ts +0 -76
  126. package/dest/sandbox/sandbox.d.ts.map +0 -1
  127. package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
  128. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
  129. package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
  130. package/dest/sandbox/sponsored_fpc.d.ts +0 -6
  131. package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
  132. package/dest/sandbox/sponsored_fpc.js +0 -26
  133. package/src/cli/chain_l2_config.ts +0 -74
  134. package/src/cli/cmds/start_faucet.ts +0 -34
  135. package/src/cli/cmds/start_pxe.ts +0 -129
  136. package/src/cli/get_l1_config.ts +0 -18
  137. package/src/sandbox/index.ts +0 -5
  138. package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
  139. package/src/sandbox/sponsored_fpc.ts +0 -38
@@ -0,0 +1,144 @@
1
+ import { RollupCheatCodes } from '@aztec/ethereum/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
+ constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
26
+ this.cheatcodes = cheatcodes;
27
+ this.dateProvider = dateProvider;
28
+ this.isLocalNetwork = false;
29
+ this.logger = createLogger(`aztecjs:utils:watcher`);
30
+ this.isMarkingAsProven = true;
31
+ this.rollup = getContract({
32
+ address: getAddress(rollupAddress.toString()),
33
+ abi: RollupAbi,
34
+ client: l1Client
35
+ });
36
+ this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
37
+ rollupAddress
38
+ });
39
+ this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
40
+ }
41
+ setIsMarkingAsProven(isMarkingAsProven) {
42
+ this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
43
+ this.isMarkingAsProven = isMarkingAsProven;
44
+ }
45
+ setisLocalNetwork(isLocalNetwork) {
46
+ this.isLocalNetwork = isLocalNetwork;
47
+ }
48
+ async start() {
49
+ if (this.filledRunningPromise) {
50
+ throw new Error('Watcher already watching for filled slot');
51
+ }
52
+ const config = await this.rollupCheatCodes.getConfig();
53
+ this.l2SlotDuration = config.slotDuration;
54
+ // If auto mining is not supported (e.g., we are on a real network), then we
55
+ // will simple do nothing. But if on an anvil or the like, this make sure that
56
+ // the local network and tests don't break because time is frozen and we never get to
57
+ // the next slot.
58
+ const isAutoMining = await this.cheatcodes.isAutoMining();
59
+ if (isAutoMining) {
60
+ this.filledRunningPromise = new RunningPromise(()=>this.warpTimeIfNeeded(), this.logger, 200);
61
+ this.filledRunningPromise.start();
62
+ this.syncDateProviderPromise = new RunningPromise(()=>this.syncDateProviderToL1IfBehind(), this.logger, 200);
63
+ this.syncDateProviderPromise.start();
64
+ this.markingAsProvenRunningPromise = new RunningPromise(()=>this.markAsProven(), this.logger, 200);
65
+ this.markingAsProvenRunningPromise.start();
66
+ this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
67
+ } else {
68
+ this.logger.info(`Watcher not started because not auto mining`);
69
+ }
70
+ }
71
+ async stop() {
72
+ await this.filledRunningPromise?.stop();
73
+ await this.syncDateProviderPromise?.stop();
74
+ await this.markingAsProvenRunningPromise?.stop();
75
+ }
76
+ async trigger() {
77
+ await this.filledRunningPromise?.trigger();
78
+ await this.syncDateProviderPromise?.trigger();
79
+ await this.markingAsProvenRunningPromise?.trigger();
80
+ }
81
+ async markAsProven() {
82
+ if (!this.isMarkingAsProven) {
83
+ return;
84
+ }
85
+ await this.rollupCheatCodes.markAsProven();
86
+ }
87
+ async syncDateProviderToL1IfBehind() {
88
+ // this doesn't apply to the local network, because we don't have a date provider in the local network
89
+ if (!this.dateProvider) {
90
+ return;
91
+ }
92
+ const l1Time = await this.cheatcodes.timestamp() * 1000;
93
+ const wallTime = this.dateProvider.now();
94
+ if (l1Time > wallTime) {
95
+ this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
96
+ this.dateProvider.setTime(l1Time);
97
+ } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
98
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
99
+ await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
100
+ }
101
+ }
102
+ async warpTimeIfNeeded() {
103
+ try {
104
+ const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
105
+ const pendingCheckpointNumber = BigInt(await this.rollup.read.getPendingCheckpointNumber());
106
+ const checkpointLog = await this.rollup.read.getCheckpoint([
107
+ pendingCheckpointNumber
108
+ ]);
109
+ const nextSlot = SlotNumber(currentSlot + 1);
110
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([
111
+ BigInt(nextSlot)
112
+ ]));
113
+ if (BigInt(currentSlot) === checkpointLog.slotNumber) {
114
+ // We should jump to the next slot
115
+ try {
116
+ await this.cheatcodes.warp(nextSlotTimestamp, {
117
+ resetBlockInterval: true
118
+ });
119
+ } catch (e) {
120
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
121
+ }
122
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
123
+ return;
124
+ }
125
+ // If we are not in local network, we don't need to warp time
126
+ if (!this.isLocalNetwork) {
127
+ return;
128
+ }
129
+ const currentTimestamp = this.dateProvider?.now() ?? Date.now();
130
+ if (currentTimestamp > nextSlotTimestamp * 1000) {
131
+ try {
132
+ await this.cheatcodes.warp(nextSlotTimestamp, {
133
+ resetBlockInterval: true
134
+ });
135
+ } catch (e) {
136
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
137
+ }
138
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
139
+ }
140
+ } catch {
141
+ this.logger.error('mineIfSlotFilled failed');
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,41 @@
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
+ eth: EthCheatCodes;
13
+ rollup: RollupCheatCodes;
14
+ constructor(
15
+ /** Cheat codes for L1.*/
16
+ eth: EthCheatCodes,
17
+ /** Cheat codes for the Aztec Rollup contract on L1. */
18
+ rollup: RollupCheatCodes);
19
+ static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes>;
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
+ */
29
+ warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number): Promise<void>;
30
+ /**
31
+ * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
32
+ * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
33
+ * number, which advances in fixed intervals.
34
+ * This is useful for testing time-dependent contract behavior.
35
+ * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
36
+ * @param node - The Aztec node used to query if a new block has been mined.
37
+ * @param duration - The duration to advance time by (in seconds)
38
+ */
39
+ warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number): Promise<void>;
40
+ }
41
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlYXRfY29kZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2NoZWF0X2NvZGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV2RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUMvRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRTs7Ozs7R0FLRztBQUNILHFCQUFhLFVBQVU7SUFHWixHQUFHLEVBQUUsYUFBYTtJQUVsQixNQUFNLEVBQUUsZ0JBQWdCO0lBSmpDO0lBQ0UseUJBQXlCO0lBQ2xCLEdBQUcsRUFBRSxhQUFhO0lBQ3pCLHVEQUF1RDtJQUNoRCxNQUFNLEVBQUUsZ0JBQWdCLEVBQzdCO0lBRUosT0FBYSxNQUFNLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxFQUFFLElBQUksRUFBRSxTQUFTLEVBQUUsWUFBWSxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBT3ZHO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDRyxtQkFBbUIsQ0FBQyxlQUFlLEVBQUUsZUFBZSxFQUFFLElBQUksRUFBRSxTQUFTLEVBQUUsZUFBZSxFQUFFLE1BQU0sR0FBRyxNQUFNLGlCQXVCNUc7SUFFRDs7Ozs7Ozs7T0FRRztJQUNHLG1CQUFtQixDQUFDLGVBQWUsRUFBRSxlQUFlLEVBQUUsSUFBSSxFQUFFLFNBQVMsRUFBRSxRQUFRLEVBQUUsTUFBTSxHQUFHLE1BQU0saUJBSXJHO0NBQ0YifQ==
@@ -0,0 +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;AAEvE,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;IAGZ,GAAG,EAAE,aAAa;IAElB,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,4 @@
1
+ export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
+ export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ export { CheatCodes } from './cheat_codes.js';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzNELE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUMifQ==
@@ -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"}
@@ -0,0 +1,3 @@
1
+ export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
+ export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ export { CheatCodes } from './cheat_codes.js';
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.0.0-test.1",
3
+ "version": "0.0.1-commit.5476d83",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": "./dest/index.js"
6
+ ".": "./dest/index.js",
7
+ "./testing": "./dest/testing/index.js"
7
8
  },
8
9
  "bin": "./dest/bin/index.js",
9
10
  "typedocOptions": {
@@ -14,14 +15,12 @@
14
15
  "tsconfig": "./tsconfig.json"
15
16
  },
16
17
  "scripts": {
17
- "build": "yarn clean && tsc -b",
18
+ "build": "yarn clean && tsgo -b",
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": "tsgo -b --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,41 +28,44 @@
29
28
  "../package.common.json"
30
29
  ],
31
30
  "dependencies": {
32
- "@aztec/accounts": "0.0.0-test.1",
33
- "@aztec/archiver": "0.0.0-test.1",
34
- "@aztec/aztec-faucet": "0.0.0-test.1",
35
- "@aztec/aztec-node": "0.0.0-test.1",
36
- "@aztec/aztec.js": "0.0.0-test.1",
37
- "@aztec/bb-prover": "0.0.0-test.1",
38
- "@aztec/blob-sink": "0.0.0-test.1",
39
- "@aztec/bot": "0.0.0-test.1",
40
- "@aztec/builder": "0.0.0-test.1",
41
- "@aztec/cli": "0.0.0-test.1",
42
- "@aztec/cli-wallet": "0.0.0-test.1",
43
- "@aztec/constants": "0.0.0-test.1",
44
- "@aztec/entrypoints": "0.0.0-test.1",
45
- "@aztec/ethereum": "0.0.0-test.1",
46
- "@aztec/foundation": "0.0.0-test.1",
47
- "@aztec/kv-store": "0.0.0-test.1",
48
- "@aztec/noir-contracts.js": "0.0.0-test.1",
49
- "@aztec/noir-protocol-circuits-types": "0.0.0-test.1",
50
- "@aztec/p2p": "0.0.0-test.1",
51
- "@aztec/p2p-bootstrap": "0.0.0-test.1",
52
- "@aztec/protocol-contracts": "0.0.0-test.1",
53
- "@aztec/prover-client": "0.0.0-test.1",
54
- "@aztec/prover-node": "0.0.0-test.1",
55
- "@aztec/pxe": "0.0.0-test.1",
56
- "@aztec/stdlib": "0.0.0-test.1",
57
- "@aztec/telemetry-client": "0.0.0-test.1",
58
- "@aztec/txe": "0.0.0-test.1",
59
- "@aztec/world-state": "0.0.0-test.1",
31
+ "@aztec/accounts": "0.0.1-commit.5476d83",
32
+ "@aztec/archiver": "0.0.1-commit.5476d83",
33
+ "@aztec/aztec-faucet": "0.0.1-commit.5476d83",
34
+ "@aztec/aztec-node": "0.0.1-commit.5476d83",
35
+ "@aztec/aztec.js": "0.0.1-commit.5476d83",
36
+ "@aztec/bb-prover": "0.0.1-commit.5476d83",
37
+ "@aztec/bb.js": "0.0.1-commit.5476d83",
38
+ "@aztec/blob-sink": "0.0.1-commit.5476d83",
39
+ "@aztec/bot": "0.0.1-commit.5476d83",
40
+ "@aztec/builder": "0.0.1-commit.5476d83",
41
+ "@aztec/cli": "0.0.1-commit.5476d83",
42
+ "@aztec/constants": "0.0.1-commit.5476d83",
43
+ "@aztec/entrypoints": "0.0.1-commit.5476d83",
44
+ "@aztec/ethereum": "0.0.1-commit.5476d83",
45
+ "@aztec/foundation": "0.0.1-commit.5476d83",
46
+ "@aztec/kv-store": "0.0.1-commit.5476d83",
47
+ "@aztec/l1-artifacts": "0.0.1-commit.5476d83",
48
+ "@aztec/node-lib": "0.0.1-commit.5476d83",
49
+ "@aztec/noir-contracts.js": "0.0.1-commit.5476d83",
50
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.5476d83",
51
+ "@aztec/p2p": "0.0.1-commit.5476d83",
52
+ "@aztec/p2p-bootstrap": "0.0.1-commit.5476d83",
53
+ "@aztec/protocol-contracts": "0.0.1-commit.5476d83",
54
+ "@aztec/prover-client": "0.0.1-commit.5476d83",
55
+ "@aztec/prover-node": "0.0.1-commit.5476d83",
56
+ "@aztec/pxe": "0.0.1-commit.5476d83",
57
+ "@aztec/stdlib": "0.0.1-commit.5476d83",
58
+ "@aztec/telemetry-client": "0.0.1-commit.5476d83",
59
+ "@aztec/test-wallet": "0.0.1-commit.5476d83",
60
+ "@aztec/txe": "0.0.1-commit.5476d83",
61
+ "@aztec/world-state": "0.0.1-commit.5476d83",
60
62
  "@types/chalk": "^2.2.0",
61
63
  "abitype": "^0.8.11",
62
64
  "chalk": "^5.3.0",
63
65
  "commander": "^12.1.0",
64
- "koa": "^2.14.2",
65
- "koa-router": "^12.0.0",
66
- "viem": "2.22.8"
66
+ "koa": "^2.16.1",
67
+ "koa-router": "^13.1.1",
68
+ "viem": "npm:@aztec/viem@2.38.2"
67
69
  },
68
70
  "files": [
69
71
  "dest",
@@ -72,12 +74,13 @@
72
74
  ],
73
75
  "types": "./dest/index.d.ts",
74
76
  "devDependencies": {
75
- "@jest/globals": "^29.5.0",
76
- "@types/jest": "^29.5.0",
77
- "@types/koa": "^2.13.6",
78
- "jest": "^29.5.0",
77
+ "@jest/globals": "^30.0.0",
78
+ "@types/jest": "^30.0.0",
79
+ "@types/koa": "^2.15.0",
80
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
81
+ "jest": "^30.0.0",
79
82
  "ts-node": "^10.9.1",
80
- "typescript": "^5.0.4"
83
+ "typescript": "^5.3.3"
81
84
  },
82
85
  "jest": {
83
86
  "moduleNameMapper": {
@@ -110,9 +113,13 @@
110
113
  "testTimeout": 120000,
111
114
  "setupFiles": [
112
115
  "../../foundation/src/jest/setup.mjs"
116
+ ],
117
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
118
+ "setupFilesAfterEnv": [
119
+ "../../foundation/src/jest/setupAfterEnv.mjs"
113
120
  ]
114
121
  },
115
122
  "engines": {
116
- "node": ">=18"
123
+ "node": ">=20.10"
117
124
  }
118
125
  }
package/src/bin/index.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  //
3
3
  import { injectCommands as injectBuilderCommands } from '@aztec/builder';
4
- import { injectCommands as injectWalletCommands } from '@aztec/cli-wallet';
4
+ import { injectCommands as injectAztecNodeCommands } from '@aztec/cli/aztec_node';
5
+ import { enrichEnvironmentWithChainName, enrichEnvironmentWithNetworkConfig } from '@aztec/cli/config';
5
6
  import { injectCommands as injectContractCommands } from '@aztec/cli/contracts';
6
- import { injectCommands as injectDevnetCommands } from '@aztec/cli/devnet';
7
7
  import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infrastructure';
8
8
  import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
9
9
  import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
10
- import { injectCommands as injectPXECommands } from '@aztec/cli/pxe';
10
+ import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
11
+ import { getActiveNetworkName } from '@aztec/foundation/config';
11
12
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
12
- import { fileURLToPath } from '@aztec/foundation/url';
13
13
 
14
14
  import { Command } from 'commander';
15
- import { readFileSync } from 'fs';
16
- import { dirname, resolve } from 'path';
17
15
 
16
+ import { NETWORK_FLAG } from '../cli/aztec_start_options.js';
18
17
  import { injectAztecCommands } from '../cli/index.js';
18
+ import { getCliVersion } from '../cli/release_version.js';
19
19
 
20
20
  const userLog = createConsoleLogger();
21
21
  const debugLogger = createLogger('cli');
@@ -28,19 +28,31 @@ async function main() {
28
28
  process.once('SIGINT', shutdown);
29
29
  process.once('SIGTERM', shutdown);
30
30
 
31
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
32
- const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
31
+ // Intercept the setting of a network and enrich the environment with defaults for that network
32
+ let networkValue: string | undefined;
33
+
34
+ const args = process.argv.slice(2);
35
+ const networkIndex = args.findIndex(arg => arg.startsWith(`--${NETWORK_FLAG}=`) || arg === `--${NETWORK_FLAG}`);
36
+
37
+ if (networkIndex !== -1) {
38
+ networkValue = args[networkIndex].split('=')[1] || args[networkIndex + 1];
39
+ }
40
+
41
+ const networkName = getActiveNetworkName(networkValue);
42
+ await enrichEnvironmentWithNetworkConfig(networkName);
43
+ enrichEnvironmentWithChainName(networkName);
44
+
45
+ const cliVersion = getCliVersion();
33
46
  let program = new Command('aztec');
34
47
  program.description('Aztec command line interface').version(cliVersion);
35
48
  program = injectAztecCommands(program, userLog, debugLogger);
36
49
  program = injectBuilderCommands(program);
37
50
  program = injectContractCommands(program, userLog, debugLogger);
38
- program = injectInfrastructureCommands(program, userLog, debugLogger);
51
+ program = injectInfrastructureCommands(program, userLog);
39
52
  program = injectL1Commands(program, userLog, debugLogger);
40
- program = injectPXECommands(program, userLog, debugLogger);
53
+ program = injectAztecNodeCommands(program, userLog, debugLogger);
41
54
  program = injectMiscCommands(program, userLog);
42
- program = injectDevnetCommands(program, userLog, debugLogger);
43
- program = injectWalletCommands(program, userLog, debugLogger);
55
+ program = injectValidatorKeysCommands(program, userLog);
44
56
 
45
57
  await program.parseAsync(process.argv);
46
58
  }
@@ -4,43 +4,38 @@ import {
4
4
  startHttpRpcServer,
5
5
  } from '@aztec/foundation/json-rpc/server';
6
6
  import type { LogFn, Logger } from '@aztec/foundation/log';
7
- import { fileURLToPath } from '@aztec/foundation/url';
8
7
  import type { ChainConfig } from '@aztec/stdlib/config';
9
- import { AztecNodeApiSchema, PXESchema } from '@aztec/stdlib/interfaces/client';
8
+ import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
10
9
  import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
11
10
  import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
12
11
 
13
- import { readFileSync } from 'fs';
14
- import { dirname, resolve } from 'path';
15
-
16
- import { createSandbox } from '../sandbox/index.js';
12
+ import { createLocalNetwork } from '../local-network/index.js';
17
13
  import { github, splash } from '../splash.js';
18
- import { enrichEnvironmentWithChainConfig } from './chain_l2_config.js';
14
+ import { getCliVersion } from './release_version.js';
19
15
  import { extractNamespacedOptions, installSignalHandlers } from './util.js';
20
16
  import { getVersions } from './versioning.js';
21
17
 
22
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
23
- const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
24
-
25
18
  export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logger) {
26
19
  // list of 'stop' functions to call when process ends
27
20
  const signalHandlers: Array<() => Promise<void>> = [];
28
21
  const services: NamespacedApiHandlers = {};
22
+ const adminServices: NamespacedApiHandlers = {};
29
23
  let config: ChainConfig | undefined = undefined;
30
24
 
31
- if (options.sandbox) {
32
- const sandboxOptions = extractNamespacedOptions(options, 'sandbox');
33
- const nodeOptions = extractNamespacedOptions(options, 'node');
25
+ if (options.localNetwork) {
26
+ const cliVersion = getCliVersion();
27
+ const localNetwork = extractNamespacedOptions(options, 'local-network');
28
+ localNetwork.testAccounts = true;
34
29
  userLog(`${splash}\n${github}\n\n`);
35
- userLog(`Setting up Aztec Sandbox ${cliVersion}, please stand by...`);
30
+ userLog(`Setting up Aztec local network ${cliVersion}, please stand by...`);
36
31
 
37
- const { node, pxe, stop } = await createSandbox(
32
+ const { node, stop } = await createLocalNetwork(
38
33
  {
39
- l1Mnemonic: options.l1Mnemonic,
34
+ l1Mnemonic: localNetwork.l1Mnemonic,
40
35
  l1RpcUrls: options.l1RpcUrls,
41
- l1Salt: nodeOptions.deployAztecContractsSalt,
42
- noPXE: sandboxOptions.noPXE,
43
- testAccounts: sandboxOptions.testAccounts,
36
+ deployAztecContractsSalt: localNetwork.deployAztecContractsSalt,
37
+ testAccounts: localNetwork.testAccounts,
38
+ realProofs: false,
44
39
  },
45
40
  userLog,
46
41
  );
@@ -48,19 +43,10 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
48
43
  // Start Node and PXE JSON-RPC server
49
44
  signalHandlers.push(stop);
50
45
  services.node = [node, AztecNodeApiSchema];
51
- if (!sandboxOptions.noPXE) {
52
- services.pxe = [pxe, PXESchema];
53
- } else {
54
- userLog(`Not exposing PXE API through JSON-RPC server`);
55
- }
56
46
  } else {
57
- // If a network is specified, enrich the environment with the chain config
58
- if (options.network) {
59
- await enrichEnvironmentWithChainConfig(options.network);
60
- }
61
47
  if (options.node) {
62
48
  const { startNode } = await import('./cmds/start_node.js');
63
- ({ config } = await startNode(options, signalHandlers, services, userLog));
49
+ ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
64
50
  } else if (options.bot) {
65
51
  const { startBot } = await import('./cmds/start_bot.js');
66
52
  await startBot(options, signalHandlers, services, userLog);
@@ -70,9 +56,6 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
70
56
  } else if (options.blobSink) {
71
57
  const { startBlobSink } = await import('./cmds/start_blob_sink.js');
72
58
  await startBlobSink(options, signalHandlers, userLog);
73
- } else if (options.pxe) {
74
- const { startPXE } = await import('./cmds/start_pxe.js');
75
- ({ config } = await startPXE(options, signalHandlers, services, userLog));
76
59
  } else if (options.archiver) {
77
60
  const { startArchiver } = await import('./cmds/start_archiver.js');
78
61
  ({ config } = await startArchiver(options, signalHandlers, services));
@@ -91,9 +74,6 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
91
74
  } else if (options.sequencer) {
92
75
  userLog(`Cannot run a standalone sequencer without a node`);
93
76
  process.exit(1);
94
- } else if (options.faucet) {
95
- const { startFaucet } = await import('./cmds/start_faucet.js');
96
- await startFaucet(options, signalHandlers, services, userLog);
97
77
  } else {
98
78
  userLog(`No module specified to start`);
99
79
  process.exit(1);
@@ -102,13 +82,30 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
102
82
 
103
83
  installSignalHandlers(debugLogger.info, signalHandlers);
104
84
  const versions = getVersions(config);
85
+
86
+ // Start the main JSON-RPC server
105
87
  if (Object.entries(services).length > 0) {
106
88
  const rpcServer = createNamespacedSafeJsonRpcServer(services, {
107
89
  http200OnError: false,
108
90
  log: debugLogger,
109
91
  middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
92
+ maxBatchSize: options.rpcMaxBatchSize,
93
+ maxBodySizeBytes: options.rpcMaxBodySize,
110
94
  });
111
95
  const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
112
96
  debugLogger.info(`Aztec Server listening on port ${port}`, versions);
113
97
  }
98
+
99
+ // If there are any admin services, start a separate JSON-RPC server for them
100
+ if (Object.entries(adminServices).length > 0) {
101
+ const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
102
+ http200OnError: false,
103
+ log: debugLogger,
104
+ middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
105
+ maxBatchSize: options.rpcMaxBatchSize,
106
+ maxBodySizeBytes: options.rpcMaxBodySize,
107
+ });
108
+ const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort });
109
+ debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
110
+ }
114
111
  }