@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.023c3e5
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 +62 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +281 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +321 -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 +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +41 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
- 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 +114 -102
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
- 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 +104 -104
- package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +26 -27
- package/dest/e2e_epochs/epochs_test.d.ts +71 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +260 -54
- 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 +61 -0
- package/dest/e2e_fees/fees_test.d.ts +38 -23
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +162 -183
- package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +56 -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 +15 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +281 -27
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +237 -175
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +153 -0
- package/dest/e2e_p2p/shared.d.ts +44 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +165 -27
- package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +96 -74
- package/dest/fixtures/e2e_prover_test.d.ts +55 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +278 -0
- package/dest/fixtures/fixtures.d.ts +6 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +5 -5
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +3 -15
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +695 -0
- package/dest/fixtures/setup_p2p_test.d.ts +15 -15
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +96 -31
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +31 -12
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +44 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +105 -51
- package/dest/shared/gas_portal_test_harness.d.ts +33 -25
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +2 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +176 -126
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +17 -18
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +27 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +233 -62
- package/dest/spartan/tx_metrics.d.ts +88 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +422 -0
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +126 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +375 -0
- package/dest/spartan/utils/nodes.d.ts +41 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- package/package.json +66 -58
- package/src/bench/client_flows/benchmark.ts +363 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +41 -85
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
- package/src/e2e_deploy_contract/deploy_test.ts +40 -48
- package/src/e2e_epochs/epochs_test.ts +341 -81
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +220 -258
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +341 -234
- package/src/e2e_p2p/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +260 -39
- package/src/e2e_token_contract/token_contract_test.ts +115 -126
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +336 -0
- package/src/fixtures/fixtures.ts +5 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup.ts +1017 -0
- package/src/fixtures/setup_p2p_test.ts +133 -50
- package/src/fixtures/token_utils.ts +33 -15
- package/src/fixtures/utils.ts +27 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +103 -91
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +18 -20
- package/src/shared/uniswap_l1_l2.ts +197 -221
- package/src/simulators/lending_simulator.ts +16 -17
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +308 -95
- package/src/spartan/tx_metrics.ts +376 -0
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +64 -0
- package/src/spartan/utils/k8s.ts +527 -0
- package/src/spartan/utils/nodes.ts +538 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -582
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/e2e_prover/e2e_prover_test.js +0 -291
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
- package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.js +0 -17
- package/dest/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.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/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- 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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { getAddressFromPrivateKey } from '@aztec/ethereum/account';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { writeFile } from 'fs/promises';
|
|
4
|
+
import { createServer } from 'http';
|
|
5
|
+
import { signMessage, signTypedData } from 'viem/accounts';
|
|
6
|
+
// Create a mock JSON RPC signer
|
|
7
|
+
// Only supports signing messages and type data
|
|
8
|
+
const SUPPORTED_METHODS = [
|
|
9
|
+
'eth_sign',
|
|
10
|
+
'eth_signTypedData_v4'
|
|
11
|
+
];
|
|
12
|
+
export function createJSONRPCSigner(keyLookup, stats) {
|
|
13
|
+
return createServer((req, res)=>{
|
|
14
|
+
if (req.method === 'POST') {
|
|
15
|
+
let body = '';
|
|
16
|
+
req.on('data', (chunk)=>{
|
|
17
|
+
body += chunk.toString();
|
|
18
|
+
});
|
|
19
|
+
req.on('end', ()=>{
|
|
20
|
+
try {
|
|
21
|
+
const jsonRequest = JSON.parse(body);
|
|
22
|
+
res.writeHead(200, {
|
|
23
|
+
'Content-Type': 'application/json'
|
|
24
|
+
});
|
|
25
|
+
if (!SUPPORTED_METHODS.includes(jsonRequest.method)) {
|
|
26
|
+
res.end(JSON.stringify({
|
|
27
|
+
jsonrpc: '2.0',
|
|
28
|
+
id: jsonRequest.id,
|
|
29
|
+
error: {
|
|
30
|
+
code: -32601,
|
|
31
|
+
message: 'Method not supported'
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// Get the address sending the transaction
|
|
37
|
+
const [address, data] = jsonRequest.params;
|
|
38
|
+
const lowerCaseAddress = address.toLowerCase();
|
|
39
|
+
stats.set(lowerCaseAddress, (stats.get(lowerCaseAddress) ?? 0) + 1);
|
|
40
|
+
// Find the private key for the address
|
|
41
|
+
const privateKey = keyLookup.get(address.toLowerCase());
|
|
42
|
+
if (!privateKey) {
|
|
43
|
+
res.end(JSON.stringify({
|
|
44
|
+
jsonrpc: '2.0',
|
|
45
|
+
id: jsonRequest.id,
|
|
46
|
+
error: {
|
|
47
|
+
code: -32602,
|
|
48
|
+
message: `No private key found for address ${address}`
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const promise = jsonRequest.method === 'eth_sign' ? signMessage({
|
|
54
|
+
message: {
|
|
55
|
+
raw: data
|
|
56
|
+
},
|
|
57
|
+
privateKey
|
|
58
|
+
}) : signTypedData({
|
|
59
|
+
privateKey,
|
|
60
|
+
...data
|
|
61
|
+
});
|
|
62
|
+
void promise.then((signature)=>{
|
|
63
|
+
res.end(JSON.stringify({
|
|
64
|
+
jsonrpc: '2.0',
|
|
65
|
+
id: jsonRequest.id,
|
|
66
|
+
result: signature
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
res.end(JSON.stringify({
|
|
71
|
+
jsonrpc: '2.0',
|
|
72
|
+
id: 1,
|
|
73
|
+
error: {
|
|
74
|
+
code: -32603,
|
|
75
|
+
message: `${err}`
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
res.writeHead(405);
|
|
82
|
+
res.end('Method not allowed');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// Functions for creating file based key stores for the e2e_multi_validator_node_key_store test
|
|
87
|
+
export async function createKeyFile1(fileName, mnemonic, validatorIndex, publisher1Key, publisher2Key, coinbase, feeRecipient) {
|
|
88
|
+
const obj = {
|
|
89
|
+
schemaVersion: 1,
|
|
90
|
+
validators: [
|
|
91
|
+
{
|
|
92
|
+
attester: {
|
|
93
|
+
mnemonic: mnemonic,
|
|
94
|
+
accountIndex: 0,
|
|
95
|
+
addressIndex: validatorIndex,
|
|
96
|
+
addressCount: 1
|
|
97
|
+
},
|
|
98
|
+
coinbase: coinbase.toChecksumString(),
|
|
99
|
+
publisher: [
|
|
100
|
+
publisher1Key,
|
|
101
|
+
publisher2Key
|
|
102
|
+
],
|
|
103
|
+
feeRecipient: feeRecipient.toString()
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
};
|
|
107
|
+
await writeFile(fileName, JSON.stringify(obj, null, 2));
|
|
108
|
+
}
|
|
109
|
+
export async function createKeyFile2(fileName, validatorKey, publisherMnemonic, publisher1Index, coinbase, feeRecipient) {
|
|
110
|
+
const obj = {
|
|
111
|
+
schemaVersion: 1,
|
|
112
|
+
validators: [
|
|
113
|
+
{
|
|
114
|
+
attester: validatorKey,
|
|
115
|
+
coinbase: coinbase.toChecksumString(),
|
|
116
|
+
publisher: {
|
|
117
|
+
mnemonic: publisherMnemonic,
|
|
118
|
+
accountIndex: 0,
|
|
119
|
+
addressIndex: publisher1Index,
|
|
120
|
+
addressCount: 2
|
|
121
|
+
},
|
|
122
|
+
feeRecipient: feeRecipient.toString()
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
await writeFile(fileName, JSON.stringify(obj, null, 2));
|
|
127
|
+
}
|
|
128
|
+
export async function createKeyFile3(fileName, validatorAddress, publisher1Key, publisher2Key, coinbase, remoteSignerUrl, feeRecipient) {
|
|
129
|
+
const obj = {
|
|
130
|
+
schemaVersion: 1,
|
|
131
|
+
validators: [
|
|
132
|
+
{
|
|
133
|
+
attester: validatorAddress.toChecksumString(),
|
|
134
|
+
coinbase: coinbase.toChecksumString(),
|
|
135
|
+
publisher: [
|
|
136
|
+
publisher1Key,
|
|
137
|
+
publisher2Key
|
|
138
|
+
],
|
|
139
|
+
feeRecipient: feeRecipient.toString(),
|
|
140
|
+
remoteSigner: {
|
|
141
|
+
remoteSignerUrl: remoteSignerUrl
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
};
|
|
146
|
+
await writeFile(fileName, JSON.stringify(obj, null, 2));
|
|
147
|
+
}
|
|
148
|
+
export async function createKeyFile4(fileName, validator1Address, validator2Address, publisher1Index, publisher2Key, mnemonic, publisher3Key, coinbase1, coinbase2, remoteSignerUrl, feeRecipient1, feeRecipient2) {
|
|
149
|
+
const obj = {
|
|
150
|
+
schemaVersion: 1,
|
|
151
|
+
remoteSigner: {
|
|
152
|
+
remoteSignerUrl: remoteSignerUrl
|
|
153
|
+
},
|
|
154
|
+
validators: [
|
|
155
|
+
{
|
|
156
|
+
attester: validator1Address.toChecksumString(),
|
|
157
|
+
coinbase: coinbase1.toChecksumString(),
|
|
158
|
+
publisher: {
|
|
159
|
+
mnemonic: mnemonic,
|
|
160
|
+
accountIndex: 0,
|
|
161
|
+
addressIndex: publisher1Index,
|
|
162
|
+
addressCount: 2
|
|
163
|
+
},
|
|
164
|
+
feeRecipient: feeRecipient1.toString()
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
attester: validator2Address.toChecksumString(),
|
|
168
|
+
coinbase: coinbase2.toChecksumString(),
|
|
169
|
+
publisher: [
|
|
170
|
+
publisher2Key,
|
|
171
|
+
publisher3Key
|
|
172
|
+
],
|
|
173
|
+
feeRecipient: feeRecipient2.toString()
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
await writeFile(fileName, JSON.stringify(obj, null, 2));
|
|
178
|
+
}
|
|
179
|
+
export async function createKeyFile5(fileName, proverAddress, remoteSignerUrl) {
|
|
180
|
+
const obj = {
|
|
181
|
+
schemaVersion: 1,
|
|
182
|
+
prover: {
|
|
183
|
+
id: '0x1234567890123456789012345678901234567890',
|
|
184
|
+
publisher: [
|
|
185
|
+
{
|
|
186
|
+
address: proverAddress.toChecksumString(),
|
|
187
|
+
remoteSignerUrl: remoteSignerUrl
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
await writeFile(fileName, JSON.stringify(obj, null, 2));
|
|
193
|
+
}
|
|
194
|
+
export async function createKeyFile6(fileName, mnemonic, validator1Index, coinbase, feeRecipient) {
|
|
195
|
+
const obj = {
|
|
196
|
+
schemaVersion: 1,
|
|
197
|
+
validators: [
|
|
198
|
+
{
|
|
199
|
+
attester: {
|
|
200
|
+
mnemonic: mnemonic,
|
|
201
|
+
accountIndex: 0,
|
|
202
|
+
addressIndex: validator1Index,
|
|
203
|
+
addressCount: 2
|
|
204
|
+
},
|
|
205
|
+
coinbase: coinbase.toChecksumString(),
|
|
206
|
+
feeRecipient: feeRecipient.toString()
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
};
|
|
210
|
+
await writeFile(fileName, JSON.stringify(obj, null, 2));
|
|
211
|
+
}
|
|
212
|
+
export function addressForPrivateKey(privateKey) {
|
|
213
|
+
return EthAddress.fromString(getAddressFromPrivateKey(privateKey));
|
|
214
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
|
|
6
|
+
import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
|
|
7
|
+
import { type EndToEndContext } from '../fixtures/setup.js';
|
|
5
8
|
export declare class NestedContractTest {
|
|
6
9
|
private numberOfAccounts;
|
|
7
|
-
|
|
10
|
+
context: EndToEndContext;
|
|
8
11
|
logger: Logger;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
wallet: Wallet;
|
|
13
|
+
defaultAccountAddress: AztecAddress;
|
|
14
|
+
aztecNode: AztecNode;
|
|
12
15
|
parentContract: ParentContract;
|
|
13
16
|
childContract: ChildContract;
|
|
14
17
|
constructor(testName: string, numberOfAccounts?: number);
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
17
|
-
* 1. Add 3 accounts.
|
|
18
|
-
* 2. Publicly deploy accounts
|
|
19
|
+
* Applies base setup by deploying accounts and publicly deploying them.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
applyBaseSetup(): Promise<void>;
|
|
21
22
|
setup(): Promise<void>;
|
|
22
23
|
teardown(): Promise<void>;
|
|
23
|
-
|
|
24
|
-
applyManualSnapshots(): Promise<void>;
|
|
24
|
+
applyManual(): Promise<void>;
|
|
25
25
|
}
|
|
26
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdGVkX2NvbnRyYWN0X3Rlc3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9lMmVfbmVzdGVkX2NvbnRyYWN0L25lc3RlZF9jb250cmFjdF90ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0scUJBQXFCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDckQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBQ3BFLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUV0RSxPQUFPLEVBQ0wsS0FBSyxlQUFlLEVBS3JCLE1BQU0sc0JBQXNCLENBQUM7QUFFOUIscUJBQWEsa0JBQWtCO0lBWTNCLE9BQU8sQ0FBQyxnQkFBZ0I7SUFYMUIsT0FBTyxFQUFHLGVBQWUsQ0FBQztJQUMxQixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBQ2YsTUFBTSxFQUFHLE1BQU0sQ0FBQztJQUNoQixxQkFBcUIsRUFBRyxZQUFZLENBQUM7SUFDckMsU0FBUyxFQUFHLFNBQVMsQ0FBQztJQUV0QixjQUFjLEVBQUcsY0FBYyxDQUFDO0lBQ2hDLGFBQWEsRUFBRyxhQUFhLENBQUM7SUFFOUIsWUFDRSxRQUFRLEVBQUUsTUFBTSxFQUNSLGdCQUFnQixTQUFJLEVBRzdCO0lBRUQ7O09BRUc7SUFDRyxjQUFjLGtCQWVuQjtJQUVLLEtBQUssa0JBT1Y7SUFFSyxRQUFRLGtCQUViO0lBRUssV0FBVyxrQkFNaEI7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nested_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_nested_contract/nested_contract_test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nested_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_nested_contract/nested_contract_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,kBAAkB;IAY3B,OAAO,CAAC,gBAAgB;IAX1B,OAAO,EAAG,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAG,MAAM,CAAC;IAChB,qBAAqB,EAAG,YAAY,CAAC;IACrC,SAAS,EAAG,SAAS,CAAC;IAEtB,cAAc,EAAG,cAAc,CAAC;IAChC,aAAa,EAAG,aAAa,CAAC;IAE9B,YACE,QAAQ,EAAE,MAAM,EACR,gBAAgB,SAAI,EAG7B;IAED;;OAEG;IACG,cAAc,kBAenB;IAEK,KAAK,kBAOV;IAEK,QAAQ,kBAEb;IAEK,WAAW,kBAMhB;CACF"}
|
|
@@ -1,60 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
|
|
6
|
-
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
+
import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
|
|
3
|
+
import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
|
|
4
|
+
import { deployAccounts, publicDeployAccounts, setup, teardown as teardownSubsystems } from '../fixtures/setup.js';
|
|
7
5
|
export class NestedContractTest {
|
|
8
6
|
numberOfAccounts;
|
|
9
|
-
|
|
7
|
+
context;
|
|
10
8
|
logger;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
wallet;
|
|
10
|
+
defaultAccountAddress;
|
|
11
|
+
aztecNode;
|
|
14
12
|
parentContract;
|
|
15
13
|
childContract;
|
|
16
14
|
constructor(testName, numberOfAccounts = 1){
|
|
17
15
|
this.numberOfAccounts = numberOfAccounts;
|
|
18
|
-
this.wallets = [];
|
|
19
|
-
this.accounts = [];
|
|
20
|
-
this.snapshot = (name, apply, restore = ()=>Promise.resolve())=>this.snapshotManager.snapshot(name, apply, restore);
|
|
21
16
|
this.logger = createLogger(`e2e:e2e_nested_contract:${testName}`);
|
|
22
|
-
this.snapshotManager = createSnapshotManager(`e2e_nested_contract/${testName}-${numberOfAccounts}`, dataPath);
|
|
23
17
|
}
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.accounts = await pxe.getRegisteredAccounts();
|
|
32
|
-
this.wallets.forEach((w, i)=>this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
33
|
-
this.pxe = pxe;
|
|
34
|
-
});
|
|
35
|
-
await this.snapshotManager.snapshot('public_deploy', async ()=>{}, async ()=>{
|
|
36
|
-
this.logger.verbose(`Public deploy accounts...`);
|
|
37
|
-
await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
|
|
19
|
+
* Applies base setup by deploying accounts and publicly deploying them.
|
|
20
|
+
*/ async applyBaseSetup() {
|
|
21
|
+
this.logger.info('Deploying accounts');
|
|
22
|
+
const { deployedAccounts } = await deployAccounts(this.numberOfAccounts, this.logger)({
|
|
23
|
+
wallet: this.context.wallet,
|
|
24
|
+
initialFundedAccounts: this.context.initialFundedAccounts
|
|
38
25
|
});
|
|
26
|
+
this.wallet = this.context.wallet;
|
|
27
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
28
|
+
this.aztecNode = this.context.aztecNodeService;
|
|
29
|
+
this.logger.info('Public deploy accounts');
|
|
30
|
+
await publicDeployAccounts(this.wallet, [
|
|
31
|
+
this.defaultAccountAddress
|
|
32
|
+
]);
|
|
39
33
|
}
|
|
40
34
|
async setup() {
|
|
41
|
-
|
|
35
|
+
this.logger.info('Setting up fresh subsystems');
|
|
36
|
+
this.context = await setup(0, {
|
|
37
|
+
fundSponsoredFPC: true,
|
|
38
|
+
skipAccountDeployment: true
|
|
39
|
+
});
|
|
40
|
+
await this.applyBaseSetup();
|
|
42
41
|
}
|
|
43
42
|
async teardown() {
|
|
44
|
-
await this.
|
|
43
|
+
await teardownSubsystems(this.context);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
childContractAddress: childContract.address
|
|
54
|
-
};
|
|
55
|
-
}, async ({ parentContractAddress, childContractAddress })=>{
|
|
56
|
-
this.parentContract = await ParentContract.at(parentContractAddress, this.wallets[0]);
|
|
57
|
-
this.childContract = await ChildContract.at(childContractAddress, this.wallets[0]);
|
|
45
|
+
async applyManual() {
|
|
46
|
+
this.logger.info('Deploying parent and child contracts');
|
|
47
|
+
const parentContract = await ParentContract.deploy(this.wallet).send({
|
|
48
|
+
from: this.defaultAccountAddress
|
|
49
|
+
});
|
|
50
|
+
const childContract = await ChildContract.deploy(this.wallet).send({
|
|
51
|
+
from: this.defaultAccountAddress
|
|
58
52
|
});
|
|
53
|
+
this.parentContract = parentContract;
|
|
54
|
+
this.childContract = childContract;
|
|
59
55
|
}
|
|
60
56
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import 'jest-extended';
|
|
5
|
+
import { P2PNetworkTest } from './p2p_network.js';
|
|
6
|
+
export declare class P2PInactivityTest {
|
|
7
|
+
readonly test: P2PNetworkTest;
|
|
8
|
+
nodes: AztecNodeService[];
|
|
9
|
+
activeNodes: AztecNodeService[];
|
|
10
|
+
inactiveNodes: AztecNodeService[];
|
|
11
|
+
rollup: RollupContract;
|
|
12
|
+
offlineValidators: EthAddress[];
|
|
13
|
+
private dataDir;
|
|
14
|
+
private inactiveNodeCount;
|
|
15
|
+
private keepInitialNode;
|
|
16
|
+
constructor(test: P2PNetworkTest, opts: {
|
|
17
|
+
inactiveNodeCount: number;
|
|
18
|
+
keepInitialNode?: boolean;
|
|
19
|
+
});
|
|
20
|
+
static create(testName: string, opts: {
|
|
21
|
+
slashInactivityConsecutiveEpochThreshold: number;
|
|
22
|
+
inactiveNodeCount: number;
|
|
23
|
+
keepInitialNode?: boolean;
|
|
24
|
+
}): Promise<P2PInactivityTest>;
|
|
25
|
+
setup(): Promise<this>;
|
|
26
|
+
teardown(): Promise<void>;
|
|
27
|
+
get ctx(): import("../fixtures/setup.js").EndToEndContext;
|
|
28
|
+
get logger(): import("@aztec/foundation/log").Logger;
|
|
29
|
+
get slashingAmount(): bigint;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5hY3Rpdml0eV9zbGFzaF90ZXN0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZTJlX3AycC9pbmFjdGl2aXR5X3NsYXNoX3Rlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUMxRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDdkQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBSTNELE9BQU8sZUFBZSxDQUFDO0FBS3ZCLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQWlCbEQscUJBQWEsaUJBQWlCO2FBYVYsSUFBSSxFQUFFLGNBQWM7SUFaL0IsS0FBSyxFQUFHLGdCQUFnQixFQUFFLENBQUM7SUFDM0IsV0FBVyxFQUFHLGdCQUFnQixFQUFFLENBQUM7SUFDakMsYUFBYSxFQUFHLGdCQUFnQixFQUFFLENBQUM7SUFFbkMsTUFBTSxFQUFHLGNBQWMsQ0FBQztJQUN4QixpQkFBaUIsRUFBRyxVQUFVLEVBQUUsQ0FBQztJQUV4QyxPQUFPLENBQUMsT0FBTyxDQUFTO0lBQ3hCLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBUztJQUNsQyxPQUFPLENBQUMsZUFBZSxDQUFVO0lBRWpDLFlBQ2tCLElBQUksRUFBRSxjQUFjLEVBQ3BDLElBQUksRUFBRTtRQUFFLGlCQUFpQixFQUFFLE1BQU0sQ0FBQztRQUFDLGVBQWUsQ0FBQyxFQUFFLE9BQU8sQ0FBQTtLQUFFLEVBSy9EO0lBRUQsT0FBYSxNQUFNLENBQ2pCLFFBQVEsRUFBRSxNQUFNLEVBQ2hCLElBQUksRUFBRTtRQUFFLHdDQUF3QyxFQUFFLE1BQU0sQ0FBQztRQUFDLGlCQUFpQixFQUFFLE1BQU0sQ0FBQztRQUFDLGVBQWUsQ0FBQyxFQUFFLE9BQU8sQ0FBQTtLQUFFLDhCQThCakg7SUFFWSxLQUFLLGtCQTBFakI7SUFFWSxRQUFRLGtCQU1wQjtJQUVELElBQVcsR0FBRyxtREFFYjtJQUVELElBQVcsTUFBTSwyQ0FFaEI7SUFFRCxJQUFXLGNBQWMsV0FFeEI7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inactivity_slash_test.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/inactivity_slash_test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,eAAe,CAAC;AAKvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiBlD,qBAAa,iBAAiB;aAaV,IAAI,EAAE,cAAc;IAZ/B,KAAK,EAAG,gBAAgB,EAAE,CAAC;IAC3B,WAAW,EAAG,gBAAgB,EAAE,CAAC;IACjC,aAAa,EAAG,gBAAgB,EAAE,CAAC;IAEnC,MAAM,EAAG,cAAc,CAAC;IACxB,iBAAiB,EAAG,UAAU,EAAE,CAAC;IAExC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,eAAe,CAAU;IAEjC,YACkB,IAAI,EAAE,cAAc,EACpC,IAAI,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,EAK/D;IAED,OAAa,MAAM,CACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;QAAE,wCAAwC,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,8BA8BjH;IAEY,KAAK,kBA0EjB;IAEY,QAAQ,kBAMpB;IAED,IAAW,GAAG,mDAEb;IAED,IAAW,MAAM,2CAEhB;IAED,IAAW,cAAc,WAExB;CACF"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import 'jest-extended';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { createNodes } from '../fixtures/setup_p2p_test.js';
|
|
7
|
+
import { P2PNetworkTest } from './p2p_network.js';
|
|
8
|
+
const NUM_NODES = 6;
|
|
9
|
+
const NUM_VALIDATORS = NUM_NODES;
|
|
10
|
+
const COMMITTEE_SIZE = NUM_VALIDATORS;
|
|
11
|
+
const SLASHING_QUORUM = 3;
|
|
12
|
+
const EPOCH_DURATION = 2;
|
|
13
|
+
const SLASHING_ROUND_SIZE_IN_EPOCHS = 2;
|
|
14
|
+
const BOOT_NODE_UDP_PORT = 4500;
|
|
15
|
+
const ETHEREUM_SLOT_DURATION = process.env.CI ? 8 : 4;
|
|
16
|
+
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
17
|
+
const SLASHING_UNIT = BigInt(1e18);
|
|
18
|
+
const SLASHING_AMOUNT = SLASHING_UNIT * 3n;
|
|
19
|
+
// How many epochs it may take to set everything up, so we dont slash during this period
|
|
20
|
+
const SETUP_EPOCH_DURATION = 8;
|
|
21
|
+
export class P2PInactivityTest {
|
|
22
|
+
test;
|
|
23
|
+
nodes;
|
|
24
|
+
activeNodes;
|
|
25
|
+
inactiveNodes;
|
|
26
|
+
rollup;
|
|
27
|
+
offlineValidators;
|
|
28
|
+
dataDir;
|
|
29
|
+
inactiveNodeCount;
|
|
30
|
+
keepInitialNode;
|
|
31
|
+
constructor(test, opts){
|
|
32
|
+
this.test = test;
|
|
33
|
+
this.dataDir = fs.mkdtempSync(path.join(os.tmpdir(), test.testName));
|
|
34
|
+
this.inactiveNodeCount = opts.inactiveNodeCount;
|
|
35
|
+
this.keepInitialNode = opts.keepInitialNode ?? false;
|
|
36
|
+
}
|
|
37
|
+
static async create(testName, opts) {
|
|
38
|
+
const test = await P2PNetworkTest.create({
|
|
39
|
+
testName,
|
|
40
|
+
numberOfNodes: 0,
|
|
41
|
+
numberOfValidators: NUM_VALIDATORS,
|
|
42
|
+
basePort: BOOT_NODE_UDP_PORT,
|
|
43
|
+
startProverNode: true,
|
|
44
|
+
initialConfig: {
|
|
45
|
+
proverNodeConfig: {
|
|
46
|
+
proverNodeEpochProvingDelayMs: AZTEC_SLOT_DURATION * 1000
|
|
47
|
+
},
|
|
48
|
+
aztecTargetCommitteeSize: COMMITTEE_SIZE,
|
|
49
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
50
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
51
|
+
aztecProofSubmissionEpochs: 1024,
|
|
52
|
+
listenAddress: '127.0.0.1',
|
|
53
|
+
minTxsPerBlock: 0,
|
|
54
|
+
aztecEpochDuration: EPOCH_DURATION,
|
|
55
|
+
validatorReexecute: false,
|
|
56
|
+
sentinelEnabled: true,
|
|
57
|
+
slashingQuorum: SLASHING_QUORUM,
|
|
58
|
+
slashingRoundSizeInEpochs: SLASHING_ROUND_SIZE_IN_EPOCHS,
|
|
59
|
+
slashInactivityTargetPercentage: 0.8,
|
|
60
|
+
slashGracePeriodL2Slots: SETUP_EPOCH_DURATION * EPOCH_DURATION,
|
|
61
|
+
slashAmountSmall: SLASHING_UNIT,
|
|
62
|
+
slashAmountMedium: SLASHING_UNIT * 2n,
|
|
63
|
+
slashAmountLarge: SLASHING_UNIT * 3n,
|
|
64
|
+
...opts
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return new P2PInactivityTest(test, opts);
|
|
68
|
+
}
|
|
69
|
+
async setup() {
|
|
70
|
+
await this.test.setup();
|
|
71
|
+
await this.test.applyBaseSetup();
|
|
72
|
+
// Set slashing penalties for inactivity
|
|
73
|
+
const { rollup } = await this.test.getContracts();
|
|
74
|
+
const [activationThreshold, ejectionThreshold, localEjectionThreshold] = await Promise.all([
|
|
75
|
+
rollup.getActivationThreshold(),
|
|
76
|
+
rollup.getEjectionThreshold(),
|
|
77
|
+
rollup.getLocalEjectionThreshold()
|
|
78
|
+
]);
|
|
79
|
+
const biggestEjection = ejectionThreshold > localEjectionThreshold ? ejectionThreshold : localEjectionThreshold;
|
|
80
|
+
expect(activationThreshold - SLASHING_AMOUNT).toBeLessThan(biggestEjection);
|
|
81
|
+
this.test.ctx.aztecNodeConfig.slashInactivityPenalty = SLASHING_AMOUNT;
|
|
82
|
+
this.rollup = rollup;
|
|
83
|
+
if (!this.keepInitialNode) {
|
|
84
|
+
await this.test.ctx.aztecNodeService.stop();
|
|
85
|
+
}
|
|
86
|
+
// Create all active nodes
|
|
87
|
+
this.activeNodes = await createNodes(this.test.ctx.aztecNodeConfig, this.test.ctx.dateProvider, this.test.bootstrapNodeEnr, NUM_NODES - this.inactiveNodeCount - Number(this.keepInitialNode), BOOT_NODE_UDP_PORT, this.test.prefilledPublicData, this.dataDir, undefined, Number(this.keepInitialNode));
|
|
88
|
+
// And the ones with an initially disabled sequencer
|
|
89
|
+
const inactiveConfig = {
|
|
90
|
+
...this.test.ctx.aztecNodeConfig,
|
|
91
|
+
dontStartSequencer: true
|
|
92
|
+
};
|
|
93
|
+
this.inactiveNodes = await createNodes(inactiveConfig, this.test.ctx.dateProvider, this.test.bootstrapNodeEnr, this.inactiveNodeCount, BOOT_NODE_UDP_PORT, this.test.prefilledPublicData, this.dataDir, undefined, NUM_NODES - this.inactiveNodeCount);
|
|
94
|
+
this.nodes = [
|
|
95
|
+
...this.keepInitialNode ? [
|
|
96
|
+
this.test.ctx.aztecNodeService
|
|
97
|
+
] : [],
|
|
98
|
+
...this.activeNodes,
|
|
99
|
+
...this.inactiveNodes
|
|
100
|
+
];
|
|
101
|
+
if (this.nodes.length !== NUM_NODES) {
|
|
102
|
+
throw new Error(`Expected ${NUM_NODES} nodes but got ${this.nodes.length}`);
|
|
103
|
+
}
|
|
104
|
+
this.offlineValidators = this.test.validators.slice(this.test.validators.length - this.inactiveNodeCount).map((a)=>a.attester);
|
|
105
|
+
this.test.logger.warn(`Setup complete. Offline validators are ${this.offlineValidators.join(', ')}.`, {
|
|
106
|
+
validators: this.test.validators,
|
|
107
|
+
offlineValidators: this.offlineValidators
|
|
108
|
+
});
|
|
109
|
+
// Wait for P2P mesh to be fully formed before starting slashing period
|
|
110
|
+
// This prevents race conditions where validators propose blocks before the network is ready
|
|
111
|
+
await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
|
|
112
|
+
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION - 1} (slashing will start after it is completed)`);
|
|
113
|
+
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(EpochNumber(SETUP_EPOCH_DURATION - 1));
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
async teardown() {
|
|
117
|
+
await this.test.stopNodes(this.nodes);
|
|
118
|
+
await this.test.teardown();
|
|
119
|
+
for(let i = 0; i < NUM_NODES; i++){
|
|
120
|
+
fs.rmSync(`${this.dataDir}-${i}`, {
|
|
121
|
+
recursive: true,
|
|
122
|
+
force: true,
|
|
123
|
+
maxRetries: 3
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get ctx() {
|
|
128
|
+
return this.test.ctx;
|
|
129
|
+
}
|
|
130
|
+
get logger() {
|
|
131
|
+
return this.test.logger;
|
|
132
|
+
}
|
|
133
|
+
get slashingAmount() {
|
|
134
|
+
return SLASHING_AMOUNT;
|
|
135
|
+
}
|
|
136
|
+
}
|