@aztec/end-to-end 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.db765a8

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 (160) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +11 -10
  4. package/dest/bench/utils.d.ts +1 -1
  5. package/dest/bench/utils.d.ts.map +1 -1
  6. package/dest/bench/utils.js +6 -3
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +22 -12
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
  11. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  12. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
  13. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  14. package/dest/e2e_epochs/epochs_test.d.ts +9 -7
  15. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  16. package/dest/e2e_epochs/epochs_test.js +53 -34
  17. package/dest/e2e_fees/fees_test.d.ts +2 -2
  18. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  19. package/dest/e2e_fees/fees_test.js +10 -10
  20. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  21. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  22. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  23. package/dest/e2e_p2p/p2p_network.d.ts +4 -3
  24. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  25. package/dest/e2e_p2p/p2p_network.js +23 -6
  26. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  27. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  28. package/dest/e2e_p2p/reqresp/utils.js +32 -8
  29. package/dest/e2e_p2p/shared.d.ts +16 -2
  30. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  31. package/dest/e2e_p2p/shared.js +27 -3
  32. package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
  33. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  34. package/dest/e2e_token_contract/token_contract_test.js +19 -9
  35. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  36. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  37. package/dest/fixtures/authwit_proxy.js +30 -0
  38. package/dest/fixtures/e2e_prover_test.d.ts +4 -4
  39. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  40. package/dest/fixtures/e2e_prover_test.js +33 -40
  41. package/dest/fixtures/elu_monitor.d.ts +21 -0
  42. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  43. package/dest/fixtures/elu_monitor.js +102 -0
  44. package/dest/fixtures/fixtures.d.ts +5 -1
  45. package/dest/fixtures/fixtures.d.ts.map +1 -1
  46. package/dest/fixtures/fixtures.js +6 -0
  47. package/dest/fixtures/ha_setup.d.ts +1 -1
  48. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  49. package/dest/fixtures/ha_setup.js +3 -1
  50. package/dest/fixtures/setup.d.ts +27 -11
  51. package/dest/fixtures/setup.d.ts.map +1 -1
  52. package/dest/fixtures/setup.js +59 -84
  53. package/dest/fixtures/setup_p2p_test.d.ts +6 -3
  54. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  55. package/dest/fixtures/setup_p2p_test.js +12 -9
  56. package/dest/fixtures/token_utils.d.ts +2 -2
  57. package/dest/fixtures/token_utils.d.ts.map +1 -1
  58. package/dest/fixtures/token_utils.js +5 -4
  59. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  60. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  61. package/dest/shared/cross_chain_test_harness.js +13 -13
  62. package/dest/shared/gas_portal_test_harness.js +2 -2
  63. package/dest/shared/index.d.ts +2 -1
  64. package/dest/shared/index.d.ts.map +1 -1
  65. package/dest/shared/index.js +1 -0
  66. package/dest/shared/jest_setup.js +41 -1
  67. package/dest/shared/mock_state_view.d.ts +86 -0
  68. package/dest/shared/mock_state_view.d.ts.map +1 -0
  69. package/dest/shared/mock_state_view.js +186 -0
  70. package/dest/shared/submit-transactions.d.ts +2 -2
  71. package/dest/shared/submit-transactions.d.ts.map +1 -1
  72. package/dest/shared/submit-transactions.js +1 -1
  73. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  74. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  75. package/dest/shared/uniswap_l1_l2.js +5 -5
  76. package/dest/simulators/lending_simulator.d.ts +1 -1
  77. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  78. package/dest/simulators/lending_simulator.js +2 -2
  79. package/dest/simulators/token_simulator.d.ts +1 -1
  80. package/dest/simulators/token_simulator.d.ts.map +1 -1
  81. package/dest/simulators/token_simulator.js +3 -24
  82. package/dest/spartan/setup_test_wallets.d.ts +9 -2
  83. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  84. package/dest/spartan/setup_test_wallets.js +34 -3
  85. package/dest/spartan/tx_metrics.js +1 -1
  86. package/dest/spartan/utils/bot.d.ts +3 -2
  87. package/dest/spartan/utils/bot.d.ts.map +1 -1
  88. package/dest/spartan/utils/bot.js +2 -1
  89. package/dest/spartan/utils/config.d.ts +4 -1
  90. package/dest/spartan/utils/config.d.ts.map +1 -1
  91. package/dest/spartan/utils/config.js +2 -1
  92. package/dest/spartan/utils/index.d.ts +3 -2
  93. package/dest/spartan/utils/index.d.ts.map +1 -1
  94. package/dest/spartan/utils/index.js +3 -1
  95. package/dest/spartan/utils/k8s.d.ts +3 -1
  96. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  97. package/dest/spartan/utils/k8s.js +6 -0
  98. package/dest/spartan/utils/nodes.d.ts +4 -5
  99. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  100. package/dest/spartan/utils/nodes.js +9 -9
  101. package/dest/test-wallet/test_wallet.d.ts +83 -0
  102. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  103. package/dest/test-wallet/test_wallet.js +214 -0
  104. package/dest/test-wallet/utils.d.ts +41 -0
  105. package/dest/test-wallet/utils.d.ts.map +1 -0
  106. package/dest/test-wallet/utils.js +71 -0
  107. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  108. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  109. package/dest/test-wallet/wallet_worker_script.js +48 -0
  110. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  111. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  112. package/dest/test-wallet/worker_wallet.js +151 -0
  113. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  114. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  115. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  116. package/package.json +43 -43
  117. package/src/bench/client_flows/client_flows_benchmark.ts +33 -32
  118. package/src/bench/utils.ts +7 -2
  119. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +27 -14
  120. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
  121. package/src/e2e_deploy_contract/deploy_test.ts +1 -1
  122. package/src/e2e_epochs/epochs_test.ts +66 -66
  123. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  124. package/src/e2e_fees/fees_test.ts +10 -21
  125. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  126. package/src/e2e_p2p/p2p_network.ts +31 -5
  127. package/src/e2e_p2p/reqresp/utils.ts +36 -8
  128. package/src/e2e_p2p/shared.ts +47 -3
  129. package/src/e2e_token_contract/token_contract_test.ts +25 -8
  130. package/src/fixtures/authwit_proxy.ts +50 -0
  131. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  132. package/src/fixtures/e2e_prover_test.ts +37 -41
  133. package/src/fixtures/elu_monitor.ts +126 -0
  134. package/src/fixtures/fixtures.ts +10 -0
  135. package/src/fixtures/ha_setup.ts +3 -1
  136. package/src/fixtures/setup.ts +78 -113
  137. package/src/fixtures/setup_p2p_test.ts +9 -17
  138. package/src/fixtures/token_utils.ts +6 -3
  139. package/src/guides/up_quick_start.sh +3 -3
  140. package/src/shared/cross_chain_test_harness.ts +13 -9
  141. package/src/shared/gas_portal_test_harness.ts +1 -1
  142. package/src/shared/index.ts +1 -0
  143. package/src/shared/jest_setup.ts +51 -1
  144. package/src/shared/mock_state_view.ts +188 -0
  145. package/src/shared/submit-transactions.ts +3 -2
  146. package/src/shared/uniswap_l1_l2.ts +7 -5
  147. package/src/simulators/lending_simulator.ts +4 -2
  148. package/src/simulators/token_simulator.ts +6 -30
  149. package/src/spartan/setup_test_wallets.ts +58 -11
  150. package/src/spartan/tx_metrics.ts +1 -1
  151. package/src/spartan/utils/bot.ts +4 -1
  152. package/src/spartan/utils/config.ts +1 -0
  153. package/src/spartan/utils/index.ts +4 -0
  154. package/src/spartan/utils/k8s.ts +8 -0
  155. package/src/spartan/utils/nodes.ts +15 -10
  156. package/src/test-wallet/test_wallet.ts +306 -0
  157. package/src/test-wallet/utils.ts +112 -0
  158. package/src/test-wallet/wallet_worker_script.ts +60 -0
  159. package/src/test-wallet/worker_wallet.ts +213 -0
  160. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -0,0 +1,126 @@
