@aztec/end-to-end 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +26 -15
- 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 +10 -30
- package/dest/bench/utils.d.ts +3 -12
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +17 -37
- 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 +13 -10
- 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 +20 -12
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +36 -27
- 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 +13 -9
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +39 -40
- 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 +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +238 -18
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +50 -25
- 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 +57 -56
- 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 +13 -11
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +57 -66
- package/dest/fixtures/fixtures.d.ts +2 -3
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +2 -3
- 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_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 +16 -15
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +84 -88
- 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 +44 -47
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +128 -185
- 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 +13 -9
- 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 +101 -16
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +414 -52
- package/package.json +43 -40
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +143 -115
- package/src/bench/client_flows/data_extractor.ts +9 -31
- package/src/bench/utils.ts +15 -39
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +46 -55
- package/src/e2e_deploy_contract/deploy_test.ts +18 -36
- package/src/e2e_epochs/epochs_test.ts +59 -42
- package/src/e2e_fees/bridging_race.notest.ts +16 -11
- package/src/e2e_fees/fees_test.ts +48 -52
- 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 +179 -0
- package/src/e2e_p2p/p2p_network.ts +125 -89
- package/src/e2e_p2p/shared.ts +69 -60
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +65 -105
- package/src/fixtures/fixtures.ts +2 -5
- 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_p2p_test.ts +79 -32
- package/src/fixtures/snapshot_manager.ts +120 -131
- package/src/fixtures/token_utils.ts +16 -24
- package/src/fixtures/utils.ts +175 -269
- 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 +80 -88
- 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 +543 -45
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
- package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.js +0 -17
- package/src/fixtures/setup_l1_contracts.ts +0 -26
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { AztecAddress
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { L2Block } from '@aztec/aztec.js/block';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import { BatchedBlob, Blob, getEthBlobEvaluationInputs, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
3
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
6
|
|
|
5
7
|
import { writeFile } from 'fs/promises';
|
|
@@ -32,23 +34,24 @@ export async function writeJson(
|
|
|
32
34
|
|
|
33
35
|
const jsonObject = {
|
|
34
36
|
populate: {
|
|
35
|
-
l1ToL2Content: l1ToL2Content.map(asHex),
|
|
37
|
+
l1ToL2Content: l1ToL2Content.map(value => asHex(value)),
|
|
36
38
|
recipient: asHex(recipientAddress.toField()),
|
|
37
39
|
sender: deployerAddress,
|
|
38
40
|
},
|
|
39
41
|
messages: {
|
|
40
|
-
l2ToL1Messages: block.body.txEffects.flatMap(txEffect => txEffect.l2ToL1Msgs).map(asHex),
|
|
42
|
+
l2ToL1Messages: block.body.txEffects.flatMap(txEffect => txEffect.l2ToL1Msgs).map(value => asHex(value)),
|
|
41
43
|
},
|
|
42
|
-
|
|
44
|
+
checkpoint: {
|
|
43
45
|
// The json formatting in forge is a bit brittle, so we convert Fr to a number in the few values below.
|
|
44
46
|
// This should not be a problem for testing as long as the values are not larger than u32.
|
|
45
47
|
archive: asHex(block.archive.root),
|
|
46
|
-
blobCommitments:
|
|
47
|
-
batchedBlobInputs:
|
|
48
|
-
|
|
48
|
+
blobCommitments: getPrefixedEthBlobCommitments(blobs),
|
|
49
|
+
batchedBlobInputs: getEthBlobEvaluationInputs(batchedBlob),
|
|
50
|
+
checkpointNumber: block.number,
|
|
49
51
|
body: `0x${block.body.toBuffer().toString('hex')}`,
|
|
50
52
|
header: {
|
|
51
53
|
lastArchiveRoot: asHex(block.header.lastArchive.root),
|
|
54
|
+
blockHeadersHash: asHex(block.header.blockHeadersHash),
|
|
52
55
|
contentCommitment: {
|
|
53
56
|
blobsHash: asHex(block.header.contentCommitment.blobsHash),
|
|
54
57
|
inHash: asHex(block.header.contentCommitment.inHash),
|
|
@@ -64,7 +67,7 @@ export async function writeJson(
|
|
|
64
67
|
},
|
|
65
68
|
totalManaUsed: block.header.totalManaUsed.toNumber(),
|
|
66
69
|
},
|
|
67
|
-
headerHash: asHex(block.
|
|
70
|
+
headerHash: asHex(block.getCheckpointHeader().hash()),
|
|
68
71
|
numTxs: block.body.txEffects.length,
|
|
69
72
|
},
|
|
70
73
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getAddressFromPrivateKey } from '@aztec/ethereum';
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { getAddressFromPrivateKey } from '@aztec/ethereum/account';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import type { EthPrivateKey } from '@aztec/node-keystore';
|
|
5
5
|
|
|
@@ -157,9 +157,7 @@ export async function createKeyFile3(
|
|
|
157
157
|
schemaVersion: 1,
|
|
158
158
|
validators: [
|
|
159
159
|
{
|
|
160
|
-
attester:
|
|
161
|
-
address: validatorAddress.toChecksumString(),
|
|
162
|
-
},
|
|
160
|
+
attester: validatorAddress.toChecksumString(),
|
|
163
161
|
coinbase: coinbase.toChecksumString(),
|
|
164
162
|
publisher: [publisher1Key, publisher2Key],
|
|
165
163
|
feeRecipient: feeRecipient.toString(),
|
|
@@ -193,9 +191,7 @@ export async function createKeyFile4(
|
|
|
193
191
|
},
|
|
194
192
|
validators: [
|
|
195
193
|
{
|
|
196
|
-
attester:
|
|
197
|
-
address: validator1Address.toChecksumString(),
|
|
198
|
-
},
|
|
194
|
+
attester: validator1Address.toChecksumString(),
|
|
199
195
|
coinbase: coinbase1.toChecksumString(),
|
|
200
196
|
publisher: {
|
|
201
197
|
mnemonic: mnemonic,
|
|
@@ -206,9 +202,7 @@ export async function createKeyFile4(
|
|
|
206
202
|
feeRecipient: feeRecipient1.toString(),
|
|
207
203
|
},
|
|
208
204
|
{
|
|
209
|
-
attester:
|
|
210
|
-
address: validator2Address.toChecksumString(),
|
|
211
|
-
},
|
|
205
|
+
attester: validator2Address.toChecksumString(),
|
|
212
206
|
coinbase: coinbase2.toChecksumString(),
|
|
213
207
|
publisher: [publisher2Key, publisher3Key],
|
|
214
208
|
feeRecipient: feeRecipient2.toString(),
|
|
@@ -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,179 @@
|
|
|
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 = 8;
|
|
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
|
+
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION - 1} (slashing will start after it is completed)`);
|
|
155
|
+
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(EpochNumber(SETUP_EPOCH_DURATION - 1));
|
|
156
|
+
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public async teardown() {
|
|
161
|
+
await this.test.stopNodes(this.nodes);
|
|
162
|
+
await this.test.teardown();
|
|
163
|
+
for (let i = 0; i < NUM_NODES; i++) {
|
|
164
|
+
fs.rmSync(`${this.dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public get ctx() {
|
|
169
|
+
return this.test.ctx;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public get logger() {
|
|
173
|
+
return this.test.logger;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public get slashingAmount() {
|
|
177
|
+
return SLASHING_AMOUNT;
|
|
178
|
+
}
|
|
179
|
+
}
|