@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.b655e406
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 +73 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +311 -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 +99 -0
- package/dest/bench/utils.d.ts +10 -36
- 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 +20 -12
- 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 +18 -24
- 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 +48 -69
- package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
- 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 +58 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +224 -43
- 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 +20 -9
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +98 -107
- 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 +57 -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 +9 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
- 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 +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +69 -22
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +180 -129
- package/dest/e2e_p2p/shared.d.ts +41 -5
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +163 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
- 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/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
- package/dest/fixtures/fixtures.d.ts +5 -6
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- 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 +10 -17
- package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +44 -18
- package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts +14 -13
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +73 -21
- package/dest/fixtures/snapshot_manager.d.ts +15 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -121
- package/dest/fixtures/token_utils.d.ts +6 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +23 -10
- package/dest/fixtures/utils.d.ts +76 -37
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -368
- 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/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +41 -25
- 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 +32 -24
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +50 -29
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +13 -11
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +138 -108
- package/dest/simulators/lending_simulator.d.ts +6 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +13 -16
- package/dest/simulators/token_simulator.d.ts +5 -2
- 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 +23 -10
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +167 -58
- package/dest/spartan/utils.d.ts +106 -303
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +434 -130
- package/package.json +61 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +402 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +111 -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 +63 -105
- package/src/e2e_deploy_contract/deploy_test.ts +23 -38
- package/src/e2e_epochs/epochs_test.ts +274 -54
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +137 -136
- package/src/e2e_l1_publisher/write_json.ts +76 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +272 -166
- package/src/e2e_p2p/shared.ts +244 -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 +101 -145
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +3 -11
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +6 -7
- package/src/fixtures/setup_p2p_test.ts +112 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +29 -12
- package/src/fixtures/utils.ts +552 -425
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +6 -14
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +108 -79
- package/src/shared/gas_portal_test_harness.ts +58 -49
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +173 -176
- package/src/simulators/lending_simulator.ts +12 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +215 -93
- package/src/spartan/utils.ts +490 -130
- package/dest/e2e_prover/e2e_prover_test.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/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
|
-
|
|
8
|
-
|
|
3
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import {
|
|
6
|
+
type EmpireSlashingProposerContract,
|
|
7
|
+
type ExtendedViemWalletClient,
|
|
8
|
+
GSEContract,
|
|
9
|
+
MultiAdderArtifact,
|
|
10
|
+
type Operator,
|
|
11
|
+
RollupContract,
|
|
12
|
+
type TallySlashingProposerContract,
|
|
13
|
+
type ViemClient,
|
|
14
|
+
createL1TxUtilsFromViemWallet,
|
|
15
|
+
deployL1Contract,
|
|
16
|
+
getL1ContractsConfigEnvVars,
|
|
17
|
+
} from '@aztec/ethereum';
|
|
18
|
+
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
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,44 @@ 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,
|
|
96
|
+
mockZkPassportVerifier?: boolean,
|
|
79
97
|
) {
|
|
80
98
|
this.logger = createLogger(`e2e:e2e_p2p:${testName}`);
|
|
81
99
|
|
|
82
100
|
// Set up the base account and node private keys for the initial network deployment
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.attesterPrivateKeys = generatePrivateKeys(
|
|
101
|
+
this.baseAccountPrivateKey = `0x${getPrivateKeyFromIndex(1)!.toString('hex')}`;
|
|
102
|
+
this.baseAccount = privateKeyToAccount(this.baseAccountPrivateKey);
|
|
103
|
+
this.attesterPrivateKeys = generatePrivateKeys(
|
|
104
|
+
ATTESTER_PRIVATE_KEYS_START_INDEX + numberOfNodes,
|
|
105
|
+
numberOfValidators,
|
|
106
|
+
);
|
|
86
107
|
this.attesterPublicKeys = this.attesterPrivateKeys.map(privateKey => privateKeyToAccount(privateKey).address);
|
|
87
108
|
|
|
109
|
+
const zkPassportParams = ZkPassportProofParams.random();
|
|
110
|
+
|
|
88
111
|
this.snapshotManager = createSnapshotManager(
|
|
89
112
|
`e2e_p2p_network/${testName}`,
|
|
90
113
|
process.env.E2E_DATA_PATH,
|
|
@@ -93,19 +116,35 @@ export class P2PNetworkTest {
|
|
|
93
116
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
94
117
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
95
118
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
96
|
-
|
|
97
|
-
initialValidatorConfig.
|
|
119
|
+
aztecProofSubmissionEpochs:
|
|
120
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
121
|
+
slashingRoundSizeInEpochs:
|
|
122
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
123
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
124
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
98
125
|
salt: 420,
|
|
99
126
|
metricsPort: metricsPort,
|
|
100
|
-
numberOfInitialFundedAccounts:
|
|
127
|
+
numberOfInitialFundedAccounts: 2,
|
|
128
|
+
startProverNode,
|
|
101
129
|
},
|
|
102
130
|
{
|
|
131
|
+
...initialValidatorConfig,
|
|
103
132
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
133
|
+
slashingRoundSizeInEpochs:
|
|
134
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
135
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
136
|
+
|
|
104
137
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
105
138
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
106
|
-
|
|
107
|
-
initialValidatorConfig.
|
|
139
|
+
aztecProofSubmissionEpochs:
|
|
140
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
141
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
108
142
|
initialValidators: [],
|
|
143
|
+
zkPassportArgs: {
|
|
144
|
+
mockZkPassportVerifier,
|
|
145
|
+
zkPassportDomain: zkPassportParams.domain,
|
|
146
|
+
zkPassportScope: zkPassportParams.scope,
|
|
147
|
+
},
|
|
109
148
|
},
|
|
110
149
|
);
|
|
111
150
|
}
|
|
@@ -113,15 +152,21 @@ export class P2PNetworkTest {
|
|
|
113
152
|
static async create({
|
|
114
153
|
testName,
|
|
115
154
|
numberOfNodes,
|
|
155
|
+
numberOfValidators,
|
|
116
156
|
basePort,
|
|
117
157
|
metricsPort,
|
|
118
158
|
initialConfig,
|
|
159
|
+
startProverNode,
|
|
160
|
+
mockZkPassportVerifier,
|
|
119
161
|
}: {
|
|
120
162
|
testName: string;
|
|
121
163
|
numberOfNodes: number;
|
|
164
|
+
numberOfValidators: number;
|
|
122
165
|
basePort?: number;
|
|
123
166
|
metricsPort?: number;
|
|
124
|
-
initialConfig?:
|
|
167
|
+
initialConfig?: SetupOptions;
|
|
168
|
+
startProverNode?: boolean;
|
|
169
|
+
mockZkPassportVerifier?: boolean;
|
|
125
170
|
}) {
|
|
126
171
|
const port = basePort || (await getPort());
|
|
127
172
|
|
|
@@ -133,7 +178,17 @@ export class P2PNetworkTest {
|
|
|
133
178
|
bootstrapNodeEnr,
|
|
134
179
|
);
|
|
135
180
|
|
|
136
|
-
return new P2PNetworkTest(
|
|
181
|
+
return new P2PNetworkTest(
|
|
182
|
+
testName,
|
|
183
|
+
bootstrapNodeEnr,
|
|
184
|
+
port,
|
|
185
|
+
numberOfValidators,
|
|
186
|
+
initialValidatorConfig,
|
|
187
|
+
numberOfNodes,
|
|
188
|
+
metricsPort,
|
|
189
|
+
startProverNode,
|
|
190
|
+
mockZkPassportVerifier,
|
|
191
|
+
);
|
|
137
192
|
}
|
|
138
193
|
|
|
139
194
|
get fundedAccount() {
|
|
@@ -143,33 +198,7 @@ export class P2PNetworkTest {
|
|
|
143
198
|
return this.deployedAccounts[0];
|
|
144
199
|
}
|
|
145
200
|
|
|
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() {
|
|
201
|
+
async addBootstrapNode() {
|
|
173
202
|
await this.snapshotManager.snapshot('add-bootstrap-node', async ({ aztecNodeConfig }) => {
|
|
174
203
|
const telemetry = getEndToEndTestTelemetryClient(this.metricsPort);
|
|
175
204
|
this.bootstrapNode = await createBootstrapNodeFromPrivateKey(
|
|
@@ -181,96 +210,105 @@ export class P2PNetworkTest {
|
|
|
181
210
|
// Overwrite enr with updated info
|
|
182
211
|
this.bootstrapNodeEnr = this.bootstrapNode.getENR().encodeTxt();
|
|
183
212
|
});
|
|
213
|
+
}
|
|
184
214
|
|
|
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
|
-
});
|
|
215
|
+
getValidators() {
|
|
216
|
+
const validators: Operator[] = [];
|
|
193
217
|
|
|
194
|
-
|
|
218
|
+
for (let i = 0; i < this.numberOfValidators; i++) {
|
|
219
|
+
const keyIndex = i;
|
|
220
|
+
const attester = privateKeyToAccount(this.attesterPrivateKeys[keyIndex]!);
|
|
195
221
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
222
|
+
validators.push({
|
|
223
|
+
attester: EthAddress.fromString(attester.address),
|
|
224
|
+
withdrawer: EthAddress.fromString(attester.address),
|
|
225
|
+
bn254SecretKey: new SecretValue(Fr.random().toBigInt()),
|
|
226
|
+
});
|
|
201
227
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
[deployL1ContractsValues.walletClient.account.address, stakeNeeded],
|
|
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
|
-
);
|
|
228
|
+
this.logger.info(`Adding attester ${attester.address} as validator`);
|
|
229
|
+
}
|
|
230
|
+
return { validators };
|
|
231
|
+
}
|
|
215
232
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
async applyBaseSnapshots() {
|
|
234
|
+
await this.addBootstrapNode();
|
|
235
|
+
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, cheatCodes }) => {
|
|
236
|
+
const rollup = getContract({
|
|
237
|
+
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
238
|
+
abi: RollupAbi,
|
|
239
|
+
client: deployL1ContractsValues.l1Client,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
243
|
+
|
|
244
|
+
const stakingAsset = getContract({
|
|
245
|
+
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
246
|
+
abi: TestERC20Abi,
|
|
247
|
+
client: deployL1ContractsValues.l1Client,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const { address: multiAdderAddress } = await deployL1Contract(
|
|
251
|
+
deployL1ContractsValues.l1Client,
|
|
252
|
+
MultiAdderArtifact.contractAbi,
|
|
253
|
+
MultiAdderArtifact.contractBytecode,
|
|
254
|
+
[rollup.address, deployL1ContractsValues.l1Client.account.address],
|
|
255
|
+
);
|
|
236
256
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
257
|
+
const multiAdder = getContract({
|
|
258
|
+
address: multiAdderAddress.toString(),
|
|
259
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
260
|
+
client: deployL1ContractsValues.l1Client,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const stakeNeeded = (await rollup.read.getActivationThreshold()) * BigInt(this.numberOfValidators);
|
|
264
|
+
await Promise.all(
|
|
265
|
+
[await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
|
|
266
|
+
deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
|
|
267
|
+
),
|
|
268
|
+
);
|
|
240
269
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const cheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
244
|
-
try {
|
|
245
|
-
await cheatCodes.warp(Number(timestamp));
|
|
246
|
-
} catch (err) {
|
|
247
|
-
this.logger.debug('Warp failed, time already satisfied');
|
|
248
|
-
}
|
|
270
|
+
const { validators } = this.getValidators();
|
|
271
|
+
this.validators = validators;
|
|
249
272
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
value: 1n,
|
|
255
|
-
account: this.baseAccount,
|
|
256
|
-
}),
|
|
257
|
-
});
|
|
273
|
+
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
274
|
+
if (!gseAddress) {
|
|
275
|
+
throw new Error('GSE contract not deployed');
|
|
276
|
+
}
|
|
258
277
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
278
|
+
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
279
|
+
|
|
280
|
+
const makeValidatorTuples = async (validator: Operator) => {
|
|
281
|
+
const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
|
|
282
|
+
return {
|
|
283
|
+
attester: validator.attester.toString() as `0x${string}`,
|
|
284
|
+
withdrawer: validator.withdrawer.toString() as `0x${string}`,
|
|
285
|
+
...registrationTuple,
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
289
|
+
|
|
290
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
291
|
+
hash: await multiAdder.write.addValidators([validatorTuples]),
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
295
|
+
(await cheatCodes.rollup.getEpoch()) + (await rollup.read.getLagInEpochs()) + 1n,
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
299
|
+
await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
300
|
+
});
|
|
264
301
|
}
|
|
265
302
|
|
|
266
303
|
async setupAccount() {
|
|
267
304
|
await this.snapshotManager.snapshot(
|
|
268
305
|
'setup-account',
|
|
269
|
-
deployAccounts(1, this.logger
|
|
270
|
-
|
|
306
|
+
deployAccounts(1, this.logger),
|
|
307
|
+
({ deployedAccounts }, { wallet }) => {
|
|
271
308
|
this.deployedAccounts = deployedAccounts;
|
|
272
|
-
|
|
273
|
-
this.wallet =
|
|
309
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
310
|
+
this.wallet = wallet;
|
|
311
|
+
return Promise.resolve();
|
|
274
312
|
},
|
|
275
313
|
);
|
|
276
314
|
}
|
|
@@ -283,7 +321,9 @@ export class P2PNetworkTest {
|
|
|
283
321
|
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
284
322
|
}
|
|
285
323
|
|
|
286
|
-
const spamContract = await SpamContract.deploy(this.wallet)
|
|
324
|
+
const spamContract = await SpamContract.deploy(this.wallet)
|
|
325
|
+
.send({ from: this.defaultAccountAddress! })
|
|
326
|
+
.deployed();
|
|
287
327
|
return { contractAddress: spamContract.address };
|
|
288
328
|
},
|
|
289
329
|
async ({ contractAddress }) => {
|
|
@@ -297,17 +337,11 @@ export class P2PNetworkTest {
|
|
|
297
337
|
|
|
298
338
|
async removeInitialNode() {
|
|
299
339
|
await this.snapshotManager.snapshot(
|
|
300
|
-
'remove-
|
|
340
|
+
'remove-initial-validator',
|
|
301
341
|
async ({ deployL1ContractsValues, aztecNode, dateProvider }) => {
|
|
302
342
|
// 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({
|
|
343
|
+
const { receipt } = await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
344
|
+
const block = await deployL1ContractsValues.l1Client.getBlock({
|
|
311
345
|
blockNumber: receipt.blockNumber,
|
|
312
346
|
});
|
|
313
347
|
dateProvider.setTime(Number(block.timestamp) * 1000);
|
|
@@ -317,29 +351,30 @@ export class P2PNetworkTest {
|
|
|
317
351
|
);
|
|
318
352
|
}
|
|
319
353
|
|
|
354
|
+
async sendDummyTx() {
|
|
355
|
+
return await this._sendDummyTx(this.ctx.deployL1ContractsValues.l1Client);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private async _sendDummyTx(l1Client: ExtendedViemWalletClient) {
|
|
359
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
|
|
360
|
+
return await l1TxUtils.sendAndMonitorTransaction({
|
|
361
|
+
to: l1Client.account!.address,
|
|
362
|
+
value: 1n,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
320
366
|
async setup() {
|
|
321
367
|
this.ctx = await this.snapshotManager.setup();
|
|
322
368
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
).prefilledPublicData;
|
|
369
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
370
|
+
const initialFundedAccounts = [...this.ctx.initialFundedAccounts.map(a => a.address), sponsoredFPCAddress];
|
|
326
371
|
|
|
327
|
-
|
|
372
|
+
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
373
|
+
this.prefilledPublicData = prefilledPublicData;
|
|
328
374
|
|
|
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();
|
|
375
|
+
const rollupContract = RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues);
|
|
376
|
+
this.monitor = new ChainMonitor(rollupContract, this.ctx.dateProvider).start();
|
|
377
|
+
this.monitor.on('l1-block', ({ timestamp }) => this.ctx.dateProvider.setTime(Number(timestamp) * 1000));
|
|
343
378
|
}
|
|
344
379
|
|
|
345
380
|
async stopNodes(nodes: AztecNodeService[]) {
|
|
@@ -355,12 +390,83 @@ export class P2PNetworkTest {
|
|
|
355
390
|
this.logger.info('Nodes stopped');
|
|
356
391
|
}
|
|
357
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
395
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
396
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
397
|
+
*
|
|
398
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
399
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
400
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
401
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
402
|
+
*/
|
|
403
|
+
async waitForP2PMeshConnectivity(
|
|
404
|
+
nodes: AztecNodeService[],
|
|
405
|
+
expectedNodeCount?: number,
|
|
406
|
+
timeoutSeconds = 30,
|
|
407
|
+
checkIntervalSeconds = 0.1,
|
|
408
|
+
) {
|
|
409
|
+
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
410
|
+
const minPeerCount = nodeCount - 1;
|
|
411
|
+
|
|
412
|
+
this.logger.warn(
|
|
413
|
+
`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`,
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
await Promise.all(
|
|
417
|
+
nodes.map(async (node, index) => {
|
|
418
|
+
const p2p = node.getP2P();
|
|
419
|
+
await retryUntil(
|
|
420
|
+
async () => {
|
|
421
|
+
const peers = await p2p.getPeers();
|
|
422
|
+
// Each node should be connected to at least N-1 other nodes
|
|
423
|
+
return peers.length >= minPeerCount ? true : undefined;
|
|
424
|
+
},
|
|
425
|
+
`Node ${index} to connect to at least ${minPeerCount} peers`,
|
|
426
|
+
timeoutSeconds,
|
|
427
|
+
checkIntervalSeconds,
|
|
428
|
+
);
|
|
429
|
+
}),
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
this.logger.warn('All nodes connected to P2P mesh');
|
|
433
|
+
}
|
|
434
|
+
|
|
358
435
|
async teardown() {
|
|
359
|
-
this.monitor.stop();
|
|
360
|
-
await this.bootstrapNode
|
|
436
|
+
await this.monitor.stop();
|
|
437
|
+
await tryStop(this.bootstrapNode, this.logger);
|
|
361
438
|
await this.snapshotManager.teardown();
|
|
362
|
-
|
|
363
|
-
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
async getContracts(): Promise<{
|
|
442
|
+
rollup: RollupContract;
|
|
443
|
+
slasherContract: GetContractReturnType<typeof SlasherAbi, ViemClient>;
|
|
444
|
+
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
445
|
+
slashFactory: SlashFactoryContract;
|
|
446
|
+
}> {
|
|
447
|
+
if (!this.ctx.deployL1ContractsValues) {
|
|
448
|
+
throw new Error('DeployL1ContractsValues not set');
|
|
364
449
|
}
|
|
450
|
+
|
|
451
|
+
const rollup = new RollupContract(
|
|
452
|
+
this.ctx.deployL1ContractsValues!.l1Client,
|
|
453
|
+
this.ctx.deployL1ContractsValues!.l1ContractAddresses.rollupAddress,
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const slasherContract = getContract({
|
|
457
|
+
address: getAddress(await rollup.getSlasherAddress()),
|
|
458
|
+
abi: SlasherAbi,
|
|
459
|
+
client: this.ctx.deployL1ContractsValues.l1Client,
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// Get the actual slashing proposer from rollup (which handles both empire and tally)
|
|
463
|
+
const slashingProposer = await rollup.getSlashingProposer();
|
|
464
|
+
|
|
465
|
+
const slashFactory = new SlashFactoryContract(
|
|
466
|
+
this.ctx.deployL1ContractsValues.l1Client,
|
|
467
|
+
getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress!.toString()),
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
return { rollup, slasherContract, slashingProposer, slashFactory };
|
|
365
471
|
}
|
|
366
472
|
}
|