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