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