@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
|
@@ -1,150 +1,323 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createCompatibleClient,
|
|
13
|
-
retryUntil,
|
|
14
|
-
} from '@aztec/aztec.js';
|
|
15
|
-
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
1
|
+
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
5
|
+
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
6
|
+
import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
7
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
8
|
+
import { type AztecNode, createAztecNodeClient, waitForTx } from '@aztec/aztec.js/node';
|
|
9
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
10
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
16
12
|
import type { Logger } from '@aztec/foundation/log';
|
|
13
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
17
14
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
15
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
16
|
+
import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
19
|
+
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
20
|
+
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
|
|
21
|
+
|
|
22
|
+
export interface TestAccounts {
|
|
23
|
+
aztecNode: AztecNode;
|
|
24
|
+
wallet: TestWallet;
|
|
25
|
+
accounts: AztecAddress[];
|
|
26
|
+
tokenContract: TokenContract;
|
|
27
|
+
tokenAdminAddress: AztecAddress;
|
|
23
28
|
tokenName: string;
|
|
24
|
-
|
|
29
|
+
recipientAddress: AztecAddress;
|
|
25
30
|
tokenAddress: AztecAddress;
|
|
26
31
|
}
|
|
27
32
|
|
|
33
|
+
export type TestAccountsWithoutTokens = Omit<
|
|
34
|
+
TestAccounts,
|
|
35
|
+
'tokenAddress' | 'tokenContract' | 'tokenName' | 'tokenAdminAddress'
|
|
36
|
+
>;
|
|
37
|
+
|
|
28
38
|
const TOKEN_NAME = 'USDC';
|
|
29
39
|
const TOKEN_SYMBOL = 'USD';
|
|
30
40
|
const TOKEN_DECIMALS = 18n;
|
|
31
41
|
|
|
32
|
-
export async function
|
|
33
|
-
|
|
42
|
+
export async function setupTestAccountsWithTokens(
|
|
43
|
+
nodeUrl: string,
|
|
44
|
+
mintAmount: bigint,
|
|
45
|
+
logger: Logger,
|
|
46
|
+
): Promise<TestAccounts> {
|
|
47
|
+
const ACCOUNT_COUNT = 1; // TODO fix this to allow for 16 wallets again
|
|
48
|
+
|
|
49
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
50
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
51
|
+
|
|
52
|
+
const [recipientAccount, ...accounts] = (await registerInitialLocalNetworkAccountsInWallet(wallet)).slice(
|
|
53
|
+
0,
|
|
54
|
+
ACCOUNT_COUNT + 1,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const tokenAdmin = accounts[0];
|
|
58
|
+
const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
|
|
59
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
aztecNode,
|
|
63
|
+
accounts,
|
|
64
|
+
wallet,
|
|
65
|
+
tokenAdminAddress: tokenAdmin,
|
|
66
|
+
tokenName: TOKEN_NAME,
|
|
67
|
+
tokenAddress,
|
|
68
|
+
tokenContract,
|
|
69
|
+
recipientAddress: recipientAccount,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function deploySponsoredTestAccountsWithTokens(
|
|
74
|
+
wallet: TestWallet,
|
|
75
|
+
aztecNode: AztecNode,
|
|
34
76
|
mintAmount: bigint,
|
|
35
77
|
logger: Logger,
|
|
36
|
-
|
|
37
|
-
|
|
78
|
+
numberOfFundedWallets = 1,
|
|
79
|
+
): Promise<TestAccounts> {
|
|
80
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
81
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
82
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
38
83
|
|
|
39
|
-
|
|
84
|
+
await registerSponsoredFPC(wallet);
|
|
40
85
|
|
|
41
|
-
const
|
|
86
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
87
|
+
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
88
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
|
|
89
|
+
await Promise.all(
|
|
90
|
+
fundedAccounts.map(async a => {
|
|
91
|
+
const deployMethod = await a.getDeployMethod();
|
|
92
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
|
|
93
|
+
logger.info(`Account deployed at ${a.address}`);
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const tokenAdmin = fundedAccounts[0];
|
|
98
|
+
const tokenAddress = await deployTokenAndMint(
|
|
99
|
+
wallet,
|
|
100
|
+
fundedAccounts.map(acc => acc.address),
|
|
101
|
+
tokenAdmin.address,
|
|
102
|
+
mintAmount,
|
|
103
|
+
new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
|
|
104
|
+
logger,
|
|
105
|
+
);
|
|
106
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
aztecNode,
|
|
110
|
+
wallet,
|
|
111
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
112
|
+
tokenAdminAddress: tokenAdmin.address,
|
|
113
|
+
tokenName: TOKEN_NAME,
|
|
114
|
+
tokenAddress,
|
|
115
|
+
tokenContract,
|
|
116
|
+
recipientAddress: recipientAccount.address,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
42
119
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
120
|
+
async function deployAccountWithDiagnostics(
|
|
121
|
+
account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any },
|
|
122
|
+
paymentMethod: SponsoredFeePaymentMethod,
|
|
123
|
+
aztecNode: AztecNode,
|
|
124
|
+
logger: Logger,
|
|
125
|
+
accountLabel: string,
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
const deployMethod = await account.getDeployMethod();
|
|
128
|
+
let txHash;
|
|
129
|
+
try {
|
|
130
|
+
txHash = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT });
|
|
131
|
+
await waitForTx(aztecNode, txHash, { timeout: 2400 });
|
|
132
|
+
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const blockNumber = await aztecNode.getBlockNumber();
|
|
135
|
+
let receipt;
|
|
136
|
+
try {
|
|
137
|
+
receipt = await aztecNode.getTxReceipt(txHash);
|
|
138
|
+
} catch {
|
|
139
|
+
receipt = 'unavailable';
|
|
140
|
+
}
|
|
141
|
+
logger.error(`${accountLabel} deployment failed`, {
|
|
142
|
+
txHash: txHash.toString(),
|
|
143
|
+
receipt: JSON.stringify(receipt),
|
|
144
|
+
currentBlockNumber: blockNumber,
|
|
145
|
+
error: String(error),
|
|
146
|
+
});
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
46
150
|
|
|
47
|
-
|
|
151
|
+
async function deployAccountsInBatches(
|
|
152
|
+
accounts: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any }[],
|
|
153
|
+
paymentMethod: SponsoredFeePaymentMethod,
|
|
154
|
+
aztecNode: AztecNode,
|
|
155
|
+
logger: Logger,
|
|
156
|
+
labelPrefix: string,
|
|
157
|
+
batchSize = 2,
|
|
158
|
+
): Promise<void> {
|
|
159
|
+
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
160
|
+
const batch = accounts.slice(i, i + batchSize);
|
|
161
|
+
await Promise.all(
|
|
162
|
+
batch.map((account, idx) =>
|
|
163
|
+
deployAccountWithDiagnostics(account, paymentMethod, aztecNode, logger, `${labelPrefix}${i + idx + 1}`),
|
|
164
|
+
),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
48
167
|
}
|
|
49
168
|
|
|
50
|
-
export async function
|
|
51
|
-
|
|
169
|
+
export async function deploySponsoredTestAccounts(
|
|
170
|
+
wallet: TestWallet,
|
|
171
|
+
aztecNode: AztecNode,
|
|
172
|
+
logger: Logger,
|
|
173
|
+
numberOfFundedWallets = 1,
|
|
174
|
+
): Promise<TestAccountsWithoutTokens> {
|
|
175
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
176
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
177
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
178
|
+
|
|
179
|
+
await registerSponsoredFPC(wallet);
|
|
180
|
+
|
|
181
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
182
|
+
|
|
183
|
+
await deployAccountWithDiagnostics(recipientAccount, paymentMethod, aztecNode, logger, 'Recipient account');
|
|
184
|
+
await deployAccountsInBatches(fundedAccounts, paymentMethod, aztecNode, logger, 'Funded account ', 2);
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
aztecNode,
|
|
188
|
+
wallet,
|
|
189
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
190
|
+
recipientAddress: recipientAccount.address,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function deployTestAccountsWithTokens(
|
|
52
195
|
nodeUrl: string,
|
|
53
|
-
|
|
196
|
+
l1RpcUrls: string[],
|
|
54
197
|
mnemonicOrPrivateKey: string,
|
|
55
198
|
mintAmount: bigint,
|
|
56
199
|
logger: Logger,
|
|
57
200
|
numberOfFundedWallets = 1,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const node = createAztecNodeClient(nodeUrl);
|
|
201
|
+
): Promise<TestAccounts> {
|
|
202
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
203
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
62
204
|
|
|
63
205
|
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
recipient.secret,
|
|
67
|
-
recipient.signingKey,
|
|
68
|
-
recipient.salt,
|
|
69
|
-
);
|
|
70
|
-
const fundedAccounts = await Promise.all(funded.map(a => getSchnorrAccount(pxe, a.secret, a.signingKey, a.salt)));
|
|
206
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
207
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
71
208
|
|
|
72
209
|
const claims = await Promise.all(
|
|
73
|
-
fundedAccounts.map(a =>
|
|
74
|
-
bridgeL1FeeJuice(l1RpcUrl, mnemonicOrPrivateKey, pxe, a.getAddress(), initialFeeJuice, logger),
|
|
75
|
-
),
|
|
210
|
+
fundedAccounts.map(a => bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, aztecNode, a.address, undefined, logger)),
|
|
76
211
|
);
|
|
77
212
|
|
|
78
|
-
// Progress by
|
|
79
|
-
await advanceL2Block(
|
|
80
|
-
await advanceL2Block(
|
|
213
|
+
// Progress by 3 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
214
|
+
await advanceL2Block(aztecNode);
|
|
215
|
+
await advanceL2Block(aztecNode);
|
|
216
|
+
await advanceL2Block(aztecNode);
|
|
81
217
|
|
|
82
|
-
|
|
218
|
+
await Promise.all(
|
|
83
219
|
fundedAccounts.map(async (a, i) => {
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
await
|
|
87
|
-
logger.info(`Account deployed at ${a.
|
|
88
|
-
return wallet;
|
|
220
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
|
|
221
|
+
const deployMethod = await a.getDeployMethod();
|
|
222
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } });
|
|
223
|
+
logger.info(`Account deployed at ${a.address}`);
|
|
89
224
|
}),
|
|
90
225
|
);
|
|
91
226
|
|
|
92
|
-
const tokenAdmin =
|
|
93
|
-
const tokenAddress = await deployTokenAndMint(
|
|
94
|
-
|
|
227
|
+
const tokenAdmin = fundedAccounts[0];
|
|
228
|
+
const tokenAddress = await deployTokenAndMint(
|
|
229
|
+
wallet,
|
|
230
|
+
fundedAccounts.map(acc => acc.address),
|
|
231
|
+
tokenAdmin.address,
|
|
232
|
+
mintAmount,
|
|
233
|
+
undefined,
|
|
234
|
+
logger,
|
|
235
|
+
);
|
|
236
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
95
237
|
|
|
96
|
-
return {
|
|
238
|
+
return {
|
|
239
|
+
aztecNode,
|
|
240
|
+
wallet,
|
|
241
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
242
|
+
tokenAdminAddress: tokenAdmin.address,
|
|
243
|
+
tokenName: TOKEN_NAME,
|
|
244
|
+
tokenAddress,
|
|
245
|
+
tokenContract,
|
|
246
|
+
recipientAddress: recipientAccount.address,
|
|
247
|
+
};
|
|
97
248
|
}
|
|
98
249
|
|
|
99
250
|
async function bridgeL1FeeJuice(
|
|
100
|
-
|
|
251
|
+
l1RpcUrls: string[],
|
|
101
252
|
mnemonicOrPrivateKey: string,
|
|
102
|
-
|
|
253
|
+
aztecNode: AztecNode,
|
|
103
254
|
recipient: AztecAddress,
|
|
104
|
-
amount: bigint,
|
|
255
|
+
amount: bigint | undefined,
|
|
105
256
|
log: Logger,
|
|
106
257
|
) {
|
|
107
|
-
const { l1ChainId } = await
|
|
108
|
-
const chain = createEthereumChain(
|
|
109
|
-
const
|
|
258
|
+
const { l1ChainId } = await aztecNode.getNodeInfo();
|
|
259
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
260
|
+
const l1Client = createExtendedL1Client(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
|
|
110
261
|
|
|
111
|
-
const portal = await L1FeeJuicePortalManager.new(
|
|
262
|
+
const portal = await L1FeeJuicePortalManager.new(aztecNode, l1Client, log);
|
|
112
263
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
113
264
|
|
|
114
|
-
const isSynced = async () =>
|
|
265
|
+
const isSynced = async () =>
|
|
266
|
+
(await aztecNode.getL1ToL2MessageBlock(Fr.fromHexString(claim.messageHash))) !== undefined;
|
|
115
267
|
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
116
268
|
|
|
117
269
|
log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
|
|
118
270
|
return claim;
|
|
119
271
|
}
|
|
120
272
|
|
|
121
|
-
async function advanceL2Block(
|
|
122
|
-
const initialBlockNumber = await
|
|
123
|
-
|
|
124
|
-
|
|
273
|
+
async function advanceL2Block(aztecNode: AztecNode, nodeAdmin?: AztecNodeAdmin) {
|
|
274
|
+
const initialBlockNumber = await aztecNode.getBlockNumber();
|
|
275
|
+
|
|
276
|
+
let minTxsPerBlock = undefined;
|
|
277
|
+
if (nodeAdmin) {
|
|
278
|
+
({ minTxsPerBlock } = await nodeAdmin.getConfig());
|
|
279
|
+
await nodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
await retryUntil(async () => (await aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
|
|
283
|
+
|
|
284
|
+
if (nodeAdmin && minTxsPerBlock !== undefined) {
|
|
285
|
+
await nodeAdmin.setConfig({ minTxsPerBlock });
|
|
286
|
+
}
|
|
125
287
|
}
|
|
126
288
|
|
|
127
289
|
async function deployTokenAndMint(
|
|
128
|
-
|
|
290
|
+
wallet: Wallet,
|
|
291
|
+
accounts: AztecAddress[],
|
|
129
292
|
admin: AztecAddress,
|
|
130
293
|
mintAmount: bigint,
|
|
294
|
+
paymentMethod: FeePaymentMethod | undefined,
|
|
131
295
|
logger: Logger,
|
|
132
296
|
) {
|
|
133
297
|
logger.verbose(`Deploying TokenContract...`);
|
|
134
|
-
const tokenContract = await TokenContract.deploy(
|
|
135
|
-
|
|
136
|
-
|
|
298
|
+
const { contract: tokenContract } = await TokenContract.deploy(
|
|
299
|
+
wallet,
|
|
300
|
+
admin,
|
|
301
|
+
TOKEN_NAME,
|
|
302
|
+
TOKEN_SYMBOL,
|
|
303
|
+
TOKEN_DECIMALS,
|
|
304
|
+
).send({
|
|
305
|
+
from: admin,
|
|
306
|
+
fee: {
|
|
307
|
+
paymentMethod,
|
|
308
|
+
},
|
|
309
|
+
wait: { timeout: 600, returnReceipt: true },
|
|
310
|
+
});
|
|
137
311
|
|
|
138
312
|
const tokenAddress = tokenContract.address;
|
|
139
313
|
|
|
140
|
-
logger.verbose(`Minting ${mintAmount} public assets to the ${
|
|
314
|
+
logger.verbose(`Minting ${mintAmount} public assets to the ${accounts.length} accounts...`);
|
|
141
315
|
|
|
142
316
|
await Promise.all(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.mint_to_public(
|
|
146
|
-
.send()
|
|
147
|
-
.wait({ timeout: 600 }),
|
|
317
|
+
accounts.map(acc =>
|
|
318
|
+
TokenContract.at(tokenAddress, wallet)
|
|
319
|
+
.methods.mint_to_public(acc, mintAmount)
|
|
320
|
+
.send({ from: admin, fee: { paymentMethod }, wait: { timeout: 600 } }),
|
|
148
321
|
),
|
|
149
322
|
);
|
|
150
323
|
|
|
@@ -154,31 +327,71 @@ async function deployTokenAndMint(
|
|
|
154
327
|
}
|
|
155
328
|
|
|
156
329
|
export async function performTransfers({
|
|
157
|
-
|
|
330
|
+
wallet,
|
|
331
|
+
testAccounts,
|
|
158
332
|
rounds,
|
|
159
333
|
transferAmount,
|
|
160
334
|
logger,
|
|
335
|
+
feePaymentMethod,
|
|
161
336
|
}: {
|
|
162
|
-
|
|
337
|
+
wallet: TestWallet;
|
|
338
|
+
testAccounts: TestAccounts;
|
|
163
339
|
rounds: number;
|
|
164
340
|
transferAmount: bigint;
|
|
165
341
|
logger: Logger;
|
|
342
|
+
feePaymentMethod?: FeePaymentMethod;
|
|
166
343
|
}) {
|
|
167
|
-
const recipient =
|
|
168
|
-
|
|
344
|
+
const recipient = testAccounts.recipientAddress;
|
|
345
|
+
// Default to sponsored fee payment if no fee method is provided
|
|
346
|
+
const defaultFeePaymentMethod = feePaymentMethod || new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
169
347
|
for (let i = 0; i < rounds; i++) {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
348
|
+
const txs = testAccounts.accounts.map(acc => {
|
|
349
|
+
const token = TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
|
|
350
|
+
return proveInteraction(wallet, token.methods.transfer_in_public(acc, recipient, transferAmount, 0), {
|
|
351
|
+
from: acc,
|
|
352
|
+
fee: {
|
|
353
|
+
paymentMethod: defaultFeePaymentMethod,
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
});
|
|
177
357
|
|
|
178
|
-
const
|
|
358
|
+
const provenTxs = await Promise.all(txs);
|
|
179
359
|
|
|
180
|
-
await Promise.all(
|
|
360
|
+
await Promise.all(provenTxs.map(t => t.send({ wait: { timeout: 600 } })));
|
|
181
361
|
|
|
182
362
|
logger.info(`Completed round ${i + 1} / ${rounds}`);
|
|
183
363
|
}
|
|
184
364
|
}
|
|
365
|
+
|
|
366
|
+
export type WalletWrapper = {
|
|
367
|
+
wallet: TestWallet;
|
|
368
|
+
aztecNode: AztecNode;
|
|
369
|
+
cleanup: () => Promise<void>;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export async function createWalletAndAztecNodeClient(
|
|
373
|
+
nodeUrl: string,
|
|
374
|
+
proverEnabled: boolean,
|
|
375
|
+
logger: Logger,
|
|
376
|
+
): Promise<WalletWrapper> {
|
|
377
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
378
|
+
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
379
|
+
const pxeConfig = {
|
|
380
|
+
dataDirectory: undefined,
|
|
381
|
+
dataStoreMapSizeKb: 1024 * 1024,
|
|
382
|
+
...bbConfig,
|
|
383
|
+
...acvmConfig,
|
|
384
|
+
proverEnabled,
|
|
385
|
+
};
|
|
386
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
387
|
+
|
|
388
|
+
return {
|
|
389
|
+
wallet,
|
|
390
|
+
aztecNode,
|
|
391
|
+
async cleanup() {
|
|
392
|
+
await wallet.stop();
|
|
393
|
+
await bbConfig?.cleanup();
|
|
394
|
+
await acvmConfig?.cleanup();
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
}
|