@aztec/end-to-end 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05
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/README.md +27 -0
- package/dest/bench/client_flows/benchmark.d.ts +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +21 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +15 -16
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +125 -145
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/client_flows/data_extractor.js +3 -1
- package/dest/bench/utils.d.ts +9 -8
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +31 -19
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -9
- 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 +108 -114
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +20 -14
- 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 +92 -71
- package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -13
- package/dest/e2e_epochs/epochs_test.d.ts +42 -15
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +159 -59
- package/dest/e2e_fees/bridging_race.notest.js +4 -6
- package/dest/e2e_fees/fees_test.d.ts +21 -17
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +139 -147
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +14 -16
- package/dest/e2e_multi_validator/utils.js +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +30 -40
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +4 -4
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +9 -12
- package/dest/e2e_p2p/p2p_network.d.ts +25 -21
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +175 -130
- 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 +193 -0
- package/dest/e2e_p2p/shared.d.ts +30 -12
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +84 -67
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +19 -10
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +100 -92
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +16 -23
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +115 -139
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +17 -3
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +18 -3
- package/dest/fixtures/get_acvm_config.js +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +5 -5
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/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/schnorr_hardcoded_account_contract.d.ts +25 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +39 -0
- package/dest/fixtures/setup.d.ts +246 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +625 -0
- package/dest/fixtures/setup_p2p_test.d.ts +18 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +46 -35
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +7 -6
- package/dest/fixtures/utils.d.ts +5 -637
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -647
- package/dest/fixtures/web3signer.js +1 -1
- 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/forward-compatibility/wallet_rpc_client.d.ts +7 -0
- package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
- package/dest/forward-compatibility/wallet_service.d.ts +3 -0
- package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_service.js +109 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- 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 +18 -6
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +27 -27
- package/dest/shared/gas_portal_test_harness.d.ts +12 -2
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +4 -4
- package/dest/shared/index.d.ts +3 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +4 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +9 -11
- package/dest/shared/uniswap_l1_l2.d.ts +3 -27
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +58 -43
- package/dest/simulators/lending_simulator.d.ts +6 -2
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +6 -6
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +15 -5
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +132 -43
- 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 +438 -0
- package/dest/spartan/utils/bot.d.ts +28 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +142 -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 +45 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +23 -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 +11 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +22 -0
- package/dest/spartan/utils/k8s.d.ts +128 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +381 -0
- package/dest/spartan/utils/nodes.d.ts +40 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/spartan/utils/scripts.d.ts +30 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +81 -0
- package/dest/spartan/utils.d.ts +2 -220
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -782
- package/dest/test-wallet/test_wallet.d.ts +84 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +255 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +71 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +151 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +279 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +49 -45
- package/src/bench/client_flows/benchmark.ts +24 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +166 -216
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +36 -21
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +123 -151
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -126
- package/src/e2e_deploy_contract/deploy_test.ts +22 -15
- package/src/e2e_epochs/epochs_test.ts +222 -112
- package/src/e2e_fees/bridging_race.notest.ts +5 -11
- package/src/e2e_fees/fees_test.ts +182 -230
- package/src/e2e_l1_publisher/write_json.ts +16 -16
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
- package/src/e2e_p2p/inactivity_slash_test.ts +10 -13
- package/src/e2e_p2p/p2p_network.ts +245 -204
- package/src/e2e_p2p/reqresp/utils.ts +257 -0
- package/src/e2e_p2p/shared.ts +111 -81
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +121 -119
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +143 -189
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +34 -5
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +932 -0
- package/src/fixtures/setup_p2p_test.ts +51 -55
- package/src/fixtures/token_utils.ts +7 -6
- package/src/fixtures/utils.ts +27 -966
- package/src/fixtures/web3signer.ts +1 -1
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/guides/up_quick_start.sh +3 -5
- package/src/legacy-jest-resolver.cjs +135 -0
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +30 -43
- package/src/shared/gas_portal_test_harness.ts +3 -4
- package/src/shared/index.ts +2 -1
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +11 -16
- package/src/shared/uniswap_l1_l2.ts +86 -106
- package/src/simulators/lending_simulator.ts +11 -7
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/DEVELOP.md +7 -0
- package/src/spartan/setup_test_wallets.ts +192 -28
- package/src/spartan/tx_metrics.ts +388 -0
- package/src/spartan/utils/bot.ts +188 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +29 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +71 -0
- package/src/spartan/utils/k8s.ts +535 -0
- package/src/spartan/utils/nodes.ts +543 -0
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/spartan/utils/scripts.ts +99 -0
- package/src/spartan/utils.ts +1 -982
- package/src/test-wallet/test_wallet.ts +357 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +214 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
- 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 -95
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -505
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/src/fixtures/setup_l1_contracts.ts +0 -26
- package/src/fixtures/snapshot_manager.ts +0 -665
|
@@ -0,0 +1,257 @@
|
|
|
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 { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { timesAsync } from '@aztec/foundation/collection';
|
|
8
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
9
|
+
|
|
10
|
+
import { expect, jest } from '@jest/globals';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import os from 'os';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
|
|
15
|
+
import { getBootNodeUdpPort, shouldCollectMetrics } from '../../fixtures/fixtures.js';
|
|
16
|
+
import { createNodes } from '../../fixtures/setup_p2p_test.js';
|
|
17
|
+
import { P2PNetworkTest, 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 = 4;
|
|
23
|
+
export const BOOT_NODE_UDP_PORT = getBootNodeUdpPort();
|
|
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
|
+
ethereumSlotDuration: 8,
|
|
42
|
+
aztecSlotDuration: 36,
|
|
43
|
+
blockDurationMs: 6000,
|
|
44
|
+
l1PublishingTime: 8,
|
|
45
|
+
minTxsPerBlock: 1,
|
|
46
|
+
maxTxsPerBlock: 2,
|
|
47
|
+
enforceTimeTable: true,
|
|
48
|
+
aztecProofSubmissionEpochs: 1024, // effectively do not reorg
|
|
49
|
+
...(disableStatusHandshake ? { p2pDisableStatusHandshake: true } : {}),
|
|
50
|
+
listenAddress: '127.0.0.1',
|
|
51
|
+
aztecEpochDuration: 64, // stable committee
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
await t.setup();
|
|
55
|
+
await t.applyBaseSetup();
|
|
56
|
+
return t;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function cleanupReqrespTest(params: { t: P2PNetworkTest; nodes?: AztecNodeService[]; dataDir: string }) {
|
|
60
|
+
const { t, nodes, dataDir } = params;
|
|
61
|
+
if (nodes) {
|
|
62
|
+
await t.stopNodes(nodes);
|
|
63
|
+
}
|
|
64
|
+
await t.teardown();
|
|
65
|
+
for (let i = 0; i < NUM_VALIDATORS; i++) {
|
|
66
|
+
fs.rmSync(`${dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const getNodePort = (nodeIndex: number) => BOOT_NODE_UDP_PORT + 1 + nodeIndex;
|
|
71
|
+
|
|
72
|
+
export async function runReqrespTxTest(params: {
|
|
73
|
+
t: P2PNetworkTest;
|
|
74
|
+
dataDir: string;
|
|
75
|
+
disableStatusHandshake?: boolean;
|
|
76
|
+
}): Promise<AztecNodeService[]> {
|
|
77
|
+
const { t, dataDir, disableStatusHandshake = false } = params;
|
|
78
|
+
|
|
79
|
+
if (!t.bootstrapNodeEnr) {
|
|
80
|
+
throw new Error('Bootstrap node ENR is not available');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
t.logger.info('Creating nodes');
|
|
84
|
+
const aztecNodeConfig = disableStatusHandshake
|
|
85
|
+
? { ...t.ctx.aztecNodeConfig, p2pDisableStatusHandshake: true }
|
|
86
|
+
: t.ctx.aztecNodeConfig;
|
|
87
|
+
|
|
88
|
+
const nodes = await createNodes(
|
|
89
|
+
aztecNodeConfig,
|
|
90
|
+
t.ctx.dateProvider,
|
|
91
|
+
t.bootstrapNodeEnr,
|
|
92
|
+
NUM_VALIDATORS,
|
|
93
|
+
BOOT_NODE_UDP_PORT,
|
|
94
|
+
t.genesis,
|
|
95
|
+
dataDir,
|
|
96
|
+
shouldCollectMetrics(),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
t.logger.info('Waiting for nodes to connect');
|
|
100
|
+
await t.waitForP2PMeshConnectivity(nodes, NUM_VALIDATORS);
|
|
101
|
+
|
|
102
|
+
await t.setupAccount();
|
|
103
|
+
|
|
104
|
+
const targetBlockNumber = await t.ctx.aztecNodeService.getBlockNumber();
|
|
105
|
+
await retryUntil(
|
|
106
|
+
async () => {
|
|
107
|
+
const blockNumbers = await Promise.all(nodes.map(node => node.getBlockNumber()));
|
|
108
|
+
return blockNumbers.every(blockNumber => blockNumber >= targetBlockNumber) ? true : undefined;
|
|
109
|
+
},
|
|
110
|
+
`validators to sync to L2 block ${targetBlockNumber}`,
|
|
111
|
+
60,
|
|
112
|
+
0.5,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
t.logger.info('Preparing transactions to send');
|
|
116
|
+
const txBatches = await timesAsync(2, () =>
|
|
117
|
+
prepareTransactions(t.logger, t.ctx.aztecNodeService, NUM_TXS_PER_NODE, t.fundedAccount),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
t.logger.info('Removing initial node');
|
|
121
|
+
await t.removeInitialNode();
|
|
122
|
+
|
|
123
|
+
t.logger.info('Starting fresh slot');
|
|
124
|
+
const [timestamp] = await t.ctx.cheatCodes.rollup.advanceToNextSlot();
|
|
125
|
+
t.ctx.dateProvider.setTime(Number(timestamp) * 1000);
|
|
126
|
+
const startSlotTimestamp = BigInt(timestamp);
|
|
127
|
+
|
|
128
|
+
const { proposerIndexes, nodesToTurnOffTxGossip } = await getProposerIndexes(t, startSlotTimestamp);
|
|
129
|
+
t.logger.info(`Turning off tx gossip for nodes: ${nodesToTurnOffTxGossip.map(getNodePort)}`);
|
|
130
|
+
t.logger.info(`Sending txs to proposer nodes: ${proposerIndexes.map(getNodePort)}`);
|
|
131
|
+
|
|
132
|
+
// 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
|
|
133
|
+
// Original implementation of `handleGossipedTx` will store received transactions in the tx pool.
|
|
134
|
+
// We chose the first 2 nodes that will be the proposers for the next few slots
|
|
135
|
+
for (const nodeIndex of nodesToTurnOffTxGossip) {
|
|
136
|
+
const logger = createLogger(`p2p:${getNodePort(nodeIndex)}`);
|
|
137
|
+
jest.spyOn((nodes[nodeIndex] as any).p2pClient.p2pService, 'handleGossipedTx').mockImplementation(((
|
|
138
|
+
payloadData: Buffer,
|
|
139
|
+
) => {
|
|
140
|
+
const txHash = Tx.fromBuffer(payloadData).getTxHash();
|
|
141
|
+
logger.info(`Skipping storage of gossiped transaction ${txHash.toString()}`);
|
|
142
|
+
return Promise.resolve();
|
|
143
|
+
}) as any);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// We send the tx to the proposer nodes directly, ignoring the pxe and node in each context
|
|
147
|
+
// We cannot just call tx.send since they were created using a pxe wired to the first node which is now stopped
|
|
148
|
+
t.logger.info('Sending transactions through proposer nodes');
|
|
149
|
+
const submittedTxs = await Promise.all(
|
|
150
|
+
txBatches.map(async (batch, batchIndex) => {
|
|
151
|
+
const proposerNode = nodes[proposerIndexes[batchIndex]];
|
|
152
|
+
for (const tx of batch) {
|
|
153
|
+
t.logger.info(`Tx ${tx.getTxHash().toString()} base64: ${tx.toBuffer().toString('base64')}`);
|
|
154
|
+
}
|
|
155
|
+
const txHashes = batch.map(tx => tx.getTxHash().toString());
|
|
156
|
+
t.logger.info(
|
|
157
|
+
`Sending batch ${batchIndex} to proposer ${getNodePort(proposerIndexes[batchIndex])}: ${txHashes.join(', ')}`,
|
|
158
|
+
);
|
|
159
|
+
await Promise.all(
|
|
160
|
+
batch.map(async tx => {
|
|
161
|
+
try {
|
|
162
|
+
await proposerNode.sendTx(tx);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
t.logger.error(`Error sending tx: ${err}`);
|
|
165
|
+
throw err;
|
|
166
|
+
}
|
|
167
|
+
}),
|
|
168
|
+
);
|
|
169
|
+
return batch.map(tx => ({ node: proposerNode, txHash: tx.getTxHash() }));
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// Log pool state per node after sending
|
|
174
|
+
for (let i = 0; i < NUM_VALIDATORS; i++) {
|
|
175
|
+
const count = await nodes[i].getPendingTxCount();
|
|
176
|
+
t.logger.info(`Node ${getNodePort(i)} pool has ${count} pending txs`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
t.logger.info('Waiting for all transactions to be mined');
|
|
180
|
+
await Promise.all(
|
|
181
|
+
submittedTxs.flatMap((batch, batchIndex) =>
|
|
182
|
+
batch.map(async (submittedTx, txIndex) => {
|
|
183
|
+
t.logger.info(`Waiting for tx ${batchIndex}-${txIndex} ${submittedTx.txHash.toString()} to be mined`);
|
|
184
|
+
await waitForTx(submittedTx.node, submittedTx.txHash, { timeout: WAIT_FOR_TX_TIMEOUT * 1.5 });
|
|
185
|
+
t.logger.info(`Tx ${batchIndex}-${txIndex} ${submittedTx.txHash.toString()} has been mined`);
|
|
186
|
+
}),
|
|
187
|
+
),
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
t.logger.info('All transactions mined');
|
|
191
|
+
|
|
192
|
+
// Assert that multiple blocks were built for at least one slot
|
|
193
|
+
t.logger.info('Verifying multiple blocks for at least one checkpoint');
|
|
194
|
+
// Wait for L1 checkpoint sync, which may lag behind P2P block propagation.
|
|
195
|
+
const checkpoints = await retryUntil(
|
|
196
|
+
async () => {
|
|
197
|
+
const cps = await nodes[0].getCheckpoints(CheckpointNumber(1), 50, { includeBlocks: true });
|
|
198
|
+
return cps.length > 0 && cps.some(cp => (cp.blocks?.length ?? 0) >= 2) ? cps : undefined;
|
|
199
|
+
},
|
|
200
|
+
'waiting for multi-block checkpoint to sync from L1',
|
|
201
|
+
30,
|
|
202
|
+
1,
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
let mbpsFound = false;
|
|
206
|
+
let expectedBlockNumber = checkpoints[0].blocks![0].number;
|
|
207
|
+
|
|
208
|
+
for (const published of checkpoints) {
|
|
209
|
+
const blocks = published.blocks!;
|
|
210
|
+
const blockCount = blocks.length;
|
|
211
|
+
mbpsFound = mbpsFound || blockCount >= 2;
|
|
212
|
+
|
|
213
|
+
for (let i = 0; i < blockCount; i++) {
|
|
214
|
+
const block = blocks[i];
|
|
215
|
+
expect(block.indexWithinCheckpoint).toBe(i);
|
|
216
|
+
expect(block.checkpointNumber).toBe(published.number);
|
|
217
|
+
expect(block.number).toBe(expectedBlockNumber);
|
|
218
|
+
expectedBlockNumber++;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
expect(mbpsFound).toBe(true);
|
|
223
|
+
return nodes;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function getProposerIndexes(t: P2PNetworkTest, startSlotTimestamp: bigint) {
|
|
227
|
+
// Get the nodes for the next set of slots
|
|
228
|
+
const rollupContract = new RollupContract(
|
|
229
|
+
t.ctx.deployL1ContractsValues.l1Client,
|
|
230
|
+
t.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const attesters = await rollupContract.getAttesters();
|
|
234
|
+
const startSlot = await rollupContract.getSlotAt(startSlotTimestamp);
|
|
235
|
+
|
|
236
|
+
const proposers = await Promise.all(
|
|
237
|
+
Array.from({ length: 3 }, async (_, i) => {
|
|
238
|
+
const slot = SlotNumber(startSlot + i);
|
|
239
|
+
const slotTimestamp = await rollupContract.getTimestampForSlot(slot);
|
|
240
|
+
return await rollupContract.getProposerAt(slotTimestamp);
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
// Get the indexes of the nodes that are responsible for the next two slots
|
|
244
|
+
const proposerIndexes = proposers.map(proposer => attesters.findIndex(a => a.equals(proposer)));
|
|
245
|
+
|
|
246
|
+
if (proposerIndexes.some(i => i === -1)) {
|
|
247
|
+
throw new Error(
|
|
248
|
+
`Proposer index not found for proposer ` +
|
|
249
|
+
`(proposers=${proposers.map(p => p.toString()).join(',')}, indices=${proposerIndexes.join(',')})`,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const nodesToTurnOffTxGossip = Array.from({ length: NUM_VALIDATORS }, (_, i) => i).filter(
|
|
254
|
+
i => !proposerIndexes.includes(i),
|
|
255
|
+
);
|
|
256
|
+
return { proposerIndexes, nodesToTurnOffTxGossip };
|
|
257
|
+
}
|
package/src/e2e_p2p/shared.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
2
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
3
3
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
-
import {
|
|
4
|
+
import { NO_WAIT, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
5
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
6
|
import type { Logger } from '@aztec/aztec.js/log';
|
|
7
|
-
import {
|
|
7
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
8
8
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
9
|
-
import type {
|
|
10
|
-
import {
|
|
9
|
+
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
10
|
+
import type { RollupContract, SlashingProposerContract } from '@aztec/ethereum/contracts';
|
|
11
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
12
|
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
13
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
14
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
13
15
|
import { pluralize } from '@aztec/foundation/string';
|
|
14
16
|
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
@@ -16,10 +18,11 @@ import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.j
|
|
|
16
18
|
import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
17
19
|
import { getRoundForOffense } from '@aztec/slasher';
|
|
18
20
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
19
|
-
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
20
|
-
import { TestWallet, proveInteraction } from '@aztec/test-wallet/server';
|
|
21
21
|
|
|
22
|
+
import { SchnorrHardcodedKeyAccountContract } from '../fixtures/schnorr_hardcoded_account_contract.js';
|
|
22
23
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
24
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
25
|
+
import { type ProvenTx, proveInteraction } from '../test-wallet/utils.js';
|
|
23
26
|
|
|
24
27
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
25
28
|
export const submitComplexTxsTo = async (
|
|
@@ -29,24 +32,15 @@ export const submitComplexTxsTo = async (
|
|
|
29
32
|
numTxs: number,
|
|
30
33
|
opts: { callPublic?: boolean } = {},
|
|
31
34
|
) => {
|
|
32
|
-
const txs:
|
|
35
|
+
const txs: TxHash[] = [];
|
|
33
36
|
|
|
34
37
|
const seed = 1234n;
|
|
35
38
|
const spamCount = 15;
|
|
36
39
|
for (let i = 0; i < numTxs; i++) {
|
|
37
|
-
const
|
|
38
|
-
const txHash = await
|
|
39
|
-
|
|
40
|
+
const method = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic);
|
|
41
|
+
const { txHash } = await method.send({ from, wait: NO_WAIT });
|
|
40
42
|
logger.info(`Tx sent with hash ${txHash.toString()}`);
|
|
41
|
-
|
|
42
|
-
expect(receipt).toEqual(
|
|
43
|
-
expect.objectContaining({
|
|
44
|
-
status: TxStatus.PENDING,
|
|
45
|
-
error: '',
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
logger.info(`Receipt received for ${txHash.toString()}`);
|
|
49
|
-
txs.push(tx);
|
|
43
|
+
txs.push(txHash);
|
|
50
44
|
}
|
|
51
45
|
return txs;
|
|
52
46
|
};
|
|
@@ -57,11 +51,22 @@ export const submitTransactions = async (
|
|
|
57
51
|
node: AztecNodeService,
|
|
58
52
|
numTxs: number,
|
|
59
53
|
fundedAccount: InitialAccountData,
|
|
60
|
-
): Promise<
|
|
54
|
+
): Promise<TxHash[]> => {
|
|
61
55
|
const rpcConfig = getRpcConfig();
|
|
62
56
|
rpcConfig.proverEnabled = false;
|
|
63
|
-
const wallet = await TestWallet.create(
|
|
64
|
-
|
|
57
|
+
const wallet = await TestWallet.create(
|
|
58
|
+
node,
|
|
59
|
+
// Use checkpointed chain tip to avoid anchoring on provisional blocks that the archiver can prune
|
|
60
|
+
// when their slot ends without a checkpoint landing on L1.
|
|
61
|
+
{ ...getPXEConfig(), proverEnabled: false, syncChainTip: 'checkpointed' },
|
|
62
|
+
{ loggerActorLabel: 'pxe-tx' },
|
|
63
|
+
);
|
|
64
|
+
const contract = new SchnorrHardcodedKeyAccountContract();
|
|
65
|
+
const fundedAccountManager = await wallet.createAccount({
|
|
66
|
+
secret: fundedAccount.secret,
|
|
67
|
+
salt: fundedAccount.salt,
|
|
68
|
+
contract,
|
|
69
|
+
});
|
|
65
70
|
return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
|
|
66
71
|
};
|
|
67
72
|
|
|
@@ -70,12 +75,21 @@ export async function prepareTransactions(
|
|
|
70
75
|
node: AztecNodeService,
|
|
71
76
|
numTxs: number,
|
|
72
77
|
fundedAccount: InitialAccountData,
|
|
73
|
-
): Promise<
|
|
78
|
+
): Promise<ProvenTx[]> {
|
|
74
79
|
const rpcConfig = getRpcConfig();
|
|
75
80
|
rpcConfig.proverEnabled = false;
|
|
76
81
|
|
|
77
|
-
const wallet = await TestWallet.create(
|
|
78
|
-
|
|
82
|
+
const wallet = await TestWallet.create(
|
|
83
|
+
node,
|
|
84
|
+
{ ...getPXEConfig(), proverEnabled: false, syncChainTip: 'checkpointed' },
|
|
85
|
+
{ loggerActorLabel: 'pxe-tx' },
|
|
86
|
+
);
|
|
87
|
+
const accountContract = new SchnorrHardcodedKeyAccountContract();
|
|
88
|
+
const fundedAccountManager = await wallet.createAccount({
|
|
89
|
+
secret: fundedAccount.secret,
|
|
90
|
+
salt: fundedAccount.salt,
|
|
91
|
+
contract: accountContract,
|
|
92
|
+
});
|
|
79
93
|
|
|
80
94
|
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
81
95
|
salt: Fr.random(),
|
|
@@ -87,14 +101,13 @@ export async function prepareTransactions(
|
|
|
87
101
|
const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
|
|
88
102
|
from: fundedAccountManager.address,
|
|
89
103
|
});
|
|
90
|
-
|
|
91
|
-
logger.info(`Tx prepared with hash ${txHash}`);
|
|
104
|
+
logger.info(`Tx prepared with hash ${tx.getTxHash()}`);
|
|
92
105
|
return tx;
|
|
93
106
|
});
|
|
94
107
|
}
|
|
95
108
|
|
|
96
109
|
export function awaitProposalExecution(
|
|
97
|
-
slashingProposer:
|
|
110
|
+
slashingProposer: SlashingProposerContract,
|
|
98
111
|
timeoutSeconds: number,
|
|
99
112
|
logger: Logger,
|
|
100
113
|
): Promise<bigint> {
|
|
@@ -104,24 +117,12 @@ export function awaitProposalExecution(
|
|
|
104
117
|
reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
|
|
105
118
|
}, timeoutSeconds * 1000);
|
|
106
119
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
logger.warn(`Proposal ${args.payload} from round ${args.round} executed`);
|
|
110
|
-
clearTimeout(timeout);
|
|
111
|
-
unwatch();
|
|
112
|
-
resolve(args.round);
|
|
113
|
-
});
|
|
114
|
-
} else if (slashingProposer.type === 'tally') {
|
|
115
|
-
const unwatch = slashingProposer.listenToRoundExecuted(args => {
|
|
116
|
-
logger.warn(`Slash from round ${args.round} executed`);
|
|
117
|
-
clearTimeout(timeout);
|
|
118
|
-
unwatch();
|
|
119
|
-
resolve(args.round);
|
|
120
|
-
});
|
|
121
|
-
} else {
|
|
120
|
+
const unwatch = slashingProposer.listenToRoundExecuted(args => {
|
|
121
|
+
logger.warn(`Slash from round ${args.round} executed`);
|
|
122
122
|
clearTimeout(timeout);
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
unwatch();
|
|
124
|
+
resolve(args.round);
|
|
125
|
+
});
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -133,7 +134,7 @@ export async function awaitCommitteeExists({
|
|
|
133
134
|
logger: Logger;
|
|
134
135
|
}): Promise<readonly `0x${string}`[]> {
|
|
135
136
|
logger.info(`Waiting for committee to be set`);
|
|
136
|
-
let committee:
|
|
137
|
+
let committee: EthAddress[] | undefined;
|
|
137
138
|
await retryUntil(
|
|
138
139
|
async () => {
|
|
139
140
|
committee = await rollup.getCurrentEpochCommittee();
|
|
@@ -142,7 +143,60 @@ export async function awaitCommitteeExists({
|
|
|
142
143
|
'non-empty committee',
|
|
143
144
|
60,
|
|
144
145
|
);
|
|
145
|
-
|
|
146
|
+
logger.warn(`Committee has been formed`, { committee: committee!.map(c => c.toString()) });
|
|
147
|
+
return committee!.map(c => c.toString() as `0x${string}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Advance epochs until we find one where the target proposer is selected for at least one slot,
|
|
152
|
+
* then stop one epoch before it. This leaves time for the caller to start sequencers before
|
|
153
|
+
* warping to the target epoch, avoiding the race where the target epoch passes before sequencers
|
|
154
|
+
* are ready.
|
|
155
|
+
*
|
|
156
|
+
* Returns the target epoch number so the caller can warp to it after starting sequencers.
|
|
157
|
+
*/
|
|
158
|
+
export async function advanceToEpochBeforeProposer({
|
|
159
|
+
epochCache,
|
|
160
|
+
cheatCodes,
|
|
161
|
+
targetProposer,
|
|
162
|
+
logger,
|
|
163
|
+
maxAttempts = 20,
|
|
164
|
+
}: {
|
|
165
|
+
epochCache: EpochCacheInterface;
|
|
166
|
+
cheatCodes: RollupCheatCodes;
|
|
167
|
+
targetProposer: EthAddress;
|
|
168
|
+
logger: Logger;
|
|
169
|
+
maxAttempts?: number;
|
|
170
|
+
}): Promise<{ targetEpoch: EpochNumber }> {
|
|
171
|
+
const { epochDuration } = await cheatCodes.getConfig();
|
|
172
|
+
|
|
173
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
174
|
+
const currentEpoch = await cheatCodes.getEpoch();
|
|
175
|
+
// Check the NEXT epoch's slots so we stay one epoch before the target,
|
|
176
|
+
// giving the caller time to start sequencers before the target epoch arrives.
|
|
177
|
+
const nextEpoch = Number(currentEpoch) + 1;
|
|
178
|
+
const startSlot = nextEpoch * Number(epochDuration);
|
|
179
|
+
const endSlot = startSlot + Number(epochDuration);
|
|
180
|
+
|
|
181
|
+
logger.info(
|
|
182
|
+
`Checking next epoch ${nextEpoch} (slots ${startSlot}-${endSlot - 1}) for proposer ${targetProposer} (current epoch: ${currentEpoch})`,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
for (let s = startSlot; s < endSlot; s++) {
|
|
186
|
+
const proposer = await epochCache.getProposerAttesterAddressInSlot(SlotNumber(s));
|
|
187
|
+
if (proposer && proposer.equals(targetProposer)) {
|
|
188
|
+
logger.warn(
|
|
189
|
+
`Found target proposer ${targetProposer} in slot ${s} of epoch ${nextEpoch}. Staying at epoch ${currentEpoch} to allow sequencer startup.`,
|
|
190
|
+
);
|
|
191
|
+
return { targetEpoch: EpochNumber(nextEpoch) };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
logger.info(`Target proposer not found in epoch ${nextEpoch}, advancing to next epoch`);
|
|
196
|
+
await cheatCodes.advanceToNextEpoch();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
throw new Error(`Target proposer ${targetProposer} not found in any slot after ${maxAttempts} epoch attempts`);
|
|
146
200
|
}
|
|
147
201
|
|
|
148
202
|
export async function awaitOffenseDetected({
|
|
@@ -187,7 +241,6 @@ export async function awaitCommitteeKicked({
|
|
|
187
241
|
rollup,
|
|
188
242
|
cheatCodes,
|
|
189
243
|
committee,
|
|
190
|
-
slashFactory,
|
|
191
244
|
slashingProposer,
|
|
192
245
|
slashingRoundSize,
|
|
193
246
|
aztecSlotDuration,
|
|
@@ -198,8 +251,7 @@ export async function awaitCommitteeKicked({
|
|
|
198
251
|
rollup: RollupContract;
|
|
199
252
|
cheatCodes: RollupCheatCodes;
|
|
200
253
|
committee: readonly `0x${string}`[];
|
|
201
|
-
|
|
202
|
-
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
254
|
+
slashingProposer: SlashingProposerContract | undefined;
|
|
203
255
|
slashingRoundSize: number;
|
|
204
256
|
aztecSlotDuration: number;
|
|
205
257
|
aztecEpochDuration: number;
|
|
@@ -212,36 +264,14 @@ export async function awaitCommitteeKicked({
|
|
|
212
264
|
|
|
213
265
|
await cheatCodes.debugRollup();
|
|
214
266
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
224
|
-
return events.length > 0 ? events : undefined;
|
|
225
|
-
},
|
|
226
|
-
'slash payload created',
|
|
227
|
-
120,
|
|
228
|
-
1,
|
|
229
|
-
);
|
|
230
|
-
expect(slashPayloadEvents.length).toBe(1);
|
|
231
|
-
// 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)
|
|
232
|
-
expect(unique(slashPayloadEvents[0].slashes.map(slash => slash.validator.toString()))).toHaveLength(
|
|
233
|
-
committee.length,
|
|
234
|
-
);
|
|
235
|
-
} else {
|
|
236
|
-
// Use the slash offset to ensure we are in the right epoch for tally
|
|
237
|
-
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
238
|
-
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
239
|
-
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
240
|
-
const firstEpochInOffenseRound = offenseEpoch - (offenseEpoch % slashingRoundSizeInEpochs);
|
|
241
|
-
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
242
|
-
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
243
|
-
await cheatCodes.advanceToEpoch(EpochNumber(targetEpoch), { offset: -aztecSlotDuration / 2 });
|
|
244
|
-
}
|
|
267
|
+
// Use the slash offset to ensure we are in the right epoch for tally
|
|
268
|
+
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
269
|
+
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
270
|
+
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
271
|
+
const firstEpochInOffenseRound = offenseEpoch - (offenseEpoch % slashingRoundSizeInEpochs);
|
|
272
|
+
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
273
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
274
|
+
await cheatCodes.advanceToEpoch(EpochNumber(targetEpoch), { offset: -aztecSlotDuration / 2 });
|
|
245
275
|
|
|
246
276
|
const attestersPre = await rollup.getAttesters();
|
|
247
277
|
expect(attestersPre.length).toBe(committee.length);
|
|
@@ -271,7 +301,7 @@ export async function awaitCommitteeKicked({
|
|
|
271
301
|
logger.info(`Advancing to check current committee`);
|
|
272
302
|
await cheatCodes.debugRollup();
|
|
273
303
|
await cheatCodes.advanceToEpoch(
|
|
274
|
-
EpochNumber
|
|
304
|
+
EpochNumber((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochsForValidatorSet()) + 1),
|
|
275
305
|
);
|
|
276
306
|
await cheatCodes.debugRollup();
|
|
277
307
|
|