@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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 +60 -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 +69 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +315 -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 +99 -0
- package/dest/bench/utils.d.ts +10 -27
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +27 -43
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -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 +66 -38
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
- 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 +34 -53
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -6
- package/dest/e2e_epochs/epochs_test.d.ts +56 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +222 -42
- 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 +60 -0
- package/dest/e2e_fees/fees_test.d.ts +16 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +87 -88
- package/dest/e2e_l1_publisher/write_json.d.ts +8 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +57 -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 +5 -5
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
- 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 +132 -0
- package/dest/e2e_p2p/p2p_network.d.ts +56 -21
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +154 -125
- package/dest/e2e_p2p/shared.d.ts +41 -3
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +146 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +51 -24
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
- package/dest/fixtures/fixtures.d.ts +5 -6
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- 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.map +1 -1
- package/dest/fixtures/get_bb_config.js +8 -15
- package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
- 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/setup_l1_contracts.d.ts +3 -3
- 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 +14 -6
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +73 -21
- package/dest/fixtures/snapshot_manager.d.ts +8 -3
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +120 -104
- package/dest/fixtures/token_utils.d.ts +4 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +24 -7
- package/dest/fixtures/utils.d.ts +65 -22
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +439 -318
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +42 -0
- package/dest/shared/cross_chain_test_harness.d.ts +28 -18
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +97 -41
- package/dest/shared/gas_portal_test_harness.d.ts +23 -18
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +43 -25
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +5 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +136 -90
- package/dest/simulators/lending_simulator.d.ts +5 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +11 -15
- package/dest/simulators/token_simulator.d.ts +2 -1
- 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 +8 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -22
- package/dest/spartan/utils.d.ts +60 -307
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +200 -115
- package/package.json +60 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +422 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +111 -0
- package/src/bench/utils.ts +26 -52
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
- package/src/e2e_deploy_contract/deploy_test.ts +11 -8
- package/src/e2e_epochs/epochs_test.ts +276 -54
- package/src/e2e_fees/bridging_race.notest.ts +75 -0
- package/src/e2e_fees/fees_test.ts +121 -108
- package/src/e2e_l1_publisher/write_json.ts +74 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
- package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
- package/src/e2e_p2p/p2p_network.ts +212 -144
- package/src/e2e_p2p/shared.ts +234 -14
- package/src/e2e_token_contract/token_contract_test.ts +42 -38
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +2 -10
- package/src/fixtures/get_bb_config.ts +15 -11
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +5 -6
- package/src/fixtures/setup_p2p_test.ts +112 -30
- package/src/fixtures/snapshot_manager.ts +150 -102
- package/src/fixtures/token_utils.ts +33 -8
- package/src/fixtures/utils.ts +530 -352
- package/src/fixtures/web3signer.ts +46 -0
- package/src/guides/up_quick_start.sh +4 -4
- package/src/shared/cross_chain_test_harness.ts +92 -52
- package/src/shared/gas_portal_test_harness.ts +47 -31
- package/src/shared/uniswap_l1_l2.ts +127 -124
- package/src/simulators/lending_simulator.ts +11 -15
- package/src/simulators/token_simulator.ts +17 -12
- package/src/spartan/DEVELOP.md +116 -0
- package/src/spartan/setup_test_wallets.ts +144 -29
- package/src/spartan/utils.ts +194 -116
- 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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
The flow is as follows:
|
|
2
|
+
|
|
3
|
+
1. Install/start KIND locally
|
|
4
|
+
2. Bootstrap (to build an aztec image)
|
|
5
|
+
3. Load image into kind
|
|
6
|
+
4. Deploy networks
|
|
7
|
+
5. Run tests in `yarn-project/end-to-end/src/spartan`
|
|
8
|
+
|
|
9
|
+
# Setup KIND
|
|
10
|
+
|
|
11
|
+
KIND is a kubernetes cluster that runs locally out of docker containers.
|
|
12
|
+
|
|
13
|
+
You can just
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
spartan/bootstrap.sh kind
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You only need to do that once. If you do it again, it will destroy the cluster and recreate it (which you almost never need to do).
|
|
20
|
+
|
|
21
|
+
Now you’ll likely want some visibility into your cluster. You can
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
spartan/scripts/create_k8s_dashboard.sh
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
And after ~30 seconds or so you can
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
spartan/scripts/forward_k8s_dashboard.sh
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
That will run a port forward to your port `8443` . If you’re running in a remote environment (e.g. the mainframe), you’ll need to subsequently forward that back to your local machine. Cursor/VSCode have built in port forwarding (cmd/ctrl shift P, “forward”)
|
|
34
|
+
|
|
35
|
+
Open the forwarded page, and copy/paste the token that was generated when you forwarded the dashboard.
|
|
36
|
+
|
|
37
|
+
# Build an aztecprotocol:aztec image
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
./bootstrap.sh
|
|
41
|
+
export AZTEC_DOCKER_IMAGE="aztecprotocol/aztec:$(docker images "aztecprotocol/aztec" --format json | \
|
|
42
|
+
jq -r 'select(.Tag != "latest") | .Tag' | \
|
|
43
|
+
head -1)"
|
|
44
|
+
kind load docker-image $AZTEC_DOCKER_IMAGE
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If you just changed typescript, you can (after the initial bootstrap)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
./yarn-project/bootstrap.sh
|
|
51
|
+
./release-image/bootstrap.sh
|
|
52
|
+
export AZTEC_DOCKER_IMAGE="aztecprotocol/aztec:$(docker images "aztecprotocol/aztec" --format json | \
|
|
53
|
+
jq -r 'select(.Tag != "latest") | .Tag' | \
|
|
54
|
+
head -1)"
|
|
55
|
+
kind load docker-image $AZTEC_DOCKER_IMAGE
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The export is important there. The `AZTEC_DOCKER_IMAGE` env var is used as both:
|
|
59
|
+
|
|
60
|
+
- the container that runs the rollup contract deployment
|
|
61
|
+
- the containers for the aztec infrastructure (validators, provers, etc)
|
|
62
|
+
|
|
63
|
+
# Deploy stuff
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
./spartan/bootstrap.sh network_deploy scenario.local.env
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
That will take 1-3 minutes. But at the end you should have everything you need.
|
|
70
|
+
|
|
71
|
+
You can (`k` is just an alias over `kubectl`)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
❯ k get pods -n scenario
|
|
75
|
+
NAME READY STATUS RESTARTS AGE
|
|
76
|
+
deploy-rollup-contracts-2025-08-31-1511-w2dlb 0/1 Completed 0 2m34s
|
|
77
|
+
scenario-eth-beacon-0 1/1 Running 0 39m
|
|
78
|
+
scenario-eth-execution-0 1/1 Running 0 39m
|
|
79
|
+
scenario-eth-validator-0 1/1 Running 0 39m
|
|
80
|
+
scenario-p2p-bootstrap-node-5cbf9658b9-6vd9b 1/1 Running 0 20m
|
|
81
|
+
scenario-prover-agent-59bd96899d-46k5s 1/1 Running 0 116s
|
|
82
|
+
scenario-prover-agent-59bd96899d-vzvkd 1/1 Running 0 116s
|
|
83
|
+
scenario-prover-broker-0 1/1 Running 0 116s
|
|
84
|
+
scenario-prover-node-0 1/1 Running 0 116s
|
|
85
|
+
scenario-rpc-aztec-node-0 1/1 Running 0 116s
|
|
86
|
+
scenario-validator-0 1/1 Running 0 116s
|
|
87
|
+
scenario-validator-1 1/1 Running 0 116s
|
|
88
|
+
scenario-validator-2 1/1 Running 0 116s
|
|
89
|
+
scenario-validator-3 1/1 Running 0 116s
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For example, you can forward back the ethereum node with
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
k port-forward -n scenario services/eth-devnet-eth-execution 8545:8545
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
And then do whatever you like with it.
|
|
99
|
+
|
|
100
|
+
# Run tests
|
|
101
|
+
|
|
102
|
+
With the cluster running, you can now easily run tests.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# run one
|
|
106
|
+
./spartan/bootstrap.sh single_test scenario.local.env spartan/smoke.test.ts
|
|
107
|
+
|
|
108
|
+
# run all (serially)
|
|
109
|
+
./spartan/bootstrap.sh network_tests scenario.local.env
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Right now, I recommend running the smoke test first, always, as it waits for the committee to exist.
|
|
113
|
+
|
|
114
|
+
# Teardown
|
|
115
|
+
|
|
116
|
+
You can just `k delete namespace scenario`. That will destroy everything in your kind cluster. To destroy the associated terraform state that was stored locally, just `./spartan/terraform/purge_local_state.sh`.
|
|
@@ -5,23 +5,33 @@ import {
|
|
|
5
5
|
type AztecAddress,
|
|
6
6
|
type AztecNode,
|
|
7
7
|
FeeJuicePaymentMethodWithClaim,
|
|
8
|
+
type FeePaymentMethod,
|
|
8
9
|
Fr,
|
|
9
10
|
L1FeeJuicePortalManager,
|
|
10
11
|
type PXE,
|
|
12
|
+
SponsoredFeePaymentMethod,
|
|
11
13
|
createAztecNodeClient,
|
|
12
14
|
createCompatibleClient,
|
|
13
15
|
retryUntil,
|
|
14
16
|
} from '@aztec/aztec.js';
|
|
15
|
-
import { createEthereumChain,
|
|
17
|
+
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
16
18
|
import type { Logger } from '@aztec/foundation/log';
|
|
17
19
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
20
|
+
import { createPXEService } from '@aztec/pxe/server';
|
|
21
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
22
|
+
|
|
23
|
+
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
24
|
+
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
25
|
+
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
|
|
18
26
|
|
|
19
27
|
export interface TestWallets {
|
|
20
28
|
pxe: PXE;
|
|
21
29
|
wallets: AccountWalletWithSecretKey[];
|
|
22
30
|
tokenAdminWallet: TokenContract;
|
|
31
|
+
tokenAdminAddress: AztecAddress;
|
|
23
32
|
tokenName: string;
|
|
24
33
|
recipientWallet: AccountWalletWithSecretKey;
|
|
34
|
+
recipientAddress: AztecAddress;
|
|
25
35
|
tokenAddress: AztecAddress;
|
|
26
36
|
}
|
|
27
37
|
|
|
@@ -41,21 +51,78 @@ export async function setupTestWalletsWithTokens(
|
|
|
41
51
|
const [recipientWallet, ...wallets] = (await getDeployedTestAccountsWallets(pxe)).slice(0, WALLET_COUNT + 1);
|
|
42
52
|
|
|
43
53
|
const tokenAdmin = wallets[0];
|
|
44
|
-
const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, logger);
|
|
54
|
+
const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, undefined, logger);
|
|
45
55
|
const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
|
|
46
56
|
|
|
47
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
pxe,
|
|
59
|
+
wallets,
|
|
60
|
+
tokenAdminWallet,
|
|
61
|
+
tokenAdminAddress: tokenAdmin.getAddress(),
|
|
62
|
+
tokenName: TOKEN_NAME,
|
|
63
|
+
tokenAddress,
|
|
64
|
+
recipientAddress: recipientWallet.getAddress(),
|
|
65
|
+
recipientWallet,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function deploySponsoredTestWallets(
|
|
70
|
+
pxe: PXE,
|
|
71
|
+
mintAmount: bigint,
|
|
72
|
+
logger: Logger,
|
|
73
|
+
numberOfFundedWallets = 1,
|
|
74
|
+
): Promise<TestWallets> {
|
|
75
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
76
|
+
const recipientWallet = await getSchnorrWalletWithSecretKey(
|
|
77
|
+
pxe,
|
|
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)));
|
|
83
|
+
|
|
84
|
+
await registerSponsoredFPC(pxe);
|
|
85
|
+
|
|
86
|
+
const wallets = await Promise.all(
|
|
87
|
+
fundedAccounts.map(async a => {
|
|
88
|
+
const wallet = await a.getWallet();
|
|
89
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
90
|
+
await a.deploy({ fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
|
|
91
|
+
logger.info(`Account deployed at ${a.getAddress()}`);
|
|
92
|
+
return wallet;
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const tokenAdmin = wallets[0];
|
|
97
|
+
const tokenAddress = await deployTokenAndMint(
|
|
98
|
+
wallets,
|
|
99
|
+
tokenAdmin.getAddress(),
|
|
100
|
+
mintAmount,
|
|
101
|
+
new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
|
|
102
|
+
logger,
|
|
103
|
+
);
|
|
104
|
+
const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
pxe,
|
|
108
|
+
wallets,
|
|
109
|
+
tokenAdminAddress: tokenAdmin.getAddress(),
|
|
110
|
+
tokenAdminWallet,
|
|
111
|
+
tokenName: TOKEN_NAME,
|
|
112
|
+
tokenAddress,
|
|
113
|
+
recipientWallet,
|
|
114
|
+
recipientAddress: recipientWallet.getAddress(),
|
|
115
|
+
};
|
|
48
116
|
}
|
|
49
117
|
|
|
50
118
|
export async function deployTestWalletWithTokens(
|
|
51
119
|
pxeUrl: string,
|
|
52
120
|
nodeUrl: string,
|
|
53
|
-
|
|
121
|
+
l1RpcUrls: string[],
|
|
54
122
|
mnemonicOrPrivateKey: string,
|
|
55
123
|
mintAmount: bigint,
|
|
56
124
|
logger: Logger,
|
|
57
125
|
numberOfFundedWallets = 1,
|
|
58
|
-
initialFeeJuice = 10n ** 22n,
|
|
59
126
|
): Promise<TestWallets> {
|
|
60
127
|
const pxe = await createCompatibleClient(pxeUrl, logger);
|
|
61
128
|
const node = createAztecNodeClient(nodeUrl);
|
|
@@ -70,12 +137,11 @@ export async function deployTestWalletWithTokens(
|
|
|
70
137
|
const fundedAccounts = await Promise.all(funded.map(a => getSchnorrAccount(pxe, a.secret, a.signingKey, a.salt)));
|
|
71
138
|
|
|
72
139
|
const claims = await Promise.all(
|
|
73
|
-
fundedAccounts.map(a =>
|
|
74
|
-
bridgeL1FeeJuice(l1RpcUrl, mnemonicOrPrivateKey, pxe, a.getAddress(), initialFeeJuice, logger),
|
|
75
|
-
),
|
|
140
|
+
fundedAccounts.map(a => bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, pxe, a.getAddress(), undefined, logger)),
|
|
76
141
|
);
|
|
77
142
|
|
|
78
|
-
// Progress by
|
|
143
|
+
// Progress by 3 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
144
|
+
await advanceL2Block(node);
|
|
79
145
|
await advanceL2Block(node);
|
|
80
146
|
await advanceL2Block(node);
|
|
81
147
|
|
|
@@ -90,26 +156,37 @@ export async function deployTestWalletWithTokens(
|
|
|
90
156
|
);
|
|
91
157
|
|
|
92
158
|
const tokenAdmin = wallets[0];
|
|
93
|
-
const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, logger);
|
|
159
|
+
const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, undefined, logger);
|
|
94
160
|
const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
|
|
95
161
|
|
|
96
|
-
return {
|
|
162
|
+
return {
|
|
163
|
+
pxe,
|
|
164
|
+
wallets,
|
|
165
|
+
tokenAdminAddress: tokenAdmin.getAddress(),
|
|
166
|
+
tokenAdminWallet,
|
|
167
|
+
tokenName: TOKEN_NAME,
|
|
168
|
+
tokenAddress,
|
|
169
|
+
recipientWallet,
|
|
170
|
+
recipientAddress: recipientWallet.getAddress(),
|
|
171
|
+
};
|
|
97
172
|
}
|
|
98
173
|
|
|
99
174
|
async function bridgeL1FeeJuice(
|
|
100
|
-
|
|
175
|
+
l1RpcUrls: string[],
|
|
101
176
|
mnemonicOrPrivateKey: string,
|
|
102
177
|
pxe: PXE,
|
|
103
178
|
recipient: AztecAddress,
|
|
104
|
-
amount: bigint,
|
|
179
|
+
amount: bigint | undefined,
|
|
105
180
|
log: Logger,
|
|
106
181
|
) {
|
|
107
182
|
const { l1ChainId } = await pxe.getNodeInfo();
|
|
108
|
-
const chain = createEthereumChain(
|
|
109
|
-
const
|
|
183
|
+
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
184
|
+
const l1Client = createExtendedL1Client(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
|
|
110
185
|
|
|
111
|
-
|
|
186
|
+
// docs:start:bridge_fee_juice
|
|
187
|
+
const portal = await L1FeeJuicePortalManager.new(pxe, l1Client, log);
|
|
112
188
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
189
|
+
// docs:end:bridge_fee_juice
|
|
113
190
|
|
|
114
191
|
const isSynced = async () => await pxe.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
|
|
115
192
|
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
@@ -118,21 +195,37 @@ async function bridgeL1FeeJuice(
|
|
|
118
195
|
return claim;
|
|
119
196
|
}
|
|
120
197
|
|
|
121
|
-
async function advanceL2Block(node: AztecNode) {
|
|
198
|
+
async function advanceL2Block(node: AztecNode, nodeAdmin?: AztecNodeAdmin) {
|
|
122
199
|
const initialBlockNumber = await node.getBlockNumber();
|
|
123
|
-
|
|
200
|
+
|
|
201
|
+
let minTxsPerBlock = undefined;
|
|
202
|
+
if (nodeAdmin) {
|
|
203
|
+
({ minTxsPerBlock } = await nodeAdmin.getConfig());
|
|
204
|
+
await nodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
|
|
205
|
+
}
|
|
206
|
+
|
|
124
207
|
await retryUntil(async () => (await node.getBlockNumber()) >= initialBlockNumber + 1);
|
|
208
|
+
|
|
209
|
+
if (nodeAdmin && minTxsPerBlock !== undefined) {
|
|
210
|
+
await nodeAdmin.setConfig({ minTxsPerBlock });
|
|
211
|
+
}
|
|
125
212
|
}
|
|
126
213
|
|
|
127
214
|
async function deployTokenAndMint(
|
|
128
215
|
wallets: AccountWalletWithSecretKey[],
|
|
129
216
|
admin: AztecAddress,
|
|
130
217
|
mintAmount: bigint,
|
|
218
|
+
paymentMethod: FeePaymentMethod | undefined,
|
|
131
219
|
logger: Logger,
|
|
132
220
|
) {
|
|
133
221
|
logger.verbose(`Deploying TokenContract...`);
|
|
134
222
|
const tokenContract = await TokenContract.deploy(wallets[0], admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS)
|
|
135
|
-
.send(
|
|
223
|
+
.send({
|
|
224
|
+
from: admin,
|
|
225
|
+
fee: {
|
|
226
|
+
paymentMethod,
|
|
227
|
+
},
|
|
228
|
+
})
|
|
136
229
|
.deployed({ timeout: 600 });
|
|
137
230
|
|
|
138
231
|
const tokenAddress = tokenContract.address;
|
|
@@ -143,7 +236,7 @@ async function deployTokenAndMint(
|
|
|
143
236
|
wallets.map(async w =>
|
|
144
237
|
(await TokenContract.at(tokenAddress, w)).methods
|
|
145
238
|
.mint_to_public(w.getAddress(), mintAmount)
|
|
146
|
-
.send()
|
|
239
|
+
.send({ from: admin, fee: { paymentMethod } })
|
|
147
240
|
.wait({ timeout: 600 }),
|
|
148
241
|
),
|
|
149
242
|
);
|
|
@@ -165,20 +258,42 @@ export async function performTransfers({
|
|
|
165
258
|
logger: Logger;
|
|
166
259
|
}) {
|
|
167
260
|
const recipient = testWallets.recipientWallet.getAddress();
|
|
168
|
-
|
|
169
261
|
for (let i = 0; i < rounds; i++) {
|
|
170
|
-
const
|
|
171
|
-
testWallets.
|
|
172
|
-
(
|
|
173
|
-
|
|
174
|
-
).methods.transfer_in_public(w.getAddress(), recipient, transferAmount, 0),
|
|
175
|
-
),
|
|
262
|
+
const txs = testWallets.wallets.map(async w =>
|
|
263
|
+
(await TokenContract.at(testWallets.tokenAddress, w)).methods
|
|
264
|
+
.transfer_in_public(w.getAddress(), recipient, transferAmount, 0)
|
|
265
|
+
.prove({ from: w.getAddress() }),
|
|
176
266
|
);
|
|
177
267
|
|
|
178
|
-
const
|
|
268
|
+
const provenTxs = await Promise.all(txs);
|
|
179
269
|
|
|
180
|
-
await Promise.all(
|
|
270
|
+
await Promise.all(provenTxs.map(t => t.send().wait({ timeout: 600 })));
|
|
181
271
|
|
|
182
272
|
logger.info(`Completed round ${i + 1} / ${rounds}`);
|
|
183
273
|
}
|
|
184
274
|
}
|
|
275
|
+
|
|
276
|
+
export async function startCompatiblePXE(
|
|
277
|
+
nodeUrl: string,
|
|
278
|
+
proverEnabled: boolean,
|
|
279
|
+
logger: Logger,
|
|
280
|
+
): Promise<{ pxe: PXE; cleanup: () => Promise<void> }> {
|
|
281
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
282
|
+
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
283
|
+
const pxe = await createPXEService(node, {
|
|
284
|
+
dataDirectory: undefined,
|
|
285
|
+
dataStoreMapSizeKb: 1024 * 1024,
|
|
286
|
+
...bbConfig,
|
|
287
|
+
...acvmConfig,
|
|
288
|
+
proverEnabled,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
pxe,
|
|
293
|
+
async cleanup() {
|
|
294
|
+
await pxe.stop();
|
|
295
|
+
await bbConfig?.cleanup();
|
|
296
|
+
await acvmConfig?.cleanup();
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|