@aztec/end-to-end 0.0.1-commit.e61ad554 → 0.0.1-commit.ee80a48

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 (59) hide show
  1. package/dest/e2e_epochs/epochs_test.d.ts +7 -1
  2. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  3. package/dest/e2e_epochs/epochs_test.js +28 -9
  4. package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
  5. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  6. package/dest/e2e_l1_publisher/write_json.js +1 -7
  7. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  8. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  9. package/dest/e2e_p2p/reqresp/utils.js +153 -0
  10. package/dest/e2e_p2p/shared.d.ts +1 -1
  11. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  12. package/dest/e2e_p2p/shared.js +2 -2
  13. package/dest/fixtures/e2e_prover_test.js +1 -1
  14. package/dest/fixtures/ha_setup.d.ts +71 -0
  15. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  16. package/dest/fixtures/ha_setup.js +114 -0
  17. package/dest/fixtures/index.d.ts +2 -1
  18. package/dest/fixtures/index.d.ts.map +1 -1
  19. package/dest/fixtures/index.js +1 -0
  20. package/dest/fixtures/setup.d.ts +3 -3
  21. package/dest/fixtures/setup.d.ts.map +1 -1
  22. package/dest/fixtures/setup.js +20 -15
  23. package/dest/fixtures/setup_p2p_test.d.ts +4 -5
  24. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  25. package/dest/fixtures/setup_p2p_test.js +24 -19
  26. package/dest/spartan/tx_metrics.d.ts +35 -1
  27. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  28. package/dest/spartan/tx_metrics.js +150 -0
  29. package/dest/spartan/utils/config.d.ts +4 -1
  30. package/dest/spartan/utils/config.d.ts.map +1 -1
  31. package/dest/spartan/utils/config.js +2 -1
  32. package/dest/spartan/utils/index.d.ts +4 -4
  33. package/dest/spartan/utils/index.d.ts.map +1 -1
  34. package/dest/spartan/utils/index.js +2 -2
  35. package/dest/spartan/utils/k8s.d.ts +29 -1
  36. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  37. package/dest/spartan/utils/k8s.js +118 -0
  38. package/dest/spartan/utils/nodes.d.ts +11 -1
  39. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  40. package/dest/spartan/utils/nodes.js +198 -27
  41. package/dest/spartan/utils/scripts.d.ts +18 -4
  42. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  43. package/dest/spartan/utils/scripts.js +19 -4
  44. package/package.json +42 -39
  45. package/src/e2e_epochs/epochs_test.ts +31 -10
  46. package/src/e2e_l1_publisher/write_json.ts +1 -6
  47. package/src/e2e_p2p/reqresp/utils.ts +207 -0
  48. package/src/e2e_p2p/shared.ts +10 -2
  49. package/src/fixtures/e2e_prover_test.ts +1 -1
  50. package/src/fixtures/ha_setup.ts +184 -0
  51. package/src/fixtures/index.ts +1 -0
  52. package/src/fixtures/setup.ts +13 -13
  53. package/src/fixtures/setup_p2p_test.ts +15 -20
  54. package/src/spartan/tx_metrics.ts +126 -0
  55. package/src/spartan/utils/config.ts +1 -0
  56. package/src/spartan/utils/index.ts +3 -1
  57. package/src/spartan/utils/k8s.ts +152 -0
  58. package/src/spartan/utils/nodes.ts +239 -24
  59. package/src/spartan/utils/scripts.ts +43 -7
@@ -1,11 +1,12 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
- import { makeBackoff, retry } from '@aztec/foundation/retry';
2
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
3
+ import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
3
4
  import { sleep } from '@aztec/foundation/sleep';
4
5
  import { createAztecNodeAdminClient } from '@aztec/stdlib/interfaces/client';
5
6
  import { exec } from 'child_process';
6
7
  import { promisify } from 'util';
7
8
  import { execHelmCommand } from './helm.js';
8
- import { deleteResourceByLabel, getChartDir, startPortForward, waitForResourceByLabel } from './k8s.js';
9
+ import { deleteResourceByLabel, getChartDir, startPortForward, waitForResourceByLabel, waitForResourceByName, waitForStatefulSetsReady } from './k8s.js';
9
10
  const execAsync = promisify(exec);
10
11
  const logger = createLogger('e2e:k8s-utils');
11
12
  export async function awaitCheckpointNumber(rollupCheatCodes, checkpointNumber, timeoutSeconds, log) {
@@ -23,6 +24,43 @@ export async function awaitCheckpointNumber(rollupCheatCodes, checkpointNumber,
23
24
  log.info(`Reached checkpoint ${tips.pending}`);
24
25
  }
25
26
  }
