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