@aztec/aztec 0.0.1-commit.3fd054f6 → 0.0.1-commit.431c48d

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 (157) hide show
  1. package/dest/bin/index.js +3 -1
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +33 -33
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +21 -16
  8. package/dest/cli/cmds/compile.d.ts +1 -1
  9. package/dest/cli/cmds/compile.d.ts.map +1 -1
  10. package/dest/cli/cmds/compile.js +32 -24
  11. package/dest/cli/cmds/profile.d.ts +1 -1
  12. package/dest/cli/cmds/profile.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile.js +1 -1
  14. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  15. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_gates.js +21 -3
  17. package/dest/cli/cmds/prover.d.ts +4 -0
  18. package/dest/cli/cmds/prover.d.ts.map +1 -0
  19. package/dest/cli/cmds/prover.js +24 -0
  20. package/dest/cli/cmds/standby.d.ts +30 -6
  21. package/dest/cli/cmds/standby.d.ts.map +1 -1
  22. package/dest/cli/cmds/standby.js +48 -5
  23. package/dest/cli/cmds/start_bot.d.ts +1 -1
  24. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_bot.js +8 -4
  26. package/dest/cli/cmds/start_node.d.ts +1 -1
  27. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  28. package/dest/cli/cmds/start_node.js +23 -47
  29. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  30. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  31. package/dest/cli/cmds/start_prover_agent.js +5 -17
  32. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  33. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  34. package/dest/cli/cmds/start_prover_broker.js +11 -8
  35. package/dest/cli/cmds/start_txe.d.ts +2 -2
  36. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_txe.js +6 -5
  38. package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
  39. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
  40. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  41. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  42. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  43. package/dest/cli/cmds/utils/needs_recompile.d.ts +1 -1
  44. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -1
  45. package/dest/cli/cmds/utils/needs_recompile.js +9 -53
  46. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  47. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  48. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  49. package/dest/cli/util.d.ts +10 -5
  50. package/dest/cli/util.d.ts.map +1 -1
  51. package/dest/cli/util.js +26 -53
  52. package/dest/deploy/bridging.d.ts +84 -0
  53. package/dest/deploy/bridging.d.ts.map +1 -0
  54. package/dest/deploy/bridging.js +121 -0
  55. package/dest/deploy/fees.d.ts +120 -0
  56. package/dest/deploy/fees.d.ts.map +1 -0
  57. package/dest/deploy/fees.js +278 -0
  58. package/dest/deploy/graph.d.ts +40 -0
  59. package/dest/deploy/graph.d.ts.map +1 -0
  60. package/dest/deploy/graph.js +120 -0
  61. package/dest/deploy/index.d.ts +19 -0
  62. package/dest/deploy/index.d.ts.map +1 -0
  63. package/dest/deploy/index.js +15 -0
  64. package/dest/deploy/reporter.d.ts +106 -0
  65. package/dest/deploy/reporter.d.ts.map +1 -0
  66. package/dest/deploy/reporter.js +76 -0
  67. package/dest/deploy/runner.d.ts +8 -0
  68. package/dest/deploy/runner.d.ts.map +1 -0
  69. package/dest/deploy/runner.js +886 -0
  70. package/dest/deploy/state.d.ts +19 -0
  71. package/dest/deploy/state.d.ts.map +1 -0
  72. package/dest/deploy/state.js +59 -0
  73. package/dest/deploy/types.d.ts +233 -0
  74. package/dest/deploy/types.d.ts.map +1 -0
  75. package/dest/deploy/types.js +9 -0
  76. package/dest/examples/token.js +3 -3
  77. package/dest/local-network/auth_registry.d.ts +5 -0
  78. package/dest/local-network/auth_registry.d.ts.map +1 -0
  79. package/dest/local-network/auth_registry.js +17 -0
  80. package/dest/local-network/banana_fpc.d.ts +3 -2
  81. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  82. package/dest/local-network/banana_fpc.js +11 -7
  83. package/dest/local-network/local-network.d.ts +10 -32
  84. package/dest/local-network/local-network.d.ts.map +1 -1
  85. package/dest/local-network/local-network.js +52 -73
  86. package/dest/testing/cheat_codes.d.ts +17 -23
  87. package/dest/testing/cheat_codes.d.ts.map +1 -1
  88. package/dest/testing/cheat_codes.js +17 -43
  89. package/dest/testing/epoch_test_settler.d.ts +2 -2
  90. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  91. package/dest/testing/epoch_test_settler.js +6 -25
  92. package/dest/testing/index.d.ts +2 -2
  93. package/dest/testing/index.d.ts.map +1 -1
  94. package/dest/testing/index.js +1 -1
  95. package/dest/testing/local-network.d.ts +51 -0
  96. package/dest/testing/local-network.d.ts.map +1 -0
  97. package/dest/testing/local-network.js +60 -0
  98. package/dest/testing/token_allowed_setup.d.ts +9 -4
  99. package/dest/testing/token_allowed_setup.d.ts.map +1 -1
  100. package/dest/testing/token_allowed_setup.js +12 -8
  101. package/package.json +37 -34
  102. package/scripts/add_crate.sh +11 -60
  103. package/scripts/aztec.sh +6 -2
  104. package/scripts/init.sh +5 -5
  105. package/scripts/new.sh +2 -2
  106. package/scripts/setup_workspace.sh +3 -2
  107. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  108. package/scripts/templates/blank/contract/src/main.nr +10 -0
  109. package/scripts/templates/blank/test/Nargo.toml +7 -0
  110. package/scripts/templates/blank/test/src/lib.nr +11 -0
  111. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  112. package/scripts/templates/counter/contract/src/main.nr +48 -0
  113. package/scripts/templates/counter/test/Nargo.toml +7 -0
  114. package/scripts/templates/counter/test/src/lib.nr +32 -0
  115. package/src/bin/index.ts +3 -1
  116. package/src/cli/aztec_start_action.ts +38 -25
  117. package/src/cli/aztec_start_options.ts +27 -23
  118. package/src/cli/cmds/compile.ts +37 -23
  119. package/src/cli/cmds/profile.ts +2 -1
  120. package/src/cli/cmds/profile_gates.ts +20 -4
  121. package/src/cli/cmds/prover.ts +42 -0
  122. package/src/cli/cmds/standby.ts +59 -7
  123. package/src/cli/cmds/start_bot.ts +9 -6
  124. package/src/cli/cmds/start_node.ts +32 -39
  125. package/src/cli/cmds/start_prover_agent.ts +5 -8
  126. package/src/cli/cmds/start_prover_broker.ts +10 -11
  127. package/src/cli/cmds/start_txe.ts +7 -5
  128. package/src/cli/cmds/utils/artifacts.ts +5 -0
  129. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  130. package/src/cli/cmds/utils/needs_recompile.ts +8 -61
  131. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  132. package/src/cli/util.ts +27 -68
  133. package/src/deploy/bridging.ts +191 -0
  134. package/src/deploy/fees.ts +322 -0
  135. package/src/deploy/graph.ts +137 -0
  136. package/src/deploy/index.ts +41 -0
  137. package/src/deploy/reporter.ts +184 -0
  138. package/src/deploy/runner.ts +936 -0
  139. package/src/deploy/state.ts +66 -0
  140. package/src/deploy/types.ts +244 -0
  141. package/src/examples/token.ts +11 -3
  142. package/src/local-network/auth_registry.ts +19 -0
  143. package/src/local-network/banana_fpc.ts +12 -8
  144. package/src/local-network/local-network.ts +61 -83
  145. package/src/testing/cheat_codes.ts +18 -49
  146. package/src/testing/epoch_test_settler.ts +8 -31
  147. package/src/testing/index.ts +1 -1
  148. package/src/testing/local-network.ts +97 -0
  149. package/src/testing/token_allowed_setup.ts +15 -8
  150. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  151. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  152. package/dest/cli/cmds/start_archiver.js +0 -48
  153. package/dest/testing/anvil_test_watcher.d.ts +0 -42
  154. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  155. package/dest/testing/anvil_test_watcher.js +0 -181
  156. package/src/cli/cmds/start_archiver.ts +0 -50
  157. package/src/testing/anvil_test_watcher.ts +0 -210
