@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.21caa21
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 +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +334 -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 +77 -0
- package/dest/bench/utils.d.ts +12 -38
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
- 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 +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -25
- 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 +50 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +59 -18
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +226 -44
- 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 +63 -0
- package/dest/e2e_fees/fees_test.d.ts +21 -10
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +103 -109
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +58 -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 +10 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
- 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 +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +275 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +184 -131
- package/dest/e2e_p2p/shared.d.ts +43 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +164 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/fixtures/e2e_prover_test.d.ts +63 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +104 -105
- package/dest/fixtures/fixtures.d.ts +6 -7
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- 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 +2 -14
- 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 +9 -6
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +44 -18
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +81 -21
- package/dest/fixtures/snapshot_manager.d.ts +17 -9
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -121
- 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 +28 -12
- package/dest/fixtures/utils.d.ts +524 -40
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -369
- 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 +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +39 -34
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +29 -31
- 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 +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 +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +14 -12
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +146 -116
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -11
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +15 -16
- 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 +26 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +201 -58
- package/dest/spartan/utils.d.ts +116 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +434 -130
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +447 -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 +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +65 -106
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +276 -55
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +142 -138
- 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 +29 -19
- package/src/e2e_p2p/inactivity_slash_test.ts +182 -0
- package/src/e2e_p2p/p2p_network.ts +279 -169
- package/src/e2e_p2p/shared.ts +247 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +107 -152
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +3 -11
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +6 -7
- package/src/fixtures/setup_p2p_test.ts +126 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +580 -434
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +108 -79
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +181 -184
- package/src/simulators/lending_simulator.ts +14 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +251 -93
- package/src/spartan/utils.ts +490 -130
- 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/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -1,149 +1,273 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type PXE,
|
|
11
|
-
createAztecNodeClient,
|
|
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 { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
4
|
+
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
5
|
+
import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import { type AztecNode, createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
8
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
16
10
|
import type { Logger } from '@aztec/foundation/log';
|
|
11
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
17
12
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
13
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
14
|
+
import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
17
|
+
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
18
|
+
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
|
|
19
|
+
|
|
20
|
+
export interface TestAccounts {
|
|
21
|
+
aztecNode: AztecNode;
|
|
22
|
+
wallet: TestWallet;
|
|
23
|
+
accounts: AztecAddress[];
|
|
24
|
+
tokenContract: TokenContract;
|
|
25
|
+
tokenAdminAddress: AztecAddress;
|
|
23
26
|
tokenName: string;
|
|
24
|
-
|
|
27
|
+
recipientAddress: AztecAddress;
|
|
25
28
|
tokenAddress: AztecAddress;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
export type TestAccountsWithoutTokens = Omit<
|
|
32
|
+
TestAccounts,
|
|
33
|
+
'tokenAddress' | 'tokenContract' | 'tokenName' | 'tokenAdminAddress'
|
|
34
|
+
>;
|
|
35
|
+
|
|
28
36
|
const TOKEN_NAME = 'USDC';
|
|
29
37
|
const TOKEN_SYMBOL = 'USD';
|
|
30
38
|
const TOKEN_DECIMALS = 18n;
|
|
31
39
|
|
|
32
|
-
export async function
|
|
33
|
-
|
|
40
|
+
export async function setupTestAccountsWithTokens(
|
|
41
|
+
nodeUrl: string,
|
|
42
|
+
mintAmount: bigint,
|
|
43
|
+
logger: Logger,
|
|
44
|
+
): Promise<TestAccounts> {
|
|
45
|
+
const ACCOUNT_COUNT = 1; // TODO fix this to allow for 16 wallets again
|
|
46
|
+
|
|
47
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
48
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
49
|
+
|
|
50
|
+
const [recipientAccount, ...accounts] = (await registerInitialLocalNetworkAccountsInWallet(wallet)).slice(
|
|
51
|
+
0,
|
|
52
|
+
ACCOUNT_COUNT + 1,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const tokenAdmin = accounts[0];
|
|
56
|
+
const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
|
|
57
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
aztecNode,
|
|
61
|
+
accounts,
|
|
62
|
+
wallet,
|
|
63
|
+
tokenAdminAddress: tokenAdmin,
|
|
64
|
+
tokenName: TOKEN_NAME,
|
|
65
|
+
tokenAddress,
|
|
66
|
+
tokenContract,
|
|
67
|
+
recipientAddress: recipientAccount,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function deploySponsoredTestAccountsWithTokens(
|
|
72
|
+
wallet: TestWallet,
|
|
73
|
+
aztecNode: AztecNode,
|
|
34
74
|
mintAmount: bigint,
|
|
35
75
|
logger: Logger,
|
|
36
|
-
|
|
37
|
-
|
|
76
|
+
numberOfFundedWallets = 1,
|
|
77
|
+
): Promise<TestAccounts> {
|
|
78
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
79
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
80
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
81
|
+
|
|
82
|
+
await registerSponsoredFPC(wallet);
|
|
83
|
+
|
|
84
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
85
|
+
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
86
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
|
|
87
|
+
await Promise.all(
|
|
88
|
+
fundedAccounts.map(async a => {
|
|
89
|
+
const deployMethod = await a.getDeployMethod();
|
|
90
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
|
|
91
|
+
logger.info(`Account deployed at ${a.address}`);
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const tokenAdmin = fundedAccounts[0];
|
|
96
|
+
const tokenAddress = await deployTokenAndMint(
|
|
97
|
+
wallet,
|
|
98
|
+
fundedAccounts.map(acc => acc.address),
|
|
99
|
+
tokenAdmin.address,
|
|
100
|
+
mintAmount,
|
|
101
|
+
new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
|
|
102
|
+
logger,
|
|
103
|
+
);
|
|
104
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
aztecNode,
|
|
108
|
+
wallet,
|
|
109
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
110
|
+
tokenAdminAddress: tokenAdmin.address,
|
|
111
|
+
tokenName: TOKEN_NAME,
|
|
112
|
+
tokenAddress,
|
|
113
|
+
tokenContract,
|
|
114
|
+
recipientAddress: recipientAccount.address,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
38
117
|
|
|
39
|
-
|
|
118
|
+
export async function deploySponsoredTestAccounts(
|
|
119
|
+
wallet: TestWallet,
|
|
120
|
+
aztecNode: AztecNode,
|
|
121
|
+
logger: Logger,
|
|
122
|
+
numberOfFundedWallets = 1,
|
|
123
|
+
): Promise<TestAccountsWithoutTokens> {
|
|
124
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
125
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
126
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
40
127
|
|
|
41
|
-
|
|
128
|
+
await registerSponsoredFPC(wallet);
|
|
42
129
|
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
130
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
131
|
+
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
132
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
|
|
133
|
+
await Promise.all(
|
|
134
|
+
fundedAccounts.map(async a => {
|
|
135
|
+
const deployMethod = await a.getDeployMethod();
|
|
136
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
|
|
137
|
+
logger.info(`Account deployed at ${a.address}`);
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
46
140
|
|
|
47
|
-
return {
|
|
141
|
+
return {
|
|
142
|
+
aztecNode,
|
|
143
|
+
wallet,
|
|
144
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
145
|
+
recipientAddress: recipientAccount.address,
|
|
146
|
+
};
|
|
48
147
|
}
|
|
49
148
|
|
|
50
|
-
export async function
|
|
51
|
-
pxeUrl: string,
|
|
149
|
+
export async function deployTestAccountsWithTokens(
|
|
52
150
|
nodeUrl: string,
|
|
53
|
-
|
|
151
|
+
l1RpcUrls: string[],
|
|
54
152
|
mnemonicOrPrivateKey: string,
|
|
55
153
|
mintAmount: bigint,
|
|
56
154
|
logger: Logger,
|
|
57
155
|
numberOfFundedWallets = 1,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const node = createAztecNodeClient(nodeUrl);
|
|
156
|
+
): Promise<TestAccounts> {
|
|
157
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
158
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
62
159
|
|
|
63
160
|
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)));
|
|
161
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
162
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
71
163
|
|
|
72
164
|
const claims = await Promise.all(
|
|
73
|
-
fundedAccounts.map(a =>
|
|
74
|
-
bridgeL1FeeJuice(l1RpcUrl, mnemonicOrPrivateKey, pxe, a.getAddress(), initialFeeJuice, logger),
|
|
75
|
-
),
|
|
165
|
+
fundedAccounts.map(a => bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, aztecNode, a.address, undefined, logger)),
|
|
76
166
|
);
|
|
77
167
|
|
|
78
|
-
// Progress by
|
|
79
|
-
await advanceL2Block(
|
|
80
|
-
await advanceL2Block(
|
|
168
|
+
// Progress by 3 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
169
|
+
await advanceL2Block(aztecNode);
|
|
170
|
+
await advanceL2Block(aztecNode);
|
|
171
|
+
await advanceL2Block(aztecNode);
|
|
81
172
|
|
|
82
|
-
|
|
173
|
+
await Promise.all(
|
|
83
174
|
fundedAccounts.map(async (a, i) => {
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
await
|
|
87
|
-
logger.info(`Account deployed at ${a.
|
|
88
|
-
return wallet;
|
|
175
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
|
|
176
|
+
const deployMethod = await a.getDeployMethod();
|
|
177
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait();
|
|
178
|
+
logger.info(`Account deployed at ${a.address}`);
|
|
89
179
|
}),
|
|
90
180
|
);
|
|
91
181
|
|
|
92
|
-
const tokenAdmin =
|
|
93
|
-
const tokenAddress = await deployTokenAndMint(
|
|
94
|
-
|
|
182
|
+
const tokenAdmin = fundedAccounts[0];
|
|
183
|
+
const tokenAddress = await deployTokenAndMint(
|
|
184
|
+
wallet,
|
|
185
|
+
fundedAccounts.map(acc => acc.address),
|
|
186
|
+
tokenAdmin.address,
|
|
187
|
+
mintAmount,
|
|
188
|
+
undefined,
|
|
189
|
+
logger,
|
|
190
|
+
);
|
|
191
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
95
192
|
|
|
96
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
aztecNode,
|
|
195
|
+
wallet,
|
|
196
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
197
|
+
tokenAdminAddress: tokenAdmin.address,
|
|
198
|
+
tokenName: TOKEN_NAME,
|
|
199
|
+
tokenAddress,
|
|
200
|
+
tokenContract,
|
|
201
|
+
recipientAddress: recipientAccount.address,
|
|
202
|
+
};
|
|
97
203
|
}
|
|
98
204
|
|
|
99
205
|
async function bridgeL1FeeJuice(
|
|
100
|
-
|
|
206
|
+
l1RpcUrls: string[],
|
|
101
207
|
mnemonicOrPrivateKey: string,
|
|
102
|
-
|
|
208
|
+
aztecNode: AztecNode,
|
|
103
209
|
recipient: AztecAddress,
|
|
104
|
-
amount: bigint,
|
|
210
|
+
amount: bigint | undefined,
|
|
105
211
|
log: Logger,
|
|
106
212
|
) {
|
|
107
|
-
const { l1ChainId } = await
|
|
108
|
-
const chain = createEthereumChain(
|
|
109
|
-
const
|
|
213
|
+
const { l1ChainId } = await aztecNode.getNodeInfo();
|
|
214
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
215
|
+
const l1Client = createExtendedL1Client(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
|
|
110
216
|
|
|
111
|
-
const portal = await L1FeeJuicePortalManager.new(
|
|
217
|
+
const portal = await L1FeeJuicePortalManager.new(aztecNode, l1Client, log);
|
|
112
218
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
113
219
|
|
|
114
|
-
const isSynced = async () =>
|
|
220
|
+
const isSynced = async () =>
|
|
221
|
+
(await aztecNode.getL1ToL2MessageBlock(Fr.fromHexString(claim.messageHash))) !== undefined;
|
|
115
222
|
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
116
223
|
|
|
117
224
|
log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
|
|
118
225
|
return claim;
|
|
119
226
|
}
|
|
120
227
|
|
|
121
|
-
async function advanceL2Block(
|
|
122
|
-
const initialBlockNumber = await
|
|
123
|
-
|
|
124
|
-
|
|
228
|
+
async function advanceL2Block(aztecNode: AztecNode, nodeAdmin?: AztecNodeAdmin) {
|
|
229
|
+
const initialBlockNumber = await aztecNode.getBlockNumber();
|
|
230
|
+
|
|
231
|
+
let minTxsPerBlock = undefined;
|
|
232
|
+
if (nodeAdmin) {
|
|
233
|
+
({ minTxsPerBlock } = await nodeAdmin.getConfig());
|
|
234
|
+
await nodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
await retryUntil(async () => (await aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
|
|
238
|
+
|
|
239
|
+
if (nodeAdmin && minTxsPerBlock !== undefined) {
|
|
240
|
+
await nodeAdmin.setConfig({ minTxsPerBlock });
|
|
241
|
+
}
|
|
125
242
|
}
|
|
126
243
|
|
|
127
244
|
async function deployTokenAndMint(
|
|
128
|
-
|
|
245
|
+
wallet: Wallet,
|
|
246
|
+
accounts: AztecAddress[],
|
|
129
247
|
admin: AztecAddress,
|
|
130
248
|
mintAmount: bigint,
|
|
249
|
+
paymentMethod: FeePaymentMethod | undefined,
|
|
131
250
|
logger: Logger,
|
|
132
251
|
) {
|
|
133
252
|
logger.verbose(`Deploying TokenContract...`);
|
|
134
|
-
const tokenContract = await TokenContract.deploy(
|
|
135
|
-
.send(
|
|
253
|
+
const tokenContract = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS)
|
|
254
|
+
.send({
|
|
255
|
+
from: admin,
|
|
256
|
+
fee: {
|
|
257
|
+
paymentMethod,
|
|
258
|
+
},
|
|
259
|
+
})
|
|
136
260
|
.deployed({ timeout: 600 });
|
|
137
261
|
|
|
138
262
|
const tokenAddress = tokenContract.address;
|
|
139
263
|
|
|
140
|
-
logger.verbose(`Minting ${mintAmount} public assets to the ${
|
|
264
|
+
logger.verbose(`Minting ${mintAmount} public assets to the ${accounts.length} accounts...`);
|
|
141
265
|
|
|
142
266
|
await Promise.all(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.mint_to_public(
|
|
146
|
-
.send()
|
|
267
|
+
accounts.map(acc =>
|
|
268
|
+
TokenContract.at(tokenAddress, wallet)
|
|
269
|
+
.methods.mint_to_public(acc, mintAmount)
|
|
270
|
+
.send({ from: admin, fee: { paymentMethod } })
|
|
147
271
|
.wait({ timeout: 600 }),
|
|
148
272
|
),
|
|
149
273
|
);
|
|
@@ -154,31 +278,65 @@ async function deployTokenAndMint(
|
|
|
154
278
|
}
|
|
155
279
|
|
|
156
280
|
export async function performTransfers({
|
|
157
|
-
|
|
281
|
+
wallet,
|
|
282
|
+
testAccounts,
|
|
158
283
|
rounds,
|
|
159
284
|
transferAmount,
|
|
160
285
|
logger,
|
|
286
|
+
feePaymentMethod,
|
|
161
287
|
}: {
|
|
162
|
-
|
|
288
|
+
wallet: TestWallet;
|
|
289
|
+
testAccounts: TestAccounts;
|
|
163
290
|
rounds: number;
|
|
164
291
|
transferAmount: bigint;
|
|
165
292
|
logger: Logger;
|
|
293
|
+
feePaymentMethod?: FeePaymentMethod;
|
|
166
294
|
}) {
|
|
167
|
-
const recipient =
|
|
168
|
-
|
|
295
|
+
const recipient = testAccounts.recipientAddress;
|
|
296
|
+
// Default to sponsored fee payment if no fee method is provided
|
|
297
|
+
const defaultFeePaymentMethod = feePaymentMethod || new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
169
298
|
for (let i = 0; i < rounds; i++) {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
299
|
+
const txs = testAccounts.accounts.map(acc => {
|
|
300
|
+
const token = TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
|
|
301
|
+
return proveInteraction(wallet, token.methods.transfer_in_public(acc, recipient, transferAmount, 0), {
|
|
302
|
+
from: acc,
|
|
303
|
+
fee: {
|
|
304
|
+
paymentMethod: defaultFeePaymentMethod,
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
});
|
|
177
308
|
|
|
178
|
-
const
|
|
309
|
+
const provenTxs = await Promise.all(txs);
|
|
179
310
|
|
|
180
|
-
await Promise.all(
|
|
311
|
+
await Promise.all(provenTxs.map(t => t.send().wait({ timeout: 600 })));
|
|
181
312
|
|
|
182
313
|
logger.info(`Completed round ${i + 1} / ${rounds}`);
|
|
183
314
|
}
|
|
184
315
|
}
|
|
316
|
+
|
|
317
|
+
export async function createWalletAndAztecNodeClient(
|
|
318
|
+
nodeUrl: string,
|
|
319
|
+
proverEnabled: boolean,
|
|
320
|
+
logger: Logger,
|
|
321
|
+
): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise<void> }> {
|
|
322
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
323
|
+
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
324
|
+
const pxeConfig = {
|
|
325
|
+
dataDirectory: undefined,
|
|
326
|
+
dataStoreMapSizeKb: 1024 * 1024,
|
|
327
|
+
...bbConfig,
|
|
328
|
+
...acvmConfig,
|
|
329
|
+
proverEnabled,
|
|
330
|
+
};
|
|
331
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
332
|
+
|
|
333
|
+
return {
|
|
334
|
+
wallet,
|
|
335
|
+
aztecNode,
|
|
336
|
+
async cleanup() {
|
|
337
|
+
await wallet.stop();
|
|
338
|
+
await bbConfig?.cleanup();
|
|
339
|
+
await acvmConfig?.cleanup();
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}
|