@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,93 +1,113 @@
|
|
|
1
1
|
import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
3
|
-
import { RollupContract,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { EthAddress, Fr } from '@aztec/aztec.js';
|
|
3
|
+
import { GSEContract, MultiAdderArtifact, RollupContract, createL1TxUtilsFromViemWallet, deployL1Contract, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
4
|
+
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
5
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
6
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
-
import {
|
|
8
|
-
import { SpamContract } from '@aztec/noir-contracts.js/Spam';
|
|
7
|
+
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
8
|
+
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
9
9
|
import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
|
|
10
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
11
|
+
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
12
|
+
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
10
13
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
11
14
|
import getPort from 'get-port';
|
|
12
|
-
import { getContract } from 'viem';
|
|
15
|
+
import { getAddress, getContract } from 'viem';
|
|
13
16
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
14
|
-
import { ATTESTER_PRIVATE_KEYS_START_INDEX,
|
|
17
|
+
import { ATTESTER_PRIVATE_KEYS_START_INDEX, createValidatorConfig, generatePrivateKeys } from '../fixtures/setup_p2p_test.js';
|
|
15
18
|
import { createSnapshotManager, deployAccounts } from '../fixtures/snapshot_manager.js';
|
|
16
|
-
import { getPrivateKeyFromIndex } from '../fixtures/utils.js';
|
|
19
|
+
import { getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
17
20
|
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
|
|
18
21
|
// Use a fixed bootstrap node private key so that we can re-use the same snapshot and the nodes can find each other
|
|
19
22
|
const BOOTSTRAP_NODE_PRIVATE_KEY = '080212208f988fc0899e4a73a5aee4d271a5f20670603a756ad8d84f2c94263a6427c591';
|
|
20
23
|
const l1ContractsConfig = getL1ContractsConfigEnvVars();
|
|
21
24
|
export const WAIT_FOR_TX_TIMEOUT = l1ContractsConfig.aztecSlotDuration * 3;
|
|
22
|
-
export const
|
|
25
|
+
export const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES = {
|
|
23
26
|
aztecSlotDuration: 12,
|
|
24
|
-
ethereumSlotDuration: 4
|
|
27
|
+
ethereumSlotDuration: 4,
|
|
28
|
+
aztecProofSubmissionWindow: 640
|
|
25
29
|
};
|
|
26
30
|
export class P2PNetworkTest {
|
|
31
|
+
testName;
|
|
27
32
|
bootstrapNodeEnr;
|
|
28
33
|
bootNodePort;
|
|
34
|
+
numberOfValidators;
|
|
29
35
|
numberOfNodes;
|
|
30
36
|
metricsPort;
|
|
31
37
|
snapshotManager;
|
|
38
|
+
baseAccountPrivateKey;
|
|
32
39
|
baseAccount;
|
|
33
40
|
logger;
|
|
34
41
|
monitor;
|
|
35
42
|
ctx;
|
|
36
43
|
attesterPrivateKeys;
|
|
37
44
|
attesterPublicKeys;
|
|
38
|
-
proposerPrivateKeys;
|
|
39
45
|
peerIdPrivateKeys;
|
|
46
|
+
validators;
|
|
40
47
|
deployedAccounts;
|
|
41
48
|
prefilledPublicData;
|
|
42
49
|
// The re-execution test needs a wallet and a spam contract
|
|
43
50
|
wallet;
|
|
51
|
+
defaultAccountAddress;
|
|
44
52
|
spamContract;
|
|
45
53
|
bootstrapNode;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
metricsPort){
|
|
54
|
+
constructor(testName, bootstrapNodeEnr, bootNodePort, numberOfValidators, initialValidatorConfig, numberOfNodes = 0, // If set enable metrics collection
|
|
55
|
+
metricsPort, startProverNode, mockZkPassportVerifier){
|
|
56
|
+
this.testName = testName;
|
|
50
57
|
this.bootstrapNodeEnr = bootstrapNodeEnr;
|
|
51
58
|
this.bootNodePort = bootNodePort;
|
|
59
|
+
this.numberOfValidators = numberOfValidators;
|
|
52
60
|
this.numberOfNodes = numberOfNodes;
|
|
53
61
|
this.metricsPort = metricsPort;
|
|
54
62
|
this.attesterPrivateKeys = [];
|
|
55
63
|
this.attesterPublicKeys = [];
|
|
56
|
-
this.proposerPrivateKeys = [];
|
|
57
64
|
this.peerIdPrivateKeys = [];
|
|
65
|
+
this.validators = [];
|
|
58
66
|
this.deployedAccounts = [];
|
|
59
67
|
this.prefilledPublicData = [];
|
|
60
|
-
this.cleanupInterval = undefined;
|
|
61
|
-
this.gasUtils = undefined;
|
|
62
68
|
this.logger = createLogger(`e2e:e2e_p2p:${testName}`);
|
|
63
69
|
// Set up the base account and node private keys for the initial network deployment
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
this.attesterPrivateKeys = generatePrivateKeys(ATTESTER_PRIVATE_KEYS_START_INDEX,
|
|
70
|
+
this.baseAccountPrivateKey = `0x${getPrivateKeyFromIndex(1).toString('hex')}`;
|
|
71
|
+
this.baseAccount = privateKeyToAccount(this.baseAccountPrivateKey);
|
|
72
|
+
this.attesterPrivateKeys = generatePrivateKeys(ATTESTER_PRIVATE_KEYS_START_INDEX + numberOfNodes, numberOfValidators);
|
|
67
73
|
this.attesterPublicKeys = this.attesterPrivateKeys.map((privateKey)=>privateKeyToAccount(privateKey).address);
|
|
74
|
+
const zkPassportParams = ZkPassportProofParams.random();
|
|
68
75
|
this.snapshotManager = createSnapshotManager(`e2e_p2p_network/${testName}`, process.env.E2E_DATA_PATH, {
|
|
69
76
|
...initialValidatorConfig,
|
|
70
77
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
71
78
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
72
79
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
73
|
-
|
|
80
|
+
aztecProofSubmissionEpochs: initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
81
|
+
slashingRoundSizeInEpochs: initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
82
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
83
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
74
84
|
salt: 420,
|
|
75
85
|
metricsPort: metricsPort,
|
|
76
|
-
numberOfInitialFundedAccounts:
|
|
86
|
+
numberOfInitialFundedAccounts: 2,
|
|
87
|
+
startProverNode
|
|
77
88
|
}, {
|
|
89
|
+
...initialValidatorConfig,
|
|
78
90
|
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
91
|
+
slashingRoundSizeInEpochs: initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
92
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
79
93
|
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
80
94
|
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
aztecProofSubmissionEpochs: initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
96
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
97
|
+
initialValidators: [],
|
|
98
|
+
zkPassportArgs: {
|
|
99
|
+
mockZkPassportVerifier,
|
|
100
|
+
zkPassportDomain: zkPassportParams.domain,
|
|
101
|
+
zkPassportScope: zkPassportParams.scope
|
|
102
|
+
}
|
|
83
103
|
});
|
|
84
104
|
}
|
|
85
|
-
static async create({ testName, numberOfNodes, basePort, metricsPort, initialConfig }) {
|
|
105
|
+
static async create({ testName, numberOfNodes, numberOfValidators, basePort, metricsPort, initialConfig, startProverNode, mockZkPassportVerifier }) {
|
|
86
106
|
const port = basePort || await getPort();
|
|
87
107
|
const bootstrapNodeENR = await getBootstrapNodeEnr(BOOTSTRAP_NODE_PRIVATE_KEY, port);
|
|
88
108
|
const bootstrapNodeEnr = bootstrapNodeENR.encodeTxt();
|
|
89
109
|
const initialValidatorConfig = await createValidatorConfig(initialConfig ?? {}, bootstrapNodeEnr);
|
|
90
|
-
return new P2PNetworkTest(testName, bootstrapNodeEnr, port,
|
|
110
|
+
return new P2PNetworkTest(testName, bootstrapNodeEnr, port, numberOfValidators, initialValidatorConfig, numberOfNodes, metricsPort, startProverNode, mockZkPassportVerifier);
|
|
91
111
|
}
|
|
92
112
|
get fundedAccount() {
|
|
93
113
|
if (!this.deployedAccounts[0]) {
|
|
@@ -95,103 +115,88 @@ export class P2PNetworkTest {
|
|
|
95
115
|
}
|
|
96
116
|
return this.deployedAccounts[0];
|
|
97
117
|
}
|
|
98
|
-
|
|
99
|
-
* Start a loop to sync the mock system time with the L1 block time
|
|
100
|
-
*/ startSyncMockSystemTimeInterval() {
|
|
101
|
-
this.cleanupInterval = setInterval(()=>{
|
|
102
|
-
void this.syncMockSystemTime().catch((err)=>this.logger.error('Error syncing mock system time', err));
|
|
103
|
-
}, l1ContractsConfig.aztecSlotDuration * 1000);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* When using fake timers, we need to keep the system and anvil clocks in sync.
|
|
107
|
-
*/ async syncMockSystemTime() {
|
|
108
|
-
this.logger.info('Syncing mock system time');
|
|
109
|
-
const { dateProvider, deployL1ContractsValues } = this.ctx;
|
|
110
|
-
// Send a tx and only update the time after the tx is mined, as eth time is not continuous
|
|
111
|
-
const { receipt } = await this.gasUtils.sendAndMonitorTransaction({
|
|
112
|
-
to: this.baseAccount.address,
|
|
113
|
-
data: '0x',
|
|
114
|
-
value: 1n
|
|
115
|
-
});
|
|
116
|
-
const timestamp = await deployL1ContractsValues.publicClient.getBlock({
|
|
117
|
-
blockNumber: receipt.blockNumber
|
|
118
|
-
});
|
|
119
|
-
this.logger.info(`Timestamp: ${timestamp.timestamp}`);
|
|
120
|
-
dateProvider.setTime(Number(timestamp.timestamp) * 1000);
|
|
121
|
-
}
|
|
122
|
-
async applyBaseSnapshots() {
|
|
118
|
+
async addBootstrapNode() {
|
|
123
119
|
await this.snapshotManager.snapshot('add-bootstrap-node', async ({ aztecNodeConfig })=>{
|
|
124
120
|
const telemetry = getEndToEndTestTelemetryClient(this.metricsPort);
|
|
125
121
|
this.bootstrapNode = await createBootstrapNodeFromPrivateKey(BOOTSTRAP_NODE_PRIVATE_KEY, this.bootNodePort, telemetry, aztecNodeConfig);
|
|
126
122
|
// Overwrite enr with updated info
|
|
127
123
|
this.bootstrapNodeEnr = this.bootstrapNode.getENR().encodeTxt();
|
|
128
124
|
});
|
|
129
|
-
|
|
125
|
+
}
|
|
126
|
+
getValidators() {
|
|
127
|
+
const validators = [];
|
|
128
|
+
for(let i = 0; i < this.numberOfValidators; i++){
|
|
129
|
+
const keyIndex = i;
|
|
130
|
+
const attester = privateKeyToAccount(this.attesterPrivateKeys[keyIndex]);
|
|
131
|
+
validators.push({
|
|
132
|
+
attester: EthAddress.fromString(attester.address),
|
|
133
|
+
withdrawer: EthAddress.fromString(attester.address),
|
|
134
|
+
bn254SecretKey: new SecretValue(Fr.random().toBigInt())
|
|
135
|
+
});
|
|
136
|
+
this.logger.info(`Adding attester ${attester.address} as validator`);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
validators
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
async applyBaseSnapshots() {
|
|
143
|
+
await this.addBootstrapNode();
|
|
144
|
+
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, dateProvider, cheatCodes })=>{
|
|
130
145
|
const rollup = getContract({
|
|
131
146
|
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
132
147
|
abi: RollupAbi,
|
|
133
|
-
client: deployL1ContractsValues.
|
|
148
|
+
client: deployL1ContractsValues.l1Client
|
|
134
149
|
});
|
|
135
|
-
this.logger.
|
|
150
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
136
151
|
const stakingAsset = getContract({
|
|
137
152
|
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
138
153
|
abi: TestERC20Abi,
|
|
139
|
-
client: deployL1ContractsValues.
|
|
154
|
+
client: deployL1ContractsValues.l1Client
|
|
155
|
+
});
|
|
156
|
+
const { address: multiAdderAddress } = await deployL1Contract(deployL1ContractsValues.l1Client, MultiAdderArtifact.contractAbi, MultiAdderArtifact.contractBytecode, [
|
|
157
|
+
rollup.address,
|
|
158
|
+
deployL1ContractsValues.l1Client.account.address
|
|
159
|
+
]);
|
|
160
|
+
const multiAdder = getContract({
|
|
161
|
+
address: multiAdderAddress.toString(),
|
|
162
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
163
|
+
client: deployL1ContractsValues.l1Client
|
|
140
164
|
});
|
|
141
|
-
const stakeNeeded =
|
|
165
|
+
const stakeNeeded = await rollup.read.getActivationThreshold() * BigInt(this.numberOfValidators);
|
|
142
166
|
await Promise.all([
|
|
143
167
|
await stakingAsset.write.mint([
|
|
144
|
-
|
|
145
|
-
stakeNeeded
|
|
146
|
-
], {}),
|
|
147
|
-
await stakingAsset.write.approve([
|
|
148
|
-
deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
168
|
+
multiAdder.address,
|
|
149
169
|
stakeNeeded
|
|
150
170
|
], {})
|
|
151
|
-
].map((txHash)=>deployL1ContractsValues.
|
|
171
|
+
].map((txHash)=>deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
152
172
|
hash: txHash
|
|
153
173
|
})));
|
|
154
|
-
const validators =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
proposerEOA.address
|
|
160
|
-
], proposerEOA.address).address;
|
|
161
|
-
validators.push({
|
|
162
|
-
attester: attester.address,
|
|
163
|
-
proposer: forwarder,
|
|
164
|
-
withdrawer: attester.address,
|
|
165
|
-
amount: l1ContractsConfig.minimumStake
|
|
166
|
-
});
|
|
167
|
-
this.logger.verbose(`Adding (attester, proposer) pair: (${attester.address}, ${forwarder}) as validator`);
|
|
174
|
+
const { validators } = this.getValidators();
|
|
175
|
+
this.validators = validators;
|
|
176
|
+
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress;
|
|
177
|
+
if (!gseAddress) {
|
|
178
|
+
throw new Error('GSE contract not deployed');
|
|
168
179
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
180
|
+
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
181
|
+
const makeValidatorTuples = async (validator)=>{
|
|
182
|
+
const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
|
|
183
|
+
return {
|
|
184
|
+
attester: validator.attester.toString(),
|
|
185
|
+
withdrawer: validator.withdrawer.toString(),
|
|
186
|
+
...registrationTuple
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
190
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
191
|
+
hash: await multiAdder.write.addValidators([
|
|
192
|
+
validatorTuples
|
|
172
193
|
])
|
|
173
194
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
slotsInEpoch
|
|
177
|
-
]);
|
|
178
|
-
const cheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
179
|
-
try {
|
|
180
|
-
await cheatCodes.warp(Number(timestamp));
|
|
181
|
-
} catch (err) {
|
|
182
|
-
this.logger.debug('Warp failed, time already satisfied');
|
|
183
|
-
}
|
|
184
|
-
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
185
|
-
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
|
|
186
|
-
hash: await deployL1ContractsValues.walletClient.sendTransaction({
|
|
187
|
-
to: this.baseAccount.address,
|
|
188
|
-
value: 1n,
|
|
189
|
-
account: this.baseAccount
|
|
190
|
-
})
|
|
195
|
+
await cheatCodes.rollup.advanceToEpoch(await cheatCodes.rollup.getEpoch() + await rollup.read.getLagInEpochs() + 1n, {
|
|
196
|
+
updateDateProvider: dateProvider
|
|
191
197
|
});
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
dateProvider.setTime(Number(timestamp) * 1000);
|
|
198
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
199
|
+
await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
195
200
|
});
|
|
196
201
|
}
|
|
197
202
|
async setupAccount() {
|
|
@@ -199,6 +204,7 @@ export class P2PNetworkTest {
|
|
|
199
204
|
this.deployedAccounts = deployedAccounts;
|
|
200
205
|
const [account] = deployedAccounts;
|
|
201
206
|
this.wallet = await getSchnorrWalletWithSecretKey(pxe, account.secret, account.signingKey, account.salt);
|
|
207
|
+
this.defaultAccountAddress = this.wallet.getAddress();
|
|
202
208
|
});
|
|
203
209
|
}
|
|
204
210
|
async deploySpamContract() {
|
|
@@ -206,7 +212,9 @@ export class P2PNetworkTest {
|
|
|
206
212
|
if (!this.wallet) {
|
|
207
213
|
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
208
214
|
}
|
|
209
|
-
const spamContract = await SpamContract.deploy(this.wallet).send(
|
|
215
|
+
const spamContract = await SpamContract.deploy(this.wallet).send({
|
|
216
|
+
from: this.defaultAccountAddress
|
|
217
|
+
}).deployed();
|
|
210
218
|
return {
|
|
211
219
|
contractAddress: spamContract.address
|
|
212
220
|
};
|
|
@@ -218,34 +226,38 @@ export class P2PNetworkTest {
|
|
|
218
226
|
});
|
|
219
227
|
}
|
|
220
228
|
async removeInitialNode() {
|
|
221
|
-
await this.snapshotManager.snapshot('remove-
|
|
229
|
+
await this.snapshotManager.snapshot('remove-initial-validator', async ({ deployL1ContractsValues, aztecNode, dateProvider })=>{
|
|
222
230
|
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
223
|
-
const receipt = await deployL1ContractsValues.
|
|
224
|
-
|
|
225
|
-
to: this.baseAccount.address,
|
|
226
|
-
value: 1n,
|
|
227
|
-
account: this.baseAccount
|
|
228
|
-
})
|
|
229
|
-
});
|
|
230
|
-
const block = await deployL1ContractsValues.publicClient.getBlock({
|
|
231
|
+
const { receipt } = await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
232
|
+
const block = await deployL1ContractsValues.l1Client.getBlock({
|
|
231
233
|
blockNumber: receipt.blockNumber
|
|
232
234
|
});
|
|
233
235
|
dateProvider.setTime(Number(block.timestamp) * 1000);
|
|
234
236
|
await aztecNode.stop();
|
|
235
237
|
});
|
|
236
238
|
}
|
|
239
|
+
async sendDummyTx() {
|
|
240
|
+
return await this._sendDummyTx(this.ctx.deployL1ContractsValues.l1Client);
|
|
241
|
+
}
|
|
242
|
+
async _sendDummyTx(l1Client) {
|
|
243
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
|
|
244
|
+
return await l1TxUtils.sendAndMonitorTransaction({
|
|
245
|
+
to: l1Client.account.address,
|
|
246
|
+
value: 1n
|
|
247
|
+
});
|
|
248
|
+
}
|
|
237
249
|
async setup() {
|
|
238
250
|
this.ctx = await this.snapshotManager.setup();
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
this.monitor
|
|
251
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
252
|
+
const initialFundedAccounts = [
|
|
253
|
+
...this.ctx.initialFundedAccounts.map((a)=>a.address),
|
|
254
|
+
sponsoredFPCAddress
|
|
255
|
+
];
|
|
256
|
+
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
257
|
+
this.prefilledPublicData = prefilledPublicData;
|
|
258
|
+
const rollupContract = RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues);
|
|
259
|
+
this.monitor = new ChainMonitor(rollupContract, this.ctx.dateProvider).start();
|
|
260
|
+
this.monitor.on('l1-block', ({ timestamp })=>this.ctx.dateProvider.setTime(Number(timestamp) * 1000));
|
|
249
261
|
}
|
|
250
262
|
async stopNodes(nodes) {
|
|
251
263
|
this.logger.info('Stopping nodes');
|
|
@@ -257,11 +269,28 @@ export class P2PNetworkTest {
|
|
|
257
269
|
this.logger.info('Nodes stopped');
|
|
258
270
|
}
|
|
259
271
|
async teardown() {
|
|
260
|
-
this.monitor.stop();
|
|
261
|
-
await this.bootstrapNode
|
|
272
|
+
await this.monitor.stop();
|
|
273
|
+
await tryStop(this.bootstrapNode, this.logger);
|
|
262
274
|
await this.snapshotManager.teardown();
|
|
263
|
-
|
|
264
|
-
|
|
275
|
+
}
|
|
276
|
+
async getContracts() {
|
|
277
|
+
if (!this.ctx.deployL1ContractsValues) {
|
|
278
|
+
throw new Error('DeployL1ContractsValues not set');
|
|
265
279
|
}
|
|
280
|
+
const rollup = new RollupContract(this.ctx.deployL1ContractsValues.l1Client, this.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress);
|
|
281
|
+
const slasherContract = getContract({
|
|
282
|
+
address: getAddress(await rollup.getSlasherAddress()),
|
|
283
|
+
abi: SlasherAbi,
|
|
284
|
+
client: this.ctx.deployL1ContractsValues.l1Client
|
|
285
|
+
});
|
|
286
|
+
// Get the actual slashing proposer from rollup (which handles both empire and tally)
|
|
287
|
+
const slashingProposer = await rollup.getSlashingProposer();
|
|
288
|
+
const slashFactory = new SlashFactoryContract(this.ctx.deployL1ContractsValues.l1Client, getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress.toString()));
|
|
289
|
+
return {
|
|
290
|
+
rollup,
|
|
291
|
+
slasherContract,
|
|
292
|
+
slashingProposer,
|
|
293
|
+
slashFactory
|
|
294
|
+
};
|
|
266
295
|
}
|
|
267
296
|
}
|
package/dest/e2e_p2p/shared.d.ts
CHANGED
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
2
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
-
import { type Logger, type SentTx } from '@aztec/aztec.js';
|
|
4
|
-
import type {
|
|
3
|
+
import { AztecAddress, type Logger, ProvenTx, type SentTx } from '@aztec/aztec.js';
|
|
4
|
+
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
5
|
+
import type { EmpireSlashingProposerContract, RollupContract, TallySlashingProposerContract } from '@aztec/ethereum';
|
|
6
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
|
+
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
8
|
+
import { PXEService } from '@aztec/pxe/server';
|
|
9
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
10
|
+
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
5
11
|
import type { NodeContext } from '../fixtures/setup_p2p_test.js';
|
|
6
|
-
export declare const submitComplexTxsTo: (logger: Logger, spamContract: SpamContract, numTxs: number, opts?: {
|
|
12
|
+
export declare const submitComplexTxsTo: (logger: Logger, from: AztecAddress, spamContract: SpamContract, numTxs: number, opts?: {
|
|
7
13
|
callPublic?: boolean;
|
|
8
14
|
}) => Promise<SentTx[]>;
|
|
9
15
|
export declare const createPXEServiceAndSubmitTransactions: (logger: Logger, node: AztecNodeService, numTxs: number, fundedAccount: InitialAccountData) => Promise<NodeContext>;
|
|
16
|
+
export declare function createPXEServiceAndPrepareTransactions(logger: Logger, node: AztecNodeService, numTxs: number, fundedAccount: InitialAccountData): Promise<{
|
|
17
|
+
pxeService: PXEService;
|
|
18
|
+
txs: ProvenTx[];
|
|
19
|
+
node: AztecNodeService;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function awaitProposalExecution(slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract, timeoutSeconds: number, logger: Logger): Promise<bigint>;
|
|
22
|
+
export declare function awaitCommitteeExists({ rollup, logger, }: {
|
|
23
|
+
rollup: RollupContract;
|
|
24
|
+
logger: Logger;
|
|
25
|
+
}): Promise<readonly `0x${string}`[]>;
|
|
26
|
+
export declare function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, }: {
|
|
27
|
+
nodeAdmin: AztecNodeAdmin;
|
|
28
|
+
logger: Logger;
|
|
29
|
+
slashingRoundSize: number;
|
|
30
|
+
epochDuration: number;
|
|
31
|
+
waitUntilOffenseCount?: number;
|
|
32
|
+
}): Promise<import("@aztec/slasher").Offense[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Await the committee to be slashed out of the validator set.
|
|
35
|
+
* Currently assumes that the committee is the same size as the validator set.
|
|
36
|
+
*/
|
|
37
|
+
export declare function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger, dateProvider, }: {
|
|
38
|
+
rollup: RollupContract;
|
|
39
|
+
cheatCodes: RollupCheatCodes;
|
|
40
|
+
committee: readonly `0x${string}`[];
|
|
41
|
+
slashFactory: SlashFactoryContract;
|
|
42
|
+
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
43
|
+
slashingRoundSize: number;
|
|
44
|
+
aztecSlotDuration: number;
|
|
45
|
+
dateProvider: TestDateProvider;
|
|
46
|
+
logger: Logger;
|
|
47
|
+
}): Promise<void>;
|
|
10
48
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/shared.ts"],"names":[],"mappings":"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"}
|