@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.017a351

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 (217) 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 +107 -49
  10. package/dest/cli/aztec_start_options.d.ts +6 -4
  11. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  12. package/dest/cli/aztec_start_options.js +160 -223
  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 +76 -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 +30 -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_bot.d.ts +4 -7
  38. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  39. package/dest/cli/cmds/start_bot.js +32 -17
  40. package/dest/cli/cmds/start_node.d.ts +3 -2
  41. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  42. package/dest/cli/cmds/start_node.js +113 -86
  43. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  44. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  45. package/dest/cli/cmds/start_p2p_bootstrap.js +10 -6
  46. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  47. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  48. package/dest/cli/cmds/start_prover_agent.js +29 -12
  49. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  50. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  51. package/dest/cli/cmds/start_prover_broker.js +25 -10
  52. package/dest/cli/cmds/start_txe.d.ts +2 -2
  53. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  54. package/dest/cli/cmds/start_txe.js +6 -5
  55. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  56. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  57. package/dest/cli/cmds/utils/artifacts.js +24 -0
  58. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  59. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  60. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  61. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  62. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  63. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  64. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  65. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  66. package/dest/cli/cmds/utils/spawn.js +16 -0
  67. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  68. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  69. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  70. package/dest/cli/index.d.ts +1 -1
  71. package/dest/cli/preload_crs.d.ts +3 -0
  72. package/dest/cli/preload_crs.d.ts.map +1 -0
  73. package/dest/cli/preload_crs.js +6 -0
  74. package/dest/cli/util.d.ts +37 -17
  75. package/dest/cli/util.d.ts.map +1 -1
  76. package/dest/cli/util.js +171 -35
  77. package/dest/cli/versioning.d.ts +1 -1
  78. package/dest/cli/versioning.js +3 -3
  79. package/dest/examples/token.d.ts +1 -1
  80. package/dest/examples/token.js +31 -18
  81. package/dest/examples/util.d.ts +5 -6
  82. package/dest/examples/util.d.ts.map +1 -1
  83. package/dest/examples/util.js +5 -6
  84. package/dest/index.d.ts +2 -2
  85. package/dest/index.d.ts.map +1 -1
  86. package/dest/index.js +1 -1
  87. package/dest/local-network/auth_registry.d.ts +5 -0
  88. package/dest/local-network/auth_registry.d.ts.map +1 -0
  89. package/dest/local-network/auth_registry.js +17 -0
  90. package/dest/local-network/banana_fpc.d.ts +11 -0
  91. package/dest/local-network/banana_fpc.d.ts.map +1 -0
  92. package/dest/{sandbox → local-network}/banana_fpc.js +29 -27
  93. package/dest/local-network/index.d.ts +4 -0
  94. package/dest/local-network/index.d.ts.map +1 -0
  95. package/dest/local-network/index.js +3 -0
  96. package/dest/local-network/local-network.d.ts +50 -0
  97. package/dest/local-network/local-network.d.ts.map +1 -0
  98. package/dest/local-network/local-network.js +248 -0
  99. package/dest/local-network/sponsored_fpc.d.ts +5 -0
  100. package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
  101. package/dest/local-network/sponsored_fpc.js +18 -0
  102. package/dest/mnemonic.d.ts +1 -1
  103. package/dest/splash.d.ts +1 -1
  104. package/dest/testing/anvil_test_watcher.d.ts +54 -0
  105. package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
  106. package/dest/testing/anvil_test_watcher.js +235 -0
  107. package/dest/testing/cheat_codes.d.ts +44 -0
  108. package/dest/testing/cheat_codes.d.ts.map +1 -0
  109. package/dest/testing/cheat_codes.js +98 -0
  110. package/dest/testing/epoch_test_settler.d.ts +19 -0
  111. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  112. package/dest/testing/epoch_test_settler.js +63 -0
  113. package/dest/testing/index.d.ts +6 -0
  114. package/dest/testing/index.d.ts.map +1 -0
  115. package/dest/testing/index.js +5 -0
  116. package/dest/testing/token_allowed_setup.d.ts +7 -0
  117. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  118. package/dest/testing/token_allowed_setup.js +20 -0
  119. package/package.json +56 -45
  120. package/scripts/add_crate.sh +53 -0
  121. package/scripts/aztec.sh +73 -0
  122. package/scripts/init.sh +39 -0
  123. package/scripts/new.sh +83 -0
  124. package/scripts/setup_workspace.sh +69 -0
  125. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  126. package/scripts/templates/blank/contract/src/main.nr +10 -0
  127. package/scripts/templates/blank/test/Nargo.toml +7 -0
  128. package/scripts/templates/blank/test/src/lib.nr +11 -0
  129. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  130. package/scripts/templates/counter/contract/src/main.nr +48 -0
  131. package/scripts/templates/counter/test/Nargo.toml +7 -0
  132. package/scripts/templates/counter/test/src/lib.nr +32 -0
  133. package/src/bin/index.ts +33 -13
  134. package/src/cli/admin_api_key_store.ts +128 -0
  135. package/src/cli/aztec_start_action.ts +100 -46
  136. package/src/cli/aztec_start_options.ts +183 -226
  137. package/src/cli/cli.ts +19 -11
  138. package/src/cli/cmds/compile.ts +192 -0
  139. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  140. package/src/cli/cmds/profile.ts +26 -0
  141. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  142. package/src/cli/cmds/profile_gates.ts +84 -0
  143. package/src/cli/cmds/profile_utils.ts +58 -0
  144. package/src/cli/cmds/standby.ts +132 -0
  145. package/src/cli/cmds/start_bot.ts +43 -19
  146. package/src/cli/cmds/start_node.ts +142 -91
  147. package/src/cli/cmds/start_p2p_bootstrap.ts +14 -6
  148. package/src/cli/cmds/start_prover_agent.ts +25 -16
  149. package/src/cli/cmds/start_prover_broker.ts +32 -9
  150. package/src/cli/cmds/start_txe.ts +7 -5
  151. package/src/cli/cmds/utils/artifacts.ts +44 -0
  152. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  153. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  154. package/src/cli/cmds/utils/spawn.ts +16 -0
  155. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  156. package/src/cli/preload_crs.ts +7 -0
  157. package/src/cli/util.ts +192 -56
  158. package/src/cli/versioning.ts +3 -3
  159. package/src/examples/token.ts +23 -19
  160. package/src/examples/util.ts +6 -8
  161. package/src/index.ts +5 -6
  162. package/src/local-network/auth_registry.ts +19 -0
  163. package/src/{sandbox → local-network}/banana_fpc.ts +32 -29
  164. package/src/local-network/index.ts +7 -0
  165. package/src/local-network/local-network.ts +303 -0
  166. package/src/local-network/sponsored_fpc.ts +26 -0
  167. package/src/testing/anvil_test_watcher.ts +273 -0
  168. package/src/testing/cheat_codes.ts +132 -0
  169. package/src/testing/epoch_test_settler.ts +69 -0
  170. package/src/testing/index.ts +5 -0
  171. package/src/testing/token_allowed_setup.ts +19 -0
  172. package/dest/cli/chain_l2_config.d.ts +0 -19
  173. package/dest/cli/chain_l2_config.d.ts.map +0 -1
  174. package/dest/cli/chain_l2_config.js +0 -56
  175. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  176. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  177. package/dest/cli/cmds/start_archiver.js +0 -42
  178. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  179. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  180. package/dest/cli/cmds/start_blob_sink.js +0 -17
  181. package/dest/cli/cmds/start_faucet.d.ts +0 -4
  182. package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
  183. package/dest/cli/cmds/start_faucet.js +0 -20
  184. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  185. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  186. package/dest/cli/cmds/start_prover_node.js +0 -110
  187. package/dest/cli/cmds/start_pxe.d.ts +0 -16
  188. package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
  189. package/dest/cli/cmds/start_pxe.js +0 -95
  190. package/dest/cli/get_l1_config.d.ts +0 -7
  191. package/dest/cli/get_l1_config.d.ts.map +0 -1
  192. package/dest/cli/get_l1_config.js +0 -13
  193. package/dest/sandbox/banana_fpc.d.ts +0 -11
  194. package/dest/sandbox/banana_fpc.d.ts.map +0 -1
  195. package/dest/sandbox/index.d.ts +0 -5
  196. package/dest/sandbox/index.d.ts.map +0 -1
  197. package/dest/sandbox/index.js +0 -4
  198. package/dest/sandbox/sandbox.d.ts +0 -76
  199. package/dest/sandbox/sandbox.d.ts.map +0 -1
  200. package/dest/sandbox/sandbox.js +0 -181
  201. package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
  202. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
  203. package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
  204. package/dest/sandbox/sponsored_fpc.d.ts +0 -6
  205. package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
  206. package/dest/sandbox/sponsored_fpc.js +0 -26
  207. package/src/cli/chain_l2_config.ts +0 -74
  208. package/src/cli/cmds/start_archiver.ts +0 -55
  209. package/src/cli/cmds/start_blob_sink.ts +0 -31
  210. package/src/cli/cmds/start_faucet.ts +0 -34
  211. package/src/cli/cmds/start_prover_node.ts +0 -121
  212. package/src/cli/cmds/start_pxe.ts +0 -129
  213. package/src/cli/get_l1_config.ts +0 -18
  214. package/src/sandbox/index.ts +0 -5
  215. package/src/sandbox/sandbox.ts +0 -229
  216. package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
  217. package/src/sandbox/sponsored_fpc.ts +0 -38
