@aztec/end-to-end 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a

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 (64) hide show
  1. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +1 -1
  2. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  3. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -2
  4. package/dest/e2e_epochs/epochs_test.d.ts +1 -1
  5. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  6. package/dest/e2e_epochs/epochs_test.js +11 -6
  7. package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
  8. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  9. package/dest/e2e_l1_publisher/write_json.js +1 -7
  10. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  11. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  12. package/dest/e2e_p2p/reqresp/utils.js +153 -0
  13. package/dest/e2e_p2p/shared.d.ts +1 -1
  14. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  15. package/dest/e2e_p2p/shared.js +5 -2
  16. package/dest/fixtures/e2e_prover_test.js +1 -1
  17. package/dest/fixtures/ha_setup.d.ts +71 -0
  18. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  19. package/dest/fixtures/ha_setup.js +114 -0
  20. package/dest/fixtures/index.d.ts +2 -1
  21. package/dest/fixtures/index.d.ts.map +1 -1
  22. package/dest/fixtures/index.js +1 -0
  23. package/dest/fixtures/setup.d.ts +3 -3
  24. package/dest/fixtures/setup.d.ts.map +1 -1
  25. package/dest/fixtures/setup.js +19 -14
  26. package/dest/fixtures/setup_p2p_test.d.ts +12 -8
  27. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  28. package/dest/fixtures/setup_p2p_test.js +29 -21
  29. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  30. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  31. package/dest/shared/uniswap_l1_l2.js +7 -5
  32. package/dest/spartan/utils/config.d.ts +4 -1
  33. package/dest/spartan/utils/config.d.ts.map +1 -1
  34. package/dest/spartan/utils/config.js +2 -1
  35. package/dest/spartan/utils/index.d.ts +4 -4
  36. package/dest/spartan/utils/index.d.ts.map +1 -1
  37. package/dest/spartan/utils/index.js +2 -2
  38. package/dest/spartan/utils/k8s.d.ts +29 -1
  39. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  40. package/dest/spartan/utils/k8s.js +118 -0
  41. package/dest/spartan/utils/nodes.d.ts +11 -1
  42. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  43. package/dest/spartan/utils/nodes.js +198 -27
  44. package/dest/spartan/utils/scripts.d.ts +18 -4
  45. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  46. package/dest/spartan/utils/scripts.js +19 -4
  47. package/package.json +42 -39
  48. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +3 -4
  49. package/src/e2e_epochs/epochs_test.ts +7 -6
  50. package/src/e2e_l1_publisher/write_json.ts +1 -6
  51. package/src/e2e_p2p/reqresp/utils.ts +207 -0
  52. package/src/e2e_p2p/shared.ts +11 -2
  53. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  54. package/src/fixtures/e2e_prover_test.ts +1 -1
  55. package/src/fixtures/ha_setup.ts +184 -0
  56. package/src/fixtures/index.ts +1 -0
  57. package/src/fixtures/setup.ts +12 -12
  58. package/src/fixtures/setup_p2p_test.ts +31 -27
  59. package/src/shared/uniswap_l1_l2.ts +7 -9
  60. package/src/spartan/utils/config.ts +1 -0
  61. package/src/spartan/utils/index.ts +3 -1
  62. package/src/spartan/utils/k8s.ts +152 -0
  63. package/src/spartan/utils/nodes.ts +239 -24
  64. package/src/spartan/utils/scripts.ts +43 -7