1
+ import { appendFileSync } from 'node:fs';
2
+ import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
3
+
4
+ const NANOS_PER_MS = 1_000_000;
5
+
6
+ /** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */
7
+ export class EluMonitor {
8
+ private filePath: string;
9
+ private intervalMs: number;
10
+ private timer: ReturnType<typeof setInterval> | undefined;
11
+ private lastELU: EventLoopUtilization | undefined;
12
+ private histogram: IntervalHistogram;
13
+ private testName: string | undefined;
14
+ private testStart: number | undefined;
15
+ private eluSamples: number[] = [];
16
+
17
+ constructor(filePath: string, intervalMs?: number) {
18
+ this.filePath = filePath;
19
+ this.intervalMs = intervalMs ?? 2000;
20
+ this.histogram = monitorEventLoopDelay({ resolution: 20 });
21
+ }
22
+
23
+ /** Begin sampling for a test. Writes a header line and starts the periodic sampler. */
24
+ startTest(testName: string): void {
25
+ this.stopTest();
26
+
27
+ this.testName = testName;
28
+ this.testStart = performance.now();
29
+ this.eluSamples = [];
30
+
31
+ appendFileSync(this.filePath, `\n=== Test: ${testName} ===\n`);
32
+ appendFileSync(
33
+ this.filePath,
34
+ padColumns('TIME', 'ELU', 'EL_DLY_P50', 'EL_DLY_P99', 'EL_DLY_MAX', 'HEAP_MB') + '\n',
35
+ );
36
+
37
+ this.lastELU = performance.eventLoopUtilization();
38
+ this.histogram.enable();
39
+
40
+ this.timer = setInterval(() => this.sample(), this.intervalMs);
41
+ // Allow the process to exit even if the timer is still running.
42
+ this.timer.unref();
43
+ }
44
+
45
+ /** Stop sampling and write a summary line. */
46
+ stopTest(): void {
47
+ if (!this.timer) {
48
+ return;
49
+ }
50
+
51
+ // Take a final sample before stopping.
52
+ this.sample();
53
+
54
+ clearInterval(this.timer);
55
+ this.timer = undefined;
56
+ this.histogram.disable();
57
+ this.histogram.reset();
58
+
59
+ this.writeSummary();
60
+
61
+ this.lastELU = undefined;
62
+ this.testName = undefined;
63
+ this.testStart = undefined;
64
+ this.eluSamples = [];
65
+ }
66
+
67
+ /** Alias for stopTest — call on process exit to flush any remaining data. */
68
+ stop(): void {
69
+ this.stopTest();
70
+ }
71
+
72
+ private sample(): void {
73
+ const newELU = performance.eventLoopUtilization();
74
+ const delta = performance.eventLoopUtilization(newELU, this.lastELU);
75
+ this.lastELU = newELU;
76
+
77
+ const elu = delta.utilization;
78
+ this.eluSamples.push(elu);
79
+
80
+ const p50 = this.histogram.percentile(50) / NANOS_PER_MS;
81
+ const p99 = this.histogram.percentile(99) / NANOS_PER_MS;
82
+ const max = this.histogram.max / NANOS_PER_MS;
83
+ const heapMb = Math.round(process.memoryUsage().heapUsed / (1024 * 1024));
84
+
85
+ const now = new Date();
86
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(n => String(n).padStart(2, '0')).join(':');
87
+
88
+ const line = padColumns(
89
+ time,
90
+ elu.toFixed(2),
91
+ `${p50.toFixed(1)}ms`,
92
+ `${p99.toFixed(1)}ms`,
93
+ `${max.toFixed(1)}ms`,
94
+ String(heapMb),
95
+ );
96
+ appendFileSync(this.filePath, line + '\n');
97
+
98
+ // Reset histogram so next sample only reflects the new interval.
99
+ this.histogram.reset();
100
+ }
101
+
102
+ private writeSummary(): void {
103
+ if (this.eluSamples.length === 0 || this.testStart === undefined) {
104
+ return;
105
+ }
106
+
107
+ const mean = this.eluSamples.reduce((a, b) => a + b, 0) / this.eluSamples.length;
108
+ const maxElu = Math.max(...this.eluSamples);
109
+ const sorted = [...this.eluSamples].sort((a, b) => a - b);
110
+ const p90Elu = sorted[Math.floor(sorted.length * 0.9)] ?? maxElu;
111
+ const durationS = ((performance.now() - this.testStart) / 1000).toFixed(1);
112
+
113
+ let summary = `--- Summary: mean_elu=${mean.toFixed(2)} max_elu=${maxElu.toFixed(2)} p90_elu=${p90Elu.toFixed(2)} duration=${durationS}s`;
114
+ if (maxElu > 0.85) {
115
+ summary += ' WARNING:ELU>0.85';
116
+ }
117
+ summary += ' ---\n';
118
+
119
+ appendFileSync(this.filePath, summary);
120
+ }
121
+ }
122
+
123
+ function padColumns(...cols: string[]): string {
124
+ const widths = [11, 7, 12, 12, 12, 8];
125
+ return cols.map((col, i) => col.padEnd(widths[i] ?? 10)).join('');
126
+ }
@@ -7,6 +7,16 @@ export const shouldCollectMetrics = () => {
7
7
  return undefined;
8
8
  };