@@ -0,0 +1,273 @@
1
+ import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import type { ViemClient } from '@aztec/ethereum/types';
3
+ import { SlotNumber } from '@aztec/foundation/branded-types';
4
+ import type { EthAddress } from '@aztec/foundation/eth-address';
5
+ import { type Logger, createLogger } from '@aztec/foundation/log';
6
+ import { RunningPromise } from '@aztec/foundation/running-promise';
7
+ import type { TestDateProvider } from '@aztec/foundation/timer';
8
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
9
+
10
+ import { type GetContractReturnType, getAddress, getContract } from 'viem';
11
+
12
+ export type AnvilTestWatcherOpts = {
13
+ isLocalNetwork?: boolean;
14
+ isMarkingAsProven?: boolean;
15
+ };
16
+
17
+ /**
18
+ * Represents a watcher for a rollup contract.
19
+ *
20
+ * It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
21
+ * it will periodically check if the current slot have already been filled, e.g., there was an L2
22
+ * block within the slot. And if so, it will time travel into the next slot.
23
+ */
24
+ export class AnvilTestWatcher {
25
+ private isLocalNetwork;
26
+ private isMarkingAsProven;
27
+
28
+ private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
29
+ private rollupCheatCodes: RollupCheatCodes;
30
+ private l2SlotDuration!: number;
31
+
32
+ private filledRunningPromise?: RunningPromise;
33
+ private syncDateProviderPromise?: RunningPromise;
34
+ private markingAsProvenRunningPromise?: RunningPromise;
35
+
36
+ private logger: Logger = createLogger(`aztecjs:utils:watcher`);
37
+
38
+ // Optional callback to check if there are pending txs in the mempool.
39
+ private getPendingTxCount?: () => Promise<number>;
40
+
41
+ // Optional callback to check if the sequencer is actively building a block.
42
+ private isSequencerBuilding?: () => boolean;
43
+
44
+ // Tracks when we first observed the current unfilled slot with pending txs (real wall time).
45
+ private unfilledSlotFirstSeen?: { slot: number; realTime: number };
46
+
47
+ // Latest target slot for which the proposer has built a block destined for L1 but which has
48
+ // not yet been committed. Set by the proposer-pipelining hook from `block-proposed` events so
49
+ // the watcher can advance L1 (and the injected date provider) to the target slot ahead of the
50
+ // publisher's `sendRequestsAt` sleep, instead of waiting a full wall-clock slot.
51
+ private proposedTargetSlot?: number;
52
+
53
+ constructor(
54
+ private cheatcodes: EthCheatCodes,
55
+ rollupAddress: EthAddress,
56
+ l1Client: ViemClient,
57
+ private dateProvider?: TestDateProvider,
58
+ opts: AnvilTestWatcherOpts = {},
59
+ ) {
60
+ this.rollup = getContract({
61
+ address: getAddress(rollupAddress.toString()),
62
+ abi: RollupAbi,
63
+ client: l1Client,
64
+ });
65
+
66
+ this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
67
+ rollupAddress,
68
+ });
69
+
70
+ this.isLocalNetwork = opts.isLocalNetwork ?? false;
71
+ this.isMarkingAsProven = opts.isMarkingAsProven ?? true;
72
+
73
+ this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
74
+ }
75
+
76
+ setIsMarkingAsProven(isMarkingAsProven: boolean) {
77
+ this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
78
+ this.isMarkingAsProven = isMarkingAsProven;
79
+ }
80
+
81
+ setisLocalNetwork(isLocalNetwork: boolean) {
82
+ this.isLocalNetwork = isLocalNetwork;
83
+ }
84
+
85
+ /** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
86
+ setGetPendingTxCount(fn: () => Promise<number>) {
87
+ this.getPendingTxCount = fn;
88
+ }
89
+
90
+ /** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
91
+ setIsSequencerBuilding(fn: () => boolean) {
92
+ this.isSequencerBuilding = fn;
93
+ }
94
+
95
+ /**
96
+ * Records the target slot for which the proposer has built a block destined for L1. Used by
97
+ * the local-network watcher to fast-forward L1 (and the injected date provider) ahead of the
98
+ * pipelined publisher's `sendRequestsAt` sleep so it ends promptly instead of waiting a full
99
+ * wall-clock slot. Only ratchets up — late warps for stale slots are no-ops.
100
+ */
101
+ setProposedTargetSlot(slot: number) {
102
+ if (this.proposedTargetSlot === undefined || slot > this.proposedTargetSlot) {
103
+ this.proposedTargetSlot = slot;
104
+ }
105
+ }
106
+
107
+ async start() {
108
+ if (this.filledRunningPromise) {
109
+ throw new Error('Watcher already watching for filled slot');
110
+ }
111
+
112
+ const config = await this.rollupCheatCodes.getConfig();
113
+ this.l2SlotDuration = config.slotDuration;
114
+
115
+ // If auto mining is not supported (e.g., we are on a real network), then we
116
+ // will simple do nothing. But if on an anvil or the like, this make sure that
117
+ // the local network and tests don't break because time is frozen and we never get to
118
+ // the next slot.
119
+ const isAutoMining = await this.cheatcodes.isAutoMining();
120
+
121
+ if (isAutoMining) {
122
+ this.filledRunningPromise = new RunningPromise(() => this.warpTimeIfNeeded(), this.logger, 200);
123
+ this.filledRunningPromise.start();
124
+ this.syncDateProviderPromise = new RunningPromise(() => this.syncDateProviderToL1IfBehind(), this.logger, 200);
125
+ this.syncDateProviderPromise.start();
126
+ this.markingAsProvenRunningPromise = new RunningPromise(() => this.markAsProven(), this.logger, 200);
127
+ this.markingAsProvenRunningPromise.start();
128
+ this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
129
+ } else {
130
+ this.logger.info(`Watcher not started because not auto mining`);
131
+ }
132
+ }
133
+
134
+ async stop() {
135
+ await this.filledRunningPromise?.stop();
136
+ await this.syncDateProviderPromise?.stop();
137
+ await this.markingAsProvenRunningPromise?.stop();
138
+ }
139
+
140
+ async trigger() {
141
+ await this.filledRunningPromise?.trigger();
142
+ await this.syncDateProviderPromise?.trigger();
143
+ await this.markingAsProvenRunningPromise?.trigger();
144
+ }
145
+
146
+ async markAsProven() {
147
+ if (!this.isMarkingAsProven) {
148
+ return;
149
+ }
150
+ await this.rollupCheatCodes.markAsProven();
151
+ }
152
+
153
+ async syncDateProviderToL1IfBehind() {
154
+ // this doesn't apply to the local network, because we don't have a date provider in the local network
155
+ if (!this.dateProvider) {
156
+ return;
157
+ }
158
+
159
+ const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
160
+ const wallTime = this.dateProvider.now();
161
+ if (l1Time > wallTime) {
162
+ this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
163
+ this.dateProvider.setTime(l1Time);
164
+ } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
165
+ // Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
166
+ // `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
167
+ // `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
168
+ // a second apart and one of them is then rejected by anvil as non-monotonic.
169
+ const wallSec = Math.floor(wallTime / 1000);
170
+ const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
171
+ const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
172
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
173
+ await this.warpToTimestamp(targetTimestamp);
174
+ }
175
+ }
176
+
177
+ async warpTimeIfNeeded() {
178
+ try {
179
+ const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
180
+ const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
181
+ const checkpointLog = await this.rollup.read.getCheckpoint([pendingCheckpointNumber]);
182
+ const nextSlot = SlotNumber(currentSlot + 1);
183
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
184
+
185
+ if (BigInt(currentSlot) === checkpointLog.slotNumber) {
186
+ // The current slot has been filled, we should jump to the next slot.
187
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
188
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
189
+ }
190
+ return;
191
+ }
192
+
193
+ // If we are not in local network, we don't need to warp time
194
+ if (!this.isLocalNetwork) {
195
+ return;
196
+ }
197
+
198
+ // Pipelined-publish shortcut: if the proposer has built a block destined for a slot
199
+ // beyond the current L1 slot, fast-forward L1 to that slot's timestamp so the publisher's
200
+ // `sendRequestsAt(targetSlot)` sleep ends and the multicall mines inside the target slot.
201
+ // Without this, the publisher waits up to a full real-time slot for wall clock to catch up.
202
+ if (this.proposedTargetSlot !== undefined && this.proposedTargetSlot > currentSlot) {
203
+ const targetSlotTimestamp = Number(
204
+ await this.rollup.read.getTimestampForSlot([BigInt(this.proposedTargetSlot)]),
205
+ );
206
+ if (await this.warpToTimestamp(targetSlotTimestamp)) {
207
+ this.logger.info(`Warped L1 to target slot ${this.proposedTargetSlot} for pipelined publish`);
208
+ }
209
+ return;
210
+ }
211
+
212
+ // If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
213
+ // sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
214
+ // the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
215
+ // to avoid invalidating its in-progress work.
216
+ if (this.getPendingTxCount) {
217
+ const pendingTxs = await this.getPendingTxCount();
218
+ if (pendingTxs > 0) {
219
+ if (this.isSequencerBuilding?.()) {
220
+ this.unfilledSlotFirstSeen = undefined;
221
+ return;
222
+ }
223
+
224
+ const realNow = Date.now();
225
+ if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
226
+ this.unfilledSlotFirstSeen = { slot: currentSlot, realTime: realNow };
227
+ return;
228
+ }
229
+
230
+ if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
231
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
232
+ this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
233
+ }
234
+ this.unfilledSlotFirstSeen = undefined;
235
+ }
236
+
237
+ return;
238
+ }
239
+ }
240
+
241
+ // Fallback: warp when the dateProvider time has passed the next slot timestamp.
242
+ const currentTimestamp = this.dateProvider?.now() ?? Date.now();
243
+ if (currentTimestamp > nextSlotTimestamp * 1000) {
244
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
245
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
246
+ }
247
+ }
248
+ } catch {
249
+ this.logger.error('mineIfSlotFilled failed');
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
255
+ * happened, false when skipped or on error. Callers use the return value to gate success logs.
256
+ */
257
+ private async warpToTimestamp(timestamp: number): Promise<boolean> {
258
+ try {
259
+ // Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
260
+ // watcher loops can race and pick targets a fraction of a second apart; skip here rather than
261
+ // letting the second one error out noisily.
262
+ const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
263
+ if (timestamp <= lastTimestamp) {
264
+ return false;
265
+ }
266
+ await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
267
+ return true;
268
+ } catch (e) {
269
+ this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
270
+ return false;
271
+ }
272
+ }
273
+ }
@@ -0,0 +1,132 @@
1
+ import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import type { DateProvider } from '@aztec/foundation/timer';
5
+ import type { AutomineSequencer } from '@aztec/sequencer-client';
6
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
7
+
8
+ /**
9
+ * A class that provides utility functions for interacting with the chain.
10
+ * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
11
+ * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
12
+ * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
13
+ */
14
+ export class CheatCodes {
15
+ private logger = createLogger('aztecjs:cheat_codes');
16
+
17
+ constructor(
18
+ /** Cheat codes for L1.*/
19
+ public eth: EthCheatCodes,
20
+ /** Cheat codes for the Aztec Rollup contract on L1. */
21
+ public rollup: RollupCheatCodes,
22
+ /** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
23
+ private automine?: AutomineSequencer,
24
+ ) {}
25
+
26
+ static async create(
27
+ rpcUrls: string[],
28
+ node: AztecNode,
29
+ dateProvider: DateProvider,
30
+ automine?: AutomineSequencer,
31
+ ): Promise<CheatCodes> {
32
+ const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
33
+ const rollupCheatCodes = new RollupCheatCodes(
34
+ ethCheatCodes,
35
+ await node.getNodeInfo().then(n => n.l1ContractAddresses),
36
+ );
37
+ return new CheatCodes(ethCheatCodes, rollupCheatCodes, automine);
38
+ }
39
+
40
+ /**
41
+ * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
42
+ * the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
43
+ * the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
44
+ * @param node - The Aztec node used to force an empty block to be mined.
45
+ * @param targetTimestamp - The target timestamp to warp to (in seconds)
46
+ */
47
+ async warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number) {
48
+ const targetBigInt = BigInt(targetTimestamp);
49
+ const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
50
+
51
+ if (targetBigInt <= currentTimestamp) {
52
+ throw new Error(
53
+ `warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`,
54
+ );
55
+ }
56
+
57
+ // AutomineSequencer owns time control through its serial queue — delegate to keep warps atomic
58
+ // with respect to any in-flight build, and avoid the mineBlock-loop hack below.
59
+ // `warpTo` internally builds an empty L2 checkpoint, which auto-mines exactly one L1 block at
60
+ // the target slot boundary, so no separate `node.mineBlock()` is needed here.
61
+ if (this.automine) {
62
+ await this.automine.warpTo(Number(targetBigInt));
63
+ return;
64
+ }
65
+
66
+ const currentSlot = await this.rollup.getSlot();
67
+ const targetSlot = await this.rollup.getSlotAt(targetBigInt);
68
+
69
+ let effectiveTimestamp = targetBigInt;
70
+ let effectiveTargetSlot = targetSlot;
71
+
72
+ if (targetSlot <= currentSlot) {
73
+ // Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
74
+ const nextSlot = SlotNumber(currentSlot + 1);
75
+ const nextSlotTimestamp = await this.rollup.getTimestampForSlot(nextSlot);
76
+ this.logger.warn(
77
+ `warpL2TimeAtLeastTo: target timestamp ${targetBigInt} falls in current slot ${currentSlot}. ` +
78
+ `Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`,
79
+ );
80
+ effectiveTimestamp = nextSlotTimestamp;
81
+ effectiveTargetSlot = nextSlot;
82
+ }
83
+
84
+ await this.eth.warp(effectiveTimestamp, { resetBlockInterval: true });
85
+
86
+ // The sequencer's polling loop may have a `work()` cycle in flight that captured pre-warp slot/timestamp values
87
+ // just before our warp landed. That cycle would mine an L2 block at the stale slot — the L1 sync prunes such a
88
+ // block from the canonical chain, but it lingers in local world state and the PXE will use it as the anchor for
89
+ // subsequent txs, leading to `expiration_timestamp` values that are already in the past relative to L1. Mine
90
+ // until we observe an L2 block at (or past) the post-warp slot, ensuring the next tx anchors to a fresh block.
91
+ const maxAttempts = 5;
92
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
93
+ await node.mineBlock();
94
+ const blockData = await node.getBlockData('latest');
95
+ const blockSlot = blockData?.header.globalVariables.slotNumber;
96
+ if (blockSlot !== undefined && BigInt(blockSlot) >= BigInt(effectiveTargetSlot)) {
97
+ return;
98
+ }
99
+ this.logger.warn(
100
+ `warpL2TimeAtLeastTo: mined L2 block at slot ${blockSlot}, expected at least ${effectiveTargetSlot}. ` +
101
+ `Retrying mineBlock (attempt ${attempt}/${maxAttempts}).`,
102
+ );
103
+ }
104
+ throw new Error(
105
+ `warpL2TimeAtLeastTo: failed to mine an L2 block at or past slot ${effectiveTargetSlot} after ${maxAttempts} attempts.`,
106
+ );
107
+ }
108
+
109
+ /**
110
+ * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
111
+ * least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
112
+ * extended to the start of the next slot so that `mineBlock()` succeeds.
113
+ * @param node - The Aztec node used to force an empty block to be mined.
114
+ * @param duration - The duration to advance time by (in seconds)
115
+ */
116
+ async warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number) {
117
+ if (BigInt(duration) <= 0n) {
118
+ throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
119
+ }
120
+
121
+ // Advance relative to whichever clock leads. A live sequencer mines L2 blocks at slot boundaries that can run
122
+ // ahead of anvil's L1 timestamp, so basing the target on L1 alone would advance the L2 timestamp by less than
123
+ // `duration`. Anchoring to the latest L2 block timestamp when it leads guarantees the post-warp L2 block is at
124
+ // least `duration` ahead of the current one.
125
+ const currentL1Timestamp = BigInt(await this.eth.lastBlockTimestamp());
126
+ const latestBlockData = await node.getBlockData('latest');
127
+ const latestL2Timestamp = latestBlockData ? BigInt(latestBlockData.header.globalVariables.timestamp) : 0n;
128
+ const baseTimestamp = latestL2Timestamp > currentL1Timestamp ? latestL2Timestamp : currentL1Timestamp;
129
+ const targetTimestamp = baseTimestamp + BigInt(duration);
130
+ await this.warpL2TimeAtLeastTo(node, targetTimestamp);
131
+ }
132
+ }
@@ -0,0 +1,69 @@
1
+ import { Fr } from '@aztec/aztec.js/fields';
2
+ import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
+ import type { Logger } from '@aztec/foundation/log';
5
+ import { EpochMonitor } from '@aztec/prover-node';
6
+ import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
7
+ import { computeEpochOutHash } from '@aztec/stdlib/messaging';
8
+
9
+ export class EpochTestSettler {
10
+ private rollupCheatCodes: RollupCheatCodes;
11
+ private epochMonitor?: EpochMonitor;
12
+
13
+ constructor(
14
+ cheatcodes: EthCheatCodes,
15
+ rollupAddress: EthAddress,
16
+ private l2BlockSource: L2BlockSource,
17
+ private log: Logger,
18
+ private options: { pollingIntervalMs: number; provingDelayMs?: number },
19
+ ) {
20
+ this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
21
+ }
22
+
23
+ async start() {
24
+ const { epochDuration } = await this.rollupCheatCodes.getConfig();
25
+ this.epochMonitor = new EpochMonitor(this.l2BlockSource, { epochDuration: Number(epochDuration) }, this.options);
26
+ this.epochMonitor.start(this);
27
+ }
28
+
29
+ async stop() {
30
+ await this.epochMonitor?.stop();
31
+ }
32
+
33
+ async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
34
+ const blocks = await this.l2BlockSource.getBlocks({ epoch, onlyCheckpointed: true });
35
+ this.log.info(
36
+ `Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`,
37
+ { blocks: blocks.map(b => b.toBlockInfo()) },
38
+ );
39
+ const messagesInEpoch: Fr[][][][] = [];
40
+ let previousSlotNumber = SlotNumber.ZERO;
41
+ let checkpointIndex = -1;
42
+
43
+ for (const block of blocks) {
44
+ const slotNumber = block.header.globalVariables.slotNumber;
45
+ if (slotNumber !== previousSlotNumber) {
46
+ checkpointIndex++;
47
+ messagesInEpoch[checkpointIndex] = [];
48
+ previousSlotNumber = slotNumber;
49
+ }
50
+ messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
51
+ }
52
+
53
+ const outHash = computeEpochOutHash(messagesInEpoch);
54
+ if (!outHash.isZero()) {
55
+ await this.rollupCheatCodes.insertOutbox(epoch, messagesInEpoch.length, outHash.toBigInt());
56
+ } else {
57
+ this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
58
+ }
59
+
60
+ const lastCheckpoint = blocks.at(-1)?.checkpointNumber;
61
+ if (lastCheckpoint !== undefined) {
62
+ await this.rollupCheatCodes.markAsProven(lastCheckpoint);
63
+ } else {
64
+ this.log.warn(`No checkpoint found for epoch ${epoch}`);
65
+ }
66
+
67
+ return true;
68
+ }
69
+ }
@@ -0,0 +1,5 @@
1
+ export { AnvilTestWatcher, type AnvilTestWatcherOpts } 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,19 @@
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
+ import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
5
+
6
+ /**
7
+ * Returns Token-specific allowlist entries needed for FPC-based fee payments.
8
+ * These are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
9
+ */
10
+ export async function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]> {
11
+ const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
12
+ const target = { classId: tokenClassId };
13
+ return Promise.all([
14
+ // Token: needed for private transfers via FPC (transfer_to_public enqueues this)
15
+ buildAllowedElement(TokenContractArtifact, target, '_increase_public_balance', { onlySelf: true }),
16
+ // Token: needed for public transfers via FPC (fee_entrypoint_public enqueues this)
17
+ buildAllowedElement(TokenContractArtifact, target, 'transfer_in_public'),
18
+ ]);
19
+ }
@@ -1,19 +0,0 @@
1
- export type NetworkNames = 'testnet-ignition';
2
- export type L2ChainConfig = {
3
- l1ChainId: number;
4
- ethereumSlotDuration: number;
5
- aztecSlotDuration: number;
6
- aztecEpochDuration: number;
7
- aztecProofSubmissionWindow: number;
8
- testAccounts: boolean;
9
- p2pEnabled: boolean;
10
- p2pBootstrapNodes: string[];
11
- registryAddress: string;
12
- seqMinTxsPerBlock: number;
13
- seqMaxTxsPerBlock: number;
14
- };
15
- export declare const testnetIgnitionL2ChainConfig: L2ChainConfig;
16
- export declare function getBootnodes(networkName: NetworkNames): Promise<any>;
17
- export declare function getL2ChainConfig(networkName: NetworkNames): Promise<L2ChainConfig | undefined>;
18
- export declare function enrichEnvironmentWithChainConfig(networkName: NetworkNames): Promise<void>;
19
- //# sourceMappingURL=chain_l2_config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/cli/chain_l2_config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aAY1C,CAAC;AAEF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,gBAQ3D;AAED,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAOpG;AAUD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBAgB/E"}
@@ -1,56 +0,0 @@
1
- export const testnetIgnitionL2ChainConfig = {
2
- l1ChainId: 11155111,
3
- ethereumSlotDuration: 12,
4
- aztecSlotDuration: 36,
5
- aztecEpochDuration: 32,
6
- aztecProofSubmissionWindow: 64,
7
- testAccounts: true,
8
- p2pEnabled: true,
9
- p2pBootstrapNodes: [],
10
- registryAddress: '0x12b3ebc176a1646b911391eab3760764f2e05fe3',
11
- seqMinTxsPerBlock: 0,
12
- seqMaxTxsPerBlock: 0
13
- };
14
- export async function getBootnodes(networkName) {
15
- const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
16
- const response = await fetch(url);
17
- if (!response.ok) {
18
- throw new Error(`Failed to fetch basic contract addresses from ${url}`);
19
- }
20
- const json = await response.json();
21
- return json['bootnodes'];
22
- }
23
- export async function getL2ChainConfig(networkName) {
24
- if (networkName === 'testnet-ignition') {
25
- const config = {
26
- ...testnetIgnitionL2ChainConfig
27
- };
28
- config.p2pBootstrapNodes = await getBootnodes(networkName);
29
- return config;
30
- }
31
- return undefined;
32
- }
33
- function enrichVar(envVar, value) {
34
- // Don't override
35
- if (process.env[envVar]) {
36
- return;
37
- }
38
- process.env[envVar] = value;
39
- }
40
- export async function enrichEnvironmentWithChainConfig(networkName) {
41
- const config = await getL2ChainConfig(networkName);
42
- if (!config) {
43
- throw new Error(`Unknown network name: ${networkName}`);
44
- }
45
- enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
46
- enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
47
- enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
48
- enrichVar('AZTEC_PROOF_SUBMISSION_WINDOW', config.aztecProofSubmissionWindow.toString());
49
- enrichVar('P2P_BOOTSTRAP_NODES', config.p2pBootstrapNodes.join(','));
50
- enrichVar('TEST_ACCOUNTS', config.testAccounts.toString());
51
- enrichVar('P2P_ENABLED', config.p2pEnabled.toString());
52
- enrichVar('L1_CHAIN_ID', config.l1ChainId.toString());
53
- enrichVar('REGISTRY_CONTRACT_ADDRESS', config.registryAddress);
54
- enrichVar('SEQ_MIN_TX_PER_BLOCK', config.seqMinTxsPerBlock.toString());
55
- enrichVar('SEQ_MAX_TX_PER_BLOCK', config.seqMaxTxsPerBlock.toString());
56
- }
@@ -1,9 +0,0 @@
1
- import { type ArchiverConfig } from '@aztec/archiver';
2
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
3
- import { type DataStoreConfig } from '@aztec/kv-store/config';
4
- export type { ArchiverConfig, DataStoreConfig };
5
- /** Starts a standalone archiver. */
6
- export declare function startArchiver(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers): Promise<{
7
- config: ArchiverConfig & DataStoreConfig;
8
- }>;
9
- //# sourceMappingURL=start_archiver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAA+C,MAAM,iBAAiB,CAAC;AAG7G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAQlF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAEhD,oCAAoC;AACpC,wBAAsB,aAAa,CACjC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,GAAG,eAAe,CAAA;CAAE,CAAC,CAmCvD"}
@@ -1,42 +0,0 @@
1
- import { Archiver, KVArchiverDataStore, archiverConfigMappings } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js';
3
- import { createBlobSinkClient } from '@aztec/blob-sink/client';
4
- import { dataConfigMappings } from '@aztec/kv-store/config';
5
- import { createStore } from '@aztec/kv-store/lmdb-v2';
6
- import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
7
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
8
- import { getL1Config } from '../get_l1_config.js';
9
- import { extractRelevantOptions } from '../util.js';
10
- /** Starts a standalone archiver. */ export async function startArchiver(options, signalHandlers, services) {
11
- let archiverConfig = extractRelevantOptions(options, {
12
- ...archiverConfigMappings,
13
- ...dataConfigMappings
14
- }, 'archiver');
15
- if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
16
- throw new Error('L1 registry address is required to start an Archiver');
17
- }
18
- const { addresses, config } = await getL1Config(archiverConfig.l1Contracts.registryAddress, archiverConfig.l1RpcUrls, archiverConfig.l1ChainId);
19
- archiverConfig.l1Contracts = addresses;
20
- archiverConfig = {
21
- ...archiverConfig,
22
- ...config
23
- };
24
- const storeLog = createLogger('archiver:lmdb');
25
- const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
26
- const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
27
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
28
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/10056): place CL url in config here
29
- const blobSinkClient = createBlobSinkClient();
30
- const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, {
31
- telemetry,
32
- blobSinkClient
33
- }, true);
34
- services.archiver = [
35
- archiver,
36
- ArchiverApiSchema
37
- ];
38
- signalHandlers.push(archiver.stop);
39
- return {
40
- config: archiverConfig
41
- };
42
- }
@@ -1,3 +0,0 @@
1
- import type { LogFn } from '@aztec/foundation/log';
2
- export declare function startBlobSink(options: any, signalHandlers: (() => Promise<void>)[], userLog: LogFn): Promise<void>;
3
- //# sourceMappingURL=start_blob_sink.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_blob_sink.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_blob_sink.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,wBAAsB,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,iBAmBxG"}
@@ -1,17 +0,0 @@
1
- import { blobSinkConfigMappings, createBlobSinkServer, getBlobSinkConfigFromEnv } from '@aztec/blob-sink/server';
2
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
3
- import { extractRelevantOptions } from '../util.js';
4
- export async function startBlobSink(options, signalHandlers, userLog) {
5
- if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
6
- userLog(`Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`);
7
- process.exit(1);
8
- }
9
- const blobSinkConfig = {
10
- ...getBlobSinkConfigFromEnv(),
11
- ...extractRelevantOptions(options, blobSinkConfigMappings, 'blobSink')
12
- };
13
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
14
- const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
15
- signalHandlers.push(blobSink.stop.bind(blobSink));
16
- await blobSink.start();
17
- }