@@ -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.29c6b1a3",
3
+ "version": "0.0.1-commit.2eb6648a",
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.29c6b1a3",
29
- "@aztec/archiver": "0.0.1-commit.29c6b1a3",
30
- "@aztec/aztec": "0.0.1-commit.29c6b1a3",
31
- "@aztec/aztec-node": "0.0.1-commit.29c6b1a3",
32
- "@aztec/aztec.js": "0.0.1-commit.29c6b1a3",
33
- "@aztec/bb-prover": "0.0.1-commit.29c6b1a3",
34
- "@aztec/bb.js": "0.0.1-commit.29c6b1a3",
35
- "@aztec/blob-client": "0.0.1-commit.29c6b1a3",
36
- "@aztec/blob-lib": "0.0.1-commit.29c6b1a3",
37
- "@aztec/bot": "0.0.1-commit.29c6b1a3",
38
- "@aztec/cli": "0.0.1-commit.29c6b1a3",
39
- "@aztec/constants": "0.0.1-commit.29c6b1a3",
40
- "@aztec/entrypoints": "0.0.1-commit.29c6b1a3",
41
- "@aztec/epoch-cache": "0.0.1-commit.29c6b1a3",
42
- "@aztec/ethereum": "0.0.1-commit.29c6b1a3",
43
- "@aztec/foundation": "0.0.1-commit.29c6b1a3",
44
- "@aztec/kv-store": "0.0.1-commit.29c6b1a3",
45
- "@aztec/l1-artifacts": "0.0.1-commit.29c6b1a3",
46
- "@aztec/merkle-tree": "0.0.1-commit.29c6b1a3",
47
- "@aztec/node-keystore": "0.0.1-commit.29c6b1a3",
48
- "@aztec/noir-contracts.js": "0.0.1-commit.29c6b1a3",
49
- "@aztec/noir-noirc_abi": "0.0.1-commit.29c6b1a3",
50
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.29c6b1a3",
51
- "@aztec/noir-test-contracts.js": "0.0.1-commit.29c6b1a3",
52
- "@aztec/p2p": "0.0.1-commit.29c6b1a3",
53
- "@aztec/protocol-contracts": "0.0.1-commit.29c6b1a3",
54
- "@aztec/prover-client": "0.0.1-commit.29c6b1a3",
55
- "@aztec/prover-node": "0.0.1-commit.29c6b1a3",
56
- "@aztec/pxe": "0.0.1-commit.29c6b1a3",
57
- "@aztec/sequencer-client": "0.0.1-commit.29c6b1a3",
58
- "@aztec/simulator": "0.0.1-commit.29c6b1a3",
59
- "@aztec/slasher": "0.0.1-commit.29c6b1a3",
60
- "@aztec/stdlib": "0.0.1-commit.29c6b1a3",
61
- "@aztec/telemetry-client": "0.0.1-commit.29c6b1a3",
62
- "@aztec/test-wallet": "0.0.1-commit.29c6b1a3",
63
- "@aztec/validator-client": "0.0.1-commit.29c6b1a3",
64
- "@aztec/validator-ha-signer": "0.0.1-commit.29c6b1a3",
65
- "@aztec/world-state": "0.0.1-commit.29c6b1a3",
29
+ "@aztec/accounts": "0.0.1-commit.2eb6648a",
30
+ "@aztec/archiver": "0.0.1-commit.2eb6648a",
31
+ "@aztec/aztec": "0.0.1-commit.2eb6648a",
32
+ "@aztec/aztec-node": "0.0.1-commit.2eb6648a",
33
+ "@aztec/aztec.js": "0.0.1-commit.2eb6648a",
34
+ "@aztec/bb-prover": "0.0.1-commit.2eb6648a",
35
+ "@aztec/bb.js": "0.0.1-commit.2eb6648a",
36
+ "@aztec/blob-client": "0.0.1-commit.2eb6648a",
37
+ "@aztec/blob-lib": "0.0.1-commit.2eb6648a",
38
+ "@aztec/bot": "0.0.1-commit.2eb6648a",
39
+ "@aztec/cli": "0.0.1-commit.2eb6648a",
40
+ "@aztec/constants": "0.0.1-commit.2eb6648a",
41
+ "@aztec/entrypoints": "0.0.1-commit.2eb6648a",
42
+ "@aztec/epoch-cache": "0.0.1-commit.2eb6648a",
43
+ "@aztec/ethereum": "0.0.1-commit.2eb6648a",
44
+ "@aztec/foundation": "0.0.1-commit.2eb6648a",
45
+ "@aztec/kv-store": "0.0.1-commit.2eb6648a",
46
+ "@aztec/l1-artifacts": "0.0.1-commit.2eb6648a",
47
+ "@aztec/merkle-tree": "0.0.1-commit.2eb6648a",
48
+ "@aztec/node-keystore": "0.0.1-commit.2eb6648a",
49
+ "@aztec/noir-contracts.js": "0.0.1-commit.2eb6648a",
50
+ "@aztec/noir-noirc_abi": "0.0.1-commit.2eb6648a",
51
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.2eb6648a",
52
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.2eb6648a",
53
+ "@aztec/p2p": "0.0.1-commit.2eb6648a",
54
+ "@aztec/protocol-contracts": "0.0.1-commit.2eb6648a",
55
+ "@aztec/prover-client": "0.0.1-commit.2eb6648a",
56
+ "@aztec/prover-node": "0.0.1-commit.2eb6648a",
57
+ "@aztec/pxe": "0.0.1-commit.2eb6648a",
58
+ "@aztec/sequencer-client": "0.0.1-commit.2eb6648a",
59
+ "@aztec/simulator": "0.0.1-commit.2eb6648a",
60
+ "@aztec/slasher": "0.0.1-commit.2eb6648a",
61
+ "@aztec/stdlib": "0.0.1-commit.2eb6648a",
62
+ "@aztec/telemetry-client": "0.0.1-commit.2eb6648a",
63
+ "@aztec/test-wallet": "0.0.1-commit.2eb6648a",
64
+ "@aztec/validator-client": "0.0.1-commit.2eb6648a",
65
+ "@aztec/validator-ha-signer": "0.0.1-commit.2eb6648a",
66
+ "@aztec/world-state": "0.0.1-commit.2eb6648a",
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",
@@ -13,7 +13,7 @@ import type {
13
13
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
14
14
  import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
15
15
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
16
- import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
16
+ import { EpochNumber } from '@aztec/foundation/branded-types';
17
17
  import { sleep } from '@aztec/foundation/sleep';
18
18
  import { TestERC20Abi, TestERC20Bytecode } from '@aztec/l1-artifacts';
19
19
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
@@ -86,9 +86,8 @@ export class CrossChainMessagingTest {
86
86
  }
87
87
 
88
88
  async advanceToEpochProven(l2TxReceipt: TxReceipt): Promise<EpochNumber> {
89
- const epoch = await this.rollup.getEpochNumberForCheckpoint(
90
- CheckpointNumber.fromBlockNumber(l2TxReceipt.blockNumber!),
91
- );
89
+ const block = await this.aztecNode.getBlock(l2TxReceipt.blockNumber!);
90
+ const epoch = await this.rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
92
91
  // Warp to the next epoch.
93
92
  await this.cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
94
93
  // Wait for the tx to be proven.
@@ -14,7 +14,7 @@ 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';
@@ -211,14 +211,14 @@ export class EpochsTestContext {
211
211
  public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
212
212
  this.logger.warn('Creating and syncing a simulated prover node...');
213
213
  const proverNodePrivateKey = this.getNextPrivateKey();
214
- const suffix = (this.proverNodes.length + 1).toString();
215
- const proverNode = await withLogNameSuffix(suffix, () =>
214
+ const proverIndex = this.proverNodes.length + 1;
215
+ const proverNode = await withLoggerBindings({ actor: `prover-${proverIndex}` }, () =>
216
216
  createAndSyncProverNode(
217
217
  proverNodePrivateKey,
218
218
  { ...this.context.config },
219
219
  {
220
220
  dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
221
- proverId: EthAddress.fromNumber(parseInt(suffix, 10)),
221
+ proverId: EthAddress.fromNumber(proverIndex),
222
222
  dontStart: opts.dontStart,
223
223
  ...opts,
224
224
  },
@@ -247,12 +247,13 @@ export class EpochsTestContext {
247
247
  private async createNode(
248
248
  opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
249
249
  ) {
250
- const suffix = (this.nodes.length + 1).toString();
250
+ const nodeIndex = this.nodes.length + 1;
251
+ const actorPrefix = opts.disableValidator ? 'node' : 'validator';
251
252
  const { mockGossipSubNetwork } = this.context;
252
253
  const resolvedConfig = { ...this.context.config, ...opts };
253
254
  const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
254
255
  const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
255
- const node = await withLogNameSuffix(suffix, () =>
256
+ const node = await withLoggerBindings({ actor: `${actorPrefix}-${nodeIndex}` }, () =>
256
257
  AztecNodeService.createAndSync(
257
258
  {
258
259
  ...resolvedConfig,
@@ -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)),
@@ -0,0 +1,207 @@
1
+ import type { AztecNodeService } from '@aztec/aztec-node';
2
+ import { createLogger } from '@aztec/aztec.js/log';
3
+ import { waitForTx } from '@aztec/aztec.js/node';
4
+ import { Tx } from '@aztec/aztec.js/tx';
5
+ import { RollupContract } from '@aztec/ethereum/contracts';
6
+ import { SlotNumber } from '@aztec/foundation/branded-types';
7
+ import { timesAsync } from '@aztec/foundation/collection';
8
+ import { retryUntil } from '@aztec/foundation/retry';
9
+
10
+ import { jest } from '@jest/globals';
11
+ import fs from 'fs';
12
+ import os from 'os';
13
+ import path from 'path';
14
+
15
+ import { shouldCollectMetrics } from '../../fixtures/fixtures.js';
16
+ import { createNodes } from '../../fixtures/setup_p2p_test.js';
17
+ import { P2PNetworkTest, SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES, WAIT_FOR_TX_TIMEOUT } from '../p2p_network.js';
18
+ import { prepareTransactions } from '../shared.js';
19
+
20
+ // Don't set this to a higher value than 9 because each node will use a different L1 publisher account and anvil seeds
21
+ export const NUM_VALIDATORS = 6;
22
+ export const NUM_TXS_PER_NODE = 2;
23
+ export const BOOT_NODE_UDP_PORT = 4500;
24
+
25
+ export const createReqrespDataDir = () => fs.mkdtempSync(path.join(os.tmpdir(), 'reqresp-'));
26
+
27
+ type ReqrespOptions = {
28
+ disableStatusHandshake?: boolean;
29
+ };
30
+
31
+ export async function createReqrespTest(options: ReqrespOptions = {}): Promise<P2PNetworkTest> {
32
+ const { disableStatusHandshake = false } = options;
33
+ const t = await P2PNetworkTest.create({
34
+ testName: 'e2e_p2p_reqresp_tx',
35
+ numberOfNodes: 0,
36
+ numberOfValidators: NUM_VALIDATORS,
37
+ basePort: BOOT_NODE_UDP_PORT,
38
+ // To collect metrics - run in aztec-packages `docker compose --profile metrics up`
39
+ metricsPort: shouldCollectMetrics(),
40
+ initialConfig: {
41
+ ...SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES,
42
+ aztecSlotDuration: 24,
43
+ ...(disableStatusHandshake ? { p2pDisableStatusHandshake: true } : {}),
44
+ listenAddress: '127.0.0.1',
45
+ aztecEpochDuration: 64, // stable committee
46
+ },
47
+ });
48
+ await t.setup();
49
+ await t.applyBaseSetup();
50
+ return t;
51
+ }
52
+
53
+ export async function cleanupReqrespTest(params: { t: P2PNetworkTest; nodes?: AztecNodeService[]; dataDir: string }) {
54
+ const { t, nodes, dataDir } = params;
55
+ if (nodes) {
56
+ await t.stopNodes(nodes);
57
+ }
58
+ await t.teardown();
59
+ for (let i = 0; i < NUM_VALIDATORS; i++) {
60
+ fs.rmSync(`${dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
61
+ }
62
+ }
63
+
64
+ const getNodePort = (nodeIndex: number) => BOOT_NODE_UDP_PORT + 1 + nodeIndex;
65
+
66
+ export async function runReqrespTxTest(params: {
67
+ t: P2PNetworkTest;
68
+ dataDir: string;
69
+ disableStatusHandshake?: boolean;
70
+ }): Promise<AztecNodeService[]> {
71
+ const { t, dataDir, disableStatusHandshake = false } = params;
72
+
73
+ if (!t.bootstrapNodeEnr) {
74
+ throw new Error('Bootstrap node ENR is not available');
75
+ }
76
+
77
+ t.logger.info('Creating nodes');
78
+ const aztecNodeConfig = disableStatusHandshake
79
+ ? { ...t.ctx.aztecNodeConfig, p2pDisableStatusHandshake: true }
80
+ : t.ctx.aztecNodeConfig;
81
+
82
+ const nodes = await createNodes(
83
+ aztecNodeConfig,
84
+ t.ctx.dateProvider!,
85
+ t.bootstrapNodeEnr,
86
+ NUM_VALIDATORS,
87
+ BOOT_NODE_UDP_PORT,
88
+ t.prefilledPublicData,
89
+ dataDir,
90
+ shouldCollectMetrics(),
91
+ );
92
+
93
+ t.logger.info('Waiting for nodes to connect');
94
+ await t.waitForP2PMeshConnectivity(nodes, NUM_VALIDATORS);
95
+
96
+ await t.setupAccount();
97
+
98
+ const targetBlockNumber = await t.ctx.aztecNodeService!.getBlockNumber();
99
+ await retryUntil(
100
+ async () => {
101
+ const blockNumbers = await Promise.all(nodes.map(node => node.getBlockNumber()));
102
+ return blockNumbers.every(blockNumber => blockNumber >= targetBlockNumber) ? true : undefined;
103
+ },
104
+ `validators to sync to L2 block ${targetBlockNumber}`,
105
+ 60,
106
+ 0.5,
107
+ );
108
+
109
+ t.logger.info('Preparing transactions to send');
110
+ const txBatches = await timesAsync(2, () =>
111
+ prepareTransactions(t.logger, t.ctx.aztecNodeService!, NUM_TXS_PER_NODE, t.fundedAccount),
112
+ );
113
+
114
+ t.logger.info('Removing initial node');
115
+ await t.removeInitialNode();
116
+
117
+ t.logger.info('Starting fresh slot');
118
+ const [timestamp] = await t.ctx.cheatCodes.rollup.advanceToNextSlot();
119
+ t.ctx.dateProvider!.setTime(Number(timestamp) * 1000);
120
+ const startSlotTimestamp = BigInt(timestamp);
121
+
122
+ const { proposerIndexes, nodesToTurnOffTxGossip } = await getProposerIndexes(t, startSlotTimestamp);
123
+ t.logger.info(`Turning off tx gossip for nodes: ${nodesToTurnOffTxGossip.map(getNodePort)}`);
124
+ t.logger.info(`Sending txs to proposer nodes: ${proposerIndexes.map(getNodePort)}`);
125
+
126
+ // Replace the p2p node implementation of some of the nodes with a spy such that it does not store transactions that are gossiped to it
127
+ // Original implementation of `handleGossipedTx` will store received transactions in the tx pool.
128
+ // We chose the first 2 nodes that will be the proposers for the next few slots
129
+ for (const nodeIndex of nodesToTurnOffTxGossip) {
130
+ const logger = createLogger(`p2p:${getNodePort(nodeIndex)}`);
131
+ jest.spyOn((nodes[nodeIndex] as any).p2pClient.p2pService, 'handleGossipedTx').mockImplementation(((
132
+ payloadData: Buffer,
133
+ ) => {
134
+ const txHash = Tx.fromBuffer(payloadData).getTxHash();
135
+ logger.info(`Skipping storage of gossiped transaction ${txHash.toString()}`);
136
+ return Promise.resolve();
137
+ }) as any);
138
+ }
139
+
140
+ // We send the tx to the proposer nodes directly, ignoring the pxe and node in each context
141
+ // We cannot just call tx.send since they were created using a pxe wired to the first node which is now stopped
142
+ t.logger.info('Sending transactions through proposer nodes');
143
+ const submittedTxs = await Promise.all(
144
+ txBatches.map(async (batch, batchIndex) => {
145
+ const proposerNode = nodes[proposerIndexes[batchIndex]];
146
+ await Promise.all(
147
+ batch.map(async tx => {
148
+ try {
149
+ await proposerNode.sendTx(tx);
150
+ } catch (err) {
151
+ t.logger.error(`Error sending tx: ${err}`);
152
+ throw err;
153
+ }
154
+ }),
155
+ );
156
+ return batch.map(tx => ({ node: proposerNode, txHash: tx.getTxHash() }));
157
+ }),
158
+ );
159
+
160
+ t.logger.info('Waiting for all transactions to be mined');
161
+ await Promise.all(
162
+ submittedTxs.flatMap((batch, batchIndex) =>
163
+ batch.map(async (submittedTx, txIndex) => {
164
+ t.logger.info(`Waiting for tx ${batchIndex}-${txIndex} ${submittedTx.txHash.toString()} to be mined`);
165
+ await waitForTx(submittedTx.node, submittedTx.txHash, { timeout: WAIT_FOR_TX_TIMEOUT * 1.5 });
166
+ t.logger.info(`Tx ${batchIndex}-${txIndex} ${submittedTx.txHash.toString()} has been mined`);
167
+ }),
168
+ ),
169
+ );
170
+
171
+ t.logger.info('All transactions mined');
172
+
173
+ return nodes;
174
+ }
175
+
176
+ async function getProposerIndexes(t: P2PNetworkTest, startSlotTimestamp: bigint) {
177
+ // Get the nodes for the next set of slots
178
+ const rollupContract = new RollupContract(
179
+ t.ctx.deployL1ContractsValues.l1Client,
180
+ t.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
181
+ );
182
+
183
+ const attesters = await rollupContract.getAttesters();
184
+ const startSlot = await rollupContract.getSlotAt(startSlotTimestamp);
185
+
186
+ const proposers = await Promise.all(
187
+ Array.from({ length: 3 }, async (_, i) => {
188
+ const slot = SlotNumber(startSlot + i);
189
+ const slotTimestamp = await rollupContract.getTimestampForSlot(slot);
190
+ return await rollupContract.getProposerAt(slotTimestamp);
191
+ }),
192
+ );
193
+ // Get the indexes of the nodes that are responsible for the next two slots
194
+ const proposerIndexes = proposers.map(proposer => attesters.findIndex(a => a.equals(proposer)));
195
+
196
+ if (proposerIndexes.some(i => i === -1)) {
197
+ throw new Error(
198
+ `Proposer index not found for proposer ` +
199
+ `(proposers=${proposers.map(p => p.toString()).join(',')}, indices=${proposerIndexes.join(',')})`,
200
+ );
201
+ }
202
+
203
+ const nodesToTurnOffTxGossip = Array.from({ length: NUM_VALIDATORS }, (_, i) => i).filter(
204
+ i => !proposerIndexes.includes(i),
205
+ );
206
+ return { proposerIndexes, nodesToTurnOffTxGossip };
207
+ }
@@ -56,7 +56,11 @@ export const submitTransactions = async (
56
56
  ): Promise<TxHash[]> => {
57
57
  const rpcConfig = getRpcConfig();
58
58
  rpcConfig.proverEnabled = false;
59
- const wallet = await TestWallet.create(node, { ...getPXEConfig(), proverEnabled: false }, { useLogSuffix: true });
59
+ const wallet = await TestWallet.create(
60
+ node,
61
+ { ...getPXEConfig(), proverEnabled: false },
62
+ { loggerActorLabel: 'pxe-tx' },
63
+ );
60
64
  const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
61
65
  return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
62
66
  };
@@ -70,7 +74,11 @@ export async function prepareTransactions(
70
74
  const rpcConfig = getRpcConfig();
71
75
  rpcConfig.proverEnabled = false;
72
76
 
73
- const wallet = await TestWallet.create(node, { ...getPXEConfig(), proverEnabled: false }, { useLogSuffix: true });
77
+ const wallet = await TestWallet.create(
78
+ node,
79
+ { ...getPXEConfig(), proverEnabled: false },
80
+ { loggerActorLabel: 'pxe-tx' },
81
+ );
74
82
  const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
75
83
 
76
84
  const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
@@ -137,6 +145,7 @@ export async function awaitCommitteeExists({
137
145
  'non-empty committee',
138
146
  60,
139
147
  );
148
+ logger.warn(`Committee has been formed`, { committee: committee!.map(c => c.toString()) });
140
149
  return committee!.map(c => c.toString() as `0x${string}`);
141
150
  }
142
151