9
9
 
10
+ /** Returns the boot node UDP port from environment variable or default value. */
11
+ export function getBootNodeUdpPort(): number {
12
+ return process.env.BOOT_NODE_UDP_PORT ? parseInt(process.env.BOOT_NODE_UDP_PORT, 10) : 4500;
13
+ }
14
+
15
+ /** Returns the anvil port from environment variable or default value. */
16
+ export function getAnvilPort(): number {
17
+ return process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT, 10) : 8545;
18
+ }
19
+
10
20
  export const TEST_PEER_CHECK_INTERVAL_MS = 1000;
11
21
  export const TEST_MAX_PENDING_TX_POOL_COUNT = 10_000; // Number of max pending TXs ~ 1.56GB
12
22
 
@@ -69,8 +69,10 @@ export async function cleanupHADatabase(pool: Pool, logger?: Logger): Promise<vo
69
69
  try {
70
70
  // Drop all HA tables
71
71
  await pool.query('DROP TABLE IF EXISTS validator_duties CASCADE');
72
- await pool.query('DROP TABLE IF EXISTS slashing_protection CASCADE');
73
72
  await pool.query('DROP TABLE IF EXISTS schema_version CASCADE');
73
+ // Drop migration tracking table (node-pg-migrate uses 'pgmigrations' by default)
74
+ // This ensures migrations will run fresh on next startup
75
+ await pool.query('DROP TABLE IF EXISTS pgmigrations CASCADE');
74
76
 
75
77
  logger?.info('HA database cleaned up successfully');
76
78
  } catch (error) {
@@ -1,6 +1,5 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
2
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { type Archiver, createArchiver } from '@aztec/archiver';
4
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
4
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
5
  import {
@@ -16,7 +15,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
15
  import type { AztecNode } from '@aztec/aztec.js/node';
17
16
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
17
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
18
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
19
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
20
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +28,9 @@ import {
30
28
  type ZKPassportArgs,
31
29
  deployAztecL1Contracts,
32
30
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
31
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
32
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
33
+ import type { Anvil } from '@aztec/ethereum/test';
40
34
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
35
  import { SecretValue } from '@aztec/foundation/config';
42
36
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,20 +39,17 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
39
  import { retryUntil } from '@aztec/foundation/retry';
46
40
  import { sleep } from '@aztec/foundation/sleep';
47
41
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
42
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
43
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
44
  import type { P2PClientDeps } from '@aztec/p2p';
52
45
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
46
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
47
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
48
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
49
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
50
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
51
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
60
52
  import { tryStop } from '@aztec/stdlib/interfaces/server';
61
- import type { P2PClientType } from '@aztec/stdlib/p2p';
62
53
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
63
54
  import {
64
55
  type TelemetryClient,
@@ -67,10 +58,9 @@ import {
67
58
  initTelemetryClient,
68
59
  } from '@aztec/telemetry-client';
69
60
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
61
+ import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
62
  import { getGenesisValues } from '@aztec/world-state/testing';
72
63
 
73
- import type { Anvil } from '@viem/anvil';
74
64
  import fs from 'fs/promises';
75
65
  import { tmpdir } from 'os';
76
66
  import path from 'path';
@@ -84,6 +74,7 @@ import {
84
74
  } from 'viem/accounts';
85
75
  import { type Chain, foundry } from 'viem/chains';
86
76
 
77
+ import { TestWallet } from '../test-wallet/test_wallet.js';
87
78
  import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
88
79
  import { getACVMConfig } from './get_acvm_config.js';
89
80
  import { getBBConfig } from './get_bb_config.js';
@@ -218,8 +209,8 @@ export type EndToEndContext = {
218
209
  aztecNodeService: AztecNodeService;
219
210
  /** Client to the Aztec Node admin interface. */
220
211
  aztecNodeAdmin: AztecNodeAdmin;
221
- /** The prover node service (only set if startProverNode is true) */
222
- proverNode: ProverNode | undefined;
212
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
213
+ proverNode: AztecNodeService | undefined;
223
214
  /** A client to the sequencer service. */
224
215
  sequencer: SequencerClient | undefined;
225
216
  /** Return values from deployAztecL1Contracts function. */
@@ -248,6 +239,10 @@ export type EndToEndContext = {
248
239
  telemetryClient: TelemetryClient;
249
240
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
250
241
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
242
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
243
+ sequencerDelayer: Delayer | undefined;
244
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
245
+ proverDelayer: Delayer | undefined;
251
246
  /** Prefilled public data used for setting up nodes. */
252
247
  prefilledPublicData: PublicDataTreeLeaf[] | undefined;
253
248
  /** ACVM config (only set if running locally). */
@@ -287,8 +282,12 @@ export async function setup(
287
282
  config.realProofs = !!opts.realProofs;
288
283
  // Only enforce the time table if requested
289
284
  config.enforceTimeTable = !!opts.enforceTimeTable;
285
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
286
+ config.enableDelayer = true;
290
287
  config.listenAddress = '127.0.0.1';
291
288
 
289
+ config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
290
+
292
291
  const logger = getLogger();
293
292
 
294
293
  // Create a temp directory for any services that need it and cleanup later
@@ -336,11 +335,11 @@ export async function setup(
336
335
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
337
336
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
338
337
  } else if (
339
- config.publisherPrivateKeys &&
340
- config.publisherPrivateKeys.length > 0 &&
341
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
338
+ config.sequencerPublisherPrivateKeys &&
339
+ config.sequencerPublisherPrivateKeys.length > 0 &&
340
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
342
341
  ) {
343
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
342
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
344
343
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
345
344
  } else if (!MNEMONIC) {
346
345
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -349,7 +348,7 @@ export async function setup(
349
348
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
350
349
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
351
350
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
352
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
351
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
353
352
  }
354
353
 
355
354
  if (config.coinbase === undefined) {
@@ -412,9 +411,14 @@ export async function setup(
412
411
  if (enableAutomine) {
413
412
  await ethCheatCodes.setAutomine(false);
414
413
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
415
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
416
414
  }
417
415
 
416
+ // Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
417
+ // In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
418
+ // warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
419
+ // slot from its dateProvider and cannot propose blocks.
420
+ dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
421
+
418
422
  if (opts.l2StartTime) {
419
423
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
420
424
  }
@@ -451,7 +455,7 @@ export async function setup(
451
455
  }
452
456
 
453
457
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
454
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
458
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
455
459
 
456
460
  if (opts.mockGossipSubNetwork) {
457
461
  mockGossipSubNetwork = new MockGossipSubNetwork();
@@ -491,36 +495,33 @@ export async function setup(
491
495
  );
492
496
  const sequencerClient = aztecNodeService.getSequencer();
493
497
 
494
- if (sequencerClient) {
495
- const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
496
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
497
- }
498
-
499
- let proverNode: ProverNode | undefined = undefined;
498
+ let proverNode: AztecNodeService | undefined = undefined;
500
499
  if (opts.startProverNode) {
501
500
  logger.verbose('Creating and syncing a simulated prover node...');
502
501
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
503
502
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
504
503
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
505
- const proverNodeConfig = {
506
- ...config.proverNodeConfig,
507
- dataDirectory: proverNodeDataDirectory,
508
- p2pEnabled: !!mockGossipSubNetwork,
504
+
505
+ const p2pClientDeps: Partial<P2PClientDeps> = {
506
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
507
+ rpcTxProviders: [aztecNodeService],
509
508
  };
510
- proverNode = await createAndSyncProverNode(
509
+
510
+ ({ proverNode } = await createAndSyncProverNode(
511
511
  proverNodePrivateKeyHex,
512
512
  config,
513
- proverNodeConfig,
514
- aztecNodeService,
515
- prefilledPublicData,
516
513
  {
517
- p2pClientDeps: mockGossipSubNetwork
518
- ? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
519
- : undefined,
514
+ ...config.proverNodeConfig,
515
+ dataDirectory: proverNodeDataDirectory,
520
516
  },
521
- );
517
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
518
+ { prefilledPublicData },
519
+ ));
522
520
  }
523
521
 
522
+ const sequencerDelayer = sequencerClient?.getDelayer();
523
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
524
+
524
525
  logger.verbose('Creating a pxe...');
525
526
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
526
527
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -621,6 +622,8 @@ export async function setup(
621
622
  mockGossipSubNetwork,
622
623
  prefilledPublicData,
623
624
  proverNode,
625
+ sequencerDelayer,
626
+ proverDelayer,
624
627
  sequencer: sequencerClient,
625
628
  teardown,
626
629
  telemetryClient,
@@ -704,93 +707,55 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
704
707
  );
705
708
  }
706
709
 
710
+ /**
711
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
712
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
713
+ */
707
714
  export function createAndSyncProverNode(
708
715
  proverNodePrivateKey: `0x${string}`,
709
- aztecNodeConfig: AztecNodeConfig,
710
- proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
711
- aztecNode: AztecNode | undefined,
712
- prefilledPublicData: PublicDataTreeLeaf[] = [],
713
- proverNodeDeps: ProverNodeDeps = {},
714
- ) {
716
+ baseConfig: AztecNodeConfig,
717
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
718
+ deps: {
719
+ telemetry?: TelemetryClient;
720
+ dateProvider: DateProvider;
721
+ p2pClientDeps?: P2PClientDeps;
722
+ },
723
+ options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
724
+ ): Promise<{ proverNode: AztecNodeService }> {
715
725
  return withLoggerBindings({ actor: 'prover-0' }, async () => {
716
- const aztecNodeTxProvider = aztecNode && {
717
- getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
718
- getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
719
- stop: () => Promise.resolve(),
720
- };
721
-
722
- const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('blob-client:prover-node'));
723
-
724
- const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
725
- const archiver = await createArchiver(
726
- archiverConfig,
727
- { blobClient, dateProvider: proverNodeDeps.dateProvider },
728
- { blockUntilSync: true },
729
- );
730
-
731
- const proverConfig: ProverNodeConfig = {
732
- ...aztecNodeConfig,
733
- txCollectionNodeRpcUrls: [],
734
- realProofs: false,
735
- proverAgentCount: 2,
736
- publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
737
- proverNodeMaxPendingJobs: 10,
738
- proverNodeMaxParallelBlocksPerEpoch: 32,
739
- proverNodePollingIntervalMs: 200,
740
- txGatheringIntervalMs: 1000,
741
- txGatheringBatchSize: 10,
742
- txGatheringMaxParallelRequestsPerNode: 10,
743
- txGatheringTimeoutMs: 24_000,
744
- proverNodeFailedEpochStore: undefined,
745
- proverId: EthAddress.fromNumber(1),
746
- proverNodeEpochProvingDelayMs: undefined,
747
- ...proverNodeConfig,
748
- };
749
-
750
- const l1TxUtils = createDelayedL1TxUtils(
751
- aztecNodeConfig,
752
- proverNodePrivateKey,
753
- 'prover-node',
754
- proverNodeDeps.dateProvider,
726
+ const proverNode = await AztecNodeService.createAndSync(
727
+ {
728
+ ...baseConfig,
729
+ ...configOverrides,
730
+ p2pPort: 0,
731
+ enableProverNode: true,
732
+ disableValidator: true,
733
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
734
+ },
735
+ deps,
736
+ { ...options, dontStartProverNode: options.dontStart },
755
737
  );
756
738
 
757
- const proverNode = await createProverNode(
758
- proverConfig,
759
- { ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
760
- { prefilledPublicData },
761
- );
762
- getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
763
- if (!proverNodeConfig.dontStart) {
764
- await proverNode.start();
739
+ if (!proverNode.getProverNode()) {
740
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
765
741
  }
766
- return proverNode;
767
- });
768
- }
769
742
 
770
- function createDelayedL1TxUtils(
771
- aztecNodeConfig: AztecNodeConfig,
772
- privateKey: `0x${string}`,
773
- logName: string,
774
- dateProvider?: DateProvider,
775
- ) {
776
- const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
777
-
778
- const log = createLogger(logName);
779
- const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
780
- l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
781
- return l1TxUtils;
743
+ getLogger().info(`Created and synced prover node`);
744
+ return { proverNode };
745
+ });
782
746
  }
783
747
 
784
748
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
785
749
  export function getBalancesFn(
786
750
  symbol: string,
787
751
  method: ContractMethod,
788
- from: AztecAddress,
789
752
  logger: any,
790
753
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
791
754
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
792
755
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
793
- const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
756
+ const b = await Promise.all(
757
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
758
+ );
794
759
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
795
760
  logger.verbose(debugString);
796
761
  return b;
@@ -908,7 +873,7 @@ export async function publicDeployAccounts(
908
873
 
909
874
  const batch = new BatchCall(wallet, calls);
910
875
 
911
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
876
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
912
877
  if (waitUntilProven) {
913
878
  if (!node) {
914
879
  throw new Error('Need to provide an AztecNode to wait for proven.');
@@ -7,7 +7,6 @@ import { SecretValue } from '@aztec/foundation/config';
7
7
  import { withLoggerBindings } from '@aztec/foundation/log/server';
8
8
  import { bufferToHex } from '@aztec/foundation/string';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
10
- import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
11
10
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
12
11
 
13
12
  import getPort from 'get-port';
@@ -131,7 +130,7 @@ export async function createNonValidatorNode(
131
130
  ...p2pConfig,
132
131
  disableValidator: true,
133
132
  validatorPrivateKeys: undefined,
134
- publisherPrivateKeys: [],
133
+ sequencerPublisherPrivateKeys: [],
135
134
  };
136
135
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
137
136
  return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
@@ -143,31 +142,24 @@ export async function createProverNode(
143
142
  tcpPort: number,
144
143
  bootstrapNode: string | undefined,
145
144
  addressIndex: number,
146
- proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
145
+ deps: { dateProvider: DateProvider },
147
146
  prefilledPublicData?: PublicDataTreeLeaf[],
148
147
  dataDirectory?: string,
149
148
  metricsPort?: number,
150
- ) {
149
+ ): Promise<{ proverNode: AztecNodeService }> {
151
150
  const actorIndex = proverCounter++;
152
151
  return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
153
152
  const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
154
153
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
155
154
 
156
- const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
157
- config,
158
- bootstrapNode,
159
- tcpPort,
160
- dataDirectory,
161
- );
155
+ const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
162
156
 
163
- const aztecNodeRpcTxProvider = undefined;
164
157
  return await createAndSyncProverNode(
165
158
  bufferToHex(proverNodePrivateKey),
166
- config,
167
- { ...proverConfig, dataDirectory },
168
- aztecNodeRpcTxProvider,
169
- prefilledPublicData,
170
- { ...proverNodeDeps, telemetry },
159
+ { ...config, ...p2pConfig },
160
+ { dataDirectory },
161
+ { ...deps, telemetry },
162
+ { prefilledPublicData: prefilledPublicData ?? [] },
171
163
  );
172
164
  });
173
165
  }
@@ -215,7 +207,7 @@ export async function createValidatorConfig(
215
207
  ...config,
216
208
  ...p2pConfig,
217
209
  validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
218
- publisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
210
+ sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
219
211
  };
220
212
 
221
213
  return nodeConfig;
@@ -6,7 +6,9 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
6
 
7
7
  export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
8
8
  logger.info(`Deploying Token contract...`);
9
- const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
9
+ const {
10
+ receipt: { contract, instance },
11
+ } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
12
  from: admin,
11
13
  wait: { returnReceipt: true },
12
14
  });
@@ -25,8 +27,9 @@ export async function mintTokensToPrivate(
25
27
  minter: AztecAddress,
26
28
  recipient: AztecAddress,
27
29
  amount: bigint,
30
+ additionalScopes?: AztecAddress[],
28
31
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
32
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
33
  }
31
34
 
32
35
  export async function expectTokenBalance(
@@ -38,7 +41,7 @@ export async function expectTokenBalance(
38
41
  ) {
39
42
  // Then check the balance
40
43
  const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
44
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
45
  logger.info(`Account ${owner} balance: ${balance}`);
43
46
  expect(balance).toBe(expectedBalance);
44
47
  }
@@ -23,6 +23,8 @@ aztec-wallet create-account -a alice -f test0
23
23
  aztec-wallet create-account -a bob -f test0
24
24
  # docs:end:declare-accounts
25
25
 
26
+ aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
27
+
26
28
  DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
27
29
  TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
28
30
  echo "Deployed contract at $TOKEN_ADDRESS"
@@ -38,9 +40,7 @@ fi
38
40
 
39
41
  TRANSFER_AMOUNT=42
40
42
 
41
- aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
42
-
43
- aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
43
+ aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
44
44
 
45
45
  # Test end result
46
46
  ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)