@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.023c3e5
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 +62 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +281 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +321 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +41 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
- 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 +114 -102
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
- 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 +104 -104
- package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +26 -27
- package/dest/e2e_epochs/epochs_test.d.ts +71 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +260 -54
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +61 -0
- package/dest/e2e_fees/fees_test.d.ts +38 -23
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +162 -183
- package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +56 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
- 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 +281 -27
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +237 -175
- 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 +44 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +165 -27
- package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +96 -74
- package/dest/fixtures/e2e_prover_test.d.ts +55 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +278 -0
- package/dest/fixtures/fixtures.d.ts +6 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +5 -5
- 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 +3 -15
- 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 +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +695 -0
- package/dest/fixtures/setup_p2p_test.d.ts +15 -15
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +96 -31
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +31 -12
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- 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/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +44 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +105 -51
- package/dest/shared/gas_portal_test_harness.d.ts +33 -25
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +2 -2
- package/dest/shared/index.d.ts.map +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 +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +176 -126
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +17 -18
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +27 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +233 -62
- package/dest/spartan/tx_metrics.d.ts +88 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +422 -0
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +126 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +375 -0
- package/dest/spartan/utils/nodes.d.ts +41 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- package/package.json +66 -58
- package/src/bench/client_flows/benchmark.ts +363 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +41 -85
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
- package/src/e2e_deploy_contract/deploy_test.ts +40 -48
- package/src/e2e_epochs/epochs_test.ts +341 -81
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +220 -258
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +341 -234
- package/src/e2e_p2p/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +260 -39
- package/src/e2e_token_contract/token_contract_test.ts +115 -126
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +336 -0
- package/src/fixtures/fixtures.ts +5 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup.ts +1017 -0
- package/src/fixtures/setup_p2p_test.ts +133 -50
- package/src/fixtures/token_utils.ts +33 -15
- package/src/fixtures/utils.ts +27 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +103 -91
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +18 -20
- package/src/shared/uniswap_l1_l2.ts +197 -221
- package/src/simulators/lending_simulator.ts +16 -17
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +308 -95
- package/src/spartan/tx_metrics.ts +376 -0
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +64 -0
- package/src/spartan/utils/k8s.ts +527 -0
- package/src/spartan/utils/nodes.ts +538 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -582
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/e2e_prover/e2e_prover_test.js +0 -291
- 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/dest/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -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
|
@@ -1,67 +1,288 @@
|
|
|
1
|
-
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
3
2
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { NO_WAIT, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
7
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
8
|
+
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
9
|
+
import type {
|
|
10
|
+
EmpireSlashingProposerContract,
|
|
11
|
+
RollupContract,
|
|
12
|
+
TallySlashingProposerContract,
|
|
13
|
+
} from '@aztec/ethereum/contracts';
|
|
14
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
15
|
+
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
16
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
18
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
19
|
+
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
20
|
+
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
21
|
+
import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
22
|
+
import { getRoundForOffense } from '@aztec/slasher';
|
|
23
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
24
|
+
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
25
|
+
import { type ProvenTx, TestWallet, proveInteraction } from '@aztec/test-wallet/server';
|
|
7
26
|
|
|
8
|
-
import type { NodeContext } from '../fixtures/setup_p2p_test.js';
|
|
9
27
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
10
28
|
|
|
11
29
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
12
30
|
export const submitComplexTxsTo = async (
|
|
13
31
|
logger: Logger,
|
|
32
|
+
from: AztecAddress,
|
|
14
33
|
spamContract: SpamContract,
|
|
15
34
|
numTxs: number,
|
|
16
35
|
opts: { callPublic?: boolean } = {},
|
|
17
36
|
) => {
|
|
18
|
-
const txs:
|
|
37
|
+
const txs: TxHash[] = [];
|
|
19
38
|
|
|
20
39
|
const seed = 1234n;
|
|
21
40
|
const spamCount = 15;
|
|
22
41
|
for (let i = 0; i < numTxs; i++) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
logger.info(`Tx sent with hash ${txHash}`);
|
|
29
|
-
const receipt = await tx.getReceipt();
|
|
30
|
-
expect(receipt).toEqual(
|
|
31
|
-
expect.objectContaining({
|
|
32
|
-
status: TxStatus.PENDING,
|
|
33
|
-
error: '',
|
|
34
|
-
}),
|
|
35
|
-
);
|
|
36
|
-
logger.info(`Receipt received for ${txHash}`);
|
|
37
|
-
txs.push(tx);
|
|
42
|
+
const method = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic);
|
|
43
|
+
const txHash = await method.send({ from, wait: NO_WAIT });
|
|
44
|
+
logger.info(`Tx sent with hash ${txHash.toString()}`);
|
|
45
|
+
txs.push(txHash);
|
|
38
46
|
}
|
|
39
47
|
return txs;
|
|
40
48
|
};
|
|
41
49
|
|
|
42
|
-
// creates
|
|
43
|
-
export const
|
|
50
|
+
// creates a wallet and submit a given number of transactions through it.
|
|
51
|
+
export const submitTransactions = async (
|
|
44
52
|
logger: Logger,
|
|
45
53
|
node: AztecNodeService,
|
|
46
54
|
numTxs: number,
|
|
47
55
|
fundedAccount: InitialAccountData,
|
|
48
|
-
): Promise<
|
|
56
|
+
): Promise<TxHash[]> => {
|
|
49
57
|
const rpcConfig = getRpcConfig();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
fundedAccount.signingKey,
|
|
56
|
-
fundedAccount.salt,
|
|
58
|
+
rpcConfig.proverEnabled = false;
|
|
59
|
+
const wallet = await TestWallet.create(
|
|
60
|
+
node,
|
|
61
|
+
{ ...getPXEConfig(), proverEnabled: false },
|
|
62
|
+
{ loggerActorLabel: 'pxe-tx' },
|
|
57
63
|
);
|
|
58
|
-
await
|
|
59
|
-
|
|
64
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
65
|
+
return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
|
|
66
|
+
};
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
export async function prepareTransactions(
|
|
69
|
+
logger: Logger,
|
|
70
|
+
node: AztecNodeService,
|
|
71
|
+
numTxs: number,
|
|
72
|
+
fundedAccount: InitialAccountData,
|
|
73
|
+
): Promise<ProvenTx[]> {
|
|
74
|
+
const rpcConfig = getRpcConfig();
|
|
75
|
+
rpcConfig.proverEnabled = false;
|
|
76
|
+
|
|
77
|
+
const wallet = await TestWallet.create(
|
|
65
78
|
node,
|
|
66
|
-
|
|
67
|
-
}
|
|
79
|
+
{ ...getPXEConfig(), proverEnabled: false },
|
|
80
|
+
{ loggerActorLabel: 'pxe-tx' },
|
|
81
|
+
);
|
|
82
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
83
|
+
|
|
84
|
+
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
85
|
+
salt: Fr.random(),
|
|
86
|
+
});
|
|
87
|
+
await wallet.registerContract(testContractInstance, TestContractArtifact);
|
|
88
|
+
const contract = TestContract.at(testContractInstance.address, wallet);
|
|
89
|
+
|
|
90
|
+
return timesAsync(numTxs, async () => {
|
|
91
|
+
const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
|
|
92
|
+
from: fundedAccountManager.address,
|
|
93
|
+
});
|
|
94
|
+
logger.info(`Tx prepared with hash ${tx.getTxHash()}`);
|
|
95
|
+
return tx;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function awaitProposalExecution(
|
|
100
|
+
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract,
|
|
101
|
+
timeoutSeconds: number,
|
|
102
|
+
logger: Logger,
|
|
103
|
+
): Promise<bigint> {
|
|
104
|
+
return new Promise<bigint>((resolve, reject) => {
|
|
105
|
+
const timeout = setTimeout(() => {
|
|
106
|
+
logger.warn(`Timed out waiting for proposal execution`);
|
|
107
|
+
reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
|
|
108
|
+
}, timeoutSeconds * 1000);
|
|
109
|
+
|
|
110
|
+
if (slashingProposer.type === 'empire') {
|
|
111
|
+
const unwatch = slashingProposer.listenToPayloadSubmitted(args => {
|
|
112
|
+
logger.warn(`Proposal ${args.payload} from round ${args.round} executed`);
|
|
113
|
+
clearTimeout(timeout);
|
|
114
|
+
unwatch();
|
|
115
|
+
resolve(args.round);
|
|
116
|
+
});
|
|
117
|
+
} else if (slashingProposer.type === 'tally') {
|
|
118
|
+
const unwatch = slashingProposer.listenToRoundExecuted(args => {
|
|
119
|
+
logger.warn(`Slash from round ${args.round} executed`);
|
|
120
|
+
clearTimeout(timeout);
|
|
121
|
+
unwatch();
|
|
122
|
+
resolve(args.round);
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
clearTimeout(timeout);
|
|
126
|
+
reject(new Error(`Unknown slashing proposer type: ${(slashingProposer as any).type}`));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function awaitCommitteeExists({
|
|
132
|
+
rollup,
|
|
133
|
+
logger,
|
|
134
|
+
}: {
|
|
135
|
+
rollup: RollupContract;
|
|
136
|
+
logger: Logger;
|
|
137
|
+
}): Promise<readonly `0x${string}`[]> {
|
|
138
|
+
logger.info(`Waiting for committee to be set`);
|
|
139
|
+
let committee: EthAddress[] | undefined;
|
|
140
|
+
await retryUntil(
|
|
141
|
+
async () => {
|
|
142
|
+
committee = await rollup.getCurrentEpochCommittee();
|
|
143
|
+
return committee && committee.length > 0;
|
|
144
|
+
},
|
|
145
|
+
'non-empty committee',
|
|
146
|
+
60,
|
|
147
|
+
);
|
|
148
|
+
return committee!.map(c => c.toString() as `0x${string}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export async function awaitOffenseDetected({
|
|
152
|
+
logger,
|
|
153
|
+
nodeAdmin,
|
|
154
|
+
slashingRoundSize,
|
|
155
|
+
epochDuration,
|
|
156
|
+
waitUntilOffenseCount,
|
|
157
|
+
timeoutSeconds = 120,
|
|
158
|
+
}: {
|
|
159
|
+
nodeAdmin: AztecNodeAdmin;
|
|
160
|
+
logger: Logger;
|
|
161
|
+
slashingRoundSize: number;
|
|
162
|
+
epochDuration: number;
|
|
163
|
+
waitUntilOffenseCount?: number;
|
|
164
|
+
timeoutSeconds?: number;
|
|
165
|
+
}) {
|
|
166
|
+
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
167
|
+
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
168
|
+
const offenses = await retryUntil(
|
|
169
|
+
async () => {
|
|
170
|
+
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
171
|
+
if (offenses.length >= targetOffenseCount) {
|
|
172
|
+
return offenses;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
'non-empty offenses',
|
|
176
|
+
timeoutSeconds,
|
|
177
|
+
);
|
|
178
|
+
logger.info(
|
|
179
|
+
`Hit ${offenses.length} offenses on rounds ${unique(offenses.map(o => getRoundForOffense(o, { slashingRoundSize, epochDuration })))}`,
|
|
180
|
+
{ offenses },
|
|
181
|
+
);
|
|
182
|
+
return offenses;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Await the committee to be slashed out of the validator set.
|
|
187
|
+
* Currently assumes that the committee is the same size as the validator set.
|
|
188
|
+
*/
|
|
189
|
+
export async function awaitCommitteeKicked({
|
|
190
|
+
rollup,
|
|
191
|
+
cheatCodes,
|
|
192
|
+
committee,
|
|
193
|
+
slashFactory,
|
|
194
|
+
slashingProposer,
|
|
195
|
+
slashingRoundSize,
|
|
196
|
+
aztecSlotDuration,
|
|
197
|
+
aztecEpochDuration,
|
|
198
|
+
logger,
|
|
199
|
+
offenseEpoch,
|
|
200
|
+
}: {
|
|
201
|
+
rollup: RollupContract;
|
|
202
|
+
cheatCodes: RollupCheatCodes;
|
|
203
|
+
committee: readonly `0x${string}`[];
|
|
204
|
+
slashFactory: SlashFactoryContract;
|
|
205
|
+
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
206
|
+
slashingRoundSize: number;
|
|
207
|
+
aztecSlotDuration: number;
|
|
208
|
+
aztecEpochDuration: number;
|
|
209
|
+
logger: Logger;
|
|
210
|
+
offenseEpoch: number;
|
|
211
|
+
}) {
|
|
212
|
+
if (!slashingProposer) {
|
|
213
|
+
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
await cheatCodes.debugRollup();
|
|
217
|
+
|
|
218
|
+
if (slashingProposer.type === 'empire') {
|
|
219
|
+
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
220
|
+
const targetEpoch = EpochNumber((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochsForValidatorSet()) + 1);
|
|
221
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
222
|
+
await cheatCodes.advanceToEpoch(targetEpoch);
|
|
223
|
+
|
|
224
|
+
const slashPayloadEvents = await retryUntil(
|
|
225
|
+
async () => {
|
|
226
|
+
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
227
|
+
return events.length > 0 ? events : undefined;
|
|
228
|
+
},
|
|
229
|
+
'slash payload created',
|
|
230
|
+
120,
|
|
231
|
+
1,
|
|
232
|
+
);
|
|
233
|
+
expect(slashPayloadEvents.length).toBe(1);
|
|
234
|
+
// The uniqueness check is needed since a validator may be slashed more than once on the same round (eg because they let two epochs be pruned)
|
|
235
|
+
expect(unique(slashPayloadEvents[0].slashes.map(slash => slash.validator.toString()))).toHaveLength(
|
|
236
|
+
committee.length,
|
|
237
|
+
);
|
|
238
|
+
} else {
|
|
239
|
+
// Use the slash offset to ensure we are in the right epoch for tally
|
|
240
|
+
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
241
|
+
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
242
|
+
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
243
|
+
const firstEpochInOffenseRound = offenseEpoch - (offenseEpoch % slashingRoundSizeInEpochs);
|
|
244
|
+
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
245
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
246
|
+
await cheatCodes.advanceToEpoch(EpochNumber(targetEpoch), { offset: -aztecSlotDuration / 2 });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const attestersPre = await rollup.getAttesters();
|
|
250
|
+
expect(attestersPre.length).toBe(committee.length);
|
|
251
|
+
|
|
252
|
+
for (const attester of attestersPre) {
|
|
253
|
+
const attesterInfo = await rollup.getAttesterView(attester);
|
|
254
|
+
expect(attesterInfo.status).toEqual(1); // Validating
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const timeout = slashingRoundSize * 2 * aztecSlotDuration + 30;
|
|
258
|
+
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
259
|
+
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
260
|
+
|
|
261
|
+
// The attesters should still form the committee but they should be reduced to the "living" status
|
|
262
|
+
await cheatCodes.debugRollup();
|
|
263
|
+
const committeePostSlashing = await rollup.getCurrentEpochCommittee();
|
|
264
|
+
expect(committeePostSlashing?.length).toBe(attestersPre.length);
|
|
265
|
+
|
|
266
|
+
const attestersPostSlashing = await rollup.getAttesters();
|
|
267
|
+
expect(attestersPostSlashing.length).toBe(0);
|
|
268
|
+
|
|
269
|
+
for (const attester of attestersPre) {
|
|
270
|
+
const attesterInfo = await rollup.getAttesterView(attester);
|
|
271
|
+
expect(attesterInfo.status).toEqual(2); // Living
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
logger.info(`Advancing to check current committee`);
|
|
275
|
+
await cheatCodes.debugRollup();
|
|
276
|
+
await cheatCodes.advanceToEpoch(
|
|
277
|
+
EpochNumber((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochsForValidatorSet()) + 1),
|
|
278
|
+
);
|
|
279
|
+
await cheatCodes.debugRollup();
|
|
280
|
+
|
|
281
|
+
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
282
|
+
// The committee should be undefined, since the validator set is empty
|
|
283
|
+
// and the tests currently using this helper always set a target committee size.
|
|
284
|
+
expect(committeeNextEpoch).toBeUndefined();
|
|
285
|
+
|
|
286
|
+
const attestersNextEpoch = await rollup.getAttesters();
|
|
287
|
+
expect(attestersNextEpoch.length).toBe(0);
|
|
288
|
+
}
|