@@ -1,15 +1,10 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
- import { BlockNumber } from '@aztec/foundation/branded-types';
3
- import { retryUntil } from '@aztec/foundation/retry';
4
2
  import type { DateProvider } from '@aztec/foundation/timer';
5
- import type { SequencerClient } from '@aztec/sequencer-client';
6
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
7
4
 
8
5
  /**
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.
6
+ * Wrapper for Aztec Debug API.
7
+ * @deprecated use the AztecNode debug API directly.
13
8
  */
14
9
  export class CheatCodes {
15
10
  constructor(
@@ -29,51 +24,25 @@ export class CheatCodes {
29
24
  }
30
25
 
31
26
  /**
32
- * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
33
- * the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
34
- * by the slot number, which advances in fixed intervals.
35
- * This is useful for testing time-dependent contract behavior.
36
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
37
- * @param node - The Aztec node used to query if a new block has been mined.
38
- * @param targetTimestamp - The target timestamp to warp to (in seconds)
27
+ * Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
28
+ * the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
29
+ * @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
30
+ * @param targetTimestamp - The target timestamp to warp to (in seconds).
31
+ * @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
39
32
  */
40
- async warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number) {
41
- const currentL2BlockNumber: BlockNumber = await node.getBlockNumber();
42
-
43
- // We warp the L1 timestamp
44
- await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
45
-
46
- // Wait until an L2 block is mined
47
- const sequencer = sequencerClient.getSequencer();
48
- const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
49
- sequencer.updateConfig({ minTxsPerBlock: 0 });
50
-
51
- await retryUntil(
52
- async () => {
53
- const newL2BlockNumber: BlockNumber = await node.getBlockNumber();
54
- return newL2BlockNumber > currentL2BlockNumber;
55
- },
56
- 'new block after warping L2 time',
57
- 36,
58
- 1,
59
- );
60
-
61
- // Restore original minTxsPerBlock
62
- sequencer.updateConfig({ minTxsPerBlock });
33
+ warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void> {
34
+ return node.warpL2TimeAtLeastTo(Number(targetTimestamp));
63
35
  }
64
36
 
65
37
  /**
66
- * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
67
- * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
68
- * number, which advances in fixed intervals.
69
- * This is useful for testing time-dependent contract behavior.
70
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
71
- * @param node - The Aztec node used to query if a new block has been mined.
72
- * @param duration - The duration to advance time by (in seconds)
38
+ * Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
39
+ * least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
40
+ * queue.
41
+ * @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
42
+ * @param duration - The duration to advance time by (in seconds).
43
+ * @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
73
44
  */
74
- async warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number) {
75
- const currentTimestamp = await this.eth.lastBlockTimestamp();
76
- const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
77
- await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
45
+ warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void> {
46
+ return node.warpL2TimeAtLeastBy(Number(duration));
78
47
  }
79
48
  }
@@ -1,10 +1,9 @@
1
- import { Fr } from '@aztec/aztec.js/fields';
2
1
  import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
- import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
4
3
  import type { Logger } from '@aztec/foundation/log';
4
+ import { settleEpochOutbox } from '@aztec/prover-client/test';
5
5
  import { EpochMonitor } from '@aztec/prover-node';
6
6
  import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
7
- import { computeEpochOutHash } from '@aztec/stdlib/messaging';
8
7
 
9
8
  export class EpochTestSettler {
10
9
  private rollupCheatCodes: RollupCheatCodes;
@@ -31,34 +30,12 @@ export class EpochTestSettler {
31
30
  }
32
31
 
33
32
  async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
34
- const checkpointedBlocks = await this.l2BlockSource.getCheckpointedBlocksForEpoch(epoch);
35
- const blocks = checkpointedBlocks.map(b => b.block);
36
- this.log.info(
37
- `Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`,
38
- { blocks: blocks.map(b => b.toBlockInfo()) },
39
- );
40
- const messagesInEpoch: Fr[][][][] = [];
41
- let previousSlotNumber = SlotNumber.ZERO;
42
- let checkpointIndex = -1;
43
-
44
- for (const block of blocks) {
45
- const slotNumber = block.header.globalVariables.slotNumber;
46
- if (slotNumber !== previousSlotNumber) {
47
- checkpointIndex++;
48
- messagesInEpoch[checkpointIndex] = [];
49
- previousSlotNumber = slotNumber;
50
- }
51
- messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
52
- }
53
-
54
- const outHash = computeEpochOutHash(messagesInEpoch);
55
- if (!outHash.isZero()) {
56
- await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
57
- } else {
58
- this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
59
- }
60
-
61
- const lastCheckpoint = checkpointedBlocks.at(-1)?.checkpointNumber;
33
+ const lastCheckpoint = await settleEpochOutbox({
34
+ rollupCheatCodes: this.rollupCheatCodes,
35
+ l2BlockSource: this.l2BlockSource,
36
+ epoch,
37
+ log: this.log,
38
+ });
62
39
  if (lastCheckpoint !== undefined) {
63
40
  await this.rollupCheatCodes.markAsProven(lastCheckpoint);
64
41
  } else {
@@ -1,5 +1,5 @@
1
- export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
1
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
2
  export { CheatCodes } from './cheat_codes.js';
4
3
  export { EpochTestSettler } from './epoch_test_settler.js';
4
+ export { setupLocalNetwork, TEST_FEE_PADDING, type LocalNetwork, type LocalNetworkOptions } from './local-network.js';
5
5
  export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
@@ -0,0 +1,97 @@
1
+ import type { AztecNodeService } from '@aztec/aztec-node';
2
+ import type { AztecNodeConfig } from '@aztec/aztec-node/config';
3
+ import type { Fr } from '@aztec/aztec.js/fields';
4
+ import { startAnvil } from '@aztec/ethereum/test';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ import { foundry } from 'viem/chains';
8
+
9
+ import { createLocalNetwork } from '../local-network/local-network.js';
10
+
11
+ /** A running in-process local network: an inline Aztec node backed by its own anvil L1. */
12
+ export interface LocalNetwork extends AsyncDisposable {
13
+ /** Fully-synced Aztec node, ready to serve client requests. */
14
+ node: AztecNodeService;
15
+ /** RPC URL of the spawned anvil instance. */
16
+ l1RpcUrl: string;
17
+ /** Chain id used on L1 (foundry's default 31337). */
18
+ l1ChainId: number;
19
+ /** Stops every process started by the fixture: node and anvil. Also invoked by `await using`. */
20
+ stop: () => Promise<void>;
21
+ }
22
+
23
+ /** Options for {@link setupLocalNetwork}. */
24
+ export interface LocalNetworkOptions {
25
+ /**
26
+ * Addresses that should hold fee juice at genesis. Saves each of these the round-trip of bridging
27
+ * + claiming fee juice before they can pay for gas.
28
+ */
29
+ fundedAddresses?: AztecAddress[];
30
+ /** Override the default per-address genesis fee juice granted to {@link fundedAddresses}. */
31
+ initialAccountFeeJuice?: Fr;
32
+ /** Node config overrides, e.g. `realProofs`, `aztecEpochDuration`, `p2pEnabled`. */
33
+ config?: Partial<AztecNodeConfig>;
34
+ }
35
+
36
+ /**
37
+ * Spin up an in-process local network with the given addresses pre-funded.
38
+ *
39
+ * Each call spawns its own anvil on an OS-assigned random port and runs the Aztec node inline via
40
+ * the same {@link createLocalNetwork} codepath that backs `aztec start --local-network` (with the
41
+ * sandbox account/FPC/token setup skipped). Distinct ports let independent suites run in parallel.
42
+ * The caller must `await result.stop()` in its teardown (or hold the result with `await using`).
43
+ *
44
+ * Requires a Foundry toolchain (`anvil`/`forge`), installed via `aztec-up` or `foundryup`. Binaries
45
+ * are located in the standard install directories or on `PATH`; set `$ANVIL_BIN` / `$FORGE_BIN` to
46
+ * pin specific ones.
47
+ */
48
+ export async function setupLocalNetwork(opts: LocalNetworkOptions = {}): Promise<LocalNetwork> {
49
+ // `--port 0` → anvil binds an ephemeral port that `startAnvil` reads back, so parallel suites
50
+ // never collide on a fixed port.
51
+ const { rpcUrl, stop: stopAnvil } = await startAnvil({ port: 0 });
52
+
53
+ try {
54
+ const { node, stop: stopNode } = await createLocalNetwork(
55
+ {
56
+ ...opts.config,
57
+ l1RpcUrls: [rpcUrl],
58
+ testAccounts: false,
59
+ prefundAddresses: (opts.fundedAddresses ?? []).map(a => a.toString()),
60
+ initialAccountFeeJuice: opts.initialAccountFeeJuice,
61
+ },
62
+ () => {},
63
+ );
64
+
65
+ // Stop the node before anvil (its teardown still talks to L1); the finally guarantees anvil is
66
+ // reaped even if node shutdown throws.
67
+ const stop = async () => {
68
+ try {
69
+ await stopNode();
70
+ } finally {
71
+ await stopAnvil();
72
+ }
73
+ };
74
+
75
+ return {
76
+ node,
77
+ l1RpcUrl: rpcUrl,
78
+ l1ChainId: foundry.id,
79
+ stop,
80
+ [Symbol.asyncDispose]: stop,
81
+ };
82
+ } catch (err) {
83
+ await stopAnvil();
84
+ throw err;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Min-fee padding multiplier for test wallets whose txs may mine well after their fee estimate.
90
+ * The automine sequencer builds one block per tx and advances L1 time in big jumps, and proposer
91
+ * pipelining evolves the fee-asset price across the build/publish gap (~20x observed in CI), so the
92
+ * network's congestion base fee can swing sharply between the wallet's fee estimate and the block
93
+ * the tx actually lands in. The default wallet padding isn't enough and trips
94
+ * `maxFeesPerGas.feePerL2Gas must be >= gasFees.feePerL2Gas`. Apply via
95
+ * `wallet.setMinFeePadding(TEST_FEE_PADDING)` on every test wallet that sends txs.
96
+ */
97
+ export const TEST_FEE_PADDING = 30;
@@ -1,19 +1,26 @@
1
1
  import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
2
2
  import { buildAllowedElement } from '@aztec/p2p/msg_validators';
3
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
3
4
  import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
4
5
  import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
5
6
 
6
7
  /**
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.
8
+ * Returns the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
9
+ * the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
10
+ * validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
11
+ * fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
12
+ * against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
13
+ * mainnet alpha.
9
14
  */
10
- export async function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]> {
11
- const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
15
+ export async function getTokenAllowedSetupFunctions(
16
+ artifact: ContractArtifact = TokenContractArtifact,
17
+ ): Promise<AllowedElement[]> {
18
+ const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
12
19
  const target = { classId: tokenClassId };
13
20
  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'),
21
+ // needed for private transfers via FPC (transfer_to_public enqueues this)
22
+ buildAllowedElement(artifact, target, '_increase_public_balance', { onlySelf: true }),
23
+ // needed for public transfers via FPC (fee_entrypoint_public enqueues this)
24
+ buildAllowedElement(artifact, target, 'transfer_in_public'),
18
25
  ]);
19
26
  }
@@ -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/stdlib/kv-store';
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=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYXJjaGl2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbGkvY21kcy9zdGFydF9hcmNoaXZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxjQUFjLEVBQW9FLE1BQU0saUJBQWlCLENBQUM7QUFJeEgsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUUvRSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQXNCLE1BQU0sd0JBQXdCLENBQUM7QUFLbEYsWUFBWSxFQUFFLGNBQWMsRUFBRSxlQUFlLEVBQUUsQ0FBQztBQUVoRCxvQ0FBb0M7QUFDcEMsd0JBQXNCLGFBQWEsQ0FDakMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsR0FDOUIsT0FBTyxDQUFDO0lBQUUsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLENBQUE7Q0FBRSxDQUFDLENBK0J2RCJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAoE,MAAM,iBAAiB,CAAC;AAIxH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAKlF,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,CA+BvD"}
@@ -1,48 +0,0 @@
1
- import { archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js/log';
3
- import { blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
- import { getL1Config } from '@aztec/cli/config';
5
- import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
6
- import { dataConfigMappings } from '@aztec/stdlib/kv-store';
7
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
8
- import { extractRelevantOptions } from '../util.js';
9
- /** Starts a standalone archiver. */ export async function startArchiver(options, signalHandlers, services) {
10
- const envConfig = getArchiverConfigFromEnv();
11
- const cliOptions = extractRelevantOptions(options, {
12
- ...archiverConfigMappings,
13
- ...dataConfigMappings,
14
- ...blobClientConfigMapping
15
- }, 'archiver');
16
- let archiverConfig = {
17
- ...envConfig,
18
- ...cliOptions
19
- };
20
- archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
21
- if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
22
- throw new Error('L1 registry address is required to start an Archiver');
23
- }
24
- const { addresses, config: l1Config } = await getL1Config(archiverConfig.l1Contracts.registryAddress, archiverConfig.l1RpcUrls, archiverConfig.l1ChainId);
25
- archiverConfig.l1Contracts = addresses;
26
- archiverConfig = {
27
- ...archiverConfig,
28
- ...l1Config
29
- };
30
- const telemetry = await initTelemetryClient(getTelemetryClientConfig());
31
- const blobClient = createBlobClient(archiverConfig, {
32
- logger: createLogger('archiver:blob-client:client')
33
- });
34
- const archiver = await createArchiver(archiverConfig, {
35
- telemetry,
36
- blobClient
37
- }, {
38
- blockUntilSync: true
39
- });
40
- services.archiver = [
41
- archiver,
42
- ArchiverApiSchema
43
- ];
44
- signalHandlers.push(archiver.stop);
45
- return {
46
- config: archiverConfig
47
- };
48
- }
@@ -1,42 +0,0 @@
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW52aWxfdGVzdF93YXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9hbnZpbF90ZXN0X3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBb0IsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUV4RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBS2hFOzs7Ozs7R0FNRztBQUNILHFCQUFhLGdCQUFnQjtJQXlCekIsT0FBTyxDQUFDLFVBQVU7SUFHbEIsT0FBTyxDQUFDLFlBQVksQ0FBQztJQTNCdkIsT0FBTyxDQUFDLGNBQWMsQ0FBa0I7SUFFeEMsT0FBTyxDQUFDLE1BQU0sQ0FBc0Q7SUFDcEUsT0FBTyxDQUFDLGdCQUFnQixDQUFtQjtJQUMzQyxPQUFPLENBQUMsY0FBYyxDQUFVO0lBRWhDLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFpQjtJQUM5QyxPQUFPLENBQUMsdUJBQXVCLENBQUMsQ0FBaUI7SUFDakQsT0FBTyxDQUFDLDZCQUE2QixDQUFDLENBQWlCO0lBRXZELE9BQU8sQ0FBQyxNQUFNLENBQWlEO0lBRS9ELE9BQU8sQ0FBQyxpQkFBaUIsQ0FBUTtJQUdqQyxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBd0I7SUFHbEQsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBQWdCO0lBRzVDLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBQyxDQUFxQztJQUVuRSxZQUNVLFVBQVUsRUFBRSxhQUFhLEVBQ2pDLGFBQWEsRUFBRSxVQUFVLEVBQ3pCLFFBQVEsRUFBRSxVQUFVLEVBQ1osWUFBWSxDQUFDLDhCQUFrQixFQWF4QztJQUVELG9CQUFvQixDQUFDLGlCQUFpQixFQUFFLE9BQU8sUUFHOUM7SUFFRCxpQkFBaUIsQ0FBQyxjQUFjLEVBQUUsT0FBTyxRQUV4QztJQUVELHlHQUF5RztJQUN6RyxvQkFBb0IsQ0FBQyxFQUFFLEVBQUUsTUFBTSxPQUFPLENBQUMsTUFBTSxDQUFDLFFBRTdDO0lBRUQsdUdBQXVHO0lBQ3ZHLHNCQUFzQixDQUFDLEVBQUUsRUFBRSxNQUFNLE9BQU8sUUFFdkM7SUFFSyxLQUFLLGtCQXlCVjtJQUVLLElBQUksa0JBSVQ7SUFFSyxPQUFPLGtCQUlaO0lBRUssWUFBWSxrQkFLakI7SUFFSyw0QkFBNEIsa0JBZWpDO0lBRUssZ0JBQWdCLGtCQXlEckI7WUFFYSxlQUFlO0NBTzlCIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/testing/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAyBzB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,YAAY,CAAC;IA3BvB,OAAO,CAAC,cAAc,CAAkB;IAExC,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAU;IAEhC,OAAO,CAAC,oBAAoB,CAAC,CAAiB;IAC9C,OAAO,CAAC,uBAAuB,CAAC,CAAiB;IACjD,OAAO,CAAC,6BAA6B,CAAC,CAAiB;IAEvD,OAAO,CAAC,MAAM,CAAiD;IAE/D,OAAO,CAAC,iBAAiB,CAAQ;IAGjC,OAAO,CAAC,iBAAiB,CAAC,CAAwB;IAGlD,OAAO,CAAC,mBAAmB,CAAC,CAAgB;IAG5C,OAAO,CAAC,qBAAqB,CAAC,CAAqC;IAEnE,YACU,UAAU,EAAE,aAAa,EACjC,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,UAAU,EACZ,YAAY,CAAC,8BAAkB,EAaxC;IAED,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,QAG9C;IAED,iBAAiB,CAAC,cAAc,EAAE,OAAO,QAExC;IAED,yGAAyG;IACzG,oBAAoB,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAE7C;IAED,uGAAuG;IACvG,sBAAsB,CAAC,EAAE,EAAE,MAAM,OAAO,QAEvC;IAEK,KAAK,kBAyBV;IAEK,IAAI,kBAIT;IAEK,OAAO,kBAIZ;IAEK,YAAY,kBAKjB;IAEK,4BAA4B,kBAejC;IAEK,gBAAgB,kBAyDrB;YAEa,eAAe;CAO9B"}
@@ -1,181 +0,0 @@
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
- // 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.lastBlockTimestamp() * 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
- }
@@ -1,50 +0,0 @@
1
- import { type ArchiverConfig, archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js/log';
3
- import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
- import { getL1Config } from '@aztec/cli/config';
5
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
6
- import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
7
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
8
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
9
-
10
- import { extractRelevantOptions } from '../util.js';
11
-
12
- export type { ArchiverConfig, DataStoreConfig };
13
-
14
- /** Starts a standalone archiver. */
15
- export async function startArchiver(
16
- options: any,
17
- signalHandlers: (() => Promise<void>)[],
18
- services: NamespacedApiHandlers,
19
- ): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
20
- const envConfig = getArchiverConfigFromEnv();
21
- const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
22
- options,
23
- { ...archiverConfigMappings, ...dataConfigMappings, ...blobClientConfigMapping },
24
- 'archiver',
25
- );
26
-
27
- let archiverConfig = { ...envConfig, ...cliOptions };
28
- archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
29
-
30
- if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
31
- throw new Error('L1 registry address is required to start an Archiver');
32
- }
33
-
34
- const { addresses, config: l1Config } = await getL1Config(
35
- archiverConfig.l1Contracts.registryAddress,
36
- archiverConfig.l1RpcUrls,
37
- archiverConfig.l1ChainId,
38
- );
39
-
40
- archiverConfig.l1Contracts = addresses;
41
- archiverConfig = { ...archiverConfig, ...l1Config };
42
-
43
- const telemetry = await initTelemetryClient(getTelemetryClientConfig());
44
- const blobClient = createBlobClient(archiverConfig, { logger: createLogger('archiver:blob-client:client') });
45
- const archiver = await createArchiver(archiverConfig, { telemetry, blobClient }, { blockUntilSync: true });
46
- services.archiver = [archiver, ArchiverApiSchema];
47
- signalHandlers.push(archiver.stop);
48
-
49
- return { config: archiverConfig };
50
- }