@aztec/end-to-end 0.0.1-commit.59e663cd → 0.0.1-commit.5cf06de3
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.
- package/dest/e2e_epochs/epochs_test.d.ts +2 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +12 -7
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -7
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +153 -0
- package/dest/e2e_p2p/shared.d.ts +1 -1
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +2 -2
- package/dest/fixtures/e2e_prover_test.js +1 -1
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +114 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +3 -3
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +19 -14
- package/dest/fixtures/setup_p2p_test.d.ts +4 -5
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +24 -19
- package/dest/spartan/tx_metrics.d.ts +35 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +150 -0
- package/dest/spartan/utils/config.d.ts +4 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +2 -1
- package/dest/spartan/utils/index.d.ts +4 -4
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +2 -2
- package/dest/spartan/utils/k8s.d.ts +29 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +118 -0
- package/dest/spartan/utils/nodes.d.ts +11 -1
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +198 -27
- package/dest/spartan/utils/scripts.d.ts +18 -4
- package/dest/spartan/utils/scripts.d.ts.map +1 -1
- package/dest/spartan/utils/scripts.js +19 -4
- package/package.json +42 -39
- package/src/e2e_epochs/epochs_test.ts +13 -8
- package/src/e2e_l1_publisher/write_json.ts +1 -6
- package/src/e2e_p2p/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +10 -2
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +1 -1
- package/src/fixtures/ha_setup.ts +184 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +12 -12
- package/src/fixtures/setup_p2p_test.ts +15 -20
- package/src/spartan/tx_metrics.ts +126 -0
- package/src/spartan/utils/config.ts +1 -0
- package/src/spartan/utils/index.ts +3 -1
- package/src/spartan/utils/k8s.ts +152 -0
- package/src/spartan/utils/nodes.ts +239 -24
- 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(
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.0.1-commit.5cf06de3",
|
|
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.
|
|
29
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
30
|
-
"@aztec/aztec": "0.0.1-commit.
|
|
31
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
32
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
33
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
34
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
35
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
36
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
37
|
-
"@aztec/bot": "0.0.1-commit.
|
|
38
|
-
"@aztec/cli": "0.0.1-commit.
|
|
39
|
-
"@aztec/constants": "0.0.1-commit.
|
|
40
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
41
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
42
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
43
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
44
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
45
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
46
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
47
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
48
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
49
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
50
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
51
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
52
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
53
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
54
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
55
|
-
"@aztec/prover-node": "0.0.1-commit.
|
|
56
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
57
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
58
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
59
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
60
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
61
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
62
|
-
"@aztec/test-wallet": "0.0.1-commit.
|
|
63
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
64
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
65
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
29
|
+
"@aztec/accounts": "0.0.1-commit.5cf06de3",
|
|
30
|
+
"@aztec/archiver": "0.0.1-commit.5cf06de3",
|
|
31
|
+
"@aztec/aztec": "0.0.1-commit.5cf06de3",
|
|
32
|
+
"@aztec/aztec-node": "0.0.1-commit.5cf06de3",
|
|
33
|
+
"@aztec/aztec.js": "0.0.1-commit.5cf06de3",
|
|
34
|
+
"@aztec/bb-prover": "0.0.1-commit.5cf06de3",
|
|
35
|
+
"@aztec/bb.js": "0.0.1-commit.5cf06de3",
|
|
36
|
+
"@aztec/blob-client": "0.0.1-commit.5cf06de3",
|
|
37
|
+
"@aztec/blob-lib": "0.0.1-commit.5cf06de3",
|
|
38
|
+
"@aztec/bot": "0.0.1-commit.5cf06de3",
|
|
39
|
+
"@aztec/cli": "0.0.1-commit.5cf06de3",
|
|
40
|
+
"@aztec/constants": "0.0.1-commit.5cf06de3",
|
|
41
|
+
"@aztec/entrypoints": "0.0.1-commit.5cf06de3",
|
|
42
|
+
"@aztec/epoch-cache": "0.0.1-commit.5cf06de3",
|
|
43
|
+
"@aztec/ethereum": "0.0.1-commit.5cf06de3",
|
|
44
|
+
"@aztec/foundation": "0.0.1-commit.5cf06de3",
|
|
45
|
+
"@aztec/kv-store": "0.0.1-commit.5cf06de3",
|
|
46
|
+
"@aztec/l1-artifacts": "0.0.1-commit.5cf06de3",
|
|
47
|
+
"@aztec/merkle-tree": "0.0.1-commit.5cf06de3",
|
|
48
|
+
"@aztec/node-keystore": "0.0.1-commit.5cf06de3",
|
|
49
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.5cf06de3",
|
|
50
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.5cf06de3",
|
|
51
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.5cf06de3",
|
|
52
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.5cf06de3",
|
|
53
|
+
"@aztec/p2p": "0.0.1-commit.5cf06de3",
|
|
54
|
+
"@aztec/protocol-contracts": "0.0.1-commit.5cf06de3",
|
|
55
|
+
"@aztec/prover-client": "0.0.1-commit.5cf06de3",
|
|
56
|
+
"@aztec/prover-node": "0.0.1-commit.5cf06de3",
|
|
57
|
+
"@aztec/pxe": "0.0.1-commit.5cf06de3",
|
|
58
|
+
"@aztec/sequencer-client": "0.0.1-commit.5cf06de3",
|
|
59
|
+
"@aztec/simulator": "0.0.1-commit.5cf06de3",
|
|
60
|
+
"@aztec/slasher": "0.0.1-commit.5cf06de3",
|
|
61
|
+
"@aztec/stdlib": "0.0.1-commit.5cf06de3",
|
|
62
|
+
"@aztec/telemetry-client": "0.0.1-commit.5cf06de3",
|
|
63
|
+
"@aztec/test-wallet": "0.0.1-commit.5cf06de3",
|
|
64
|
+
"@aztec/validator-client": "0.0.1-commit.5cf06de3",
|
|
65
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.5cf06de3",
|
|
66
|
+
"@aztec/world-state": "0.0.1-commit.5cf06de3",
|
|
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,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 {
|
|
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';
|
|
@@ -51,7 +51,11 @@ export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
|
|
|
51
51
|
export const ARCHIVER_POLL_INTERVAL = 50;
|
|
52
52
|
export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
|
|
53
53
|
|
|
54
|
-
export type EpochsTestOpts = Partial<SetupOptions> & {
|
|
54
|
+
export type EpochsTestOpts = Partial<SetupOptions> & {
|
|
55
|
+
numberOfAccounts?: number;
|
|
56
|
+
pxeOpts?: Partial<PXEConfig>;
|
|
57
|
+
aztecSlotDurationInL1Slots?: number;
|
|
58
|
+
};
|
|
55
59
|
|
|
56
60
|
export type TrackedSequencerEvent = {
|
|
57
61
|
[K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
|
|
@@ -96,7 +100,7 @@ export class EpochsTestContext {
|
|
|
96
100
|
? parseInt(process.env.L1_BLOCK_TIME)
|
|
97
101
|
: DEFAULT_L1_BLOCK_TIME;
|
|
98
102
|
const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
|
|
99
|
-
const aztecSlotDuration = opts.aztecSlotDuration ??
|
|
103
|
+
const aztecSlotDuration = opts.aztecSlotDuration ?? (opts.aztecSlotDurationInL1Slots ?? 2) * ethereumSlotDuration;
|
|
100
104
|
const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
|
|
101
105
|
const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
|
|
102
106
|
const l1PublishingTime = opts.l1PublishingTime ?? 1;
|
|
@@ -207,14 +211,14 @@ export class EpochsTestContext {
|
|
|
207
211
|
public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
|
|
208
212
|
this.logger.warn('Creating and syncing a simulated prover node...');
|
|
209
213
|
const proverNodePrivateKey = this.getNextPrivateKey();
|
|
210
|
-
const
|
|
211
|
-
const proverNode = await
|
|
214
|
+
const proverIndex = this.proverNodes.length + 1;
|
|
215
|
+
const proverNode = await withLoggerBindings({ actor: `prover-${proverIndex}` }, () =>
|
|
212
216
|
createAndSyncProverNode(
|
|
213
217
|
proverNodePrivateKey,
|
|
214
218
|
{ ...this.context.config },
|
|
215
219
|
{
|
|
216
220
|
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
|
|
217
|
-
proverId: EthAddress.fromNumber(
|
|
221
|
+
proverId: EthAddress.fromNumber(proverIndex),
|
|
218
222
|
dontStart: opts.dontStart,
|
|
219
223
|
...opts,
|
|
220
224
|
},
|
|
@@ -243,12 +247,13 @@ export class EpochsTestContext {
|
|
|
243
247
|
private async createNode(
|
|
244
248
|
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
245
249
|
) {
|
|
246
|
-
const
|
|
250
|
+
const nodeIndex = this.nodes.length + 1;
|
|
251
|
+
const actorPrefix = opts.disableValidator ? 'node' : 'validator';
|
|
247
252
|
const { mockGossipSubNetwork } = this.context;
|
|
248
253
|
const resolvedConfig = { ...this.context.config, ...opts };
|
|
249
254
|
const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
|
|
250
255
|
const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
|
|
251
|
-
const node = await
|
|
256
|
+
const node = await withLoggerBindings({ actor: `${actorPrefix}-${nodeIndex}` }, () =>
|
|
252
257
|
AztecNodeService.createAndSync(
|
|
253
258
|
{
|
|
254
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
|
+
}
|
package/src/e2e_p2p/shared.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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, {
|