27
+ /**
28
+ * Waits until the proven block number increases.
29
+ *
30
+ * @param rpcUrl - URL of an Aztec RPC node to query
31
+ * @param log - Logger instance
32
+ * @param timeoutSeconds - Maximum time to wait
33
+ * @param pollIntervalSeconds - How often to check
34
+ */ export async function waitForProvenToAdvance(rpcUrl, log, timeoutSeconds = 300, pollIntervalSeconds = 12) {
35
+ const node = createAztecNodeClient(rpcUrl);
36
+ log.info('Waiting for proven block to advance (indicating epoch proof just submitted)...');
37
+ // Get current proven block number
38
+ let initialProvenBlock;
39
+ try {
40
+ const tips = await node.getL2Tips();
41
+ initialProvenBlock = Number(tips.proven.block.number);
42
+ log.info(`Current proven block: ${initialProvenBlock}. Waiting for it to increase...`);
43
+ } catch (err) {
44
+ log.warn(`Error getting initial tips: ${err}. Will poll until successful.`);
45
+ initialProvenBlock = 0;
46
+ }
47
+ await retryUntil(async ()=>{
48
+ try {
49
+ const tips = await node.getL2Tips();
50
+ const currentProvenBlock = Number(tips.proven.block.number);
51
+ const proposedBlock = Number(tips.proposed.number);
52
+ log.verbose(`Chain state: proposed=${proposedBlock}, proven=${currentProvenBlock} (waiting for > ${initialProvenBlock})`);
53
+ if (currentProvenBlock > initialProvenBlock) {
54
+ log.info(`Proven block advanced from ${initialProvenBlock} to ${currentProvenBlock}.`);
55
+ return true;
56
+ }
57
+ return false;
58
+ } catch (err) {
59
+ log.verbose(`Error checking tips: ${err}`);
60
+ return false;
61
+ }
62
+ }, 'proven block to advance', timeoutSeconds, pollIntervalSeconds);
63
+ }
26
64
  export async function getSequencers(namespace) {
27
65
  const selectors = [
28
66
  'app.kubernetes.io/name=validator',
@@ -61,9 +99,15 @@ export async function withSequencersAdmin(env, fn) {
61
99
  const sequencers = await getSequencers(namespace);
62
100
  const results = [];
63
101
  for (const sequencer of sequencers){
102
+ // Ensure pod is Ready before attempting port-forward.
103
+ await waitForResourceByName({
104
+ resource: 'pods',
105
+ name: sequencer,
106
+ namespace
107
+ });
64
108
  // Wrap port-forward + fetch in a retry to handle flaky port-forwards
65
109
  const result = await retry(async ()=>{
66
- const { process, port } = await startPortForward({
110
+ const { process: process1, port } = await startPortForward({
67
111
  resource: `pod/${sequencer}`,
68
112
  namespace,
69
113
  containerPort: adminContainerPort
@@ -78,11 +122,11 @@ export async function withSequencersAdmin(env, fn) {
78
122
  const client = createAztecNodeAdminClient(url);
79
123
  return {
80
124
  result: await fn(client),
81
- process
125
+ process: process1
82
126
  };
83
127
  } catch (err) {
84
128
  // Kill the port-forward before retrying
85
- process.kill();
129
+ process1.kill();
86
130
  throw err;
87
131
  }
88
132
  }, 'connect to node admin', makeBackoff([
@@ -96,6 +140,58 @@ export async function withSequencersAdmin(env, fn) {
96
140
  }
97
141
  return results;
98
142
  }
143
+ async function getAztecImageForMigrations(namespace) {
144
+ const aztecDockerImage = process.env.AZTEC_DOCKER_IMAGE;
145
+ if (aztecDockerImage) {
146
+ return aztecDockerImage;
147
+ }
148
+ const { stdout } = await execAsync(`kubectl get pods -l app.kubernetes.io/name=validator -n ${namespace} -o jsonpath='{.items[0].spec.containers[?(@.name=="aztec")].image}' | cat`);
149
+ const image = stdout.trim().replace(/^'|'$/g, '');
150
+ if (!image) {
151
+ throw new Error(`Could not detect aztec image from validator pod in namespace ${namespace}`);
152
+ }
153
+ return image;
154
+ }
155
+ async function getHaDbConnectionUrl(namespace) {
156
+ const secretName = `${namespace}-validator-ha-db-postgres`;
157
+ const { stdout } = await execAsync(`kubectl get secret ${secretName} -n ${namespace} -o json`);
158
+ const secret = JSON.parse(stdout);
159
+ const data = secret?.data ?? {};
160
+ const decode = (value)=>value ? Buffer.from(value, 'base64').toString('utf8') : '';
161
+ const user = decode(data.POSTGRES_USER);
162
+ const password = decode(data.POSTGRES_PASSWORD);
163
+ const database = decode(data.POSTGRES_DB);
164
+ if (!user || !password || !database) {
165
+ throw new Error(`Missing HA DB credentials in secret ${secretName}`);
166
+ }
167
+ const host = `${namespace}-validator-ha-db-postgres.${namespace}.svc.cluster.local`;
168
+ return `postgresql://${encodeURIComponent(user)}:${encodeURIComponent(password)}@${host}:5432/${database}`;
169
+ }
170
+ export async function initHADb(namespace) {
171
+ const databaseUrl = await getHaDbConnectionUrl(namespace);
172
+ const image = await getAztecImageForMigrations(namespace);
173
+ const jobName = `${namespace}-validator-ha-db-migrate`;
174
+ await execAsync(`kubectl delete pod ${jobName} -n ${namespace} --ignore-not-found=true`).catch(()=>undefined);
175
+ const migrateCmd = [
176
+ `kubectl run ${jobName} -n ${namespace}`,
177
+ '--rm -i',
178
+ '--restart=Never',
179
+ `--image=${image}`,
180
+ `--env=DATABASE_URL=${databaseUrl}`,
181
+ '--command -- node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js migrate-ha-db up'
182
+ ].join(' ');
183
+ const migrateCmdForLog = migrateCmd.replace(/--env=DATABASE_URL=\S+/, '--env=DATABASE_URL=<redacted>');
184
+ await retry(async ()=>{
185
+ logger.info(`command: ${migrateCmdForLog}`);
186
+ await execAsync(migrateCmd);
187
+ }, 'run HA DB migrations', makeBackoff([
188
+ 1,
189
+ 2,
190
+ 4,
191
+ 8,
192
+ 16
193
+ ]), logger, true);
194
+ }
99
195
  /**
100
196
  * Enables or disables probabilistic transaction dropping on validators and waits for rollout.
101
197
  * Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
@@ -201,14 +297,16 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
201
297
  'prover-broker',
202
298
  'prover-agent',
203
299
  'sequencer-node',
204
- 'rpc'
300
+ 'rpc',
301
+ 'validator-ha-db'
205
302
  ];
206
303
  const pvcComponents = [
207
304
  'p2p-bootstrap',
208
305
  'prover-node',
209
306
  'prover-broker',
210
307
  'sequencer-node',
211
- 'rpc'
308
+ 'rpc',
309
+ 'validator-ha-db'
212
310
  ];
213
311
  // StatefulSet components that need to be scaled down before PVC deletion
214
312
  // Note: validators use 'sequencer-node' as component label, not 'validator'
@@ -217,20 +315,27 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
217
315
  'prover-node',
218
316
  'prover-broker',
219
317
  'sequencer-node',
220
- 'rpc'
318
+ 'rpc',
319
+ 'validator-ha-db'
221
320
  ];
222
321
  if (clearState) {
223
322
  // To delete PVCs, we must first scale down StatefulSets so pods release the volumes
224
323
  // Otherwise PVC deletion will hang waiting for pods to terminate
225
- // First, save original replica counts
324
+ // Save original replica counts for all StatefulSets
226
325
  const originalReplicas = new Map();
227
326
  for (const component of statefulSetComponents){
228
327
  try {
229
- const getCmd = `kubectl get statefulset -l app.kubernetes.io/component=${component} -n ${namespace} -o jsonpath='{.items[0].spec.replicas}'`;
328
+ // Get all StatefulSets that match the component label
329
+ const getCmd = `kubectl get statefulset -l app.kubernetes.io/component=${component} -n ${namespace} -o json`;
230
330
  const { stdout } = await execAsync(getCmd);
231
- const replicas = parseInt(stdout.replace(/'/g, '').trim(), 10);
232
- if (!isNaN(replicas) && replicas > 0) {
233
- originalReplicas.set(component, replicas);
331
+ const result = JSON.parse(stdout);
332
+ for (const sts of result.items || []){
333
+ const name = sts.metadata.name;
334
+ const replicas = sts.spec.replicas ?? 1;
335
+ if (replicas > 0) {
336
+ originalReplicas.set(name, replicas);
337
+ logger.debug(`Saved replica count for StatefulSet ${name}: ${replicas}`);
338
+ }
234
339
  }
235
340
  } catch {
236
341
  // Component might not exist, continue
@@ -247,25 +352,79 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
247
352
  logger.verbose(`Scale down ${component} skipped: ${e}`);
248
353
  }
249
354
  }
250
- // Wait for pods to terminate
251
- await sleep(15 * 1000);
355
+ // Wait for all pods to fully terminate before deleting PVCs.
356
+ // terminationGracePeriodSeconds default is 30s.
357
+ logger.info('Waiting for pods to fully terminate before deleting PVCs...');
358
+ for (const component of statefulSetComponents){
359
+ try {
360
+ // Wait for all pods with this component label to be deleted
361
+ const waitCmd = `kubectl wait pods -l app.kubernetes.io/component=${component} --for=delete -n ${namespace} --timeout=2m`;
362
+ logger.info(`command: ${waitCmd}`);
363
+ await execAsync(waitCmd);
364
+ } catch (e) {
365
+ logger.verbose(`Wait for pod deletion ${component} skipped: ${e}`);
366
+ }
367
+ }
368
+ // Extra buffer to ensure PVC protection finalizers are cleared
369
+ await sleep(5 * 1000);
252
370
  // Now delete PVCs (they should no longer be in use)
253
371
  for (const component of pvcComponents){
254
- await deleteResourceByLabel({
255
- resource: 'persistentvolumeclaims',
256
- namespace: namespace,
257
- label: `app.kubernetes.io/component=${component}`
258
- });
372
+ try {
373
+ await deleteResourceByLabel({
374
+ resource: 'persistentvolumeclaims',
375
+ namespace: namespace,
376
+ label: `app.kubernetes.io/component=${component}`
377
+ });
378
+ } catch (e) {
379
+ logger.warn(`Failed to delete PVCs for ${component}: ${e}`);
380
+ }
259
381
  }
260
- // Scale StatefulSets back up to original replica counts
261
- for (const component of statefulSetComponents){
262
- const replicas = originalReplicas.get(component) ?? 1;
382
+ // Verify PVCs are deleted
383
+ for (const component of pvcComponents){
384
+ try {
385
+ const waitCmd = `kubectl wait pvc -l app.kubernetes.io/component=${component} --for=delete -n ${namespace} --timeout=2m`;
386
+ logger.info(`command: ${waitCmd}`);
387
+ await execAsync(waitCmd);
388
+ } catch (e) {
389
+ logger.verbose(`Wait for PVC deletion ${component} skipped: ${e}`);
390
+ }
391
+ }
392
+ const haDbStatefulSets = [
393
+ ...originalReplicas.entries()
394
+ ].filter(([name])=>name.includes('validator-ha-db'));
395
+ const otherStatefulSets = [
396
+ ...originalReplicas.entries()
397
+ ].filter(([name])=>!name.includes('validator-ha-db'));
398
+ // Bring up HA DB first so we can run migrations before validators start
399
+ for (const [stsName, replicas] of haDbStatefulSets){
400
+ try {
401
+ const scaleCmd = `kubectl scale statefulset ${stsName} -n ${namespace} --replicas=${replicas} --timeout=2m`;
402
+ logger.info(`command: ${scaleCmd}`);
403
+ await execAsync(scaleCmd);
404
+ } catch (e) {
405
+ logger.verbose(`Scale up ${stsName} skipped: ${e}`);
406
+ }
407
+ }
408
+ if (haDbStatefulSets.length > 0) {
409
+ try {
410
+ await waitForStatefulSetsReady({
411
+ namespace,
412
+ label: 'app.kubernetes.io/component=validator-ha-db',
413
+ timeoutSeconds: 600
414
+ });
415
+ await initHADb(namespace);
416
+ } catch (e) {
417
+ logger.warn(`HA DB migration step skipped or failed: ${e}`);
418
+ }
419
+ }
420
+ // Scale remaining StatefulSets back up to original replica counts (by name, not label)
421
+ for (const [stsName, replicas] of otherStatefulSets){
263
422
  try {
264
- const scaleCmd = `kubectl scale statefulset -l app.kubernetes.io/component=${component} -n ${namespace} --replicas=${replicas} --timeout=2m`;
423
+ const scaleCmd = `kubectl scale statefulset ${stsName} -n ${namespace} --replicas=${replicas} --timeout=2m`;
265
424
  logger.info(`command: ${scaleCmd}`);
266
425
  await execAsync(scaleCmd);
267
426
  } catch (e) {
268
- logger.verbose(`Scale up ${component} skipped: ${e}`);
427
+ logger.verbose(`Scale up ${stsName} skipped: ${e}`);
269
428
  }
270
429
  }
271
430
  } else {
@@ -279,8 +438,20 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
279
438
  }
280
439
  }
281
440
  await sleep(10 * 1000);
282
- // Wait for pods to come back
283
- for (const component of podComponents){
441
+ // Wait for StatefulSets to have all replicas ready.
442
+ for (const component of statefulSetComponents){
443
+ try {
444
+ await waitForStatefulSetsReady({
445
+ namespace,
446
+ label: `app.kubernetes.io/component=${component}`,
447
+ timeoutSeconds: 600
448
+ });
449
+ } catch (e) {
450
+ logger.warn(`StatefulSet component ${component} may not be fully ready: ${e}`);
451
+ }
452
+ }
453
+ const nonStatefulSetComponents = podComponents.filter((c)=>!statefulSetComponents.includes(c));
454
+ for (const component of nonStatefulSetComponents){
284
455
  await waitForResourceByLabel({
285
456
  resource: 'pods',
286
457
  namespace: namespace,
@@ -1,4 +1,10 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
+ /** Result from running a script */
3
+ export type ScriptResult = {
4
+ exitCode: number;
5
+ stdout: string;
6
+ stderr: string;
7
+ };
2
8
  /**
3
9
  * Returns the absolute path to the git repository root
4
10
  */
@@ -9,8 +15,16 @@ export declare function getAztecBin(): string;
9
15
  * @param args - The arguments to pass to the Aztec binary
10
16
  * @param logger - The logger to use
11
17
  * @param env - Optional environment variables to set for the process
12
- * @returns The exit code of the Aztec binary
18
+ * @returns The exit code, stdout, and stderr of the Aztec binary
13
19
  */
14
- export declare function runAztecBin(args: string[], logger: Logger, env?: Record<string, string>): Promise<number>;
15
- export declare function runProjectScript(script: string, args: string[], logger: Logger, env?: Record<string, string>): Promise<number>;
16
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyaXB0cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NwYXJ0YW4vdXRpbHMvc2NyaXB0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQTRCcEQ7O0dBRUc7QUFDSCx3QkFBZ0IsaUJBQWlCLElBQUksTUFBTSxDQVcxQztBQUVELHdCQUFnQixXQUFXLFdBRTFCO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsd0JBQWdCLFdBQVcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxtQkFFdkY7QUFFRCx3QkFBZ0IsZ0JBQWdCLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxtQkFHNUcifQ==
20
+ export declare function runAztecBin(args: string[], logger: Logger, env?: Record<string, string>): Promise<ScriptResult>;
21
+ /**
22
+ * Runs a script from the project root
23
+ * @param script - The path to the script, relative to the project root
24
+ * @param args - The arguments to pass to the script
25
+ * @param logger - The logger to use
26
+ * @param env - Optional environment variables to set for the process
27
+ * @returns The exit code, stdout, and stderr of the script
28
+ */
29
+ export declare function runProjectScript(script: string, args: string[], logger: Logger, env?: Record<string, string>): Promise<ScriptResult>;
30
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyaXB0cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NwYXJ0YW4vdXRpbHMvc2NyaXB0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUtwRCxtQ0FBbUM7QUFDbkMsTUFBTSxNQUFNLFlBQVksR0FBRztJQUN6QixRQUFRLEVBQUUsTUFBTSxDQUFDO0lBQ2pCLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDZixNQUFNLEVBQUUsTUFBTSxDQUFDO0NBQ2hCLENBQUM7QUF5Q0Y7O0dBRUc7QUFDSCx3QkFBZ0IsaUJBQWlCLElBQUksTUFBTSxDQVcxQztBQUVELHdCQUFnQixXQUFXLFdBRTFCO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsd0JBQWdCLFdBQVcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FFL0c7QUFFRDs7Ozs7OztHQU9HO0FBQ0gsd0JBQWdCLGdCQUFnQixDQUM5QixNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxNQUFNLEVBQUUsRUFDZCxNQUFNLEVBQUUsTUFBTSxFQUNkLEdBQUcsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLEdBQzNCLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FHdkIifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AA4BpD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C;AAED,wBAAgB,WAAW,WAE1B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBAEvF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBAG5G"}
1
+ {"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,mCAAmC;AACnC,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAyCF;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C;AAED,wBAAgB,WAAW,WAE1B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAE/G;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,OAAO,CAAC,YAAY,CAAC,CAGvB"}
@@ -4,7 +4,7 @@ import path from 'path';
4
4
  * @param scriptPath - The path to the script, relative to the project root
5
5
  * @param args - The arguments to pass to the script
6
6
  * @param logger - The logger to use
7
- * @returns The exit code of the script
7
+ * @returns The exit code, stdout, and stderr of the script
8
8
  */ function runScript(scriptPath, args, logger, env) {
9
9
  const childProcess = spawn(scriptPath, args, {
10
10
  stdio: [
@@ -17,13 +17,21 @@ import path from 'path';
17
17
  ...env
18
18
  } : process.env
19
19
  });
20
+ const stdoutChunks = [];
21
+ const stderrChunks = [];
20
22
  return new Promise((resolve, reject)=>{
21
- childProcess.on('close', (code)=>resolve(code ?? 0));
23
+ childProcess.on('close', (code)=>resolve({
24
+ exitCode: code ?? 0,
25
+ stdout: Buffer.concat(stdoutChunks).toString(),
26
+ stderr: Buffer.concat(stderrChunks).toString()
27
+ }));
22
28
  childProcess.on('error', reject);
23
29
  childProcess.stdout?.on('data', (data)=>{
30
+ stdoutChunks.push(data);
24
31
  logger.info(data.toString());
25
32
  });
26
33
  childProcess.stderr?.on('data', (data)=>{
34
+ stderrChunks.push(data);
27
35
  logger.error(data.toString());
28
36
  });
29
37
  });
@@ -53,14 +61,21 @@ export function getAztecBin() {
53
61
  * @param args - The arguments to pass to the Aztec binary
54
62
  * @param logger - The logger to use
55
63
  * @param env - Optional environment variables to set for the process
56
- * @returns The exit code of the Aztec binary
64
+ * @returns The exit code, stdout, and stderr of the Aztec binary
57
65
  */ export function runAztecBin(args, logger, env) {
58
66
  return runScript('node', [
59
67
  getAztecBin(),
60
68
  ...args
61
69
  ], logger, env);
62
70
  }
63
- export function runProjectScript(script, args, logger, env) {
71
+ /**
72
+ * Runs a script from the project root
73
+ * @param script - The path to the script, relative to the project root
74
+ * @param args - The arguments to pass to the script
75
+ * @param logger - The logger to use
76
+ * @param env - Optional environment variables to set for the process
77
+ * @returns The exit code, stdout, and stderr of the script
78
+ */ export function runProjectScript(script, args, logger, env) {
64
79
  const scriptPath = script.startsWith('/') ? script : path.join(getGitProjectRoot(), script);
65
80
  return runScript(scriptPath, args, logger, env);
66
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/end-to-end",
3
- "version": "0.0.1-commit.e61ad554",
3
+ "version": "0.0.1-commit.ee80a48",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "inherits": [
@@ -22,47 +22,48 @@
22
22
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --no-cache --runInBand --config jest.integration.config.json",
23
23
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests src/fixtures",
24
24
  "test:compose": "./scripts/run_test.sh compose",
25
+ "test:ha": "./scripts/run_test.sh ha",
25
26
  "formatting": "run -T prettier --check ./src && run -T eslint ./src"
26
27
  },
27
28
  "dependencies": {
28
- "@aztec/accounts": "0.0.1-commit.e61ad554",
29
- "@aztec/archiver": "0.0.1-commit.e61ad554",
30
- "@aztec/aztec": "0.0.1-commit.e61ad554",
31
- "@aztec/aztec-node": "0.0.1-commit.e61ad554",
32
- "@aztec/aztec.js": "0.0.1-commit.e61ad554",
33
- "@aztec/bb-prover": "0.0.1-commit.e61ad554",
34
- "@aztec/bb.js": "0.0.1-commit.e61ad554",
35
- "@aztec/blob-client": "0.0.1-commit.e61ad554",
36
- "@aztec/blob-lib": "0.0.1-commit.e61ad554",
37
- "@aztec/bot": "0.0.1-commit.e61ad554",
38
- "@aztec/cli": "0.0.1-commit.e61ad554",
39
- "@aztec/constants": "0.0.1-commit.e61ad554",
40
- "@aztec/entrypoints": "0.0.1-commit.e61ad554",
41
- "@aztec/epoch-cache": "0.0.1-commit.e61ad554",
42
- "@aztec/ethereum": "0.0.1-commit.e61ad554",
43
- "@aztec/foundation": "0.0.1-commit.e61ad554",
44
- "@aztec/kv-store": "0.0.1-commit.e61ad554",
45
- "@aztec/l1-artifacts": "0.0.1-commit.e61ad554",
46
- "@aztec/merkle-tree": "0.0.1-commit.e61ad554",
47
- "@aztec/node-keystore": "0.0.1-commit.e61ad554",
48
- "@aztec/noir-contracts.js": "0.0.1-commit.e61ad554",
49
- "@aztec/noir-noirc_abi": "0.0.1-commit.e61ad554",
50
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.e61ad554",
51
- "@aztec/noir-test-contracts.js": "0.0.1-commit.e61ad554",
52
- "@aztec/p2p": "0.0.1-commit.e61ad554",
53
- "@aztec/protocol-contracts": "0.0.1-commit.e61ad554",
54
- "@aztec/prover-client": "0.0.1-commit.e61ad554",
55
- "@aztec/prover-node": "0.0.1-commit.e61ad554",
56
- "@aztec/pxe": "0.0.1-commit.e61ad554",
57
- "@aztec/sequencer-client": "0.0.1-commit.e61ad554",
58
- "@aztec/simulator": "0.0.1-commit.e61ad554",
59
- "@aztec/slasher": "0.0.1-commit.e61ad554",
60
- "@aztec/stdlib": "0.0.1-commit.e61ad554",
61
- "@aztec/telemetry-client": "0.0.1-commit.e61ad554",
62
- "@aztec/test-wallet": "0.0.1-commit.e61ad554",
63
- "@aztec/validator-client": "0.0.1-commit.e61ad554",
64
- "@aztec/validator-ha-signer": "0.0.1-commit.e61ad554",
65
- "@aztec/world-state": "0.0.1-commit.e61ad554",
29
+ "@aztec/accounts": "0.0.1-commit.ee80a48",
30
+ "@aztec/archiver": "0.0.1-commit.ee80a48",
31
+ "@aztec/aztec": "0.0.1-commit.ee80a48",
32
+ "@aztec/aztec-node": "0.0.1-commit.ee80a48",
33
+ "@aztec/aztec.js": "0.0.1-commit.ee80a48",
34
+ "@aztec/bb-prover": "0.0.1-commit.ee80a48",
35
+ "@aztec/bb.js": "0.0.1-commit.ee80a48",
36
+ "@aztec/blob-client": "0.0.1-commit.ee80a48",
37
+ "@aztec/blob-lib": "0.0.1-commit.ee80a48",
38
+ "@aztec/bot": "0.0.1-commit.ee80a48",
39
+ "@aztec/cli": "0.0.1-commit.ee80a48",
40
+ "@aztec/constants": "0.0.1-commit.ee80a48",
41
+ "@aztec/entrypoints": "0.0.1-commit.ee80a48",
42
+ "@aztec/epoch-cache": "0.0.1-commit.ee80a48",
43
+ "@aztec/ethereum": "0.0.1-commit.ee80a48",
44
+ "@aztec/foundation": "0.0.1-commit.ee80a48",
45
+ "@aztec/kv-store": "0.0.1-commit.ee80a48",
46
+ "@aztec/l1-artifacts": "0.0.1-commit.ee80a48",
47
+ "@aztec/merkle-tree": "0.0.1-commit.ee80a48",
48
+ "@aztec/node-keystore": "0.0.1-commit.ee80a48",
49
+ "@aztec/noir-contracts.js": "0.0.1-commit.ee80a48",
50
+ "@aztec/noir-noirc_abi": "0.0.1-commit.ee80a48",
51
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.ee80a48",
52
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.ee80a48",
53
+ "@aztec/p2p": "0.0.1-commit.ee80a48",
54
+ "@aztec/protocol-contracts": "0.0.1-commit.ee80a48",
55
+ "@aztec/prover-client": "0.0.1-commit.ee80a48",
56
+ "@aztec/prover-node": "0.0.1-commit.ee80a48",
57
+ "@aztec/pxe": "0.0.1-commit.ee80a48",
58
+ "@aztec/sequencer-client": "0.0.1-commit.ee80a48",
59
+ "@aztec/simulator": "0.0.1-commit.ee80a48",
60
+ "@aztec/slasher": "0.0.1-commit.ee80a48",
61
+ "@aztec/stdlib": "0.0.1-commit.ee80a48",
62
+ "@aztec/telemetry-client": "0.0.1-commit.ee80a48",
63
+ "@aztec/test-wallet": "0.0.1-commit.ee80a48",
64
+ "@aztec/validator-client": "0.0.1-commit.ee80a48",
65
+ "@aztec/validator-ha-signer": "0.0.1-commit.ee80a48",
66
+ "@aztec/world-state": "0.0.1-commit.ee80a48",
66
67
  "@iarna/toml": "^2.2.5",
67
68
  "@jest/globals": "^30.0.0",
68
69
  "@noble/curves": "=1.0.0",
@@ -90,6 +91,7 @@
90
91
  "lodash.every": "^4.6.0",
91
92
  "lodash.omit": "^4.5.0",
92
93
  "msgpackr": "^1.11.2",
94
+ "pg": "^8.17.1",
93
95
  "process": "^0.11.10",
94
96
  "snappy": "^7.2.2",
95
97
  "stream-browserify": "^3.0.0",
@@ -108,6 +110,7 @@
108
110
  "@types/jest": "^30.0.0",
109
111
  "@types/js-yaml": "^4.0.9",
110
112
  "@types/lodash.chunk": "^4.2.9",
113
+ "@types/pg": "^8",
111
114
  "@typescript/native-preview": "7.0.0-dev.20260113.1",
112
115
  "concurrently": "^7.6.0",
113
116
  "jest": "^30.0.0",
@@ -14,13 +14,15 @@ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
14
14
  import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
15
15
  import { SecretValue } from '@aztec/foundation/config';
16
16
  import { randomBytes } from '@aztec/foundation/crypto/random';
17
- import { withLogNameSuffix } from '@aztec/foundation/log';
17
+ import { withLoggerBindings } from '@aztec/foundation/log/server';
18
18
  import { retryUntil } from '@aztec/foundation/retry';
19
19
  import { sleep } from '@aztec/foundation/sleep';
20
20
  import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
21
+ import { TestContract } from '@aztec/noir-test-contracts.js/Test';
21
22
  import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
22
23
  import { ProverNode, type ProverNodeConfig, ProverNodePublisher } from '@aztec/prover-node';
23
24
  import type { TestProverNode } from '@aztec/prover-node/test';
25
+ import type { PXEConfig } from '@aztec/pxe/config';
24
26
  import {
25
27
  type SequencerClient,
26
28
  type SequencerEvents,
@@ -49,7 +51,11 @@ export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
49
51
  export const ARCHIVER_POLL_INTERVAL = 50;
50
52
  export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
51
53
 
52
- export type EpochsTestOpts = Partial<SetupOptions> & { numberOfAccounts?: number };
54
+ export type EpochsTestOpts = Partial<SetupOptions> & {
55
+ numberOfAccounts?: number;
56
+ pxeOpts?: Partial<PXEConfig>;
57
+ aztecSlotDurationInL1Slots?: number;
58
+ };
53
59
 
54
60
  export type TrackedSequencerEvent = {
55
61
  [K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
@@ -94,7 +100,7 @@ export class EpochsTestContext {
94
100
  ? parseInt(process.env.L1_BLOCK_TIME)
95
101
  : DEFAULT_L1_BLOCK_TIME;
96
102
  const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
97
- const aztecSlotDuration = opts.aztecSlotDuration ?? ethereumSlotDuration * 2;
103
+ const aztecSlotDuration = opts.aztecSlotDuration ?? (opts.aztecSlotDurationInL1Slots ?? 2) * ethereumSlotDuration;
98
104
  const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
99
105
  const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
100
106
  const l1PublishingTime = opts.l1PublishingTime ?? 1;
@@ -147,8 +153,9 @@ export class EpochsTestContext {
147
153
  l1PublishingTime,
148
154
  ...opts,
149
155
  },
150
- // Use checkpointed chain tip for PXE to avoid issues with blocks being dropped due to pruned anchor blocks.
151
- { syncChainTip: 'checkpointed' },
156
+ // Use checkpointed chain tip for PXE by default to avoid issues with blocks being dropped due to pruned anchor blocks.
157
+ // Can be overridden via opts.pxeOpts.
158
+ { syncChainTip: 'checkpointed', ...opts.pxeOpts },
152
159
  );
153
160
 
154
161
  this.context = context;
@@ -204,14 +211,14 @@ export class EpochsTestContext {
204
211
  public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
205
212
  this.logger.warn('Creating and syncing a simulated prover node...');
206
213
  const proverNodePrivateKey = this.getNextPrivateKey();
207
- const suffix = (this.proverNodes.length + 1).toString();
208
- const proverNode = await withLogNameSuffix(suffix, () =>
214
+ const proverIndex = this.proverNodes.length + 1;
215
+ const proverNode = await withLoggerBindings({ actor: `prover-${proverIndex}` }, () =>
209
216
  createAndSyncProverNode(
210
217
  proverNodePrivateKey,
211
218
  { ...this.context.config },
212
219
  {
213
220
  dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
214
- proverId: EthAddress.fromNumber(parseInt(suffix, 10)),
221
+ proverId: EthAddress.fromNumber(proverIndex),
215
222
  dontStart: opts.dontStart,
216
223
  ...opts,
217
224
  },
@@ -240,12 +247,13 @@ export class EpochsTestContext {
240
247
  private async createNode(
241
248
  opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
242
249
  ) {
243
- const suffix = (this.nodes.length + 1).toString();
250
+ const nodeIndex = this.nodes.length + 1;
251
+ const actorPrefix = opts.disableValidator ? 'node' : 'validator';
244
252
  const { mockGossipSubNetwork } = this.context;
245
253
  const resolvedConfig = { ...this.context.config, ...opts };
246
254
  const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
247
255
  const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
248
- const node = await withLogNameSuffix(suffix, () =>
256
+ const node = await withLoggerBindings({ actor: `${actorPrefix}-${nodeIndex}` }, () =>
249
257
  AztecNodeService.createAndSync(
250
258
  {
251
259
  ...resolvedConfig,
@@ -375,6 +383,19 @@ export class EpochsTestContext {
375
383
  return SpamContract.at(instance.address, wallet);
376
384
  }
377
385
 
386
+ /** Registers the TestContract on the given wallet. */
387
+ public async registerTestContract(wallet: Wallet, salt = Fr.ZERO) {
388
+ const instance = await getContractInstanceFromInstantiationParams(TestContract.artifact, {
389
+ constructorArgs: [],
390
+ constructorArtifact: undefined,
391
+ salt,
392
+ publicKeys: undefined,
393
+ deployer: undefined,
394
+ });
395
+ await wallet.registerContract(instance, TestContract.artifact);
396
+ return TestContract.at(instance.address, wallet);
397
+ }
398
+
378
399
  /** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */
379
400
  public async createL1Client() {
380
401
  const { client, delayer } = withDelayer(
@@ -15,6 +15,7 @@ const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA;
15
15
  */
16
16
  export async function writeJson(
17
17
  fileName: string,
18
+ checkpointHeader: CheckpointHeader,
18
19
  block: L2Block,
19
20
  l1ToL2Content: Fr[],
20
21
  blobs: Blob[],
@@ -33,12 +34,6 @@ export async function writeJson(
33
34
  return `0x${buffer.toString('hex').padStart(size, '0')}`;
34
35
  };
35
36
 
36
- // Create a checkpoint header for this block
37
- const checkpointHeader = CheckpointHeader.random({
38
- slotNumber: block.slot,
39
- timestamp: block.timestamp,
40
- });
41
-
42
37
  const jsonObject = {
43
38
  populate: {
44
39
  l1ToL2Content: l1ToL2Content.map(value => asHex(value)),