@aztec/end-to-end 3.0.0-nightly.20251025 → 3.0.0-nightly.20251026
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_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +3 -0
- package/dest/e2e_p2p/p2p_network.d.ts +11 -0
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +24 -0
- package/package.json +37 -37
- package/src/e2e_p2p/inactivity_slash_test.ts +4 -0
- package/src/e2e_p2p/p2p_network.ts +43 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inactivity_slash_test.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/inactivity_slash_test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,eAAe,CAAC;AAKvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiBlD,qBAAa,iBAAiB;aAaV,IAAI,EAAE,cAAc;IAZ/B,KAAK,EAAG,gBAAgB,EAAE,CAAC;IAC3B,WAAW,EAAG,gBAAgB,EAAE,CAAC;IACjC,aAAa,EAAG,gBAAgB,EAAE,CAAC;IAEnC,MAAM,EAAG,cAAc,CAAC;IACxB,iBAAiB,EAAG,UAAU,EAAE,CAAC;IAExC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,eAAe,CAAU;gBAGf,IAAI,EAAE,cAAc,EACpC,IAAI,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE;WAOnD,MAAM,CACjB,Q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,6 +105,9 @@ export class P2PInactivityTest {
|
|
|
105
105
|
validators: this.test.validators,
|
|
106
106
|
offlineValidators: this.offlineValidators
|
|
107
107
|
});
|
|
108
|
+
// Wait for P2P mesh to be fully formed before starting slashing period
|
|
109
|
+
// This prevents race conditions where validators propose blocks before the network is ready
|
|
110
|
+
await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
|
|
108
111
|
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION + 1} to start slashing`);
|
|
109
112
|
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(SETUP_EPOCH_DURATION + 1);
|
|
110
113
|
return this;
|
|
@@ -86,6 +86,17 @@ export declare class P2PNetworkTest {
|
|
|
86
86
|
private _sendDummyTx;
|
|
87
87
|
setup(): Promise<void>;
|
|
88
88
|
stopNodes(nodes: AztecNodeService[]): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
91
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
92
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
93
|
+
*
|
|
94
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
95
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
96
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
97
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
98
|
+
*/
|
|
99
|
+
waitForP2PMeshConnectivity(nodes: AztecNodeService[], expectedNodeCount?: number, timeoutSeconds?: number, checkIntervalSeconds?: number): Promise<void>;
|
|
89
100
|
teardown(): Promise<void>;
|
|
90
101
|
getContracts(): Promise<{
|
|
91
102
|
rollup: RollupContract;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p_network.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/p2p_network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAA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AA,EAC5B,eAAe,CAAC,EAAE,OAAO,EACzB,sBAAsB,CAAC,EAAE,OAAO;WAwDrB,MAAM,CAAC,EAClB,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,eAAe,EACf,sBAAsB,GACvB,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,YAAY,CAAC;QAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;IAwBD,IAAI,aAAa,uBAKhB;IAEK,gBAAgB;IActB,aAAa;;;IAkBP,kBAAkB;IAsElB,YAAY;IAaZ,kBAAkB;IAsBlB,iBAAiB;IAgBjB,WAAW;;;;YAIH,YAAY;IAQpB,KAAK;IAcL,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAAE;IAazC;;;;;;;;;OASG;IACG,0BAA0B,CAC9B,KAAK,EAAE,gBAAgB,EAAE,EACzB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,cAAc,SAAK,EACnB,oBAAoB,SAAM;IA4BtB,QAAQ;IAMR,YAAY,IAAI,OAAO,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,eAAe,EAAE,qBAAqB,CAAC,OAAO,UAAU,EAAE,UAAU,CAAC,CAAC;QACtE,gBAAgB,EAAE,8BAA8B,GAAG,6BAA6B,GAAG,SAAS,CAAC;QAC7F,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CA0BH"}
|
|
@@ -4,6 +4,7 @@ import { GSEContract, MultiAdderArtifact, RollupContract, createL1TxUtilsFromVie
|
|
|
4
4
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
5
5
|
import { SecretValue } from '@aztec/foundation/config';
|
|
6
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
7
8
|
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
8
9
|
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
9
10
|
import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
|
|
@@ -266,6 +267,29 @@ export class P2PNetworkTest {
|
|
|
266
267
|
await Promise.all(nodes.map((node)=>node.stop()));
|
|
267
268
|
this.logger.info('Nodes stopped');
|
|
268
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
272
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
273
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
274
|
+
*
|
|
275
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
276
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
277
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
278
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
279
|
+
*/ async waitForP2PMeshConnectivity(nodes, expectedNodeCount, timeoutSeconds = 30, checkIntervalSeconds = 0.1) {
|
|
280
|
+
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
281
|
+
const minPeerCount = nodeCount - 1;
|
|
282
|
+
this.logger.warn(`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`);
|
|
283
|
+
await Promise.all(nodes.map(async (node, index)=>{
|
|
284
|
+
const p2p = node.getP2P();
|
|
285
|
+
await retryUntil(async ()=>{
|
|
286
|
+
const peers = await p2p.getPeers();
|
|
287
|
+
// Each node should be connected to at least N-1 other nodes
|
|
288
|
+
return peers.length >= minPeerCount ? true : undefined;
|
|
289
|
+
}, `Node ${index} to connect to at least ${minPeerCount} peers`, timeoutSeconds, checkIntervalSeconds);
|
|
290
|
+
}));
|
|
291
|
+
this.logger.warn('All nodes connected to P2P mesh');
|
|
292
|
+
}
|
|
269
293
|
async teardown() {
|
|
270
294
|
await this.monitor.stop();
|
|
271
295
|
await tryStop(this.bootstrapNode, this.logger);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/end-to-end",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251026",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"inherits": [
|
|
@@ -25,42 +25,42 @@
|
|
|
25
25
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aztec/accounts": "3.0.0-nightly.
|
|
29
|
-
"@aztec/archiver": "3.0.0-nightly.
|
|
30
|
-
"@aztec/aztec": "3.0.0-nightly.
|
|
31
|
-
"@aztec/aztec-node": "3.0.0-nightly.
|
|
32
|
-
"@aztec/aztec.js": "3.0.0-nightly.
|
|
33
|
-
"@aztec/bb-prover": "3.0.0-nightly.
|
|
34
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
35
|
-
"@aztec/blob-sink": "3.0.0-nightly.
|
|
36
|
-
"@aztec/bot": "3.0.0-nightly.
|
|
37
|
-
"@aztec/cli": "3.0.0-nightly.
|
|
38
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
39
|
-
"@aztec/entrypoints": "3.0.0-nightly.
|
|
40
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
41
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
42
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
43
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
44
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
45
|
-
"@aztec/merkle-tree": "3.0.0-nightly.
|
|
46
|
-
"@aztec/node-keystore": "3.0.0-nightly.
|
|
47
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
48
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
49
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
50
|
-
"@aztec/noir-test-contracts.js": "3.0.0-nightly.
|
|
51
|
-
"@aztec/p2p": "3.0.0-nightly.
|
|
52
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
53
|
-
"@aztec/prover-client": "3.0.0-nightly.
|
|
54
|
-
"@aztec/prover-node": "3.0.0-nightly.
|
|
55
|
-
"@aztec/pxe": "3.0.0-nightly.
|
|
56
|
-
"@aztec/sequencer-client": "3.0.0-nightly.
|
|
57
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
58
|
-
"@aztec/slasher": "3.0.0-nightly.
|
|
59
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
60
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
61
|
-
"@aztec/test-wallet": "3.0.0-nightly.
|
|
62
|
-
"@aztec/validator-client": "3.0.0-nightly.
|
|
63
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
28
|
+
"@aztec/accounts": "3.0.0-nightly.20251026",
|
|
29
|
+
"@aztec/archiver": "3.0.0-nightly.20251026",
|
|
30
|
+
"@aztec/aztec": "3.0.0-nightly.20251026",
|
|
31
|
+
"@aztec/aztec-node": "3.0.0-nightly.20251026",
|
|
32
|
+
"@aztec/aztec.js": "3.0.0-nightly.20251026",
|
|
33
|
+
"@aztec/bb-prover": "3.0.0-nightly.20251026",
|
|
34
|
+
"@aztec/blob-lib": "3.0.0-nightly.20251026",
|
|
35
|
+
"@aztec/blob-sink": "3.0.0-nightly.20251026",
|
|
36
|
+
"@aztec/bot": "3.0.0-nightly.20251026",
|
|
37
|
+
"@aztec/cli": "3.0.0-nightly.20251026",
|
|
38
|
+
"@aztec/constants": "3.0.0-nightly.20251026",
|
|
39
|
+
"@aztec/entrypoints": "3.0.0-nightly.20251026",
|
|
40
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20251026",
|
|
41
|
+
"@aztec/ethereum": "3.0.0-nightly.20251026",
|
|
42
|
+
"@aztec/foundation": "3.0.0-nightly.20251026",
|
|
43
|
+
"@aztec/kv-store": "3.0.0-nightly.20251026",
|
|
44
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251026",
|
|
45
|
+
"@aztec/merkle-tree": "3.0.0-nightly.20251026",
|
|
46
|
+
"@aztec/node-keystore": "3.0.0-nightly.20251026",
|
|
47
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251026",
|
|
48
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251026",
|
|
49
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251026",
|
|
50
|
+
"@aztec/noir-test-contracts.js": "3.0.0-nightly.20251026",
|
|
51
|
+
"@aztec/p2p": "3.0.0-nightly.20251026",
|
|
52
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251026",
|
|
53
|
+
"@aztec/prover-client": "3.0.0-nightly.20251026",
|
|
54
|
+
"@aztec/prover-node": "3.0.0-nightly.20251026",
|
|
55
|
+
"@aztec/pxe": "3.0.0-nightly.20251026",
|
|
56
|
+
"@aztec/sequencer-client": "3.0.0-nightly.20251026",
|
|
57
|
+
"@aztec/simulator": "3.0.0-nightly.20251026",
|
|
58
|
+
"@aztec/slasher": "3.0.0-nightly.20251026",
|
|
59
|
+
"@aztec/stdlib": "3.0.0-nightly.20251026",
|
|
60
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251026",
|
|
61
|
+
"@aztec/test-wallet": "3.0.0-nightly.20251026",
|
|
62
|
+
"@aztec/validator-client": "3.0.0-nightly.20251026",
|
|
63
|
+
"@aztec/world-state": "3.0.0-nightly.20251026",
|
|
64
64
|
"@iarna/toml": "^2.2.5",
|
|
65
65
|
"@jest/globals": "^30.0.0",
|
|
66
66
|
"@noble/curves": "=1.0.0",
|
|
@@ -146,6 +146,10 @@ export class P2PInactivityTest {
|
|
|
146
146
|
offlineValidators: this.offlineValidators,
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
+
// Wait for P2P mesh to be fully formed before starting slashing period
|
|
150
|
+
// This prevents race conditions where validators propose blocks before the network is ready
|
|
151
|
+
await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
|
|
152
|
+
|
|
149
153
|
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION + 1} to start slashing`);
|
|
150
154
|
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(SETUP_EPOCH_DURATION + 1);
|
|
151
155
|
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
19
19
|
import { SecretValue } from '@aztec/foundation/config';
|
|
20
20
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
21
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
21
22
|
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
22
23
|
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
23
24
|
import type { BootstrapNode } from '@aztec/p2p/bootstrap';
|
|
@@ -389,6 +390,48 @@ export class P2PNetworkTest {
|
|
|
389
390
|
this.logger.info('Nodes stopped');
|
|
390
391
|
}
|
|
391
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
395
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
396
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
397
|
+
*
|
|
398
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
399
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
400
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
401
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
402
|
+
*/
|
|
403
|
+
async waitForP2PMeshConnectivity(
|
|
404
|
+
nodes: AztecNodeService[],
|
|
405
|
+
expectedNodeCount?: number,
|
|
406
|
+
timeoutSeconds = 30,
|
|
407
|
+
checkIntervalSeconds = 0.1,
|
|
408
|
+
) {
|
|
409
|
+
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
410
|
+
const minPeerCount = nodeCount - 1;
|
|
411
|
+
|
|
412
|
+
this.logger.warn(
|
|
413
|
+
`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`,
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
await Promise.all(
|
|
417
|
+
nodes.map(async (node, index) => {
|
|
418
|
+
const p2p = node.getP2P();
|
|
419
|
+
await retryUntil(
|
|
420
|
+
async () => {
|
|
421
|
+
const peers = await p2p.getPeers();
|
|
422
|
+
// Each node should be connected to at least N-1 other nodes
|
|
423
|
+
return peers.length >= minPeerCount ? true : undefined;
|
|
424
|
+
},
|
|
425
|
+
`Node ${index} to connect to at least ${minPeerCount} peers`,
|
|
426
|
+
timeoutSeconds,
|
|
427
|
+
checkIntervalSeconds,
|
|
428
|
+
);
|
|
429
|
+
}),
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
this.logger.warn('All nodes connected to P2P mesh');
|
|
433
|
+
}
|
|
434
|
+
|
|
392
435
|
async teardown() {
|
|
393
436
|
await this.monitor.stop();
|
|
394
437
|
await tryStop(this.bootstrapNode, this.logger);
|