@aztec/end-to-end 0.0.1-fake-c83136db25 → 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 +2 -3
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +12 -16
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +58 -54
- package/dest/bench/client_flows/data_extractor.js +3 -3
- package/dest/bench/utils.d.ts +11 -2
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +34 -10
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -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 +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +8 -10
- 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 +33 -31
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -9
- package/dest/e2e_epochs/epochs_test.d.ts +1 -3
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +9 -10
- package/dest/e2e_fees/bridging_race.notest.js +9 -12
- package/dest/e2e_fees/fees_test.d.ts +5 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +31 -23
- package/dest/e2e_l1_publisher/write_json.d.ts +1 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -5
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +9 -7
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +2 -2
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +2 -5
- package/dest/e2e_p2p/p2p_network.d.ts +2 -14
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +10 -32
- package/dest/e2e_p2p/shared.d.ts +13 -11
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +45 -49
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +17 -14
- package/dest/fixtures/e2e_prover_test.d.ts +6 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +50 -40
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +2 -2
- package/dest/fixtures/setup_p2p_test.d.ts +7 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.d.ts +7 -10
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +32 -42
- package/dest/fixtures/token_utils.d.ts +4 -6
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +15 -11
- package/dest/fixtures/utils.d.ts +27 -23
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +100 -75
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/web3signer.d.ts.map +1 -1
- package/dest/fixtures/web3signer.js +5 -16
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +10 -16
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +15 -13
- package/dest/shared/gas_portal_test_harness.d.ts +6 -9
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +7 -10
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +3 -5
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +7 -8
- package/dest/shared/uniswap_l1_l2.d.ts +6 -9
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +45 -29
- package/dest/simulators/lending_simulator.d.ts +1 -2
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -3
- package/dest/simulators/token_simulator.d.ts +1 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +13 -19
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +84 -107
- package/dest/spartan/utils.d.ts +0 -44
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +20 -212
- package/package.json +36 -37
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +82 -62
- package/src/bench/client_flows/data_extractor.ts +4 -4
- package/src/bench/utils.ts +37 -9
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +63 -46
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -33
- package/src/e2e_deploy_contract/deploy_test.ts +35 -17
- package/src/e2e_epochs/epochs_test.ts +14 -12
- package/src/e2e_fees/bridging_race.notest.ts +9 -14
- package/src/e2e_fees/fees_test.ts +38 -26
- package/src/e2e_l1_publisher/write_json.ts +6 -8
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +10 -11
- package/src/e2e_p2p/inactivity_slash_test.ts +3 -7
- package/src/e2e_p2p/p2p_network.ts +67 -105
- package/src/e2e_p2p/shared.ts +55 -50
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +88 -51
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +2 -3
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +8 -0
- package/src/fixtures/snapshot_manager.ts +59 -59
- package/src/fixtures/token_utils.ts +21 -13
- package/src/fixtures/utils.ts +137 -86
- package/src/fixtures/web3signer.ts +5 -22
- package/src/guides/up_quick_start.sh +10 -2
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +29 -18
- package/src/shared/gas_portal_test_harness.ts +19 -12
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +8 -12
- package/src/shared/uniswap_l1_l2.ts +67 -61
- package/src/simulators/lending_simulator.ts +2 -3
- package/src/simulators/token_simulator.ts +2 -5
- package/src/spartan/DEVELOP.md +3 -8
- package/src/spartan/setup_test_wallets.ts +125 -132
- package/src/spartan/utils.ts +18 -268
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
-
import { EthAddress } from '@aztec/aztec.js
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js';
|
|
3
3
|
import { RollupContract } from '@aztec/ethereum';
|
|
4
4
|
|
|
5
5
|
import fs from 'fs';
|
|
@@ -17,8 +17,8 @@ const SLASHING_QUORUM = 3;
|
|
|
17
17
|
const EPOCH_DURATION = 2;
|
|
18
18
|
const SLASHING_ROUND_SIZE_IN_EPOCHS = 2;
|
|
19
19
|
const BOOT_NODE_UDP_PORT = 4500;
|
|
20
|
-
const ETHEREUM_SLOT_DURATION =
|
|
21
|
-
const AZTEC_SLOT_DURATION =
|
|
20
|
+
const ETHEREUM_SLOT_DURATION = 4;
|
|
21
|
+
const AZTEC_SLOT_DURATION = 8;
|
|
22
22
|
const SLASHING_UNIT = BigInt(1e18);
|
|
23
23
|
const SLASHING_AMOUNT = SLASHING_UNIT * 3n;
|
|
24
24
|
|
|
@@ -146,10 +146,6 @@ export class P2PInactivityTest {
|
|
|
146
146
|
offlineValidators: this.offlineValidators,
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
// Wait for P2P mesh to be fully formed before starting slashing period
|
|
150
|
-
// This prevents race conditions where validators propose blocks before the network is ready
|
|
151
|
-
await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
|
|
152
|
-
|
|
153
149
|
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION + 1} to start slashing`);
|
|
154
150
|
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(SETUP_EPOCH_DURATION + 1);
|
|
155
151
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
1
2
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
3
|
import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
-
import { AztecAddress, EthAddress } from '@aztec/aztec.js
|
|
4
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import { type AccountWalletWithSecretKey, AztecAddress, EthAddress, Fr } from '@aztec/aztec.js';
|
|
5
5
|
import {
|
|
6
6
|
type EmpireSlashingProposerContract,
|
|
7
7
|
type ExtendedViemWalletClient,
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
19
19
|
import { SecretValue } from '@aztec/foundation/config';
|
|
20
20
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
21
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
22
21
|
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
23
22
|
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
24
23
|
import type { BootstrapNode } from '@aztec/p2p/bootstrap';
|
|
@@ -27,7 +26,6 @@ import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
|
27
26
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
28
27
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
29
28
|
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
30
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
31
29
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
32
30
|
|
|
33
31
|
import getPort from 'get-port';
|
|
@@ -77,7 +75,7 @@ export class P2PNetworkTest {
|
|
|
77
75
|
public prefilledPublicData: PublicDataTreeLeaf[] = [];
|
|
78
76
|
|
|
79
77
|
// The re-execution test needs a wallet and a spam contract
|
|
80
|
-
public wallet?:
|
|
78
|
+
public wallet?: AccountWalletWithSecretKey;
|
|
81
79
|
public defaultAccountAddress?: AztecAddress;
|
|
82
80
|
public spamContract?: SpamContract;
|
|
83
81
|
|
|
@@ -232,83 +230,89 @@ export class P2PNetworkTest {
|
|
|
232
230
|
|
|
233
231
|
async applyBaseSnapshots() {
|
|
234
232
|
await this.addBootstrapNode();
|
|
235
|
-
await this.snapshotManager.snapshot(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
await this.snapshotManager.snapshot(
|
|
234
|
+
'add-validators',
|
|
235
|
+
async ({ deployL1ContractsValues, dateProvider, cheatCodes }) => {
|
|
236
|
+
const rollup = getContract({
|
|
237
|
+
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
238
|
+
abi: RollupAbi,
|
|
239
|
+
client: deployL1ContractsValues.l1Client,
|
|
240
|
+
});
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
const stakingAsset = getContract({
|
|
245
|
+
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
246
|
+
abi: TestERC20Abi,
|
|
247
|
+
client: deployL1ContractsValues.l1Client,
|
|
248
|
+
});
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
250
|
+
const { address: multiAdderAddress } = await deployL1Contract(
|
|
251
|
+
deployL1ContractsValues.l1Client,
|
|
252
|
+
MultiAdderArtifact.contractAbi,
|
|
253
|
+
MultiAdderArtifact.contractBytecode,
|
|
254
|
+
[rollup.address, deployL1ContractsValues.l1Client.account.address],
|
|
255
|
+
);
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
const multiAdder = getContract({
|
|
258
|
+
address: multiAdderAddress.toString(),
|
|
259
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
260
|
+
client: deployL1ContractsValues.l1Client,
|
|
261
|
+
});
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
const stakeNeeded = (await rollup.read.getActivationThreshold()) * BigInt(this.numberOfValidators);
|
|
264
|
+
await Promise.all(
|
|
265
|
+
[await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
|
|
266
|
+
deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
|
|
267
|
+
),
|
|
268
|
+
);
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
const { validators } = this.getValidators();
|
|
271
|
+
this.validators = validators;
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
274
|
+
if (!gseAddress) {
|
|
275
|
+
throw new Error('GSE contract not deployed');
|
|
276
|
+
}
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
279
279
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
+
};
|
|
286
287
|
};
|
|
287
|
-
|
|
288
|
-
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
288
|
+
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
289
289
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
291
|
+
hash: await multiAdder.write.addValidators([validatorTuples]),
|
|
292
|
+
});
|
|
293
293
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
295
|
+
(await cheatCodes.rollup.getEpoch()) + (await rollup.read.getLagInEpochs()) + 1n,
|
|
296
|
+
{
|
|
297
|
+
updateDateProvider: dateProvider,
|
|
298
|
+
},
|
|
299
|
+
);
|
|
297
300
|
|
|
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);
|
|
303
|
+
},
|
|
304
|
+
);
|
|
301
305
|
}
|
|
302
306
|
|
|
303
307
|
async setupAccount() {
|
|
304
308
|
await this.snapshotManager.snapshot(
|
|
305
309
|
'setup-account',
|
|
306
|
-
deployAccounts(1, this.logger),
|
|
307
|
-
({ deployedAccounts }, {
|
|
310
|
+
deployAccounts(1, this.logger, false),
|
|
311
|
+
async ({ deployedAccounts }, { pxe }) => {
|
|
308
312
|
this.deployedAccounts = deployedAccounts;
|
|
309
|
-
[
|
|
310
|
-
this.wallet =
|
|
311
|
-
|
|
313
|
+
const [account] = deployedAccounts;
|
|
314
|
+
this.wallet = await getSchnorrWalletWithSecretKey(pxe, account.secret, account.signingKey, account.salt);
|
|
315
|
+
this.defaultAccountAddress = this.wallet.getAddress();
|
|
312
316
|
},
|
|
313
317
|
);
|
|
314
318
|
}
|
|
@@ -390,48 +394,6 @@ export class P2PNetworkTest {
|
|
|
390
394
|
this.logger.info('Nodes stopped');
|
|
391
395
|
}
|
|
392
396
|
|
|
393
|
-
/**
|
|
394
|
-
* Wait for P2P mesh to be fully formed across all nodes.
|
|
395
|
-
* This ensures that all nodes are connected to each other before proceeding,
|
|
396
|
-
* preventing race conditions where validators propose blocks before the network is ready.
|
|
397
|
-
*
|
|
398
|
-
* @param nodes - Array of nodes to check for P2P connectivity
|
|
399
|
-
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
400
|
-
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
401
|
-
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
402
|
-
*/
|
|
403
|
-
async waitForP2PMeshConnectivity(
|
|
404
|
-
nodes: AztecNodeService[],
|
|
405
|
-
expectedNodeCount?: number,
|
|
406
|
-
timeoutSeconds = 30,
|
|
407
|
-
checkIntervalSeconds = 0.1,
|
|
408
|
-
) {
|
|
409
|
-
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
410
|
-
const minPeerCount = nodeCount - 1;
|
|
411
|
-
|
|
412
|
-
this.logger.warn(
|
|
413
|
-
`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`,
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
await Promise.all(
|
|
417
|
-
nodes.map(async (node, index) => {
|
|
418
|
-
const p2p = node.getP2P();
|
|
419
|
-
await retryUntil(
|
|
420
|
-
async () => {
|
|
421
|
-
const peers = await p2p.getPeers();
|
|
422
|
-
// Each node should be connected to at least N-1 other nodes
|
|
423
|
-
return peers.length >= minPeerCount ? true : undefined;
|
|
424
|
-
},
|
|
425
|
-
`Node ${index} to connect to at least ${minPeerCount} peers`,
|
|
426
|
-
timeoutSeconds,
|
|
427
|
-
checkIntervalSeconds,
|
|
428
|
-
);
|
|
429
|
-
}),
|
|
430
|
-
);
|
|
431
|
-
|
|
432
|
-
this.logger.warn('All nodes connected to P2P mesh');
|
|
433
|
-
}
|
|
434
|
-
|
|
435
397
|
async teardown() {
|
|
436
398
|
await this.monitor.stop();
|
|
437
399
|
await tryStop(this.bootstrapNode, this.logger);
|
package/src/e2e_p2p/shared.ts
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
1
2
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
3
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import {
|
|
5
|
+
AztecAddress,
|
|
6
|
+
Fr,
|
|
7
|
+
type Logger,
|
|
8
|
+
ProvenTx,
|
|
9
|
+
type SentTx,
|
|
10
|
+
TxStatus,
|
|
11
|
+
getContractInstanceFromInstantiationParams,
|
|
12
|
+
retryUntil,
|
|
13
|
+
} from '@aztec/aztec.js';
|
|
8
14
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
9
15
|
import type { EmpireSlashingProposerContract, RollupContract, TallySlashingProposerContract } from '@aztec/ethereum';
|
|
10
16
|
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
11
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
12
17
|
import { pluralize } from '@aztec/foundation/string';
|
|
18
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
13
19
|
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
14
20
|
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
15
|
-
import {
|
|
21
|
+
import { PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
16
22
|
import { getRoundForOffense } from '@aztec/slasher';
|
|
17
23
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
18
24
|
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
19
|
-
import { TestWallet, proveInteraction } from '@aztec/test-wallet/server';
|
|
20
25
|
|
|
26
|
+
import type { NodeContext } from '../fixtures/setup_p2p_test.js';
|
|
21
27
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
22
28
|
|
|
23
29
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
@@ -50,46 +56,56 @@ export const submitComplexTxsTo = async (
|
|
|
50
56
|
return txs;
|
|
51
57
|
};
|
|
52
58
|
|
|
53
|
-
// creates
|
|
54
|
-
export const
|
|
59
|
+
// creates an instance of the PXE and submit a given number of transactions to it.
|
|
60
|
+
export const createPXEServiceAndSubmitTransactions = async (
|
|
55
61
|
logger: Logger,
|
|
56
62
|
node: AztecNodeService,
|
|
57
63
|
numTxs: number,
|
|
58
64
|
fundedAccount: InitialAccountData,
|
|
59
|
-
): Promise<
|
|
65
|
+
): Promise<NodeContext> => {
|
|
60
66
|
const rpcConfig = getRpcConfig();
|
|
61
67
|
rpcConfig.proverEnabled = false;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
const pxeService = await createPXEService(node, rpcConfig, { useLogSuffix: true });
|
|
69
|
+
|
|
70
|
+
const account = await getSchnorrAccount(
|
|
71
|
+
pxeService,
|
|
72
|
+
fundedAccount.secret,
|
|
73
|
+
fundedAccount.signingKey,
|
|
74
|
+
fundedAccount.salt,
|
|
75
|
+
);
|
|
76
|
+
await account.register();
|
|
77
|
+
const wallet = await account.getWallet();
|
|
78
|
+
|
|
79
|
+
const txs = await submitTxsTo(pxeService, numTxs, wallet, logger);
|
|
80
|
+
return { txs, pxeService, node };
|
|
65
81
|
};
|
|
66
82
|
|
|
67
|
-
export async function
|
|
83
|
+
export async function createPXEServiceAndPrepareTransactions(
|
|
68
84
|
logger: Logger,
|
|
69
85
|
node: AztecNodeService,
|
|
70
86
|
numTxs: number,
|
|
71
87
|
fundedAccount: InitialAccountData,
|
|
72
|
-
): Promise<
|
|
88
|
+
): Promise<{ pxeService: PXEService; txs: ProvenTx[]; node: AztecNodeService }> {
|
|
73
89
|
const rpcConfig = getRpcConfig();
|
|
74
90
|
rpcConfig.proverEnabled = false;
|
|
91
|
+
const pxe = await createPXEService(node, rpcConfig, { useLogSuffix: true });
|
|
75
92
|
|
|
76
|
-
const
|
|
77
|
-
|
|
93
|
+
const account = await getSchnorrAccount(pxe, fundedAccount.secret, fundedAccount.signingKey, fundedAccount.salt);
|
|
94
|
+
await account.register();
|
|
95
|
+
const wallet = await account.getWallet();
|
|
78
96
|
|
|
79
|
-
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
await wallet.registerContract(testContractInstance, TestContractArtifact);
|
|
97
|
+
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {});
|
|
98
|
+
await wallet.registerContract({ instance: testContractInstance, artifact: TestContractArtifact });
|
|
83
99
|
const contract = await TestContract.at(testContractInstance.address, wallet);
|
|
84
100
|
|
|
85
|
-
|
|
86
|
-
const tx = await
|
|
87
|
-
from: fundedAccountManager.address,
|
|
88
|
-
});
|
|
101
|
+
const txs = await timesAsync(numTxs, async () => {
|
|
102
|
+
const tx = await contract.methods.emit_nullifier(Fr.random()).prove({ from: account.getAddress() });
|
|
89
103
|
const txHash = tx.getTxHash();
|
|
90
104
|
logger.info(`Tx prepared with hash ${txHash}`);
|
|
91
105
|
return tx;
|
|
92
106
|
});
|
|
107
|
+
|
|
108
|
+
return { txs, pxeService: pxe, node };
|
|
93
109
|
}
|
|
94
110
|
|
|
95
111
|
export function awaitProposalExecution(
|
|
@@ -150,14 +166,12 @@ export async function awaitOffenseDetected({
|
|
|
150
166
|
slashingRoundSize,
|
|
151
167
|
epochDuration,
|
|
152
168
|
waitUntilOffenseCount,
|
|
153
|
-
timeoutSeconds = 120,
|
|
154
169
|
}: {
|
|
155
170
|
nodeAdmin: AztecNodeAdmin;
|
|
156
171
|
logger: Logger;
|
|
157
172
|
slashingRoundSize: number;
|
|
158
173
|
epochDuration: number;
|
|
159
174
|
waitUntilOffenseCount?: number;
|
|
160
|
-
timeoutSeconds?: number;
|
|
161
175
|
}) {
|
|
162
176
|
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
163
177
|
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
@@ -169,11 +183,11 @@ export async function awaitOffenseDetected({
|
|
|
169
183
|
}
|
|
170
184
|
},
|
|
171
185
|
'non-empty offenses',
|
|
172
|
-
|
|
186
|
+
60,
|
|
173
187
|
);
|
|
174
188
|
logger.info(
|
|
175
189
|
`Hit ${offenses.length} offenses on rounds ${unique(offenses.map(o => getRoundForOffense(o, { slashingRoundSize, epochDuration })))}`,
|
|
176
|
-
|
|
190
|
+
offenses,
|
|
177
191
|
);
|
|
178
192
|
return offenses;
|
|
179
193
|
}
|
|
@@ -190,9 +204,8 @@ export async function awaitCommitteeKicked({
|
|
|
190
204
|
slashingProposer,
|
|
191
205
|
slashingRoundSize,
|
|
192
206
|
aztecSlotDuration,
|
|
193
|
-
aztecEpochDuration,
|
|
194
207
|
logger,
|
|
195
|
-
|
|
208
|
+
dateProvider,
|
|
196
209
|
}: {
|
|
197
210
|
rollup: RollupContract;
|
|
198
211
|
cheatCodes: RollupCheatCodes;
|
|
@@ -201,22 +214,21 @@ export async function awaitCommitteeKicked({
|
|
|
201
214
|
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
202
215
|
slashingRoundSize: number;
|
|
203
216
|
aztecSlotDuration: number;
|
|
204
|
-
|
|
217
|
+
dateProvider: TestDateProvider;
|
|
205
218
|
logger: Logger;
|
|
206
|
-
offenseEpoch: number;
|
|
207
219
|
}) {
|
|
208
220
|
if (!slashingProposer) {
|
|
209
221
|
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
210
222
|
}
|
|
211
223
|
|
|
224
|
+
logger.info(`Advancing epochs so we start slashing`);
|
|
212
225
|
await cheatCodes.debugRollup();
|
|
226
|
+
await cheatCodes.advanceToEpoch((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochs()) + 1n, {
|
|
227
|
+
updateDateProvider: dateProvider,
|
|
228
|
+
});
|
|
213
229
|
|
|
230
|
+
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
214
231
|
if (slashingProposer.type === 'empire') {
|
|
215
|
-
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
216
|
-
const targetEpoch = (await cheatCodes.getEpoch()) + (await rollup.getLagInEpochs()) + 1n;
|
|
217
|
-
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
218
|
-
await cheatCodes.advanceToEpoch(targetEpoch);
|
|
219
|
-
|
|
220
232
|
const slashPayloadEvents = await retryUntil(
|
|
221
233
|
async () => {
|
|
222
234
|
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
@@ -231,15 +243,6 @@ export async function awaitCommitteeKicked({
|
|
|
231
243
|
expect(unique(slashPayloadEvents[0].slashes.map(slash => slash.validator.toString()))).toHaveLength(
|
|
232
244
|
committee.length,
|
|
233
245
|
);
|
|
234
|
-
} else {
|
|
235
|
-
// Use the slash offset to ensure we are in the right epoch for tally
|
|
236
|
-
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
237
|
-
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
238
|
-
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
239
|
-
const firstEpochInOffenseRound = offenseEpoch - (offenseEpoch % slashingRoundSizeInEpochs);
|
|
240
|
-
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
241
|
-
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
242
|
-
await cheatCodes.advanceToEpoch(targetEpoch, { offset: -aztecSlotDuration / 2 });
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
const attestersPre = await rollup.getAttesters();
|
|
@@ -250,7 +253,7 @@ export async function awaitCommitteeKicked({
|
|
|
250
253
|
expect(attesterInfo.status).toEqual(1); // Validating
|
|
251
254
|
}
|
|
252
255
|
|
|
253
|
-
const timeout = slashingRoundSize * 2 * aztecSlotDuration
|
|
256
|
+
const timeout = slashingRoundSize * 2 * aztecSlotDuration;
|
|
254
257
|
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
255
258
|
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
256
259
|
|
|
@@ -269,7 +272,9 @@ export async function awaitCommitteeKicked({
|
|
|
269
272
|
|
|
270
273
|
logger.info(`Advancing to check current committee`);
|
|
271
274
|
await cheatCodes.debugRollup();
|
|
272
|
-
await cheatCodes.advanceToEpoch((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochs()) + 1n
|
|
275
|
+
await cheatCodes.advanceToEpoch((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochs()) + 1n, {
|
|
276
|
+
updateDateProvider: dateProvider,
|
|
277
|
+
});
|
|
273
278
|
await cheatCodes.debugRollup();
|
|
274
279
|
|
|
275
280
|
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/aztec.js
|
|
3
|
-
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
1
|
+
import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { type AccountWallet, AztecAddress, type AztecNode, type Logger, createLogger } from '@aztec/aztec.js';
|
|
4
3
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
4
|
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
6
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
7
5
|
|
|
8
6
|
import { jest } from '@jest/globals';
|
|
9
7
|
|
|
@@ -30,9 +28,11 @@ export class TokenContractTest {
|
|
|
30
28
|
node!: AztecNode;
|
|
31
29
|
|
|
32
30
|
badAccount!: InvalidAccountContract;
|
|
33
|
-
|
|
31
|
+
admin!: AccountWallet;
|
|
34
32
|
adminAddress!: AztecAddress;
|
|
33
|
+
account1!: AccountWallet;
|
|
35
34
|
account1Address!: AztecAddress;
|
|
35
|
+
account2!: AccountWallet;
|
|
36
36
|
account2Address!: AztecAddress;
|
|
37
37
|
|
|
38
38
|
constructor(testName: string) {
|
|
@@ -54,11 +54,11 @@ export class TokenContractTest {
|
|
|
54
54
|
await this.snapshotManager.snapshot(
|
|
55
55
|
'3_accounts',
|
|
56
56
|
deployAccounts(3, this.logger),
|
|
57
|
-
({ deployedAccounts }, {
|
|
57
|
+
async ({ deployedAccounts }, { pxe, aztecNode }) => {
|
|
58
58
|
this.node = aztecNode;
|
|
59
|
-
|
|
60
|
-
[this.
|
|
61
|
-
|
|
59
|
+
const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
60
|
+
[this.admin, this.account1, this.account2] = wallets;
|
|
61
|
+
[this.adminAddress, this.account1Address, this.account2Address] = wallets.map(w => w.getAddress());
|
|
62
62
|
},
|
|
63
63
|
);
|
|
64
64
|
|
|
@@ -68,11 +68,11 @@ export class TokenContractTest {
|
|
|
68
68
|
// Create the token contract state.
|
|
69
69
|
// Move this account thing to addAccounts above?
|
|
70
70
|
this.logger.verbose(`Public deploy accounts...`);
|
|
71
|
-
await publicDeployAccounts(this.
|
|
71
|
+
await publicDeployAccounts(this.admin, [this.adminAddress, this.account1Address]);
|
|
72
72
|
|
|
73
73
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
74
74
|
const asset = await TokenContract.deploy(
|
|
75
|
-
this.
|
|
75
|
+
this.admin,
|
|
76
76
|
this.adminAddress,
|
|
77
77
|
TokenContractTest.TOKEN_NAME,
|
|
78
78
|
TokenContractTest.TOKEN_SYMBOL,
|
|
@@ -83,22 +83,22 @@ export class TokenContractTest {
|
|
|
83
83
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
84
84
|
|
|
85
85
|
this.logger.verbose(`Deploying bad account...`);
|
|
86
|
-
this.badAccount = await InvalidAccountContract.deploy(this.
|
|
86
|
+
this.badAccount = await InvalidAccountContract.deploy(this.admin).send({ from: this.adminAddress }).deployed();
|
|
87
87
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
88
88
|
|
|
89
89
|
return { tokenContractAddress: asset.address, badAccountAddress: this.badAccount.address };
|
|
90
90
|
},
|
|
91
91
|
async ({ tokenContractAddress, badAccountAddress }) => {
|
|
92
92
|
// Restore the token contract state.
|
|
93
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
93
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.admin);
|
|
94
94
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
95
95
|
|
|
96
|
-
this.tokenSim = new TokenSimulator(this.asset, this.
|
|
96
|
+
this.tokenSim = new TokenSimulator(this.asset, this.admin, this.adminAddress, this.logger, [
|
|
97
97
|
this.adminAddress,
|
|
98
98
|
this.account1Address,
|
|
99
99
|
]);
|
|
100
100
|
|
|
101
|
-
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.
|
|
101
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.admin);
|
|
102
102
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
103
103
|
|
|
104
104
|
expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
|
|
@@ -131,14 +131,14 @@ export class TokenContractTest {
|
|
|
131
131
|
await this.snapshotManager.snapshot(
|
|
132
132
|
'mint',
|
|
133
133
|
async () => {
|
|
134
|
-
const { asset, adminAddress } = this;
|
|
134
|
+
const { asset, admin, adminAddress } = this;
|
|
135
135
|
const amount = 10000n;
|
|
136
136
|
|
|
137
137
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
138
138
|
await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress }).wait();
|
|
139
139
|
|
|
140
140
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
141
|
-
await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
|
|
141
|
+
await mintTokensToPrivate(asset, adminAddress, admin, adminAddress, amount);
|
|
142
142
|
this.logger.verbose(`Minting complete.`);
|
|
143
143
|
|
|
144
144
|
return { amount };
|