@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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/bench/client_flows/benchmark.d.ts +4 -3
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +25 -14
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +111 -90
- package/dest/bench/client_flows/config.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.js +8 -30
- package/dest/bench/utils.d.ts +4 -13
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +10 -34
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +8 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +12 -9
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +35 -35
- package/dest/e2e_deploy_contract/deploy_test.d.ts +12 -6
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +19 -12
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +30 -22
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +14 -11
- package/dest/e2e_fees/fees_test.d.ts +10 -8
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +35 -38
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +9 -8
- package/dest/e2e_multi_validator/utils.d.ts +2 -2
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +4 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -4
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +11 -12
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +238 -17
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +46 -19
- package/dest/e2e_p2p/shared.d.ts +16 -17
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +56 -55
- package/dest/e2e_token_contract/token_contract_test.d.ts +6 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +12 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +53 -58
- package/dest/fixtures/fixtures.d.ts +1 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +1 -1
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +1 -1
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +2 -2
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +3 -3
- package/dest/fixtures/setup_p2p_test.d.ts +12 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +50 -24
- package/dest/fixtures/snapshot_manager.d.ts +13 -10
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +66 -51
- package/dest/fixtures/token_utils.d.ts +10 -5
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +17 -18
- package/dest/fixtures/utils.d.ts +479 -35
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +106 -125
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +20 -23
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +14 -16
- package/dest/shared/gas_portal_test_harness.d.ts +10 -17
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +11 -8
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +12 -8
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +44 -58
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +4 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +8 -5
- package/dest/simulators/token_simulator.d.ts +4 -2
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +22 -14
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +144 -86
- package/dest/spartan/tx_metrics.d.ts +39 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +95 -0
- package/dest/spartan/utils.d.ts +92 -17
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +386 -63
- package/package.json +43 -40
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +141 -114
- package/src/bench/client_flows/data_extractor.ts +9 -31
- package/src/bench/utils.ts +9 -37
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +38 -51
- package/src/e2e_deploy_contract/deploy_test.ts +18 -36
- package/src/e2e_epochs/epochs_test.ts +41 -35
- package/src/e2e_fees/bridging_race.notest.ts +16 -11
- package/src/e2e_fees/fees_test.ts +42 -47
- package/src/e2e_l1_publisher/write_json.ts +12 -9
- package/src/e2e_multi_validator/utils.ts +5 -11
- package/src/e2e_nested_contract/nested_contract_test.ts +15 -13
- package/src/e2e_p2p/inactivity_slash_test.ts +184 -0
- package/src/e2e_p2p/p2p_network.ts +124 -82
- package/src/e2e_p2p/shared.ts +66 -58
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +60 -97
- package/src/fixtures/fixtures.ts +1 -2
- package/src/fixtures/get_acvm_config.ts +2 -2
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/setup_l1_contracts.ts +5 -4
- package/src/fixtures/setup_p2p_test.ts +79 -32
- package/src/fixtures/snapshot_manager.ts +87 -82
- package/src/fixtures/token_utils.ts +16 -24
- package/src/fixtures/utils.ts +142 -172
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +3 -11
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +23 -31
- package/src/shared/gas_portal_test_harness.ts +14 -21
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +77 -86
- package/src/simulators/lending_simulator.ts +9 -6
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +15 -3
- package/src/spartan/setup_test_wallets.ts +171 -127
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +463 -64
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
5
|
import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
|
|
4
6
|
import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
|
|
5
7
|
|
|
@@ -16,9 +18,9 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
16
18
|
export class NestedContractTest {
|
|
17
19
|
private snapshotManager: ISnapshotManager;
|
|
18
20
|
logger: Logger;
|
|
19
|
-
wallet!:
|
|
21
|
+
wallet!: Wallet;
|
|
20
22
|
defaultAccountAddress!: AztecAddress;
|
|
21
|
-
|
|
23
|
+
aztecNode!: AztecNode;
|
|
22
24
|
|
|
23
25
|
parentContract!: ParentContract;
|
|
24
26
|
childContract!: ChildContract;
|
|
@@ -40,12 +42,11 @@ export class NestedContractTest {
|
|
|
40
42
|
await this.snapshotManager.snapshot(
|
|
41
43
|
'accounts',
|
|
42
44
|
deployAccounts(this.numberOfAccounts, this.logger),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.pxe = pxe;
|
|
45
|
+
({ deployedAccounts }, { wallet, aztecNode }) => {
|
|
46
|
+
this.wallet = wallet;
|
|
47
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
48
|
+
this.aztecNode = aztecNode;
|
|
49
|
+
return Promise.resolve();
|
|
49
50
|
},
|
|
50
51
|
);
|
|
51
52
|
|
|
@@ -85,9 +86,10 @@ export class NestedContractTest {
|
|
|
85
86
|
.deployed();
|
|
86
87
|
return { parentContractAddress: parentContract.address, childContractAddress: childContract.address };
|
|
87
88
|
},
|
|
88
|
-
|
|
89
|
-
this.parentContract =
|
|
90
|
-
this.childContract =
|
|
89
|
+
({ parentContractAddress, childContractAddress }) => {
|
|
90
|
+
this.parentContract = ParentContract.at(parentContractAddress, this.wallet);
|
|
91
|
+
this.childContract = ChildContract.at(childContractAddress, this.wallet);
|
|
92
|
+
return Promise.resolve();
|
|
91
93
|
},
|
|
92
94
|
);
|
|
93
95
|
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
5
|
+
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import 'jest-extended';
|
|
8
|
+
import os from 'os';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
|
|
11
|
+
import { createNodes } from '../fixtures/setup_p2p_test.js';
|
|
12
|
+
import { P2PNetworkTest } from './p2p_network.js';
|
|
13
|
+
|
|
14
|
+
const NUM_NODES = 6;
|
|
15
|
+
const NUM_VALIDATORS = NUM_NODES;
|
|
16
|
+
const COMMITTEE_SIZE = NUM_VALIDATORS;
|
|
17
|
+
const SLASHING_QUORUM = 3;
|
|
18
|
+
const EPOCH_DURATION = 2;
|
|
19
|
+
const SLASHING_ROUND_SIZE_IN_EPOCHS = 2;
|
|
20
|
+
const BOOT_NODE_UDP_PORT = 4500;
|
|
21
|
+
const ETHEREUM_SLOT_DURATION = process.env.CI ? 8 : 4;
|
|
22
|
+
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
23
|
+
const SLASHING_UNIT = BigInt(1e18);
|
|
24
|
+
const SLASHING_AMOUNT = SLASHING_UNIT * 3n;
|
|
25
|
+
|
|
26
|
+
// How many epochs it may take to set everything up, so we dont slash during this period
|
|
27
|
+
const SETUP_EPOCH_DURATION = 5;
|
|
28
|
+
|
|
29
|
+
export class P2PInactivityTest {
|
|
30
|
+
public nodes!: AztecNodeService[];
|
|
31
|
+
public activeNodes!: AztecNodeService[];
|
|
32
|
+
public inactiveNodes!: AztecNodeService[];
|
|
33
|
+
|
|
34
|
+
public rollup!: RollupContract;
|
|
35
|
+
public offlineValidators!: EthAddress[];
|
|
36
|
+
|
|
37
|
+
private dataDir: string;
|
|
38
|
+
private inactiveNodeCount: number;
|
|
39
|
+
private keepInitialNode: boolean;
|
|
40
|
+
|
|
41
|
+
constructor(
|
|
42
|
+
public readonly test: P2PNetworkTest,
|
|
43
|
+
opts: { inactiveNodeCount: number; keepInitialNode?: boolean },
|
|
44
|
+
) {
|
|
45
|
+
this.dataDir = fs.mkdtempSync(path.join(os.tmpdir(), test.testName));
|
|
46
|
+
this.inactiveNodeCount = opts.inactiveNodeCount;
|
|
47
|
+
this.keepInitialNode = opts.keepInitialNode ?? false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static async create(
|
|
51
|
+
testName: string,
|
|
52
|
+
opts: { slashInactivityConsecutiveEpochThreshold: number; inactiveNodeCount: number; keepInitialNode?: boolean },
|
|
53
|
+
) {
|
|
54
|
+
const test = await P2PNetworkTest.create({
|
|
55
|
+
testName,
|
|
56
|
+
numberOfNodes: 0,
|
|
57
|
+
numberOfValidators: NUM_VALIDATORS,
|
|
58
|
+
basePort: BOOT_NODE_UDP_PORT,
|
|
59
|
+
startProverNode: true,
|
|
60
|
+
initialConfig: {
|
|
61
|
+
proverNodeConfig: { proverNodeEpochProvingDelayMs: AZTEC_SLOT_DURATION * 1000 },
|
|
62
|
+
aztecTargetCommitteeSize: COMMITTEE_SIZE,
|
|
63
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
64
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
65
|
+
aztecProofSubmissionEpochs: 1024, // effectively do not reorg
|
|
66
|
+
listenAddress: '127.0.0.1',
|
|
67
|
+
minTxsPerBlock: 0,
|
|
68
|
+
aztecEpochDuration: EPOCH_DURATION,
|
|
69
|
+
validatorReexecute: false,
|
|
70
|
+
sentinelEnabled: true,
|
|
71
|
+
slashingQuorum: SLASHING_QUORUM,
|
|
72
|
+
slashingRoundSizeInEpochs: SLASHING_ROUND_SIZE_IN_EPOCHS,
|
|
73
|
+
slashInactivityTargetPercentage: 0.8,
|
|
74
|
+
slashGracePeriodL2Slots: SETUP_EPOCH_DURATION * EPOCH_DURATION, // do not slash during setup
|
|
75
|
+
slashAmountSmall: SLASHING_UNIT,
|
|
76
|
+
slashAmountMedium: SLASHING_UNIT * 2n,
|
|
77
|
+
slashAmountLarge: SLASHING_UNIT * 3n,
|
|
78
|
+
...opts,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return new P2PInactivityTest(test, opts);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public async setup() {
|
|
85
|
+
await this.test.applyBaseSnapshots();
|
|
86
|
+
await this.test.setup();
|
|
87
|
+
|
|
88
|
+
// Set slashing penalties for inactivity
|
|
89
|
+
const { rollup } = await this.test.getContracts();
|
|
90
|
+
const [activationThreshold, ejectionThreshold, localEjectionThreshold] = await Promise.all([
|
|
91
|
+
rollup.getActivationThreshold(),
|
|
92
|
+
rollup.getEjectionThreshold(),
|
|
93
|
+
rollup.getLocalEjectionThreshold(),
|
|
94
|
+
]);
|
|
95
|
+
const biggestEjection = ejectionThreshold > localEjectionThreshold ? ejectionThreshold : localEjectionThreshold;
|
|
96
|
+
expect(activationThreshold - SLASHING_AMOUNT).toBeLessThan(biggestEjection);
|
|
97
|
+
this.test.ctx.aztecNodeConfig.slashInactivityPenalty = SLASHING_AMOUNT;
|
|
98
|
+
this.rollup = rollup;
|
|
99
|
+
|
|
100
|
+
if (!this.keepInitialNode) {
|
|
101
|
+
await this.test.ctx.aztecNode.stop();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Create all active nodes
|
|
105
|
+
this.activeNodes = await createNodes(
|
|
106
|
+
this.test.ctx.aztecNodeConfig,
|
|
107
|
+
this.test.ctx.dateProvider,
|
|
108
|
+
this.test.bootstrapNodeEnr,
|
|
109
|
+
NUM_NODES - this.inactiveNodeCount - Number(this.keepInitialNode),
|
|
110
|
+
BOOT_NODE_UDP_PORT,
|
|
111
|
+
this.test.prefilledPublicData,
|
|
112
|
+
this.dataDir,
|
|
113
|
+
undefined,
|
|
114
|
+
Number(this.keepInitialNode),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// And the ones with an initially disabled sequencer
|
|
118
|
+
const inactiveConfig = { ...this.test.ctx.aztecNodeConfig, dontStartSequencer: true };
|
|
119
|
+
this.inactiveNodes = await createNodes(
|
|
120
|
+
inactiveConfig,
|
|
121
|
+
this.test.ctx.dateProvider,
|
|
122
|
+
this.test.bootstrapNodeEnr,
|
|
123
|
+
this.inactiveNodeCount,
|
|
124
|
+
BOOT_NODE_UDP_PORT,
|
|
125
|
+
this.test.prefilledPublicData,
|
|
126
|
+
this.dataDir,
|
|
127
|
+
undefined,
|
|
128
|
+
NUM_NODES - this.inactiveNodeCount,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
this.nodes = [
|
|
132
|
+
...(this.keepInitialNode ? [this.test.ctx.aztecNode] : []),
|
|
133
|
+
...this.activeNodes,
|
|
134
|
+
...this.inactiveNodes,
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
if (this.nodes.length !== NUM_NODES) {
|
|
138
|
+
throw new Error(`Expected ${NUM_NODES} nodes but got ${this.nodes.length}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.offlineValidators = this.test.validators
|
|
142
|
+
.slice(this.test.validators.length - this.inactiveNodeCount)
|
|
143
|
+
.map(a => a.attester);
|
|
144
|
+
|
|
145
|
+
this.test.logger.warn(`Setup complete. Offline validators are ${this.offlineValidators.join(', ')}.`, {
|
|
146
|
+
validators: this.test.validators,
|
|
147
|
+
offlineValidators: this.offlineValidators,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Wait for P2P mesh to be fully formed before starting slashing period
|
|
151
|
+
// This prevents race conditions where validators propose blocks before the network is ready
|
|
152
|
+
await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
|
|
153
|
+
|
|
154
|
+
const ethereumSlotDuration = this.test.ctx.aztecNodeConfig.ethereumSlotDuration!;
|
|
155
|
+
this.test.logger.warn(
|
|
156
|
+
`Advancing to epoch ${SETUP_EPOCH_DURATION} (slashing will start after this epoch is complete)`,
|
|
157
|
+
);
|
|
158
|
+
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(EpochNumber(SETUP_EPOCH_DURATION), {
|
|
159
|
+
offset: -ethereumSlotDuration,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public async teardown() {
|
|
166
|
+
await this.test.stopNodes(this.nodes);
|
|
167
|
+
await this.test.teardown();
|
|
168
|
+
for (let i = 0; i < NUM_NODES; i++) {
|
|
169
|
+
fs.rmSync(`${this.dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public get ctx() {
|
|
174
|
+
return this.test.ctx;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public get logger() {
|
|
178
|
+
return this.test.logger;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public get slashingAmount() {
|
|
182
|
+
return SLASHING_AMOUNT;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
2
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
3
2
|
import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
-
import {
|
|
3
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
5
6
|
import {
|
|
6
7
|
type EmpireSlashingProposerContract,
|
|
7
|
-
type ExtendedViemWalletClient,
|
|
8
8
|
GSEContract,
|
|
9
|
-
MultiAdderArtifact,
|
|
10
|
-
type Operator,
|
|
11
9
|
RollupContract,
|
|
12
10
|
type TallySlashingProposerContract,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '@aztec/ethereum';
|
|
11
|
+
} from '@aztec/ethereum/contracts';
|
|
12
|
+
import type { Operator } from '@aztec/ethereum/deploy-l1-contracts';
|
|
13
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contracts';
|
|
14
|
+
import { MultiAdderArtifact } from '@aztec/ethereum/l1-artifacts';
|
|
15
|
+
import { createL1TxUtilsFromViemWallet } from '@aztec/ethereum/l1-tx-utils';
|
|
18
16
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
17
|
+
import type { ExtendedViemWalletClient, ViemClient } from '@aztec/ethereum/types';
|
|
18
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
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';
|
|
@@ -26,6 +27,7 @@ import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
|
26
27
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
27
28
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
28
29
|
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
30
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
29
31
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
30
32
|
|
|
31
33
|
import getPort from 'get-port';
|
|
@@ -43,7 +45,7 @@ import {
|
|
|
43
45
|
createSnapshotManager,
|
|
44
46
|
deployAccounts,
|
|
45
47
|
} from '../fixtures/snapshot_manager.js';
|
|
46
|
-
import { getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
48
|
+
import { type SetupOptions, getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
47
49
|
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
|
|
48
50
|
|
|
49
51
|
// Use a fixed bootstrap node private key so that we can re-use the same snapshot and the nodes can find each other
|
|
@@ -75,18 +77,18 @@ export class P2PNetworkTest {
|
|
|
75
77
|
public prefilledPublicData: PublicDataTreeLeaf[] = [];
|
|
76
78
|
|
|
77
79
|
// The re-execution test needs a wallet and a spam contract
|
|
78
|
-
public wallet?:
|
|
80
|
+
public wallet?: TestWallet;
|
|
79
81
|
public defaultAccountAddress?: AztecAddress;
|
|
80
82
|
public spamContract?: SpamContract;
|
|
81
83
|
|
|
82
84
|
public bootstrapNode?: BootstrapNode;
|
|
83
85
|
|
|
84
86
|
constructor(
|
|
85
|
-
testName: string,
|
|
87
|
+
public readonly testName: string,
|
|
86
88
|
public bootstrapNodeEnr: string,
|
|
87
89
|
public bootNodePort: number,
|
|
88
90
|
public numberOfValidators: number,
|
|
89
|
-
initialValidatorConfig:
|
|
91
|
+
initialValidatorConfig: SetupOptions,
|
|
90
92
|
public numberOfNodes = 0,
|
|
91
93
|
// If set enable metrics collection
|
|
92
94
|
private metricsPort?: number,
|
|
@@ -162,7 +164,7 @@ export class P2PNetworkTest {
|
|
|
162
164
|
numberOfValidators: number;
|
|
163
165
|
basePort?: number;
|
|
164
166
|
metricsPort?: number;
|
|
165
|
-
initialConfig?:
|
|
167
|
+
initialConfig?: SetupOptions;
|
|
166
168
|
startProverNode?: boolean;
|
|
167
169
|
mockZkPassportVerifier?: boolean;
|
|
168
170
|
}) {
|
|
@@ -198,7 +200,7 @@ export class P2PNetworkTest {
|
|
|
198
200
|
|
|
199
201
|
async addBootstrapNode() {
|
|
200
202
|
await this.snapshotManager.snapshot('add-bootstrap-node', async ({ aztecNodeConfig }) => {
|
|
201
|
-
const telemetry = getEndToEndTestTelemetryClient(this.metricsPort);
|
|
203
|
+
const telemetry = await getEndToEndTestTelemetryClient(this.metricsPort);
|
|
202
204
|
this.bootstrapNode = await createBootstrapNodeFromPrivateKey(
|
|
203
205
|
BOOTSTRAP_NODE_PRIVATE_KEY,
|
|
204
206
|
this.bootNodePort,
|
|
@@ -230,88 +232,85 @@ export class P2PNetworkTest {
|
|
|
230
232
|
|
|
231
233
|
async applyBaseSnapshots() {
|
|
232
234
|
await this.addBootstrapNode();
|
|
233
|
-
await this.snapshotManager.snapshot(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
client: deployL1ContractsValues.l1Client,
|
|
240
|
-
});
|
|
235
|
+
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, cheatCodes }) => {
|
|
236
|
+
const rollup = getContract({
|
|
237
|
+
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
238
|
+
abi: RollupAbi,
|
|
239
|
+
client: deployL1ContractsValues.l1Client,
|
|
240
|
+
});
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
const stakingAsset = getContract({
|
|
245
|
+
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
246
|
+
abi: TestERC20Abi,
|
|
247
|
+
client: deployL1ContractsValues.l1Client,
|
|
248
|
+
});
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
250
|
+
const { address: multiAdderAddress } = await deployL1Contract(
|
|
251
|
+
deployL1ContractsValues.l1Client,
|
|
252
|
+
MultiAdderArtifact.contractAbi,
|
|
253
|
+
MultiAdderArtifact.contractBytecode,
|
|
254
|
+
[rollup.address, deployL1ContractsValues.l1Client.account.address],
|
|
255
|
+
);
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
const multiAdder = getContract({
|
|
258
|
+
address: multiAdderAddress.toString(),
|
|
259
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
260
|
+
client: deployL1ContractsValues.l1Client,
|
|
261
|
+
});
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
const stakeNeeded = (await rollup.read.getActivationThreshold()) * BigInt(this.numberOfValidators);
|
|
264
|
+
await Promise.all(
|
|
265
|
+
[await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
|
|
266
|
+
deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
|
|
267
|
+
),
|
|
268
|
+
);
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
const { validators } = this.getValidators();
|
|
271
|
+
this.validators = validators;
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
274
|
+
if (!gseAddress) {
|
|
275
|
+
throw new Error('GSE contract not deployed');
|
|
276
|
+
}
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
279
279
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
};
|
|
280
|
+
const makeValidatorTuples = async (validator: Operator) => {
|
|
281
|
+
const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
|
|
282
|
+
return {
|
|
283
|
+
attester: validator.attester.toString() as `0x${string}`,
|
|
284
|
+
withdrawer: validator.withdrawer.toString() as `0x${string}`,
|
|
285
|
+
...registrationTuple,
|
|
287
286
|
};
|
|
288
|
-
|
|
287
|
+
};
|
|
288
|
+
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
289
289
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const timestamp = await cheatCodes.rollup.advanceToEpoch(2n, { updateDateProvider: dateProvider });
|
|
290
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
291
|
+
hash: await multiAdder.write.addValidators([validatorTuples]),
|
|
292
|
+
});
|
|
295
293
|
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
295
|
+
EpochNumber.fromBigInt(
|
|
296
|
+
BigInt(await cheatCodes.rollup.getEpoch()) + (await rollup.read.getLagInEpochsForValidatorSet()) + 1n,
|
|
297
|
+
),
|
|
298
|
+
);
|
|
298
299
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
},
|
|
303
|
-
);
|
|
300
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
301
|
+
await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
302
|
+
});
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
async setupAccount() {
|
|
307
306
|
await this.snapshotManager.snapshot(
|
|
308
307
|
'setup-account',
|
|
309
|
-
deployAccounts(1, this.logger
|
|
310
|
-
|
|
308
|
+
deployAccounts(1, this.logger),
|
|
309
|
+
({ deployedAccounts }, { wallet }) => {
|
|
311
310
|
this.deployedAccounts = deployedAccounts;
|
|
312
|
-
|
|
313
|
-
this.wallet =
|
|
314
|
-
|
|
311
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
312
|
+
this.wallet = wallet;
|
|
313
|
+
return Promise.resolve();
|
|
315
314
|
},
|
|
316
315
|
);
|
|
317
316
|
}
|
|
@@ -329,11 +328,12 @@ export class P2PNetworkTest {
|
|
|
329
328
|
.deployed();
|
|
330
329
|
return { contractAddress: spamContract.address };
|
|
331
330
|
},
|
|
332
|
-
|
|
331
|
+
({ contractAddress }) => {
|
|
333
332
|
if (!this.wallet) {
|
|
334
333
|
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
335
334
|
}
|
|
336
|
-
this.spamContract =
|
|
335
|
+
this.spamContract = SpamContract.at(contractAddress, this.wallet);
|
|
336
|
+
return Promise.resolve();
|
|
337
337
|
},
|
|
338
338
|
);
|
|
339
339
|
}
|
|
@@ -393,6 +393,48 @@ export class P2PNetworkTest {
|
|
|
393
393
|
this.logger.info('Nodes stopped');
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
398
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
399
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
400
|
+
*
|
|
401
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
402
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
403
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
404
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
405
|
+
*/
|
|
406
|
+
async waitForP2PMeshConnectivity(
|
|
407
|
+
nodes: AztecNodeService[],
|
|
408
|
+
expectedNodeCount?: number,
|
|
409
|
+
timeoutSeconds = 30,
|
|
410
|
+
checkIntervalSeconds = 0.1,
|
|
411
|
+
) {
|
|
412
|
+
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
413
|
+
const minPeerCount = nodeCount - 1;
|
|
414
|
+
|
|
415
|
+
this.logger.warn(
|
|
416
|
+
`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`,
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
await Promise.all(
|
|
420
|
+
nodes.map(async (node, index) => {
|
|
421
|
+
const p2p = node.getP2P();
|
|
422
|
+
await retryUntil(
|
|
423
|
+
async () => {
|
|
424
|
+
const peers = await p2p.getPeers();
|
|
425
|
+
// Each node should be connected to at least N-1 other nodes
|
|
426
|
+
return peers.length >= minPeerCount ? true : undefined;
|
|
427
|
+
},
|
|
428
|
+
`Node ${index} to connect to at least ${minPeerCount} peers`,
|
|
429
|
+
timeoutSeconds,
|
|
430
|
+
checkIntervalSeconds,
|
|
431
|
+
);
|
|
432
|
+
}),
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
this.logger.warn('All nodes connected to P2P mesh');
|
|
436
|
+
}
|
|
437
|
+
|
|
396
438
|
async teardown() {
|
|
397
439
|
await this.monitor.stop();
|
|
398
440
|
await tryStop(this.bootstrapNode, this.logger);
|
|
@@ -415,7 +457,7 @@ export class P2PNetworkTest {
|
|
|
415
457
|
);
|
|
416
458
|
|
|
417
459
|
const slasherContract = getContract({
|
|
418
|
-
address: getAddress(await rollup.
|
|
460
|
+
address: getAddress(await rollup.getSlasherAddress()),
|
|
419
461
|
abi: SlasherAbi,
|
|
420
462
|
client: this.ctx.deployL1ContractsValues.l1Client,
|
|
421
463
|
});
|