@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.017a351
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/README.md +27 -0
- package/dest/bench/client_flows/benchmark.d.ts +76 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +298 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +318 -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 +124 -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 +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +46 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +30 -20
- 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 +137 -106
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +44 -33
- 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 +136 -103
- package/dest/e2e_deploy_contract/deploy_test.d.ts +20 -11
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +28 -28
- package/dest/e2e_epochs/epochs_test.d.ts +98 -24
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +366 -61
- 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 +61 -0
- package/dest/e2e_fees/fees_test.d.ts +42 -24
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +194 -182
- package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +56 -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 +16 -16
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +38 -43
- 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 +137 -0
- package/dest/e2e_p2p/p2p_network.d.ts +287 -31
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +281 -183
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +206 -0
- package/dest/e2e_p2p/shared.d.ts +73 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +205 -27
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +30 -15
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +110 -76
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +56 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +267 -0
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +79 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +76 -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/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- 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/schnorr_hardcoded_account_contract.d.ts +25 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
- package/dest/fixtures/setup.d.ts +272 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +735 -0
- package/dest/fixtures/setup_p2p_test.d.ts +28 -16
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +103 -32
- 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 +30 -13
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- 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/forward-compatibility/wallet_rpc_client.d.ts +7 -0
- package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
- package/dest/forward-compatibility/wallet_service.d.ts +3 -0
- package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_service.js +109 -0
- package/dest/index.d.ts +1 -1
- package/dest/install_legacy_contracts.d.cts +10 -0
- package/dest/install_legacy_contracts.d.cts.map +1 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- package/dest/quality_of_service/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +46 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +113 -55
- package/dest/shared/gas_portal_test_harness.d.ts +39 -28
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +64 -34
- package/dest/shared/index.d.ts +3 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +42 -2
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- 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 +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +202 -135
- package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
- package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +16 -9
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +38 -27
- 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 +12 -30
- package/dest/spartan/setup_test_wallets.d.ts +36 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +301 -63
- package/dest/spartan/tx_metrics.d.ts +102 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +475 -0
- package/dest/spartan/utils/bot.d.ts +28 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +142 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +19 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +23 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +11 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +22 -0
- package/dest/spartan/utils/k8s.d.ts +128 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +381 -0
- package/dest/spartan/utils/nodes.d.ts +40 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/spartan/utils/scripts.d.ts +30 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +81 -0
- package/dest/spartan/utils.d.ts +2 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- package/dest/test-wallet/test_wallet.d.ts +85 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +273 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +66 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +53 -0
- package/dest/test-wallet/worker_wallet.d.ts +53 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +155 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +22 -0
- package/package.json +79 -64
- package/src/bench/client_flows/benchmark.ts +382 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +399 -0
- package/src/bench/client_flows/config.ts +69 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +49 -87
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +164 -172
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +194 -183
- package/src/e2e_deploy_contract/deploy_test.ts +42 -49
- package/src/e2e_epochs/epochs_test.ts +451 -93
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +249 -262
- 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 +51 -60
- package/src/e2e_p2p/inactivity_slash_test.ts +180 -0
- package/src/e2e_p2p/p2p_network.ts +391 -240
- package/src/e2e_p2p/reqresp/utils.ts +274 -0
- package/src/e2e_p2p/shared.ts +304 -39
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +140 -124
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +329 -0
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +98 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +19 -13
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +1056 -0
- package/src/fixtures/setup_p2p_test.ts +142 -54
- package/src/fixtures/token_utils.ts +34 -16
- package/src/fixtures/utils.ts +29 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/guides/up_quick_start.sh +9 -19
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +112 -0
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +116 -90
- package/src/shared/gas_portal_test_harness.ts +75 -56
- package/src/shared/index.ts +2 -1
- package/src/shared/jest_setup.ts +52 -2
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +19 -20
- package/src/shared/uniswap_l1_l2.ts +259 -234
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +43 -26
- package/src/simulators/token_simulator.ts +18 -34
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +420 -96
- package/src/spartan/tx_metrics.ts +434 -0
- package/src/spartan/utils/bot.ts +188 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +29 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +71 -0
- package/src/spartan/utils/k8s.ts +535 -0
- package/src/spartan/utils/nodes.ts +543 -0
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/spartan/utils/scripts.ts +99 -0
- package/src/spartan/utils.ts +1 -582
- package/src/test-wallet/test_wallet.ts +376 -0
- package/src/test-wallet/utils.ts +108 -0
- package/src/test-wallet/wallet_worker_script.ts +63 -0
- package/src/test-wallet/worker_wallet.ts +218 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
- 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/e2e_prover/e2e_prover_test.js +0 -291
- 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/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.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/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- 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,24 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
2
4
|
import {
|
|
3
|
-
type AccountWallet,
|
|
4
|
-
type AztecAddress,
|
|
5
|
-
type AztecNode,
|
|
6
|
-
EthAddress,
|
|
7
|
-
type FieldsOf,
|
|
8
|
-
Fr,
|
|
9
5
|
type L1TokenManager,
|
|
10
6
|
L1TokenPortalManager,
|
|
11
7
|
type L2AmountClaim,
|
|
12
8
|
type L2AmountClaimWithRecipient,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from '@aztec/
|
|
21
|
-
import
|
|
9
|
+
} from '@aztec/aztec.js/ethereum';
|
|
10
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
11
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
12
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
13
|
+
import type { SiblingPath } from '@aztec/aztec.js/trees';
|
|
14
|
+
import type { TxReceipt } from '@aztec/aztec.js/tx';
|
|
15
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
16
|
+
import { OutboxContract } from '@aztec/ethereum/contracts';
|
|
17
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
18
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
19
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
20
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
22
21
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
23
22
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
24
23
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
@@ -26,8 +25,8 @@ import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
|
26
25
|
import { type Hex, getContract } from 'viem';
|
|
27
26
|
|
|
28
27
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
28
|
+
import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
|
|
29
29
|
|
|
30
|
-
// docs:start:deployAndInitializeTokenAndBridgeContracts
|
|
31
30
|
/**
|
|
32
31
|
* Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
|
|
33
32
|
* @param wallet - the wallet instance
|
|
@@ -40,8 +39,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
40
39
|
*/
|
|
41
40
|
export async function deployAndInitializeTokenAndBridgeContracts(
|
|
42
41
|
wallet: Wallet,
|
|
43
|
-
|
|
44
|
-
publicClient: ViemPublicClient,
|
|
42
|
+
l1Client: ExtendedViemWalletClient,
|
|
45
43
|
rollupRegistryAddress: EthAddress,
|
|
46
44
|
owner: AztecAddress,
|
|
47
45
|
underlyingERC20Address: EthAddress,
|
|
@@ -68,35 +66,34 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
68
66
|
underlyingERC20: any;
|
|
69
67
|
}> {
|
|
70
68
|
// deploy the token portal
|
|
71
|
-
const { address: tokenPortalAddress } = await deployL1Contract(
|
|
72
|
-
walletClient,
|
|
73
|
-
publicClient,
|
|
74
|
-
TokenPortalAbi,
|
|
75
|
-
TokenPortalBytecode,
|
|
76
|
-
);
|
|
69
|
+
const { address: tokenPortalAddress } = await deployL1Contract(l1Client, TokenPortalAbi, TokenPortalBytecode);
|
|
77
70
|
const tokenPortal = getContract({
|
|
78
71
|
address: tokenPortalAddress.toString(),
|
|
79
72
|
abi: TokenPortalAbi,
|
|
80
|
-
client:
|
|
73
|
+
client: l1Client,
|
|
81
74
|
});
|
|
82
75
|
|
|
83
76
|
// deploy l2 token
|
|
84
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send(
|
|
77
|
+
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
78
|
+
from: owner,
|
|
79
|
+
});
|
|
85
80
|
|
|
86
81
|
// deploy l2 token bridge and attach to the portal
|
|
87
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send(
|
|
82
|
+
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
83
|
+
from: owner,
|
|
84
|
+
});
|
|
88
85
|
|
|
89
|
-
if ((await token.methods.get_admin().simulate()) !== owner.toBigInt()) {
|
|
86
|
+
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
|
|
90
87
|
throw new Error(`Token admin is not ${owner}`);
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
if (!(await bridge.methods.get_config().simulate()).token.equals(token.address)) {
|
|
90
|
+
if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
|
|
94
91
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
// make the bridge a minter on the token:
|
|
98
|
-
await token.methods.set_minter(bridge.address, true).send()
|
|
99
|
-
if ((await token.methods.is_minter(bridge.address).simulate()) === 1n) {
|
|
95
|
+
await token.methods.set_minter(bridge.address, true).send({ from: owner });
|
|
96
|
+
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
|
|
100
97
|
throw new Error(`Bridge is not a minter`);
|
|
101
98
|
}
|
|
102
99
|
|
|
@@ -109,12 +106,22 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
109
106
|
const underlyingERC20 = getContract({
|
|
110
107
|
address: underlyingERC20Address.toString(),
|
|
111
108
|
abi: TestERC20Abi,
|
|
112
|
-
client:
|
|
109
|
+
client: l1Client,
|
|
113
110
|
});
|
|
114
111
|
|
|
115
112
|
return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
|
|
116
113
|
}
|
|
117
|
-
|
|
114
|
+
|
|
115
|
+
export type CrossChainContext = {
|
|
116
|
+
l2Token: AztecAddress;
|
|
117
|
+
l2Bridge: AztecAddress;
|
|
118
|
+
tokenPortal: EthAddress;
|
|
119
|
+
underlying: EthAddress;
|
|
120
|
+
ethAccount: EthAddress;
|
|
121
|
+
ownerAddress: AztecAddress;
|
|
122
|
+
inbox: EthAddress;
|
|
123
|
+
outbox: EthAddress;
|
|
124
|
+
};
|
|
118
125
|
|
|
119
126
|
/**
|
|
120
127
|
* A Class for testing cross chain interactions, contains common interactions
|
|
@@ -123,54 +130,48 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
123
130
|
export class CrossChainTestHarness {
|
|
124
131
|
static async new(
|
|
125
132
|
aztecNode: AztecNode,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
wallet: AccountWallet,
|
|
133
|
+
l1Client: ExtendedViemWalletClient,
|
|
134
|
+
wallet: Wallet,
|
|
135
|
+
ownerAddress: AztecAddress,
|
|
130
136
|
logger: Logger,
|
|
131
137
|
underlyingERC20Address: EthAddress,
|
|
132
138
|
): Promise<CrossChainTestHarness> {
|
|
133
|
-
const ethAccount = EthAddress.fromString((await
|
|
134
|
-
const l1ContractAddresses = (await
|
|
139
|
+
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
140
|
+
const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
|
|
135
141
|
|
|
136
142
|
// Deploy and initialize all required contracts
|
|
137
143
|
logger.info('Deploying and initializing token, portal and its bridge...');
|
|
138
144
|
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(
|
|
139
145
|
wallet,
|
|
140
|
-
|
|
141
|
-
publicClient,
|
|
146
|
+
l1Client,
|
|
142
147
|
l1ContractAddresses.registryAddress,
|
|
143
|
-
|
|
148
|
+
ownerAddress,
|
|
144
149
|
underlyingERC20Address,
|
|
145
150
|
);
|
|
146
151
|
logger.info('Deployed and initialized token, portal and its bridge.');
|
|
147
152
|
|
|
148
153
|
return new CrossChainTestHarness(
|
|
149
154
|
aztecNode,
|
|
150
|
-
pxeService,
|
|
151
155
|
logger,
|
|
152
156
|
token,
|
|
153
157
|
bridge,
|
|
154
158
|
ethAccount,
|
|
155
159
|
tokenPortalAddress,
|
|
156
160
|
underlyingERC20.address,
|
|
157
|
-
|
|
158
|
-
walletClient,
|
|
161
|
+
l1Client,
|
|
159
162
|
l1ContractAddresses,
|
|
160
163
|
wallet,
|
|
164
|
+
ownerAddress,
|
|
161
165
|
);
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
private readonly l1TokenManager: L1TokenManager;
|
|
165
169
|
private readonly l1TokenPortalManager: L1TokenPortalManager;
|
|
166
|
-
|
|
167
|
-
public readonly ownerAddress: AztecAddress;
|
|
170
|
+
public readonly outboxContract: OutboxContract;
|
|
168
171
|
|
|
169
172
|
constructor(
|
|
170
173
|
/** Aztec node instance. */
|
|
171
174
|
public aztecNode: AztecNode,
|
|
172
|
-
/** Private eXecution Environment (PXE). */
|
|
173
|
-
public pxeService: PXE,
|
|
174
175
|
/** Logger. */
|
|
175
176
|
public logger: Logger,
|
|
176
177
|
|
|
@@ -186,32 +187,40 @@ export class CrossChainTestHarness {
|
|
|
186
187
|
public tokenPortalAddress: EthAddress,
|
|
187
188
|
/** Underlying token for portal tests. */
|
|
188
189
|
public underlyingERC20Address: EthAddress,
|
|
189
|
-
/** Viem
|
|
190
|
-
public
|
|
191
|
-
/** Viem Wallet Client instance. */
|
|
192
|
-
public walletClient: ViemWalletClient,
|
|
190
|
+
/** Viem Extended client instance. */
|
|
191
|
+
public l1Client: ExtendedViemWalletClient,
|
|
193
192
|
|
|
194
193
|
/** Deployment addresses for all L1 contracts */
|
|
195
194
|
public readonly l1ContractAddresses: L1ContractAddresses,
|
|
196
195
|
|
|
197
|
-
/** Wallet
|
|
198
|
-
public readonly
|
|
196
|
+
/** Wallet to simulate and send txs from. */
|
|
197
|
+
public readonly wallet: Wallet,
|
|
198
|
+
|
|
199
|
+
/** Owner of the l2 token and bridge */
|
|
200
|
+
public readonly ownerAddress: AztecAddress,
|
|
199
201
|
) {
|
|
200
202
|
this.l1TokenPortalManager = new L1TokenPortalManager(
|
|
201
203
|
this.tokenPortalAddress,
|
|
202
204
|
this.underlyingERC20Address,
|
|
205
|
+
this.l1ContractAddresses.feeAssetHandlerAddress,
|
|
203
206
|
this.l1ContractAddresses.outboxAddress,
|
|
204
|
-
this.
|
|
205
|
-
this.walletClient,
|
|
207
|
+
this.l1Client,
|
|
206
208
|
this.logger,
|
|
207
209
|
);
|
|
208
210
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
209
|
-
this.
|
|
211
|
+
this.outboxContract = new OutboxContract(this.l1Client, this.l1ContractAddresses.outboxAddress);
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
async mintTokensOnL1(amount: bigint) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
const contract = getContract({
|
|
216
|
+
abi: TestERC20Abi,
|
|
217
|
+
address: this.l1TokenManager.tokenAddress.toString(),
|
|
218
|
+
client: this.l1Client,
|
|
219
|
+
});
|
|
220
|
+
const balanceBefore = await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString());
|
|
221
|
+
const hash = await contract.write.mint([this.ethAccount.toString(), amount]);
|
|
222
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
223
|
+
expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(balanceBefore + amount);
|
|
215
224
|
}
|
|
216
225
|
|
|
217
226
|
getL1BalanceOf(address: EthAddress) {
|
|
@@ -228,16 +237,18 @@ export class CrossChainTestHarness {
|
|
|
228
237
|
|
|
229
238
|
async mintTokensPublicOnL2(amount: bigint) {
|
|
230
239
|
this.logger.info('Minting tokens on L2 publicly');
|
|
231
|
-
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send(
|
|
240
|
+
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
|
|
232
241
|
}
|
|
233
242
|
|
|
234
243
|
async mintTokensPrivateOnL2(amount: bigint) {
|
|
235
|
-
await mintTokensToPrivate(this.l2Token, this.
|
|
244
|
+
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
|
|
236
245
|
}
|
|
237
246
|
|
|
238
247
|
async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
|
|
239
248
|
// send a transfer tx to force through rollup with the message included
|
|
240
|
-
await this.l2Token.methods
|
|
249
|
+
await this.l2Token.methods
|
|
250
|
+
.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
|
|
251
|
+
.send({ from: this.ownerAddress });
|
|
241
252
|
}
|
|
242
253
|
|
|
243
254
|
async consumeMessageOnAztecAndMintPrivately(
|
|
@@ -247,8 +258,7 @@ export class CrossChainTestHarness {
|
|
|
247
258
|
const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
|
|
248
259
|
await this.l2Bridge.methods
|
|
249
260
|
.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
|
|
250
|
-
.send()
|
|
251
|
-
.wait();
|
|
261
|
+
.send({ from: this.ownerAddress });
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
async consumeMessageOnAztecAndMintPublicly(
|
|
@@ -258,30 +268,31 @@ export class CrossChainTestHarness {
|
|
|
258
268
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
259
269
|
await this.l2Bridge.methods
|
|
260
270
|
.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
|
|
261
|
-
.send()
|
|
262
|
-
.wait();
|
|
271
|
+
.send({ from: this.ownerAddress });
|
|
263
272
|
}
|
|
264
273
|
|
|
265
|
-
async withdrawPrivateFromAztecToL1(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
274
|
+
async withdrawPrivateFromAztecToL1(
|
|
275
|
+
withdrawAmount: bigint,
|
|
276
|
+
authwitNonce: Fr = Fr.ZERO,
|
|
277
|
+
authWitness: AuthWitness,
|
|
278
|
+
): Promise<TxReceipt> {
|
|
279
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
280
|
+
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
281
|
+
.send({ authWitnesses: [authWitness], from: this.ownerAddress });
|
|
270
282
|
|
|
271
283
|
return withdrawReceipt;
|
|
272
284
|
}
|
|
273
285
|
|
|
274
|
-
async withdrawPublicFromAztecToL1(withdrawAmount: bigint,
|
|
275
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
276
|
-
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO,
|
|
277
|
-
.send()
|
|
278
|
-
.wait();
|
|
286
|
+
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
|
|
287
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
288
|
+
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
289
|
+
.send({ from: this.ownerAddress });
|
|
279
290
|
|
|
280
291
|
return withdrawReceipt;
|
|
281
292
|
}
|
|
282
293
|
|
|
283
294
|
async getL2PrivateBalanceOf(owner: AztecAddress) {
|
|
284
|
-
return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
|
|
295
|
+
return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
|
|
285
296
|
}
|
|
286
297
|
|
|
287
298
|
async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -291,7 +302,7 @@ export class CrossChainTestHarness {
|
|
|
291
302
|
}
|
|
292
303
|
|
|
293
304
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
294
|
-
return await this.l2Token.methods.balance_of_public(owner).simulate();
|
|
305
|
+
return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
|
|
295
306
|
}
|
|
296
307
|
|
|
297
308
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -299,8 +310,8 @@ export class CrossChainTestHarness {
|
|
|
299
310
|
expect(balance).toBe(expectedBalance);
|
|
300
311
|
}
|
|
301
312
|
|
|
302
|
-
getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Fr {
|
|
303
|
-
return this.l1TokenPortalManager.getL2ToL1MessageLeaf(
|
|
313
|
+
async getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Promise<Fr> {
|
|
314
|
+
return await this.l1TokenPortalManager.getL2ToL1MessageLeaf(
|
|
304
315
|
withdrawAmount,
|
|
305
316
|
this.ethAccount,
|
|
306
317
|
this.l2Bridge.address,
|
|
@@ -310,14 +321,16 @@ export class CrossChainTestHarness {
|
|
|
310
321
|
|
|
311
322
|
withdrawFundsFromBridgeOnL1(
|
|
312
323
|
amount: bigint,
|
|
313
|
-
|
|
324
|
+
epochNumber: EpochNumber,
|
|
325
|
+
numCheckpointsInEpoch: number,
|
|
314
326
|
messageIndex: bigint,
|
|
315
327
|
siblingPath: SiblingPath<number>,
|
|
316
328
|
) {
|
|
317
329
|
return this.l1TokenPortalManager.withdrawFunds(
|
|
318
330
|
amount,
|
|
319
331
|
this.ethAccount,
|
|
320
|
-
|
|
332
|
+
epochNumber,
|
|
333
|
+
numCheckpointsInEpoch,
|
|
321
334
|
messageIndex,
|
|
322
335
|
siblingPath,
|
|
323
336
|
);
|
|
@@ -325,12 +338,14 @@ export class CrossChainTestHarness {
|
|
|
325
338
|
|
|
326
339
|
async transferToPrivateOnL2(shieldAmount: bigint) {
|
|
327
340
|
this.logger.info('Transferring to private on L2');
|
|
328
|
-
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send(
|
|
341
|
+
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({ from: this.ownerAddress });
|
|
329
342
|
}
|
|
330
343
|
|
|
331
|
-
async transferToPublicOnL2(amount: bigint,
|
|
344
|
+
async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
|
|
332
345
|
this.logger.info('Transferring tokens to public');
|
|
333
|
-
await this.l2Token.methods
|
|
346
|
+
await this.l2Token.methods
|
|
347
|
+
.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
|
|
348
|
+
.send({ from: this.ownerAddress });
|
|
334
349
|
}
|
|
335
350
|
|
|
336
351
|
/**
|
|
@@ -342,11 +357,22 @@ export class CrossChainTestHarness {
|
|
|
342
357
|
*/
|
|
343
358
|
async makeMessageConsumable(msgHash: Fr | Hex) {
|
|
344
359
|
const frMsgHash = typeof msgHash === 'string' ? Fr.fromHexString(msgHash) : msgHash;
|
|
345
|
-
|
|
346
|
-
await retryUntil(async () => await this.aztecNode.isL1ToL2MessageSynced(frMsgHash), 'message sync', 10);
|
|
360
|
+
await waitForL1ToL2MessageSeen(this.aztecNode, frMsgHash, { timeoutSeconds: 10 });
|
|
347
361
|
|
|
348
362
|
await this.mintTokensPublicOnL2(0n);
|
|
349
363
|
await this.mintTokensPublicOnL2(0n);
|
|
350
364
|
}
|
|
365
|
+
|
|
366
|
+
toCrossChainContext(): CrossChainContext {
|
|
367
|
+
return {
|
|
368
|
+
l2Token: this.l2Token.address,
|
|
369
|
+
l2Bridge: this.l2Bridge.address,
|
|
370
|
+
tokenPortal: this.tokenPortalAddress,
|
|
371
|
+
underlying: this.underlyingERC20Address,
|
|
372
|
+
ethAccount: this.ethAccount,
|
|
373
|
+
ownerAddress: this.ownerAddress,
|
|
374
|
+
inbox: this.l1ContractAddresses.inboxAddress,
|
|
375
|
+
outbox: this.l1ContractAddresses.outboxAddress,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
351
378
|
}
|
|
352
|
-
// docs:end:cross_chain_test_harness
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type Logger,
|
|
10
|
-
type PXE,
|
|
11
|
-
type Wallet,
|
|
12
|
-
retryUntil,
|
|
13
|
-
} from '@aztec/aztec.js';
|
|
14
|
-
import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
|
|
1
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim } from '@aztec/aztec.js/ethereum';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
5
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
6
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
7
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
8
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
15
9
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
16
10
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
11
|
+
import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
12
|
+
|
|
13
|
+
import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
|
|
14
|
+
|
|
15
|
+
/** Aztec node that may expose the debug mining API in local e2e setups. */
|
|
16
|
+
type MiningAztecNode = AztecNode & Partial<AztecNodeDebug>;
|
|
17
17
|
|
|
18
18
|
export interface IGasBridgingTestHarness {
|
|
19
19
|
getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
|
|
20
|
-
prepareTokensOnL1(
|
|
21
|
-
bridgeFromL1ToL2(
|
|
20
|
+
prepareTokensOnL1(owner: AztecAddress): Promise<L2AmountClaim>;
|
|
21
|
+
bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress): Promise<void>;
|
|
22
22
|
feeJuice: FeeJuiceContract;
|
|
23
23
|
l1FeeJuiceAddress: EthAddress;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface FeeJuicePortalTestingHarnessFactoryConfig {
|
|
27
|
-
aztecNode:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
walletClient: ViemWalletClient;
|
|
27
|
+
aztecNode: MiningAztecNode;
|
|
28
|
+
aztecNodeAdmin?: AztecNodeAdmin;
|
|
29
|
+
l1Client: ExtendedViemWalletClient;
|
|
31
30
|
wallet: Wallet;
|
|
32
31
|
logger: Logger;
|
|
33
32
|
mockL1?: boolean;
|
|
@@ -37,10 +36,10 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
37
36
|
private constructor(private config: FeeJuicePortalTestingHarnessFactoryConfig) {}
|
|
38
37
|
|
|
39
38
|
private async createReal() {
|
|
40
|
-
const { aztecNode,
|
|
39
|
+
const { aztecNode, aztecNodeAdmin, l1Client, wallet, logger } = this.config;
|
|
41
40
|
|
|
42
|
-
const ethAccount = EthAddress.fromString((await
|
|
43
|
-
const l1ContractAddresses = (await
|
|
41
|
+
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
42
|
+
const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
|
|
44
43
|
|
|
45
44
|
const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
|
|
46
45
|
const feeJuicePortalAddress = l1ContractAddresses.feeJuicePortalAddress;
|
|
@@ -49,18 +48,19 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
49
48
|
throw new Error('Fee Juice portal not deployed on L1');
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
const gasL2 =
|
|
51
|
+
const gasL2 = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
|
|
53
52
|
|
|
54
53
|
return new GasBridgingTestHarness(
|
|
55
54
|
aztecNode,
|
|
56
|
-
|
|
55
|
+
aztecNodeAdmin,
|
|
56
|
+
wallet,
|
|
57
57
|
logger,
|
|
58
58
|
gasL2,
|
|
59
59
|
ethAccount,
|
|
60
60
|
feeJuicePortalAddress,
|
|
61
61
|
feeJuiceAddress,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
l1ContractAddresses.feeAssetHandlerAddress!,
|
|
63
|
+
l1Client,
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -80,9 +80,11 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
80
80
|
|
|
81
81
|
constructor(
|
|
82
82
|
/** Aztec node */
|
|
83
|
-
public aztecNode:
|
|
84
|
-
/**
|
|
85
|
-
public
|
|
83
|
+
public aztecNode: MiningAztecNode,
|
|
84
|
+
/** Aztec node admin interface */
|
|
85
|
+
public aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
86
|
+
/** Wallet. */
|
|
87
|
+
public wallet: Wallet,
|
|
86
88
|
/** Logger. */
|
|
87
89
|
public logger: Logger,
|
|
88
90
|
|
|
@@ -96,44 +98,45 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
96
98
|
public feeJuicePortalAddress: EthAddress,
|
|
97
99
|
/** Underlying token for portal tests. */
|
|
98
100
|
public l1FeeJuiceAddress: EthAddress,
|
|
99
|
-
/**
|
|
100
|
-
public
|
|
101
|
-
/** Viem
|
|
102
|
-
public
|
|
101
|
+
/** Fee asset handler address. */
|
|
102
|
+
public feeAssetHandlerAddress: EthAddress,
|
|
103
|
+
/** Viem Extended client instance. */
|
|
104
|
+
public l1Client: ExtendedViemWalletClient,
|
|
103
105
|
) {
|
|
104
106
|
this.feeJuicePortalManager = new L1FeeJuicePortalManager(
|
|
105
107
|
this.feeJuicePortalAddress,
|
|
106
108
|
this.l1FeeJuiceAddress,
|
|
107
|
-
this.
|
|
108
|
-
this.
|
|
109
|
+
this.feeAssetHandlerAddress,
|
|
110
|
+
this.l1Client,
|
|
109
111
|
this.logger,
|
|
110
112
|
);
|
|
111
113
|
|
|
112
114
|
this.l1TokenManager = this.feeJuicePortalManager.getTokenManager();
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
async mintTokensOnL1(
|
|
116
|
-
const balanceBefore = await this.l1TokenManager.getL1TokenBalance(to.toString());
|
|
117
|
-
await this.l1TokenManager.mint(
|
|
118
|
-
|
|
117
|
+
async mintTokensOnL1(to: EthAddress = this.ethAccount) {
|
|
118
|
+
// const balanceBefore = await this.l1TokenManager.getL1TokenBalance(to.toString());
|
|
119
|
+
await this.l1TokenManager.mint(to.toString());
|
|
120
|
+
|
|
121
|
+
// expect(await this.l1TokenManager.getL1TokenBalance(to.toString())).toEqual(balanceBefore + amount);
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
async getL1FeeJuiceBalance(address: EthAddress) {
|
|
122
125
|
return await this.l1TokenManager.getL1TokenBalance(address.toString());
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress
|
|
126
|
-
return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount,
|
|
128
|
+
sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress) {
|
|
129
|
+
return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, false);
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim) {
|
|
132
|
+
async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim) {
|
|
130
133
|
this.logger.info('Consuming messages on L2 Privately');
|
|
131
134
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
132
|
-
await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send()
|
|
135
|
+
await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer });
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
136
|
-
return await this.feeJuice.methods.balance_of_public(owner).simulate();
|
|
139
|
+
return (await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner })).result;
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -141,11 +144,12 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
141
144
|
expect(balance).toBe(expectedBalance);
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
async prepareTokensOnL1(
|
|
145
|
-
const
|
|
147
|
+
async prepareTokensOnL1(owner: AztecAddress) {
|
|
148
|
+
const bridgeAmount = await this.l1TokenManager.getMintAmount();
|
|
149
|
+
await this.mintTokensOnL1();
|
|
150
|
+
const claim = await this.sendTokensToPortalPublic(bridgeAmount, owner);
|
|
146
151
|
|
|
147
|
-
|
|
148
|
-
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 1);
|
|
152
|
+
await waitForL1ToL2MessageSeen(this.aztecNode, Fr.fromHexString(claim.messageHash), { timeoutSeconds: 24 });
|
|
149
153
|
|
|
150
154
|
// Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
151
155
|
await this.advanceL2Block();
|
|
@@ -154,19 +158,34 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
154
158
|
return claim;
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
async bridgeFromL1ToL2(
|
|
161
|
+
async bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress) {
|
|
158
162
|
// Prepare the tokens on the L1 side
|
|
159
|
-
const claim = await this.prepareTokensOnL1(
|
|
163
|
+
const claim = await this.prepareTokensOnL1(owner);
|
|
160
164
|
|
|
161
165
|
// Consume L1 -> L2 message and claim tokens privately on L2
|
|
162
|
-
await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
|
|
163
|
-
await this.expectPublicBalanceOnL2(owner, bridgeAmount);
|
|
166
|
+
await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
private async advanceL2Block() {
|
|
170
|
+
if (this.aztecNode.mineBlock) {
|
|
171
|
+
await this.aztecNode.mineBlock();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
const initialBlockNumber = await this.aztecNode.getBlockNumber();
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
|
|
177
|
+
let minTxsPerBlock = undefined;
|
|
178
|
+
if (this.aztecNodeAdmin) {
|
|
179
|
+
({ minTxsPerBlock } = await this.aztecNodeAdmin.getConfig());
|
|
180
|
+
await this.aztecNodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
await retryUntil(async () => (await this.aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
|
|
185
|
+
} finally {
|
|
186
|
+
if (this.aztecNodeAdmin && minTxsPerBlock !== undefined) {
|
|
187
|
+
await this.aztecNodeAdmin.setConfig({ minTxsPerBlock });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
170
190
|
}
|
|
171
191
|
}
|
|
172
|
-
// docs:end:cross_chain_test_harness
|
package/src/shared/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { uniswapL1L2TestSuite
|
|
1
|
+
export { uniswapL1L2TestSuite } from './uniswap_l1_l2.js';
|
|
2
|
+
export { MockStateView, diffInBps } from './mock_state_view.js';
|