@aztec/end-to-end 0.0.1-commit.381b1a9 → 0.0.1-commit.3a4ae741b

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 (77) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +3 -2
  4. package/dest/e2e_epochs/epochs_test.d.ts +3 -1
  5. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  6. package/dest/e2e_epochs/epochs_test.js +3 -1
  7. package/dest/e2e_p2p/p2p_network.d.ts +4 -3
  8. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  9. package/dest/e2e_p2p/p2p_network.js +17 -13
  10. package/dest/e2e_p2p/reqresp/utils.d.ts +1 -1
  11. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  12. package/dest/e2e_p2p/reqresp/utils.js +15 -2
  13. package/dest/e2e_p2p/shared.d.ts +21 -1
  14. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  15. package/dest/e2e_p2p/shared.js +32 -1
  16. package/dest/fixtures/e2e_prover_test.d.ts +4 -3
  17. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  18. package/dest/fixtures/e2e_prover_test.js +3 -5
  19. package/dest/fixtures/elu_monitor.d.ts +21 -0
  20. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  21. package/dest/fixtures/elu_monitor.js +102 -0
  22. package/dest/fixtures/get_bb_config.d.ts +1 -1
  23. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  24. package/dest/fixtures/get_bb_config.js +5 -5
  25. package/dest/fixtures/setup.d.ts +3 -2
  26. package/dest/fixtures/setup.d.ts.map +1 -1
  27. package/dest/fixtures/setup.js +12 -9
  28. package/dest/fixtures/token_utils.d.ts +2 -2
  29. package/dest/fixtures/token_utils.d.ts.map +1 -1
  30. package/dest/fixtures/token_utils.js +3 -2
  31. package/dest/shared/jest_setup.js +41 -1
  32. package/dest/simulators/lending_simulator.d.ts +1 -1
  33. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  34. package/dest/simulators/lending_simulator.js +2 -2
  35. package/dest/simulators/token_simulator.js +1 -1
  36. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  37. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  38. package/dest/spartan/setup_test_wallets.js +6 -6
  39. package/dest/spartan/tx_metrics.js +1 -1
  40. package/dest/spartan/utils/config.d.ts +7 -1
  41. package/dest/spartan/utils/config.d.ts.map +1 -1
  42. package/dest/spartan/utils/config.js +3 -1
  43. package/dest/spartan/utils/index.d.ts +2 -1
  44. package/dest/spartan/utils/index.d.ts.map +1 -1
  45. package/dest/spartan/utils/index.js +2 -0
  46. package/dest/spartan/utils/nodes.d.ts +4 -5
  47. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  48. package/dest/spartan/utils/nodes.js +9 -9
  49. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  50. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  51. package/dest/spartan/utils/pod_logs.js +74 -0
  52. package/dest/test-wallet/test_wallet.d.ts +10 -17
  53. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  54. package/dest/test-wallet/test_wallet.js +48 -49
  55. package/dest/test-wallet/worker_wallet_schema.d.ts +2 -2
  56. package/package.json +42 -44
  57. package/src/bench/client_flows/client_flows_benchmark.ts +3 -1
  58. package/src/e2e_epochs/epochs_test.ts +13 -2
  59. package/src/e2e_p2p/p2p_network.ts +22 -19
  60. package/src/e2e_p2p/reqresp/utils.ts +23 -2
  61. package/src/e2e_p2p/shared.ts +54 -1
  62. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  63. package/src/fixtures/e2e_prover_test.ts +5 -11
  64. package/src/fixtures/elu_monitor.ts +126 -0
  65. package/src/fixtures/get_bb_config.ts +7 -6
  66. package/src/fixtures/setup.ts +13 -9
  67. package/src/fixtures/token_utils.ts +2 -1
  68. package/src/shared/jest_setup.ts +51 -1
  69. package/src/simulators/lending_simulator.ts +4 -2
  70. package/src/simulators/token_simulator.ts +1 -1
  71. package/src/spartan/setup_test_wallets.ts +14 -5
  72. package/src/spartan/tx_metrics.ts +1 -1
  73. package/src/spartan/utils/config.ts +2 -0
  74. package/src/spartan/utils/index.ts +3 -0
  75. package/src/spartan/utils/nodes.ts +15 -10
  76. package/src/spartan/utils/pod_logs.ts +99 -0
  77. package/src/test-wallet/test_wallet.ts +61 -66
