@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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 +60 -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 +69 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +315 -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 -27
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +27 -43
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
- 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 +66 -38
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
- 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 +34 -53
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -6
- package/dest/e2e_epochs/epochs_test.d.ts +56 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +222 -42
- 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 +60 -0
- package/dest/e2e_fees/fees_test.d.ts +16 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +87 -88
- package/dest/e2e_l1_publisher/write_json.d.ts +8 -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 +5 -5
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
- 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 +132 -0
- package/dest/e2e_p2p/p2p_network.d.ts +56 -21
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +154 -125
- package/dest/e2e_p2p/shared.d.ts +41 -3
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +146 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +51 -24
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
- 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.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +8 -15
- 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 +3 -3
- package/dest/fixtures/setup_p2p_test.d.ts +14 -6
- 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 +8 -3
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +120 -104
- package/dest/fixtures/token_utils.d.ts +4 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +24 -7
- package/dest/fixtures/utils.d.ts +65 -22
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +439 -318
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +42 -0
- package/dest/shared/cross_chain_test_harness.d.ts +28 -18
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +97 -41
- package/dest/shared/gas_portal_test_harness.d.ts +23 -18
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +43 -25
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +5 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +136 -90
- package/dest/simulators/lending_simulator.d.ts +5 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +11 -15
- package/dest/simulators/token_simulator.d.ts +2 -1
- 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 +8 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -22
- package/dest/spartan/utils.d.ts +60 -307
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +200 -115
- package/package.json +60 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +422 -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 +26 -52
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
- package/src/e2e_deploy_contract/deploy_test.ts +11 -8
- package/src/e2e_epochs/epochs_test.ts +276 -54
- package/src/e2e_fees/bridging_race.notest.ts +75 -0
- package/src/e2e_fees/fees_test.ts +121 -108
- package/src/e2e_l1_publisher/write_json.ts +74 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
- package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
- package/src/e2e_p2p/p2p_network.ts +212 -144
- package/src/e2e_p2p/shared.ts +234 -14
- package/src/e2e_token_contract/token_contract_test.ts +42 -38
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +2 -10
- package/src/fixtures/get_bb_config.ts +15 -11
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +5 -6
- package/src/fixtures/setup_p2p_test.ts +112 -30
- package/src/fixtures/snapshot_manager.ts +150 -102
- package/src/fixtures/token_utils.ts +33 -8
- package/src/fixtures/utils.ts +530 -352
- package/src/fixtures/web3signer.ts +46 -0
- package/src/guides/up_quick_start.sh +4 -4
- package/src/shared/cross_chain_test_harness.ts +92 -52
- package/src/shared/gas_portal_test_harness.ts +47 -31
- package/src/shared/uniswap_l1_l2.ts +127 -124
- package/src/simulators/lending_simulator.ts +11 -15
- package/src/simulators/token_simulator.ts +17 -12
- package/src/spartan/DEVELOP.md +116 -0
- package/src/spartan/setup_test_wallets.ts +144 -29
- package/src/spartan/utils.ts +194 -116
- 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,39 @@
|
|
|
1
1
|
import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
2
2
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
3
3
|
import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
-
import type
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { type AccountWalletWithSecretKey, AztecAddress, EthAddress, Fr } from '@aztec/aztec.js';
|
|
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 { SpamContract } from '@aztec/noir-contracts.js/Spam';
|
|
21
|
+
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
22
|
+
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
12
23
|
import type { BootstrapNode } from '@aztec/p2p/bootstrap';
|
|
13
24
|
import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
|
|
25
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
26
|
+
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
14
27
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
28
|
+
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
15
29
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
16
30
|
|
|
17
31
|
import getPort from 'get-port';
|
|
18
|
-
import { getContract } from 'viem';
|
|
32
|
+
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
19
33
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
20
34
|
|
|
21
35
|
import {
|
|
22
36
|
ATTESTER_PRIVATE_KEYS_START_INDEX,
|
|
23
|
-
PROPOSER_PRIVATE_KEYS_START_INDEX,
|
|
24
37
|
createValidatorConfig,
|
|
25
38
|
generatePrivateKeys,
|
|
26
39
|
} from '../fixtures/setup_p2p_test.js';
|
|
@@ -30,7 +43,7 @@ import {
|
|
|
30
43
|
createSnapshotManager,
|
|
31
44
|
deployAccounts,
|
|
32
45
|
} from '../fixtures/snapshot_manager.js';
|
|
33
|
-
import { getPrivateKeyFromIndex } from '../fixtures/utils.js';
|
|
46
|
+
import { type SetupOptions, getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
34
47
|
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
|
|
35
48
|
|
|
36
49
|
// 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 +51,16 @@ const BOOTSTRAP_NODE_PRIVATE_KEY = '080212208f988fc0899e4a73a5aee4d271a5f2067060
|
|
|
38
51
|
const l1ContractsConfig = getL1ContractsConfigEnvVars();
|
|
39
52
|
export const WAIT_FOR_TX_TIMEOUT = l1ContractsConfig.aztecSlotDuration * 3;
|
|
40
53
|
|
|
41
|
-
export const
|
|
54
|
+
export const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES = {
|
|
42
55
|
aztecSlotDuration: 12,
|
|
43
56
|
ethereumSlotDuration: 4,
|
|
57
|
+
aztecProofSubmissionWindow: 640,
|
|
44
58
|
};
|
|
45
59
|
|
|
46
60
|
export class P2PNetworkTest {
|
|
47
61
|
private snapshotManager: ISnapshotManager;
|
|
48
|
-
|
|
62
|
+
public baseAccountPrivateKey: `0x${string}`;
|
|
63
|
+
public baseAccount;
|
|
49
64
|
|
|
50
65
|
public logger: Logger;
|
|
51
66
|
public monitor!: ChainMonitor;
|
|
@@ -53,38 +68,44 @@ export class P2PNetworkTest {
|
|
|
53
68
|
public ctx!: SubsystemsContext;
|
|
54
69
|
public attesterPrivateKeys: `0x${string}`[] = [];
|
|
55
70
|
public attesterPublicKeys: string[] = [];
|
|
56
|
-
public proposerPrivateKeys: `0x${string}`[] = [];
|
|
57
71
|
public peerIdPrivateKeys: string[] = [];
|
|
72
|
+
public validators: Operator[] = [];
|
|
58
73
|
|
|
59
74
|
public deployedAccounts: InitialAccountData[] = [];
|
|
60
75
|
public prefilledPublicData: PublicDataTreeLeaf[] = [];
|
|
76
|
+
|
|
61
77
|
// The re-execution test needs a wallet and a spam contract
|
|
62
78
|
public wallet?: AccountWalletWithSecretKey;
|
|
79
|
+
public defaultAccountAddress?: AztecAddress;
|
|
63
80
|
public spamContract?: SpamContract;
|
|
64
81
|
|
|
65
82
|
public bootstrapNode?: BootstrapNode;
|
|
66
83
|
|
|
67
|
-
private cleanupInterval: NodeJS.Timeout | undefined = undefined;
|
|
68
|
-
|
|
69
|
-
private gasUtils: L1TxUtilsWithBlobs | undefined = undefined;
|
|
70
|
-
|
|
71
84
|
constructor(
|
|
72
|
-
testName: string,
|
|
85
|
+
public readonly testName: string,
|
|
73
86
|
public bootstrapNodeEnr: string,
|
|
74
87
|
public bootNodePort: number,
|
|
75
|
-
|
|
76
|
-
initialValidatorConfig:
|
|
88
|
+
public numberOfValidators: number,
|
|
89
|
+
initialValidatorConfig: SetupOptions,
|
|
90
|
+
public numberOfNodes = 0,
|
|
77
91
|
// If set enable metrics collection
|
|
78
92
|
private metricsPort?: number,
|
|
93
|
+
startProverNode?: boolean,
|
|
94
|
+
mockZkPassportVerifier?: boolean,
|
|
79
95
|
) {
|
|
80
96
|
this.logger = createLogger(`e2e:e2e_p2p:${testName}`);
|
|
81
97
|
|
|
82
98
|
// Set up the base account and node private keys for the initial network deployment
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.attesterPrivateKeys = generatePrivateKeys(
|
|
99
|
+
this.baseAccountPrivateKey = `0x${getPrivateKeyFromIndex(1)!.toString('hex')}`;
|
|
100
|
+
this.baseAccount = privateKeyToAccount(this.baseAccountPrivateKey);
|
|
101
|
+
this.attesterPrivateKeys = generatePrivateKeys(
|
|
102
|
+
ATTESTER_PRIVATE_KEYS_START_INDEX + numberOfNodes,
|
|
103
|
+
numberOfValidators,
|
|
104
|
+
);
|
|
86
105
|
this.attesterPublicKeys = this.attesterPrivateKeys.map(privateKey => privateKeyToAccount(privateKey).address);
|
|
87
106
|
|
|
107
|
+
const zkPassportParams = ZkPassportProofParams.random();
|
|
108
|
+
|
|
88
109
|
this.snapshotManager = createSnapshotManager(
|
|
89
110
|
`e2e_p2p_network/${testName}`,
|
|
90
111
|
process.env.E2E_DATA_PATH,
|
|
@@ -93,19 +114,35 @@ export class P2PNetworkTest {
|
|
|
93
114
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
94
115
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
95
116
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
96
|
-
|
|
97
|
-
initialValidatorConfig.
|
|
117
|
+
aztecProofSubmissionEpochs:
|
|
118
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
119
|
+
slashingRoundSizeInEpochs:
|
|
120
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
121
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
122
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
98
123
|
salt: 420,
|
|
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
|
+
mockZkPassportVerifier,
|
|
143
|
+
zkPassportDomain: zkPassportParams.domain,
|
|
144
|
+
zkPassportScope: zkPassportParams.scope,
|
|
145
|
+
},
|
|
109
146
|
},
|
|
110
147
|
);
|
|
111
148
|
}
|
|
@@ -113,15 +150,21 @@ export class P2PNetworkTest {
|
|
|
113
150
|
static async create({
|
|
114
151
|
testName,
|
|
115
152
|
numberOfNodes,
|
|
153
|
+
numberOfValidators,
|
|
116
154
|
basePort,
|
|
117
155
|
metricsPort,
|
|
118
156
|
initialConfig,
|
|
157
|
+
startProverNode,
|
|
158
|
+
mockZkPassportVerifier,
|
|
119
159
|
}: {
|
|
120
160
|
testName: string;
|
|
121
161
|
numberOfNodes: number;
|
|
162
|
+
numberOfValidators: number;
|
|
122
163
|
basePort?: number;
|
|
123
164
|
metricsPort?: number;
|
|
124
|
-
initialConfig?:
|
|
165
|
+
initialConfig?: SetupOptions;
|
|
166
|
+
startProverNode?: boolean;
|
|
167
|
+
mockZkPassportVerifier?: boolean;
|
|
125
168
|
}) {
|
|
126
169
|
const port = basePort || (await getPort());
|
|
127
170
|
|
|
@@ -133,7 +176,17 @@ export class P2PNetworkTest {
|
|
|
133
176
|
bootstrapNodeEnr,
|
|
134
177
|
);
|
|
135
178
|
|
|
136
|
-
return new P2PNetworkTest(
|
|
179
|
+
return new P2PNetworkTest(
|
|
180
|
+
testName,
|
|
181
|
+
bootstrapNodeEnr,
|
|
182
|
+
port,
|
|
183
|
+
numberOfValidators,
|
|
184
|
+
initialValidatorConfig,
|
|
185
|
+
numberOfNodes,
|
|
186
|
+
metricsPort,
|
|
187
|
+
startProverNode,
|
|
188
|
+
mockZkPassportVerifier,
|
|
189
|
+
);
|
|
137
190
|
}
|
|
138
191
|
|
|
139
192
|
get fundedAccount() {
|
|
@@ -143,33 +196,7 @@ export class P2PNetworkTest {
|
|
|
143
196
|
return this.deployedAccounts[0];
|
|
144
197
|
}
|
|
145
198
|
|
|
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() {
|
|
199
|
+
async addBootstrapNode() {
|
|
173
200
|
await this.snapshotManager.snapshot('add-bootstrap-node', async ({ aztecNodeConfig }) => {
|
|
174
201
|
const telemetry = getEndToEndTestTelemetryClient(this.metricsPort);
|
|
175
202
|
this.bootstrapNode = await createBootstrapNodeFromPrivateKey(
|
|
@@ -181,84 +208,98 @@ export class P2PNetworkTest {
|
|
|
181
208
|
// Overwrite enr with updated info
|
|
182
209
|
this.bootstrapNodeEnr = this.bootstrapNode.getENR().encodeTxt();
|
|
183
210
|
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
getValidators() {
|
|
214
|
+
const validators: Operator[] = [];
|
|
215
|
+
|
|
216
|
+
for (let i = 0; i < this.numberOfValidators; i++) {
|
|
217
|
+
const keyIndex = i;
|
|
218
|
+
const attester = privateKeyToAccount(this.attesterPrivateKeys[keyIndex]!);
|
|
219
|
+
|
|
220
|
+
validators.push({
|
|
221
|
+
attester: EthAddress.fromString(attester.address),
|
|
222
|
+
withdrawer: EthAddress.fromString(attester.address),
|
|
223
|
+
bn254SecretKey: new SecretValue(Fr.random().toBigInt()),
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
this.logger.info(`Adding attester ${attester.address} as validator`);
|
|
227
|
+
}
|
|
228
|
+
return { validators };
|
|
229
|
+
}
|
|
184
230
|
|
|
231
|
+
async applyBaseSnapshots() {
|
|
232
|
+
await this.addBootstrapNode();
|
|
185
233
|
await this.snapshotManager.snapshot(
|
|
186
234
|
'add-validators',
|
|
187
|
-
async ({ deployL1ContractsValues,
|
|
235
|
+
async ({ deployL1ContractsValues, dateProvider, cheatCodes }) => {
|
|
188
236
|
const rollup = getContract({
|
|
189
237
|
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
190
238
|
abi: RollupAbi,
|
|
191
|
-
client: deployL1ContractsValues.
|
|
239
|
+
client: deployL1ContractsValues.l1Client,
|
|
192
240
|
});
|
|
193
241
|
|
|
194
|
-
this.logger.
|
|
242
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
195
243
|
|
|
196
244
|
const stakingAsset = getContract({
|
|
197
245
|
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
198
246
|
abi: TestERC20Abi,
|
|
199
|
-
client: deployL1ContractsValues.
|
|
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
|
+
);
|
|
256
|
+
|
|
257
|
+
const multiAdder = getContract({
|
|
258
|
+
address: multiAdderAddress.toString(),
|
|
259
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
260
|
+
client: deployL1ContractsValues.l1Client,
|
|
200
261
|
});
|
|
201
262
|
|
|
202
|
-
const stakeNeeded =
|
|
263
|
+
const stakeNeeded = (await rollup.read.getActivationThreshold()) * BigInt(this.numberOfValidators);
|
|
203
264
|
await Promise.all(
|
|
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 })),
|
|
265
|
+
[await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
|
|
266
|
+
deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
|
|
267
|
+
),
|
|
214
268
|
);
|
|
215
269
|
|
|
216
|
-
const validators =
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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`);
|
|
270
|
+
const { validators } = this.getValidators();
|
|
271
|
+
this.validators = validators;
|
|
272
|
+
|
|
273
|
+
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
274
|
+
if (!gseAddress) {
|
|
275
|
+
throw new Error('GSE contract not deployed');
|
|
235
276
|
}
|
|
236
277
|
|
|
237
|
-
|
|
238
|
-
hash: await rollup.write.cheat__InitialiseValidatorSet([validators]),
|
|
239
|
-
});
|
|
278
|
+
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
240
279
|
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
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));
|
|
249
289
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
hash: await deployL1ContractsValues.walletClient.sendTransaction({
|
|
253
|
-
to: this.baseAccount.address,
|
|
254
|
-
value: 1n,
|
|
255
|
-
account: this.baseAccount,
|
|
256
|
-
}),
|
|
290
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
291
|
+
hash: await multiAdder.write.addValidators([validatorTuples]),
|
|
257
292
|
});
|
|
258
293
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
294
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
295
|
+
(await cheatCodes.rollup.getEpoch()) + (await rollup.read.getLagInEpochs()) + 1n,
|
|
296
|
+
{
|
|
297
|
+
updateDateProvider: dateProvider,
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
302
|
+
await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
262
303
|
},
|
|
263
304
|
);
|
|
264
305
|
}
|
|
@@ -271,6 +312,7 @@ export class P2PNetworkTest {
|
|
|
271
312
|
this.deployedAccounts = deployedAccounts;
|
|
272
313
|
const [account] = deployedAccounts;
|
|
273
314
|
this.wallet = await getSchnorrWalletWithSecretKey(pxe, account.secret, account.signingKey, account.salt);
|
|
315
|
+
this.defaultAccountAddress = this.wallet.getAddress();
|
|
274
316
|
},
|
|
275
317
|
);
|
|
276
318
|
}
|
|
@@ -283,7 +325,9 @@ export class P2PNetworkTest {
|
|
|
283
325
|
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
284
326
|
}
|
|
285
327
|
|
|
286
|
-
const spamContract = await SpamContract.deploy(this.wallet)
|
|
328
|
+
const spamContract = await SpamContract.deploy(this.wallet)
|
|
329
|
+
.send({ from: this.defaultAccountAddress! })
|
|
330
|
+
.deployed();
|
|
287
331
|
return { contractAddress: spamContract.address };
|
|
288
332
|
},
|
|
289
333
|
async ({ contractAddress }) => {
|
|
@@ -297,17 +341,11 @@ export class P2PNetworkTest {
|
|
|
297
341
|
|
|
298
342
|
async removeInitialNode() {
|
|
299
343
|
await this.snapshotManager.snapshot(
|
|
300
|
-
'remove-
|
|
344
|
+
'remove-initial-validator',
|
|
301
345
|
async ({ deployL1ContractsValues, aztecNode, dateProvider }) => {
|
|
302
346
|
// 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({
|
|
347
|
+
const { receipt } = await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
348
|
+
const block = await deployL1ContractsValues.l1Client.getBlock({
|
|
311
349
|
blockNumber: receipt.blockNumber,
|
|
312
350
|
});
|
|
313
351
|
dateProvider.setTime(Number(block.timestamp) * 1000);
|
|
@@ -317,29 +355,30 @@ export class P2PNetworkTest {
|
|
|
317
355
|
);
|
|
318
356
|
}
|
|
319
357
|
|
|
358
|
+
async sendDummyTx() {
|
|
359
|
+
return await this._sendDummyTx(this.ctx.deployL1ContractsValues.l1Client);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private async _sendDummyTx(l1Client: ExtendedViemWalletClient) {
|
|
363
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
|
|
364
|
+
return await l1TxUtils.sendAndMonitorTransaction({
|
|
365
|
+
to: l1Client.account!.address,
|
|
366
|
+
value: 1n,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
320
370
|
async setup() {
|
|
321
371
|
this.ctx = await this.snapshotManager.setup();
|
|
322
372
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
).prefilledPublicData;
|
|
373
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
374
|
+
const initialFundedAccounts = [...this.ctx.initialFundedAccounts.map(a => a.address), sponsoredFPCAddress];
|
|
326
375
|
|
|
327
|
-
|
|
376
|
+
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
377
|
+
this.prefilledPublicData = prefilledPublicData;
|
|
328
378
|
|
|
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();
|
|
379
|
+
const rollupContract = RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues);
|
|
380
|
+
this.monitor = new ChainMonitor(rollupContract, this.ctx.dateProvider).start();
|
|
381
|
+
this.monitor.on('l1-block', ({ timestamp }) => this.ctx.dateProvider.setTime(Number(timestamp) * 1000));
|
|
343
382
|
}
|
|
344
383
|
|
|
345
384
|
async stopNodes(nodes: AztecNodeService[]) {
|
|
@@ -356,11 +395,40 @@ export class P2PNetworkTest {
|
|
|
356
395
|
}
|
|
357
396
|
|
|
358
397
|
async teardown() {
|
|
359
|
-
this.monitor.stop();
|
|
360
|
-
await this.bootstrapNode
|
|
398
|
+
await this.monitor.stop();
|
|
399
|
+
await tryStop(this.bootstrapNode, this.logger);
|
|
361
400
|
await this.snapshotManager.teardown();
|
|
362
|
-
|
|
363
|
-
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
async getContracts(): Promise<{
|
|
404
|
+
rollup: RollupContract;
|
|
405
|
+
slasherContract: GetContractReturnType<typeof SlasherAbi, ViemClient>;
|
|
406
|
+
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
407
|
+
slashFactory: SlashFactoryContract;
|
|
408
|
+
}> {
|
|
409
|
+
if (!this.ctx.deployL1ContractsValues) {
|
|
410
|
+
throw new Error('DeployL1ContractsValues not set');
|
|
364
411
|
}
|
|
412
|
+
|
|
413
|
+
const rollup = new RollupContract(
|
|
414
|
+
this.ctx.deployL1ContractsValues!.l1Client,
|
|
415
|
+
this.ctx.deployL1ContractsValues!.l1ContractAddresses.rollupAddress,
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
const slasherContract = getContract({
|
|
419
|
+
address: getAddress(await rollup.getSlasherAddress()),
|
|
420
|
+
abi: SlasherAbi,
|
|
421
|
+
client: this.ctx.deployL1ContractsValues.l1Client,
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Get the actual slashing proposer from rollup (which handles both empire and tally)
|
|
425
|
+
const slashingProposer = await rollup.getSlashingProposer();
|
|
426
|
+
|
|
427
|
+
const slashFactory = new SlashFactoryContract(
|
|
428
|
+
this.ctx.deployL1ContractsValues.l1Client,
|
|
429
|
+
getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress!.toString()),
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
return { rollup, slasherContract, slashingProposer, slashFactory };
|
|
365
433
|
}
|
|
366
434
|
}
|