@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.03f7ef2
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 +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +336 -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 +77 -0
- package/dest/bench/utils.d.ts +12 -38
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
- 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 +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +20 -25
- 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 +51 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +65 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +233 -49
- 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 +63 -0
- package/dest/e2e_fees/fees_test.d.ts +27 -12
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +106 -109
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +58 -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 +10 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
- 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 +276 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +188 -133
- package/dest/e2e_p2p/shared.d.ts +43 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +164 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/fixtures/e2e_prover_test.d.ts +61 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +108 -112
- 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_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +82 -22
- package/dest/fixtures/snapshot_manager.d.ts +20 -14
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +154 -140
- 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 +28 -12
- package/dest/fixtures/utils.d.ts +95 -54
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +456 -389
- 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 +42 -35
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +29 -31
- 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 +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 +16 -13
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +149 -117
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -11
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +16 -17
- 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 +26 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +202 -58
- 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 +129 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +559 -151
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +450 -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 +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +70 -107
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +299 -65
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +151 -141
- 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 +29 -19
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +274 -171
- package/src/e2e_p2p/shared.ts +251 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +113 -160
- 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_p2p_test.ts +127 -39
- package/src/fixtures/snapshot_manager.ts +196 -162
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +562 -475
- 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 +1 -1
- package/src/shared/cross_chain_test_harness.ts +112 -80
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +187 -192
- package/src/simulators/lending_simulator.ts +15 -16
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +252 -93
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +641 -146
- 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/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/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/fixtures/setup_l1_contracts.ts +0 -27
- 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
|
@@ -1,26 +1,41 @@
|
|
|
1
|
-
import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
2
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
3
2
|
import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
3
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
6
|
+
import {
|
|
7
|
+
type EmpireSlashingProposerContract,
|
|
8
|
+
GSEContract,
|
|
9
|
+
RollupContract,
|
|
10
|
+
type TallySlashingProposerContract,
|
|
11
|
+
} from '@aztec/ethereum/contracts';
|
|
12
|
+
import type { Operator } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
13
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
14
|
+
import { MultiAdderArtifact } from '@aztec/ethereum/l1-artifacts';
|
|
15
|
+
import { createL1TxUtilsFromViemWallet } from '@aztec/ethereum/l1-tx-utils';
|
|
16
|
+
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
17
|
+
import type { ExtendedViemWalletClient, ViemClient } from '@aztec/ethereum/types';
|
|
18
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
19
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
9
20
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
21
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
22
|
+
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
23
|
+
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
12
24
|
import type { BootstrapNode } from '@aztec/p2p/bootstrap';
|
|
13
25
|
import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
|
|
26
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
27
|
+
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
14
28
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
29
|
+
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
30
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
15
31
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
16
32
|
|
|
17
33
|
import getPort from 'get-port';
|
|
18
|
-
import { getContract } from 'viem';
|
|
34
|
+
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
19
35
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
20
36
|
|
|
21
37
|
import {
|
|
22
38
|
ATTESTER_PRIVATE_KEYS_START_INDEX,
|
|
23
|
-
PROPOSER_PRIVATE_KEYS_START_INDEX,
|
|
24
39
|
createValidatorConfig,
|
|
25
40
|
generatePrivateKeys,
|
|
26
41
|
} from '../fixtures/setup_p2p_test.js';
|
|
@@ -30,7 +45,7 @@ import {
|
|
|
30
45
|
createSnapshotManager,
|
|
31
46
|
deployAccounts,
|
|
32
47
|
} from '../fixtures/snapshot_manager.js';
|
|
33
|
-
import { getPrivateKeyFromIndex } from '../fixtures/utils.js';
|
|
48
|
+
import { type SetupOptions, getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
34
49
|
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
|
|
35
50
|
|
|
36
51
|
// Use a fixed bootstrap node private key so that we can re-use the same snapshot and the nodes can find each other
|
|
@@ -38,14 +53,16 @@ const BOOTSTRAP_NODE_PRIVATE_KEY = '080212208f988fc0899e4a73a5aee4d271a5f2067060
|
|
|
38
53
|
const l1ContractsConfig = getL1ContractsConfigEnvVars();
|
|
39
54
|
export const WAIT_FOR_TX_TIMEOUT = l1ContractsConfig.aztecSlotDuration * 3;
|
|
40
55
|
|
|
41
|
-
export const
|
|
56
|
+
export const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES = {
|
|
42
57
|
aztecSlotDuration: 12,
|
|
43
58
|
ethereumSlotDuration: 4,
|
|
59
|
+
aztecProofSubmissionWindow: 640,
|
|
44
60
|
};
|
|
45
61
|
|
|
46
62
|
export class P2PNetworkTest {
|
|
47
63
|
private snapshotManager: ISnapshotManager;
|
|
48
|
-
|
|
64
|
+
public baseAccountPrivateKey: `0x${string}`;
|
|
65
|
+
public baseAccount;
|
|
49
66
|
|
|
50
67
|
public logger: Logger;
|
|
51
68
|
public monitor!: ChainMonitor;
|
|
@@ -53,38 +70,43 @@ export class P2PNetworkTest {
|
|
|
53
70
|
public ctx!: SubsystemsContext;
|
|
54
71
|
public attesterPrivateKeys: `0x${string}`[] = [];
|
|
55
72
|
public attesterPublicKeys: string[] = [];
|
|
56
|
-
public proposerPrivateKeys: `0x${string}`[] = [];
|
|
57
73
|
public peerIdPrivateKeys: string[] = [];
|
|
74
|
+
public validators: Operator[] = [];
|
|
58
75
|
|
|
59
76
|
public deployedAccounts: InitialAccountData[] = [];
|
|
60
77
|
public prefilledPublicData: PublicDataTreeLeaf[] = [];
|
|
78
|
+
|
|
61
79
|
// The re-execution test needs a wallet and a spam contract
|
|
62
|
-
public wallet?:
|
|
80
|
+
public wallet?: TestWallet;
|
|
81
|
+
public defaultAccountAddress?: AztecAddress;
|
|
63
82
|
public spamContract?: SpamContract;
|
|
64
83
|
|
|
65
84
|
public bootstrapNode?: BootstrapNode;
|
|
66
85
|
|
|
67
|
-
private cleanupInterval: NodeJS.Timeout | undefined = undefined;
|
|
68
|
-
|
|
69
|
-
private gasUtils: L1TxUtilsWithBlobs | undefined = undefined;
|
|
70
|
-
|
|
71
86
|
constructor(
|
|
72
|
-
testName: string,
|
|
87
|
+
public readonly testName: string,
|
|
73
88
|
public bootstrapNodeEnr: string,
|
|
74
89
|
public bootNodePort: number,
|
|
75
|
-
|
|
76
|
-
initialValidatorConfig:
|
|
90
|
+
public numberOfValidators: number,
|
|
91
|
+
initialValidatorConfig: SetupOptions,
|
|
92
|
+
public numberOfNodes = 0,
|
|
77
93
|
// If set enable metrics collection
|
|
78
94
|
private metricsPort?: number,
|
|
95
|
+
startProverNode?: boolean,
|
|
79
96
|
) {
|
|
80
97
|
this.logger = createLogger(`e2e:e2e_p2p:${testName}`);
|
|
81
98
|
|
|
82
99
|
// Set up the base account and node private keys for the initial network deployment
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.attesterPrivateKeys = generatePrivateKeys(
|
|
100
|
+
this.baseAccountPrivateKey = `0x${getPrivateKeyFromIndex(1)!.toString('hex')}`;
|
|
101
|
+
this.baseAccount = privateKeyToAccount(this.baseAccountPrivateKey);
|
|
102
|
+
this.attesterPrivateKeys = generatePrivateKeys(
|
|
103
|
+
ATTESTER_PRIVATE_KEYS_START_INDEX + numberOfNodes,
|
|
104
|
+
numberOfValidators,
|
|
105
|
+
);
|
|
86
106
|
this.attesterPublicKeys = this.attesterPrivateKeys.map(privateKey => privateKeyToAccount(privateKey).address);
|
|
87
107
|
|
|
108
|
+
const zkPassportParams = ZkPassportProofParams.random();
|
|
109
|
+
|
|
88
110
|
this.snapshotManager = createSnapshotManager(
|
|
89
111
|
`e2e_p2p_network/${testName}`,
|
|
90
112
|
process.env.E2E_DATA_PATH,
|
|
@@ -93,19 +115,33 @@ export class P2PNetworkTest {
|
|
|
93
115
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
94
116
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
95
117
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
96
|
-
|
|
97
|
-
initialValidatorConfig.
|
|
98
|
-
|
|
118
|
+
aztecProofSubmissionEpochs:
|
|
119
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
120
|
+
slashingRoundSizeInEpochs:
|
|
121
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
122
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
123
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
99
124
|
metricsPort: metricsPort,
|
|
100
|
-
numberOfInitialFundedAccounts:
|
|
125
|
+
numberOfInitialFundedAccounts: 2,
|
|
126
|
+
startProverNode,
|
|
101
127
|
},
|
|
102
128
|
{
|
|
129
|
+
...initialValidatorConfig,
|
|
103
130
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
131
|
+
slashingRoundSizeInEpochs:
|
|
132
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
133
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
134
|
+
|
|
104
135
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
105
136
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
106
|
-
|
|
107
|
-
initialValidatorConfig.
|
|
137
|
+
aztecProofSubmissionEpochs:
|
|
138
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
139
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
108
140
|
initialValidators: [],
|
|
141
|
+
zkPassportArgs: {
|
|
142
|
+
zkPassportDomain: zkPassportParams.domain,
|
|
143
|
+
zkPassportScope: zkPassportParams.scope,
|
|
144
|
+
},
|
|
109
145
|
},
|
|
110
146
|
);
|
|
111
147
|
}
|
|
@@ -113,15 +149,19 @@ export class P2PNetworkTest {
|
|
|
113
149
|
static async create({
|
|
114
150
|
testName,
|
|
115
151
|
numberOfNodes,
|
|
152
|
+
numberOfValidators,
|
|
116
153
|
basePort,
|
|
117
154
|
metricsPort,
|
|
118
155
|
initialConfig,
|
|
156
|
+
startProverNode,
|
|
119
157
|
}: {
|
|
120
158
|
testName: string;
|
|
121
159
|
numberOfNodes: number;
|
|
160
|
+
numberOfValidators: number;
|
|
122
161
|
basePort?: number;
|
|
123
162
|
metricsPort?: number;
|
|
124
|
-
initialConfig?:
|
|
163
|
+
initialConfig?: SetupOptions;
|
|
164
|
+
startProverNode?: boolean;
|
|
125
165
|
}) {
|
|
126
166
|
const port = basePort || (await getPort());
|
|
127
167
|
|
|
@@ -133,7 +173,16 @@ export class P2PNetworkTest {
|
|
|
133
173
|
bootstrapNodeEnr,
|
|
134
174
|
);
|
|
135
175
|
|
|
136
|
-
return new P2PNetworkTest(
|
|
176
|
+
return new P2PNetworkTest(
|
|
177
|
+
testName,
|
|
178
|
+
bootstrapNodeEnr,
|
|
179
|
+
port,
|
|
180
|
+
numberOfValidators,
|
|
181
|
+
initialValidatorConfig,
|
|
182
|
+
numberOfNodes,
|
|
183
|
+
metricsPort,
|
|
184
|
+
startProverNode,
|
|
185
|
+
);
|
|
137
186
|
}
|
|
138
187
|
|
|
139
188
|
get fundedAccount() {
|
|
@@ -143,35 +192,9 @@ export class P2PNetworkTest {
|
|
|
143
192
|
return this.deployedAccounts[0];
|
|
144
193
|
}
|
|
145
194
|
|
|
146
|
-
|
|
147
|
-
* Start a loop to sync the mock system time with the L1 block time
|
|
148
|
-
*/
|
|
149
|
-
public startSyncMockSystemTimeInterval() {
|
|
150
|
-
this.cleanupInterval = setInterval(() => {
|
|
151
|
-
void this.syncMockSystemTime().catch(err => this.logger.error('Error syncing mock system time', err));
|
|
152
|
-
}, l1ContractsConfig.aztecSlotDuration * 1000);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* When using fake timers, we need to keep the system and anvil clocks in sync.
|
|
157
|
-
*/
|
|
158
|
-
public async syncMockSystemTime() {
|
|
159
|
-
this.logger.info('Syncing mock system time');
|
|
160
|
-
const { dateProvider, deployL1ContractsValues } = this.ctx!;
|
|
161
|
-
// Send a tx and only update the time after the tx is mined, as eth time is not continuous
|
|
162
|
-
const { receipt } = await this.gasUtils!.sendAndMonitorTransaction({
|
|
163
|
-
to: this.baseAccount.address,
|
|
164
|
-
data: '0x',
|
|
165
|
-
value: 1n,
|
|
166
|
-
});
|
|
167
|
-
const timestamp = await deployL1ContractsValues.publicClient.getBlock({ blockNumber: receipt.blockNumber });
|
|
168
|
-
this.logger.info(`Timestamp: ${timestamp.timestamp}`);
|
|
169
|
-
dateProvider.setTime(Number(timestamp.timestamp) * 1000);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
async applyBaseSnapshots() {
|
|
195
|
+
async addBootstrapNode() {
|
|
173
196
|
await this.snapshotManager.snapshot('add-bootstrap-node', async ({ aztecNodeConfig }) => {
|
|
174
|
-
const telemetry = getEndToEndTestTelemetryClient(this.metricsPort);
|
|
197
|
+
const telemetry = await getEndToEndTestTelemetryClient(this.metricsPort);
|
|
175
198
|
this.bootstrapNode = await createBootstrapNodeFromPrivateKey(
|
|
176
199
|
BOOTSTRAP_NODE_PRIVATE_KEY,
|
|
177
200
|
this.bootNodePort,
|
|
@@ -181,96 +204,107 @@ export class P2PNetworkTest {
|
|
|
181
204
|
// Overwrite enr with updated info
|
|
182
205
|
this.bootstrapNodeEnr = this.bootstrapNode.getENR().encodeTxt();
|
|
183
206
|
});
|
|
207
|
+
}
|
|
184
208
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
async ({ deployL1ContractsValues, aztecNodeConfig, dateProvider }) => {
|
|
188
|
-
const rollup = getContract({
|
|
189
|
-
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
190
|
-
abi: RollupAbi,
|
|
191
|
-
client: deployL1ContractsValues.walletClient,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
this.logger.verbose(`Adding ${this.numberOfNodes} validators`);
|
|
209
|
+
getValidators() {
|
|
210
|
+
const validators: Operator[] = [];
|
|
195
211
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
client: deployL1ContractsValues.walletClient,
|
|
200
|
-
});
|
|
212
|
+
for (let i = 0; i < this.numberOfValidators; i++) {
|
|
213
|
+
const keyIndex = i;
|
|
214
|
+
const attester = privateKeyToAccount(this.attesterPrivateKeys[keyIndex]!);
|
|
201
215
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
{} as any,
|
|
208
|
-
),
|
|
209
|
-
await stakingAsset.write.approve(
|
|
210
|
-
[deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(), stakeNeeded],
|
|
211
|
-
{} as any,
|
|
212
|
-
),
|
|
213
|
-
].map(txHash => deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: txHash })),
|
|
214
|
-
);
|
|
216
|
+
validators.push({
|
|
217
|
+
attester: EthAddress.fromString(attester.address),
|
|
218
|
+
withdrawer: EthAddress.fromString(attester.address),
|
|
219
|
+
bn254SecretKey: new SecretValue(Fr.random().toBigInt()),
|
|
220
|
+
});
|
|
215
221
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const proposerEOA = privateKeyToAccount(this.proposerPrivateKeys[i]!);
|
|
221
|
-
const forwarder = getExpectedAddress(
|
|
222
|
-
ForwarderAbi,
|
|
223
|
-
ForwarderBytecode,
|
|
224
|
-
[proposerEOA.address],
|
|
225
|
-
proposerEOA.address,
|
|
226
|
-
).address;
|
|
227
|
-
validators.push({
|
|
228
|
-
attester: attester.address,
|
|
229
|
-
proposer: forwarder,
|
|
230
|
-
withdrawer: attester.address,
|
|
231
|
-
amount: l1ContractsConfig.minimumStake,
|
|
232
|
-
} as const);
|
|
233
|
-
|
|
234
|
-
this.logger.verbose(`Adding (attester, proposer) pair: (${attester.address}, ${forwarder}) as validator`);
|
|
235
|
-
}
|
|
222
|
+
this.logger.info(`Adding attester ${attester.address} as validator`);
|
|
223
|
+
}
|
|
224
|
+
return { validators };
|
|
225
|
+
}
|
|
236
226
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
227
|
+
async applyBaseSnapshots() {
|
|
228
|
+
await this.addBootstrapNode();
|
|
229
|
+
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, cheatCodes }) => {
|
|
230
|
+
const rollup = getContract({
|
|
231
|
+
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
232
|
+
abi: RollupAbi,
|
|
233
|
+
client: deployL1ContractsValues.l1Client,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
237
|
+
|
|
238
|
+
const stakingAsset = getContract({
|
|
239
|
+
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
240
|
+
abi: TestERC20Abi,
|
|
241
|
+
client: deployL1ContractsValues.l1Client,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const { address: multiAdderAddress } = await deployL1Contract(
|
|
245
|
+
deployL1ContractsValues.l1Client,
|
|
246
|
+
MultiAdderArtifact.contractAbi,
|
|
247
|
+
MultiAdderArtifact.contractBytecode,
|
|
248
|
+
[rollup.address, deployL1ContractsValues.l1Client.account.address],
|
|
249
|
+
);
|
|
240
250
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
const multiAdder = getContract({
|
|
252
|
+
address: multiAdderAddress.toString(),
|
|
253
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
254
|
+
client: deployL1ContractsValues.l1Client,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const stakeNeeded = (await rollup.read.getActivationThreshold()) * BigInt(this.numberOfValidators);
|
|
258
|
+
await Promise.all(
|
|
259
|
+
[await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
|
|
260
|
+
deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
|
|
261
|
+
),
|
|
262
|
+
);
|
|
249
263
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
const { validators } = this.getValidators();
|
|
265
|
+
this.validators = validators;
|
|
266
|
+
|
|
267
|
+
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
268
|
+
if (!gseAddress) {
|
|
269
|
+
throw new Error('GSE contract not deployed');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
273
|
+
|
|
274
|
+
const makeValidatorTuples = async (validator: Operator) => {
|
|
275
|
+
const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
|
|
276
|
+
return {
|
|
277
|
+
attester: validator.attester.toString() as `0x${string}`,
|
|
278
|
+
withdrawer: validator.withdrawer.toString() as `0x${string}`,
|
|
279
|
+
...registrationTuple,
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
283
|
+
|
|
284
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
285
|
+
hash: await multiAdder.write.addValidators([validatorTuples]),
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
289
|
+
EpochNumber.fromBigInt(
|
|
290
|
+
BigInt(await cheatCodes.rollup.getEpoch()) + (await rollup.read.getLagInEpochsForValidatorSet()) + 1n,
|
|
291
|
+
),
|
|
292
|
+
);
|
|
258
293
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
);
|
|
294
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
295
|
+
await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
296
|
+
});
|
|
264
297
|
}
|
|
265
298
|
|
|
266
299
|
async setupAccount() {
|
|
267
300
|
await this.snapshotManager.snapshot(
|
|
268
301
|
'setup-account',
|
|
269
|
-
deployAccounts(1, this.logger
|
|
270
|
-
|
|
302
|
+
deployAccounts(1, this.logger),
|
|
303
|
+
({ deployedAccounts }, { wallet }) => {
|
|
271
304
|
this.deployedAccounts = deployedAccounts;
|
|
272
|
-
|
|
273
|
-
this.wallet =
|
|
305
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
306
|
+
this.wallet = wallet;
|
|
307
|
+
return Promise.resolve();
|
|
274
308
|
},
|
|
275
309
|
);
|
|
276
310
|
}
|
|
@@ -283,31 +317,28 @@ export class P2PNetworkTest {
|
|
|
283
317
|
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
284
318
|
}
|
|
285
319
|
|
|
286
|
-
const spamContract = await SpamContract.deploy(this.wallet)
|
|
320
|
+
const spamContract = await SpamContract.deploy(this.wallet)
|
|
321
|
+
.send({ from: this.defaultAccountAddress! })
|
|
322
|
+
.deployed();
|
|
287
323
|
return { contractAddress: spamContract.address };
|
|
288
324
|
},
|
|
289
|
-
|
|
325
|
+
({ contractAddress }) => {
|
|
290
326
|
if (!this.wallet) {
|
|
291
327
|
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
292
328
|
}
|
|
293
|
-
this.spamContract =
|
|
329
|
+
this.spamContract = SpamContract.at(contractAddress, this.wallet);
|
|
330
|
+
return Promise.resolve();
|
|
294
331
|
},
|
|
295
332
|
);
|
|
296
333
|
}
|
|
297
334
|
|
|
298
335
|
async removeInitialNode() {
|
|
299
336
|
await this.snapshotManager.snapshot(
|
|
300
|
-
'remove-
|
|
337
|
+
'remove-initial-validator',
|
|
301
338
|
async ({ deployL1ContractsValues, aztecNode, dateProvider }) => {
|
|
302
339
|
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
303
|
-
const receipt = await deployL1ContractsValues.
|
|
304
|
-
|
|
305
|
-
to: this.baseAccount.address,
|
|
306
|
-
value: 1n,
|
|
307
|
-
account: this.baseAccount,
|
|
308
|
-
}),
|
|
309
|
-
});
|
|
310
|
-
const block = await deployL1ContractsValues.publicClient.getBlock({
|
|
340
|
+
const { receipt } = await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
341
|
+
const block = await deployL1ContractsValues.l1Client.getBlock({
|
|
311
342
|
blockNumber: receipt.blockNumber,
|
|
312
343
|
});
|
|
313
344
|
dateProvider.setTime(Number(block.timestamp) * 1000);
|
|
@@ -317,29 +348,30 @@ export class P2PNetworkTest {
|
|
|
317
348
|
);
|
|
318
349
|
}
|
|
319
350
|
|
|
351
|
+
async sendDummyTx() {
|
|
352
|
+
return await this._sendDummyTx(this.ctx.deployL1ContractsValues.l1Client);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private async _sendDummyTx(l1Client: ExtendedViemWalletClient) {
|
|
356
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
|
|
357
|
+
return await l1TxUtils.sendAndMonitorTransaction({
|
|
358
|
+
to: l1Client.account!.address,
|
|
359
|
+
value: 1n,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
320
363
|
async setup() {
|
|
321
364
|
this.ctx = await this.snapshotManager.setup();
|
|
322
365
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
).prefilledPublicData;
|
|
366
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
367
|
+
const initialFundedAccounts = [...this.ctx.initialFundedAccounts.map(a => a.address), sponsoredFPCAddress];
|
|
326
368
|
|
|
327
|
-
|
|
369
|
+
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
370
|
+
this.prefilledPublicData = prefilledPublicData;
|
|
328
371
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.logger,
|
|
333
|
-
{
|
|
334
|
-
gasLimitBufferPercentage: 20,
|
|
335
|
-
maxGwei: 500n,
|
|
336
|
-
maxAttempts: 3,
|
|
337
|
-
checkIntervalMs: 100,
|
|
338
|
-
stallTimeMs: 1000,
|
|
339
|
-
},
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
this.monitor = new ChainMonitor(RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues)).start();
|
|
372
|
+
const rollupContract = RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues);
|
|
373
|
+
this.monitor = new ChainMonitor(rollupContract, this.ctx.dateProvider).start();
|
|
374
|
+
this.monitor.on('l1-block', ({ timestamp }) => this.ctx.dateProvider.setTime(Number(timestamp) * 1000));
|
|
343
375
|
}
|
|
344
376
|
|
|
345
377
|
async stopNodes(nodes: AztecNodeService[]) {
|
|
@@ -355,12 +387,83 @@ export class P2PNetworkTest {
|
|
|
355
387
|
this.logger.info('Nodes stopped');
|
|
356
388
|
}
|
|
357
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
392
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
393
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
394
|
+
*
|
|
395
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
396
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
397
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
398
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
399
|
+
*/
|
|
400
|
+
async waitForP2PMeshConnectivity(
|
|
401
|
+
nodes: AztecNodeService[],
|
|
402
|
+
expectedNodeCount?: number,
|
|
403
|
+
timeoutSeconds = 30,
|
|
404
|
+
checkIntervalSeconds = 0.1,
|
|
405
|
+
) {
|
|
406
|
+
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
407
|
+
const minPeerCount = nodeCount - 1;
|
|
408
|
+
|
|
409
|
+
this.logger.warn(
|
|
410
|
+
`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`,
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
await Promise.all(
|
|
414
|
+
nodes.map(async (node, index) => {
|
|
415
|
+
const p2p = node.getP2P();
|
|
416
|
+
await retryUntil(
|
|
417
|
+
async () => {
|
|
418
|
+
const peers = await p2p.getPeers();
|
|
419
|
+
// Each node should be connected to at least N-1 other nodes
|
|
420
|
+
return peers.length >= minPeerCount ? true : undefined;
|
|
421
|
+
},
|
|
422
|
+
`Node ${index} to connect to at least ${minPeerCount} peers`,
|
|
423
|
+
timeoutSeconds,
|
|
424
|
+
checkIntervalSeconds,
|
|
425
|
+
);
|
|
426
|
+
}),
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
this.logger.warn('All nodes connected to P2P mesh');
|
|
430
|
+
}
|
|
431
|
+
|
|
358
432
|
async teardown() {
|
|
359
|
-
this.monitor.stop();
|
|
360
|
-
await this.bootstrapNode
|
|
433
|
+
await this.monitor.stop();
|
|
434
|
+
await tryStop(this.bootstrapNode, this.logger);
|
|
361
435
|
await this.snapshotManager.teardown();
|
|
362
|
-
|
|
363
|
-
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async getContracts(): Promise<{
|
|
439
|
+
rollup: RollupContract;
|
|
440
|
+
slasherContract: GetContractReturnType<typeof SlasherAbi, ViemClient>;
|
|
441
|
+
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
442
|
+
slashFactory: SlashFactoryContract;
|
|
443
|
+
}> {
|
|
444
|
+
if (!this.ctx.deployL1ContractsValues) {
|
|
445
|
+
throw new Error('DeployAztecL1ContractsValues not set');
|
|
364
446
|
}
|
|
447
|
+
|
|
448
|
+
const rollup = new RollupContract(
|
|
449
|
+
this.ctx.deployL1ContractsValues!.l1Client,
|
|
450
|
+
this.ctx.deployL1ContractsValues!.l1ContractAddresses.rollupAddress,
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
const slasherContract = getContract({
|
|
454
|
+
address: getAddress(await rollup.getSlasherAddress()),
|
|
455
|
+
abi: SlasherAbi,
|
|
456
|
+
client: this.ctx.deployL1ContractsValues.l1Client,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// Get the actual slashing proposer from rollup (which handles both empire and tally)
|
|
460
|
+
const slashingProposer = await rollup.getSlashingProposer();
|
|
461
|
+
|
|
462
|
+
const slashFactory = new SlashFactoryContract(
|
|
463
|
+
this.ctx.deployL1ContractsValues.l1Client,
|
|
464
|
+
getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress!.toString()),
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
return { rollup, slasherContract, slashingProposer, slashFactory };
|
|
365
468
|
}
|
|
366
469
|
}
|