@@ -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
+ }
@@ -13,8 +13,10 @@ const {
13
13
  BB_SKIP_CLEANUP = '',
14
14
  TEMP_DIR = tmpdir(),
15
15
  BB_WORKING_DIRECTORY = '',
16
- BB_NUM_IVC_VERIFIERS = '1',
16
+ BB_NUM_IVC_VERIFIERS = '8',
17
17
  BB_IVC_CONCURRENCY = '1',
18
+ BB_CHONK_VERIFY_MAX_BATCH = '16',
19
+ BB_CHONK_VERIFY_BATCH_CONCURRENCY = '6',
18
20
  } = process.env;
19
21
 
20
22
  export const getBBConfig = async (
@@ -41,16 +43,15 @@ export const getBBConfig = async (
41
43
  const bbSkipCleanup = ['1', 'true'].includes(BB_SKIP_CLEANUP);
42
44
  const cleanup = bbSkipCleanup ? () => Promise.resolve() : () => tryRmDir(directoryToCleanup);
43
45
 
44
- const numIvcVerifiers = Number(BB_NUM_IVC_VERIFIERS);
45
- const ivcConcurrency = Number(BB_IVC_CONCURRENCY);
46
-
47
46
  return {
48
47
  bbSkipCleanup,
49
48
  bbBinaryPath,
50
49
  bbWorkingDirectory,
51
50
  cleanup,
52
- numConcurrentIVCVerifiers: numIvcVerifiers,
53
- bbIVCConcurrency: ivcConcurrency,
51
+ numConcurrentIVCVerifiers: Number(BB_NUM_IVC_VERIFIERS),
52
+ bbIVCConcurrency: Number(BB_IVC_CONCURRENCY),
53
+ bbChonkVerifyMaxBatch: Number(BB_CHONK_VERIFY_MAX_BATCH),
54
+ bbChonkVerifyConcurrency: Number(BB_CHONK_VERIFY_BATCH_CONCURRENCY),
54
55
  };
55
56
  } catch (err) {
56
57
  logger.error(`Native BB not available, error: ${err}`);
@@ -1,6 +1,7 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
2
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
+ import { NO_FROM } from '@aztec/aztec.js/account';
4
5
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
5
6
  import {
6
7
  BatchCall,
@@ -29,7 +30,8 @@ import {
29
30
  deployAztecL1Contracts,
30
31
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
31
32
  import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
32
- import { type Anvil, EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
33
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
34
+ import type { Anvil } from '@aztec/ethereum/test';
33
35
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
34
36
  import { SecretValue } from '@aztec/foundation/config';
35
37
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -301,6 +303,8 @@ export async function setup(
301
303
  config.dataDirectory = directoryToCleanup;
302
304
  }
303
305
 
306
+ const dateProvider = new TestDateProvider();
307
+
304
308
  if (!config.l1RpcUrls?.length) {
305
309
  if (!isAnvilTestChain(chain.id)) {
306
310
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
@@ -310,6 +314,7 @@ export async function setup(
310
314
  accounts: opts.anvilAccounts,
311
315
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
312
316
  slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
317
+ dateProvider,
313
318
  });
314
319
  anvil = res.anvil;
315
320
  config.l1RpcUrls = [res.rpcUrl];
@@ -321,8 +326,6 @@ export async function setup(
321
326
  logger.info(`Logging metrics to ${filename}`);
322
327
  setupMetricsLogger(filename);
323
328
  }
324
-
325
- const dateProvider = new TestDateProvider();
326
329
  const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
327
330
 
328
331
  if (opts.stateLoad) {
@@ -418,11 +421,12 @@ export async function setup(
418
421
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
419
422
  }
420
423
 
421
- // Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
422
- // In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
423
- // warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
424
- // slot from its dateProvider and cannot propose blocks.
425
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
424
+ // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
425
+ // ahead of system time due to the local-network watcher warping time forward on each filled slot.
426
+ // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
427
+ if (!anvil) {
428
+ dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
429
+ }
426
430
 
427
431
  if (opts.l2StartTime) {
428
432
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
@@ -846,7 +850,7 @@ export const deployAccounts =
846
850
  );
847
851
  const deployMethod = await accountManager.getDeployMethod();
848
852
  await deployMethod.send({
849
- from: AztecAddress.ZERO,
853
+ from: NO_FROM,
850
854
  skipClassPublication: i !== 0, // Publish the contract class at most once.
851
855
  });
852
856
  }
@@ -27,8 +27,9 @@ export async function mintTokensToPrivate(
27
27
  minter: AztecAddress,
28
28
  recipient: AztecAddress,
29
29
  amount: bigint,
30
+ additionalScopes?: AztecAddress[],
30
31
  ) {
31
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
32
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
32
33
  }
33
34
 
34
35
  export async function expectTokenBalance(
@@ -1,8 +1,19 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
2
 
3
- import { beforeEach, expect } from '@jest/globals';
3
+ import { afterAll, afterEach, beforeEach, expect } from '@jest/globals';
4
+ import { readlinkSync } from 'fs';
4
5
  import { basename } from 'path';
5
6
 
7
+ import { EluMonitor } from '../fixtures/elu_monitor.js';
8
+
9
+ const eluMonitor = process.env.ELU_MONITOR_FILE
10
+ ? new EluMonitor(process.env.ELU_MONITOR_FILE, Number(process.env.ELU_MONITOR_INTERVAL_MS) || undefined)
11
+ : undefined;
12
+
13
+ if (eluMonitor) {
14
+ process.on('exit', () => eluMonitor.stop());
15
+ }
16
+
6
17
  beforeEach(() => {
7
18
  const { testPath, currentTestName } = expect.getState();
8
19
  if (!testPath || !currentTestName) {
@@ -10,4 +21,43 @@ beforeEach(() => {
10
21
  }
11
22
  const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
12
23
  logger.info(`Running test: ${currentTestName}`);
24
+ eluMonitor?.startTest(currentTestName);
25
+ });
26
+
27
+ afterEach(() => {
28
+ eluMonitor?.stopTest();
29
+ });
30
+
31
+ // Log leaked handles after all tests complete. This runs after test-level afterAll hooks,
32
+ // so any handles still alive at this point were not properly cleaned up during teardown.
33
+ // This diagnostic helps identify the source of exit hangs without masking them.
34
+ afterAll(() => {
35
+ const handles = (process as any)._getActiveHandles();
36
+ if (handles.length > 0) {
37
+ const details = handles.map((h: any) => {
38
+ const type = h?.constructor?.name ?? typeof h;
39
+ const fd = h?.fd ?? h?._handle?.fd ?? '?';
40
+ const destroyed = h?.destroyed ?? '?';
41
+ const hasRef = typeof h?.hasRef === 'function' ? h.hasRef() : '?';
42
+ const localAddr = h?.localAddress ?? '';
43
+ const remoteAddr = h?.remoteAddress ?? '';
44
+ const localPort = h?.localPort ?? '';
45
+ const remotePort = h?.remotePort ?? '';
46
+ const proto = Object.getPrototypeOf(h)?.constructor?.name ?? '?';
47
+ const keys = Object.keys(h).slice(0, 10).join(',');
48
+ let fdTarget = '';
49
+ if (typeof fd === 'number') {
50
+ try {
51
+ fdTarget = ` -> ${readlinkSync(`/proc/self/fd/${fd}`)}`;
52
+ } catch {
53
+ // ignore
54
+ }
55
+ }
56
+ return ` ${type}(fd=${fd}, destroyed=${destroyed}, hasRef=${hasRef}${fdTarget}) proto=${proto} addr=${localAddr}:${localPort}->${remoteAddr}:${remotePort} keys=[${keys}]`;
57
+ });
58
+ process.stderr.write(
59
+ `\n[jest_setup] WARNING: ${handles.length} handle(s) still active after teardown:\n${details.join('\n')}\n` +
60
+ `These may prevent Jest from exiting. Investigate and fix the leak.\n\n`,
61
+ );
62
+ }
13
63
  });
@@ -94,7 +94,9 @@ export class LendingSimulator {
94
94
 
95
95
  async prepare() {
96
96
  this.accumulator = BASE;
97
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration));
97
+ const slot = await this.rollup.getSlotAt(
98
+ BigInt(await this.cc.eth.lastBlockTimestamp()) + BigInt(this.ethereumSlotDuration),
99
+ );
98
100
  this.time = Number(await this.rollup.getTimestampForSlot(slot));
99
101
  }
100
102
 
@@ -103,7 +105,7 @@ export class LendingSimulator {
103
105
  return;
104
106
  }
105
107
 
106
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
108
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.lastBlockTimestamp()));
107
109
  const targetSlot = SlotNumber(slot + diff);
108
110
  const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
109
111
  const timeDiff = ts - this.time;
@@ -110,7 +110,7 @@ export class TokenSimulator {
110
110
  chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
111
111
  )
112
112
  )
113
- .flat()
113
+ .flatMap(r => r.result)
114
114
  .map(r => r.result);
115
115
  expect(results[0]).toEqual(this.totalSupply);
116
116
 
@@ -1,4 +1,5 @@
1
1
  import { generateSchnorrAccounts } from '@aztec/accounts/testing';
2
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
3
  import { AztecAddress } from '@aztec/aztec.js/addresses';
3
4
  import { NO_WAIT } from '@aztec/aztec.js/contracts';
4
5
  import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
@@ -88,11 +89,19 @@ export async function deploySponsoredTestAccountsWithTokens(
88
89
 
89
90
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
90
91
  const recipientDeployMethod = await recipientAccount.getDeployMethod();
91
- await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
92
+ await recipientDeployMethod.send({
93
+ from: NO_FROM,
94
+ fee: { paymentMethod },
95
+ wait: { timeout: 2400 },
96
+ });
92
97
  await Promise.all(
93
98
  fundedAccounts.map(async a => {
94
99
  const deployMethod = await a.getDeployMethod();
95
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
100
+ await deployMethod.send({
101
+ from: NO_FROM,
102
+ fee: { paymentMethod },
103
+ wait: { timeout: 2400 },
104
+ }); // increase timeout on purpose in order to account for two empty epochs
96
105
  logger.info(`Account deployed at ${a.address}`);
97
106
  }),
98
107
  );
@@ -133,12 +142,12 @@ async function deployAccountWithDiagnostics(
133
142
  try {
134
143
  let gasSettings;
135
144
  if (estimateGas) {
136
- const sim = await deployMethod.simulate({ from: AztecAddress.ZERO, fee: { paymentMethod } });
145
+ const sim = await deployMethod.simulate({ from: NO_FROM, fee: { paymentMethod } });
137
146
  gasSettings = sim.estimatedGas;
138
147
  logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
139
148
  }
140
149
  const deployResult = await deployMethod.send({
141
- from: AztecAddress.ZERO,
150
+ from: NO_FROM,
142
151
  fee: { paymentMethod, gasSettings },
143
152
  wait: NO_WAIT,
144
153
  });
@@ -261,7 +270,7 @@ export async function deployTestAccountsWithTokens(
261
270
  fundedAccounts.map(async (a, i) => {
262
271
  const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
263
272
  const deployMethod = await a.getDeployMethod();
264
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } });
273
+ await deployMethod.send({ from: NO_FROM, fee: { paymentMethod } });
265
274
  logger.info(`Account deployed at ${a.address}`);
266
275
  }),
267
276
  );
@@ -296,7 +296,7 @@ export class TxInclusionMetrics {
296
296
  value: stats.mean,
297
297
  },
298
298
  {
299
- name: `${group}/median_inclusion`,
299
+ name: `${group}/p50_inclusion`,
300
300
  unit: 's',
301
301
  value: stats.median,
302
302
  },
@@ -8,6 +8,7 @@ const logger = createLogger('e2e:k8s-utils');
8
8
  const testConfigSchema = z.object({
9
9
  NAMESPACE: z.string().default('scenario'),
10
10
  REAL_VERIFIER: schemas.Boolean.optional().default(true),
11
+ DEBUG_FORCE_TX_PROOF_VERIFICATION: schemas.Boolean.optional().default(true),
11
12
  CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
12
13
  L1_RPC_URLS_JSON: z.string().optional(),
13
14
  L1_ACCOUNT_MNEMONIC: z.string().optional(),
@@ -16,6 +17,7 @@ const testConfigSchema = z.object({
16
17
  AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
17
18
  AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
18
19
  FUNDING_PRIVATE_KEY: z.string().optional(),
20
+ AZTEC_ADMIN_API_KEY: z.string().optional(),
19
21
  });
20
22
 
21
23
  export type TestConfig = z.infer<typeof testConfigSchema>;
@@ -66,3 +66,6 @@ export { getPublicViemClient, getL1DeploymentAddresses, getNodeClient } from './
66
66
 
67
67
  // Health checks
68
68
  export { ChainHealth, type ChainHealthSnapshot } from './health.js';
69
+
70
+ // Pod log extraction
71
+ export { type BlockBuiltLogEntry, fetchBlockBuiltLogs } from './pod_logs.js';
@@ -173,7 +173,7 @@ export async function withSequencersAdmin<T>(env: TestConfig, fn: (node: AztecNo
173
173
  if (statusRes.status !== 200) {
174
174
  throw new Error(`Admin endpoint returned status ${statusRes.status}`);
175
175
  }
176
- const client = createAztecNodeAdminClient(url);
176
+ const client = createAztecNodeAdminClient(url, {}, undefined, env.AZTEC_ADMIN_API_KEY);
177
177
  return { result: await fn(client), process };
178
178
  } catch (err) {
179
179
  // Kill the port-forward before retrying
@@ -255,21 +255,18 @@ export async function initHADb(namespace: string): Promise<void> {
255
255
  }
256
256
 
257
257
  /**
258
- * Enables or disables probabilistic transaction dropping on validators and waits for rollout.
259
- * Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
258
+ * Sets probabilistic transaction dropping on validators and waits for rollout.
259
+ * Use probability=0 to disable. Wired to env var P2P_DROP_TX_CHANCE via Helm values.
260
260
  */
261
261
  export async function setValidatorTxDrop({
262
262
  namespace,
263
- enabled,
264
263
  probability,
265
264
  logger: log,
266
265
  }: {
267
266
  namespace: string;
268
- enabled: boolean;
269
267
  probability: number;
270
268
  logger: Logger;
271
269
  }) {
272
- const drop = enabled ? 'true' : 'false';
273
270
  const prob = String(probability);
274
271
 
275
272
  const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator'];
@@ -284,7 +281,7 @@ export async function setValidatorTxDrop({
284
281
  if (names.length === 0) {
285
282
  continue;
286
283
  }
287
- const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
284
+ const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
288
285
  log.info(`command: ${cmd}`);
289
286
  await execAsync(cmd);
290
287
  updated = true;
@@ -366,16 +363,24 @@ export async function enableValidatorDynamicBootNode(
366
363
  */
367
364
  export async function rollAztecPods(namespace: string, clearState: boolean = false) {
368
365
  // Pod components use 'validator', but StatefulSets and PVCs use 'sequencer-node' for validators
366
+ // RPC nodes have nodeType='rpc-node' in Helm values, so their component label is 'rpc-node' (not 'rpc')
369
367
  const podComponents = [
370
368
  'p2p-bootstrap',
371
369
  'prover-node',
372
370
  'prover-broker',
373
371
  'prover-agent',
374
372
  'sequencer-node',
375
- 'rpc',
373
+ 'rpc-node',
374
+ 'validator-ha-db',
375
+ ];
376
+ const pvcComponents = [
377
+ 'p2p-bootstrap',
378
+ 'prover-node',
379
+ 'prover-broker',
380
+ 'sequencer-node',
381
+ 'rpc-node',
376
382
  'validator-ha-db',
377
383
  ];
378
- const pvcComponents = ['p2p-bootstrap', 'prover-node', 'prover-broker', 'sequencer-node', 'rpc', 'validator-ha-db'];
379
384
  // StatefulSet components that need to be scaled down before PVC deletion
380
385
  // Note: validators use 'sequencer-node' as component label, not 'validator'
381
386
  const statefulSetComponents = [
@@ -383,7 +388,7 @@ export async function rollAztecPods(namespace: string, clearState: boolean = fal
383
388
  'prover-node',
384
389
  'prover-broker',
385
390
  'sequencer-node',
386
- 'rpc',
391
+ 'rpc-node',
387
392
  'validator-ha-db',
388
393
  ];
389
394
 
@@ -0,0 +1,99 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+
3
+ import { exec } from 'child_process';
4
+ import { promisify } from 'util';
5
+
6
+ import { getSequencers } from './nodes.js';
7
+
8
+ const execAsync = promisify(exec);
9
+
10
+ /** Parsed l2-block-built stats from a sequencer pod log line. */
11
+ export type BlockBuiltLogEntry = {
12
+ blockNumber: number;
13
+ txCount: number;
14
+ duration: number;
15
+ publicProcessDuration: number;
16
+ manaPerSec: number;
17
+ privateLogCount: number;
18
+ publicLogCount: number;
19
+ contractClassLogCount: number;
20
+ contractClassLogSize: number;
21
+ };
22
+
23
+ const FIELDS: (keyof BlockBuiltLogEntry)[] = [
24
+ 'blockNumber',
25
+ 'txCount',
26
+ 'duration',
27
+ 'publicProcessDuration',
28
+ 'manaPerSec',
29
+ 'privateLogCount',
30
+ 'publicLogCount',
31
+ 'contractClassLogCount',
32
+ 'contractClassLogSize',
33
+ ];
34
+
35
+ /**
36
+ * Fetches l2-block-built log entries from sequencer pods for given block numbers.
37
+ * Queries all validator pods (only the proposer will have the log for a given block).
38
+ *
39
+ * @param namespace - Kubernetes namespace
40
+ * @param sinceTime - ISO 8601 timestamp to limit log search (e.g., from before block building was re-enabled)
41
+ * @param blockNumbers - Set of block numbers to filter for
42
+ * @param logger - Logger instance
43
+ * @returns Array of parsed BlockBuiltLogEntry, de-duplicated by blockNumber, sorted ascending
44
+ */
45
+ export async function fetchBlockBuiltLogs(
46
+ namespace: string,
47
+ sinceTime: string,
48
+ blockNumbers: Set<number>,
49
+ logger: Logger,
50
+ ): Promise<BlockBuiltLogEntry[]> {
51
+ const pods = await getSequencers(namespace);
52
+ const entriesByBlock = new Map<number, BlockBuiltLogEntry>();
53
+
54
+ // Subtract 60s from sinceTime to account for clock skew between test runner and k8s pods.
55
+ // Block number filtering ensures we only match the right blocks, so extra lines are harmless.
56
+ const sinceDate = new Date(new Date(sinceTime).getTime() - 60_000);
57
+ const sinceFlag = sinceDate.toISOString();
58
+
59
+ for (const pod of pods) {
60
+ try {
61
+ const cmd = `kubectl logs ${pod} -n ${namespace} -c aztec --since-time=${sinceFlag}`;
62
+ logger.info(`Fetching logs: ${cmd}`);
63
+ const { stdout } = await execAsync(cmd, { maxBuffer: 10 * 1024 * 1024 });
64
+
65
+ const lines = stdout.split('\n');
66
+ const matchingLines = lines.filter(l => l.includes('l2-block-built'));
67
+ logger.info(`Pod ${pod}: ${lines.length} log lines, ${matchingLines.length} contain l2-block-built`);
68
+
69
+ for (const line of matchingLines) {
70
+ try {
71
+ const parsed = JSON.parse(line);
72
+ if (parsed.eventName !== 'l2-block-built' || !blockNumbers.has(parsed.blockNumber)) {
73
+ continue;
74
+ }
75
+ if (entriesByBlock.has(parsed.blockNumber)) {
76
+ continue;
77
+ }
78
+ const entry: BlockBuiltLogEntry = {} as BlockBuiltLogEntry;
79
+ for (const field of FIELDS) {
80
+ entry[field] = parsed[field] ?? 0;
81
+ }
82
+ entriesByBlock.set(entry.blockNumber, entry);
83
+ logger.verbose(`Parsed l2-block-built log for block ${entry.blockNumber}`, entry);
84
+ } catch {
85
+ // Not valid JSON, skip
86
+ }
87
+ }
88
+ } catch (err) {
89
+ logger.warn(`Failed to fetch logs from pod ${pod}: ${err}`);
90
+ }
91
+ }
92
+
93
+ if (entriesByBlock.size < blockNumbers.size) {
94
+ const missing = [...blockNumbers].filter(bn => !entriesByBlock.has(bn));
95
+ logger.warn(`Missing l2-block-built logs for block(s): ${missing.join(', ')}`);
96
+ }
97
+
98
+ return [...entriesByBlock.values()].sort((a, b) => a.blockNumber - b.blockNumber);
99
+ }