@aztec/end-to-end 0.0.1-commit.24de95ac → 0.0.1-commit.2606882
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 +17 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +38 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +23 -17
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +143 -136
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/client_flows/data_extractor.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.js +7 -27
- package/dest/bench/utils.d.ts +8 -7
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +33 -19
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
- 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 +120 -117
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +33 -16
- 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 +124 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +7 -6
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +20 -14
- package/dest/e2e_epochs/epochs_test.d.ts +49 -16
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +188 -64
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +5 -7
- package/dest/e2e_fees/fees_test.d.ts +25 -18
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +162 -141
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +18 -19
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.js +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +32 -40
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +11 -9
- package/dest/e2e_p2p/p2p_network.d.ts +237 -28
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +176 -129
- 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 +44 -15
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +102 -68
- 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 +20 -11
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +103 -93
- 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 +19 -24
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +126 -145
- 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 +75 -3
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +73 -3
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.js +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +5 -5
- 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 +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/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 +22 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +57 -38
- package/dest/fixtures/token_utils.d.ts +6 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +13 -9
- package/dest/fixtures/utils.d.ts +5 -192
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -648
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/web3signer.js +1 -1
- 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 +9 -6
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +34 -30
- package/dest/shared/gas_portal_test_harness.d.ts +9 -6
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +21 -12
- 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 +41 -1
- 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 +4 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +9 -11
- package/dest/shared/uniswap_l1_l2.d.ts +3 -27
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +87 -50
- 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 +11 -4
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +32 -18
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +18 -6
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +159 -30
- 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 -218
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -749
- 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 +56 -46
- package/src/bench/client_flows/benchmark.ts +43 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +203 -206
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/client_flows/data_extractor.ts +6 -28
- package/src/bench/utils.ts +38 -22
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +180 -127
- package/src/e2e_deploy_contract/deploy_test.ts +25 -17
- package/src/e2e_epochs/epochs_test.ts +254 -116
- package/src/e2e_fees/bridging_race.notest.ts +6 -12
- package/src/e2e_fees/fees_test.ts +215 -229
- package/src/e2e_l1_publisher/write_json.ts +20 -19
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +38 -56
- package/src/e2e_p2p/inactivity_slash_test.ts +12 -10
- package/src/e2e_p2p/p2p_network.ts +246 -201
- package/src/e2e_p2p/reqresp/utils.ts +274 -0
- package/src/e2e_p2p/shared.ts +132 -82
- 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 +129 -117
- 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 +154 -199
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +95 -5
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +1056 -0
- package/src/fixtures/setup_p2p_test.ts +70 -56
- package/src/fixtures/token_utils.ts +9 -8
- package/src/fixtures/utils.ts +29 -947
- package/src/fixtures/web3signer.ts +1 -1
- 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 +4 -6
- 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} +1 -1
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +37 -40
- package/src/shared/gas_portal_test_harness.ts +24 -14
- package/src/shared/index.ts +2 -1
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +11 -16
- package/src/shared/uniswap_l1_l2.ts +142 -114
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +39 -19
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/DEVELOP.md +7 -0
- package/src/spartan/setup_test_wallets.ts +234 -32
- 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 -942
- 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/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 -95
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -505
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/src/fixtures/setup_l1_contracts.ts +0 -26
- package/src/fixtures/snapshot_manager.ts +0 -665
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { waitForProven } from '@aztec/aztec.js/contracts';
|
|
3
4
|
import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
|
|
4
5
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
6
|
import type { Logger } from '@aztec/aztec.js/log';
|
|
6
7
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
7
8
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from '@aztec/
|
|
15
|
-
import {
|
|
9
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
10
|
+
import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
11
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
12
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
13
|
+
import { extractEvent } from '@aztec/ethereum/utils';
|
|
14
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
15
|
+
import { sha256ToField } from '@aztec/foundation/crypto/sha256';
|
|
16
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
16
17
|
import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
17
18
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
18
19
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
19
|
-
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
20
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
21
20
|
|
|
22
21
|
import { jest } from '@jest/globals';
|
|
23
22
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
24
23
|
|
|
25
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
type EndToEndContext,
|
|
26
|
+
ensureAccountContractsPublished,
|
|
27
|
+
ensureAuthRegistryPublished,
|
|
28
|
+
} from '../fixtures/utils.js';
|
|
29
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
26
30
|
import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
27
31
|
|
|
28
32
|
// PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
|
|
@@ -32,30 +36,10 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
|
32
36
|
// anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
|
|
33
37
|
// For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
|
|
34
38
|
|
|
35
|
-
const TIMEOUT =
|
|
36
|
-
|
|
37
|
-
/** Objects to be returned by the uniswap setup function */
|
|
38
|
-
export type UniswapSetupContext = {
|
|
39
|
-
/** Aztec Node instance */
|
|
40
|
-
aztecNode: AztecNode;
|
|
41
|
-
/** Logger instance named as the current test. */
|
|
42
|
-
logger: Logger;
|
|
43
|
-
/** The L1 wallet client, extended with public actions. */
|
|
44
|
-
l1Client: ExtendedViemWalletClient;
|
|
45
|
-
/** The wallet. */
|
|
46
|
-
wallet: TestWallet;
|
|
47
|
-
/** The owner address. */
|
|
48
|
-
ownerAddress: AztecAddress;
|
|
49
|
-
/** The sponsor wallet. */
|
|
50
|
-
sponsorAddress: AztecAddress;
|
|
51
|
-
/** */
|
|
52
|
-
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
53
|
-
/** Cheat codes instance. */
|
|
54
|
-
cheatCodes: CheatCodes;
|
|
55
|
-
};
|
|
39
|
+
const TIMEOUT = 15 * 60 * 1000;
|
|
56
40
|
|
|
57
41
|
export const uniswapL1L2TestSuite = (
|
|
58
|
-
setup: () => Promise<
|
|
42
|
+
setup: () => Promise<EndToEndContext>,
|
|
59
43
|
cleanup: () => Promise<void>,
|
|
60
44
|
expectedForkBlockNumber = 17514288,
|
|
61
45
|
) => {
|
|
@@ -79,7 +63,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
79
63
|
let daiCrossChainHarness: CrossChainTestHarness;
|
|
80
64
|
let wethCrossChainHarness: CrossChainTestHarness;
|
|
81
65
|
|
|
82
|
-
let deployL1ContractsValues:
|
|
66
|
+
let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
83
67
|
let rollup: RollupContract;
|
|
84
68
|
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
|
|
85
69
|
let uniswapPortalAddress: EthAddress;
|
|
@@ -92,8 +76,19 @@ export const uniswapL1L2TestSuite = (
|
|
|
92
76
|
let cheatCodes: CheatCodes;
|
|
93
77
|
let version: number;
|
|
94
78
|
beforeAll(async () => {
|
|
95
|
-
|
|
96
|
-
|
|
79
|
+
const t = await setup();
|
|
80
|
+
({
|
|
81
|
+
aztecNode,
|
|
82
|
+
logger,
|
|
83
|
+
deployL1ContractsValues,
|
|
84
|
+
cheatCodes,
|
|
85
|
+
wallet,
|
|
86
|
+
accounts: [ownerAddress, sponsorAddress],
|
|
87
|
+
} = t);
|
|
88
|
+
|
|
89
|
+
l1Client = deployL1ContractsValues.l1Client;
|
|
90
|
+
|
|
91
|
+
t.watcher.setIsMarkingAsProven(false);
|
|
97
92
|
|
|
98
93
|
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
99
94
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
@@ -107,6 +102,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
107
102
|
ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
108
103
|
|
|
109
104
|
await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
|
|
105
|
+
await ensureAuthRegistryPublished(wallet, ownerAddress);
|
|
110
106
|
|
|
111
107
|
logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
|
|
112
108
|
daiCrossChainHarness = await CrossChainTestHarness.new(
|
|
@@ -139,9 +135,9 @@ export const uniswapL1L2TestSuite = (
|
|
|
139
135
|
client: l1Client,
|
|
140
136
|
});
|
|
141
137
|
// deploy l2 uniswap contract and attach to portal
|
|
142
|
-
uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress)
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
|
|
139
|
+
from: ownerAddress,
|
|
140
|
+
}));
|
|
145
141
|
|
|
146
142
|
const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
147
143
|
|
|
@@ -163,7 +159,6 @@ export const uniswapL1L2TestSuite = (
|
|
|
163
159
|
await cleanup();
|
|
164
160
|
});
|
|
165
161
|
|
|
166
|
-
// docs:start:uniswap_private
|
|
167
162
|
it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
|
|
168
163
|
const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
169
164
|
|
|
@@ -206,7 +201,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
206
201
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
207
202
|
const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
208
203
|
|
|
209
|
-
const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
|
|
204
|
+
const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
|
|
210
205
|
.swap_private(
|
|
211
206
|
wethCrossChainHarness.l2Token.address,
|
|
212
207
|
wethCrossChainHarness.l2Bridge.address,
|
|
@@ -218,8 +213,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
218
213
|
secretHashForDepositingSwappedDai,
|
|
219
214
|
ownerEthAddress,
|
|
220
215
|
)
|
|
221
|
-
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
|
|
222
|
-
.wait();
|
|
216
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
|
|
223
217
|
|
|
224
218
|
const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
|
|
225
219
|
const swapPrivateContent = sha256ToField([
|
|
@@ -261,33 +255,43 @@ export const uniswapL1L2TestSuite = (
|
|
|
261
255
|
// ensure that uniswap contract didn't eat the funds.
|
|
262
256
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
263
257
|
|
|
264
|
-
// Since the outbox is only consumable when the
|
|
265
|
-
|
|
258
|
+
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
|
|
259
|
+
// before we can ask the witness helper for a covering root.
|
|
260
|
+
const minedReceipt = await aztecNode.getTxReceipt(l2UniswapInteractionReceipt.txHash);
|
|
261
|
+
if (minedReceipt.epochNumber === undefined) {
|
|
262
|
+
throw new Error('L2 Uniswap interaction tx is not yet in an epoch');
|
|
263
|
+
}
|
|
264
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
|
|
265
|
+
await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
|
|
266
266
|
|
|
267
267
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
268
268
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
269
269
|
const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
|
|
270
270
|
daiCrossChainHarness.tokenPortalAddress,
|
|
271
271
|
);
|
|
272
|
-
const swapResult = await
|
|
273
|
-
aztecNode,
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
const swapResult = await retryUntil(
|
|
273
|
+
() => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
|
|
274
|
+
'swap private l2 to l1 witness',
|
|
275
|
+
60,
|
|
276
|
+
1,
|
|
276
277
|
);
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
|
|
279
|
+
const withdrawResult = await retryUntil(
|
|
280
|
+
() => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
|
|
281
|
+
'withdraw l2 to l1 witness',
|
|
282
|
+
60,
|
|
283
|
+
1,
|
|
281
284
|
);
|
|
282
285
|
|
|
283
|
-
const swapPrivateL2MessageIndex = swapResult
|
|
284
|
-
const swapPrivateSiblingPath = swapResult
|
|
286
|
+
const swapPrivateL2MessageIndex = swapResult.leafIndex;
|
|
287
|
+
const swapPrivateSiblingPath = swapResult.siblingPath;
|
|
285
288
|
|
|
286
|
-
const withdrawL2MessageIndex = withdrawResult
|
|
287
|
-
const withdrawSiblingPath = withdrawResult
|
|
289
|
+
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
290
|
+
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
288
291
|
|
|
289
292
|
const withdrawMessageMetadata = {
|
|
290
|
-
|
|
293
|
+
_epoch: BigInt(epoch),
|
|
294
|
+
_numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
|
|
291
295
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
292
296
|
_path: withdrawSiblingPath
|
|
293
297
|
.toBufferArray()
|
|
@@ -295,7 +299,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
295
299
|
};
|
|
296
300
|
|
|
297
301
|
const swapPrivateMessageMetadata = {
|
|
298
|
-
|
|
302
|
+
_epoch: BigInt(epoch),
|
|
303
|
+
_numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
|
|
299
304
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
300
305
|
_path: swapPrivateSiblingPath
|
|
301
306
|
.toBufferArray()
|
|
@@ -353,10 +358,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
353
358
|
logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
|
|
354
359
|
logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
|
|
355
360
|
});
|
|
356
|
-
// docs:end:uniswap_private
|
|
357
361
|
|
|
358
362
|
// TODO(#7463): reenable look into this failure https://github.com/AztecProtocol/aztec-packages/actions/runs/9912612912/job/27388320150?pr=7462
|
|
359
|
-
// // docs:start:uniswap_public
|
|
360
363
|
// it('should uniswap trade on L1 from L2 funds publicly (swaps WETH -> DAI)', async () => {
|
|
361
364
|
// const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
362
365
|
|
|
@@ -442,10 +445,10 @@ export const uniswapL1L2TestSuite = (
|
|
|
442
445
|
// ownerEthAddress,
|
|
443
446
|
// nonceForSwap,
|
|
444
447
|
// );
|
|
445
|
-
// await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send()
|
|
448
|
+
// await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
|
|
446
449
|
|
|
447
450
|
// // 4.2 Call swap_public from user2 on behalf of owner
|
|
448
|
-
// const uniswapL2Interaction = await action.send()
|
|
451
|
+
// const uniswapL2Interaction = await action.send();
|
|
449
452
|
|
|
450
453
|
// const swapPublicContent = sha256ToField([
|
|
451
454
|
// Buffer.from(
|
|
@@ -506,7 +509,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
506
509
|
// );
|
|
507
510
|
|
|
508
511
|
// const withdrawMessageMetadata = {
|
|
509
|
-
//
|
|
512
|
+
// _epoch: epoch,
|
|
510
513
|
// _leafIndex: BigInt(withdrawL2MessageIndex),
|
|
511
514
|
// _path: withdrawSiblingPath
|
|
512
515
|
// .toBufferArray()
|
|
@@ -514,7 +517,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
514
517
|
// };
|
|
515
518
|
|
|
516
519
|
// const swapPrivateMessageMetadata = {
|
|
517
|
-
//
|
|
520
|
+
// _epoch: epoch,
|
|
518
521
|
// _leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
519
522
|
// _path: swapPrivateSiblingPath
|
|
520
523
|
// .toBufferArray()
|
|
@@ -589,7 +592,6 @@ export const uniswapL1L2TestSuite = (
|
|
|
589
592
|
// logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
|
|
590
593
|
// logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
|
|
591
594
|
// });
|
|
592
|
-
// // docs:end:uniswap_public
|
|
593
595
|
|
|
594
596
|
// Edge cases for the private flow:
|
|
595
597
|
// note - tests for uniswapPortal.sol and minting asset on L2 are covered in other tests.
|
|
@@ -663,8 +665,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
663
665
|
Fr.random(),
|
|
664
666
|
ownerEthAddress,
|
|
665
667
|
)
|
|
666
|
-
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] })
|
|
667
|
-
.wait(),
|
|
668
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
|
|
668
669
|
).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
669
670
|
});
|
|
670
671
|
|
|
@@ -689,7 +690,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
689
690
|
},
|
|
690
691
|
true,
|
|
691
692
|
);
|
|
692
|
-
await validateActionInteraction.send()
|
|
693
|
+
await validateActionInteraction.send();
|
|
693
694
|
|
|
694
695
|
// No approval to call `swap` but should work even without it:
|
|
695
696
|
const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
@@ -708,8 +709,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
708
709
|
ownerEthAddress,
|
|
709
710
|
Fr.ZERO, // nonce for swap -> doesn't matter
|
|
710
711
|
)
|
|
711
|
-
.send({ from: ownerAddress })
|
|
712
|
-
.wait();
|
|
712
|
+
.send({ from: ownerAddress });
|
|
713
713
|
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
714
714
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
715
715
|
});
|
|
@@ -739,7 +739,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
739
739
|
{ caller: approvedUser, action },
|
|
740
740
|
true,
|
|
741
741
|
);
|
|
742
|
-
await validateActionInteraction.send()
|
|
742
|
+
await validateActionInteraction.send();
|
|
743
743
|
|
|
744
744
|
await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
|
|
745
745
|
});
|
|
@@ -761,7 +761,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
761
761
|
},
|
|
762
762
|
true,
|
|
763
763
|
);
|
|
764
|
-
await validateActionInteraction.send()
|
|
764
|
+
await validateActionInteraction.send();
|
|
765
765
|
|
|
766
766
|
await expect(
|
|
767
767
|
uniswapL2Contract.methods
|
|
@@ -806,7 +806,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
806
806
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
807
807
|
|
|
808
808
|
const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
809
|
-
const withdrawReceipt = await uniswapL2Contract.methods
|
|
809
|
+
const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
|
|
810
810
|
.swap_private(
|
|
811
811
|
wethCrossChainHarness.l2Token.address,
|
|
812
812
|
wethCrossChainHarness.l2Bridge.address,
|
|
@@ -818,8 +818,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
818
818
|
secretHashForDepositingSwappedDai,
|
|
819
819
|
ownerEthAddress,
|
|
820
820
|
)
|
|
821
|
-
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
|
|
822
|
-
.wait();
|
|
821
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
|
|
823
822
|
|
|
824
823
|
const swapPrivateContent = sha256ToField([
|
|
825
824
|
Buffer.from(
|
|
@@ -858,21 +857,41 @@ export const uniswapL1L2TestSuite = (
|
|
|
858
857
|
chainId: new Fr(l1Client.chain.id),
|
|
859
858
|
});
|
|
860
859
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
860
|
+
// ensure that user's funds were burnt
|
|
861
|
+
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
862
|
+
|
|
863
|
+
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
|
|
864
|
+
// before we can ask the witness helper for a covering root.
|
|
865
|
+
const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
|
|
866
|
+
if (minedReceipt.epochNumber === undefined) {
|
|
867
|
+
throw new Error('Withdraw tx is not yet in an epoch');
|
|
868
|
+
}
|
|
869
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
|
|
870
|
+
await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
|
|
871
|
+
|
|
872
|
+
const swapResult = await retryUntil(
|
|
873
|
+
() => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
|
|
874
|
+
'swap private l2 to l1 witness',
|
|
875
|
+
60,
|
|
876
|
+
1,
|
|
877
|
+
);
|
|
878
|
+
const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
|
|
879
|
+
const withdrawResult = await retryUntil(
|
|
880
|
+
() => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
|
|
881
|
+
'withdraw l2 to l1 witness',
|
|
882
|
+
60,
|
|
883
|
+
1,
|
|
866
884
|
);
|
|
867
885
|
|
|
868
|
-
const swapPrivateL2MessageIndex = swapResult
|
|
869
|
-
const swapPrivateSiblingPath = swapResult
|
|
886
|
+
const swapPrivateL2MessageIndex = swapResult.leafIndex;
|
|
887
|
+
const swapPrivateSiblingPath = swapResult.siblingPath;
|
|
870
888
|
|
|
871
|
-
const withdrawL2MessageIndex = withdrawResult
|
|
872
|
-
const withdrawSiblingPath = withdrawResult
|
|
889
|
+
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
890
|
+
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
873
891
|
|
|
874
892
|
const withdrawMessageMetadata = {
|
|
875
|
-
|
|
893
|
+
_epoch: BigInt(epoch),
|
|
894
|
+
_numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
|
|
876
895
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
877
896
|
_path: withdrawSiblingPath
|
|
878
897
|
.toBufferArray()
|
|
@@ -880,19 +899,14 @@ export const uniswapL1L2TestSuite = (
|
|
|
880
899
|
};
|
|
881
900
|
|
|
882
901
|
const swapPrivateMessageMetadata = {
|
|
883
|
-
|
|
902
|
+
_epoch: BigInt(epoch),
|
|
903
|
+
_numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
|
|
884
904
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
885
905
|
_path: swapPrivateSiblingPath
|
|
886
906
|
.toBufferArray()
|
|
887
907
|
.map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
|
|
888
908
|
};
|
|
889
909
|
|
|
890
|
-
// ensure that user's funds were burnt
|
|
891
|
-
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
892
|
-
|
|
893
|
-
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
894
|
-
await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
|
|
895
|
-
|
|
896
910
|
// On L1 call swap_public!
|
|
897
911
|
logger.info('call swap_public on L1');
|
|
898
912
|
const swapArgs = [
|
|
@@ -932,11 +946,11 @@ export const uniswapL1L2TestSuite = (
|
|
|
932
946
|
},
|
|
933
947
|
true,
|
|
934
948
|
);
|
|
935
|
-
await validateActionInteraction.send()
|
|
949
|
+
await validateActionInteraction.send();
|
|
936
950
|
|
|
937
951
|
// Call swap_public on L2
|
|
938
952
|
const secretHashForDepositingSwappedDai = Fr.random();
|
|
939
|
-
const withdrawReceipt = await uniswapL2Contract.methods
|
|
953
|
+
const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
|
|
940
954
|
.swap_public(
|
|
941
955
|
ownerAddress,
|
|
942
956
|
wethCrossChainHarness.l2Bridge.address,
|
|
@@ -950,8 +964,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
950
964
|
ownerEthAddress,
|
|
951
965
|
Fr.ZERO,
|
|
952
966
|
)
|
|
953
|
-
.send({ from: ownerAddress })
|
|
954
|
-
.wait();
|
|
967
|
+
.send({ from: ownerAddress });
|
|
955
968
|
|
|
956
969
|
const swapPublicContent = sha256ToField([
|
|
957
970
|
Buffer.from(
|
|
@@ -993,21 +1006,41 @@ export const uniswapL1L2TestSuite = (
|
|
|
993
1006
|
chainId: new Fr(l1Client.chain.id),
|
|
994
1007
|
});
|
|
995
1008
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1009
|
+
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
1010
|
+
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
1011
|
+
|
|
1012
|
+
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
|
|
1013
|
+
// before we can ask the witness helper for a covering root.
|
|
1014
|
+
const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
|
|
1015
|
+
if (minedReceipt.epochNumber === undefined) {
|
|
1016
|
+
throw new Error('Withdraw tx is not yet in an epoch');
|
|
1017
|
+
}
|
|
1018
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
|
|
1019
|
+
await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
|
|
1020
|
+
|
|
1021
|
+
const swapResult = await retryUntil(
|
|
1022
|
+
() => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPublicLeaf),
|
|
1023
|
+
'swap public l2 to l1 witness',
|
|
1024
|
+
60,
|
|
1025
|
+
1,
|
|
1026
|
+
);
|
|
1027
|
+
const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
|
|
1028
|
+
const withdrawResult = await retryUntil(
|
|
1029
|
+
() => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
|
|
1030
|
+
'withdraw l2 to l1 witness',
|
|
1031
|
+
60,
|
|
1032
|
+
1,
|
|
1001
1033
|
);
|
|
1002
1034
|
|
|
1003
|
-
const swapPublicL2MessageIndex = swapResult
|
|
1004
|
-
const swapPublicSiblingPath = swapResult
|
|
1035
|
+
const swapPublicL2MessageIndex = swapResult.leafIndex;
|
|
1036
|
+
const swapPublicSiblingPath = swapResult.siblingPath;
|
|
1005
1037
|
|
|
1006
|
-
const withdrawL2MessageIndex = withdrawResult
|
|
1007
|
-
const withdrawSiblingPath = withdrawResult
|
|
1038
|
+
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
1039
|
+
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
1008
1040
|
|
|
1009
1041
|
const withdrawMessageMetadata = {
|
|
1010
|
-
|
|
1042
|
+
_epoch: BigInt(epoch),
|
|
1043
|
+
_numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
|
|
1011
1044
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
1012
1045
|
_path: withdrawSiblingPath
|
|
1013
1046
|
.toBufferArray()
|
|
@@ -1015,19 +1048,14 @@ export const uniswapL1L2TestSuite = (
|
|
|
1015
1048
|
};
|
|
1016
1049
|
|
|
1017
1050
|
const swapPublicMessageMetadata = {
|
|
1018
|
-
|
|
1051
|
+
_epoch: BigInt(epoch),
|
|
1052
|
+
_numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
|
|
1019
1053
|
_leafIndex: BigInt(swapPublicL2MessageIndex),
|
|
1020
1054
|
_path: swapPublicSiblingPath
|
|
1021
1055
|
.toBufferArray()
|
|
1022
1056
|
.map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
|
|
1023
1057
|
};
|
|
1024
1058
|
|
|
1025
|
-
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
1026
|
-
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
1027
|
-
|
|
1028
|
-
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
1029
|
-
await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
|
|
1030
|
-
|
|
1031
1059
|
// Call swap_private on L1
|
|
1032
1060
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
1033
1061
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Waits until the archiver has seen the L1 to L2 message and indexed it. Unlike
|
|
7
|
+
* {@link waitForL1ToL2MessageReady} from `@aztec/aztec.js/messaging`, this does not
|
|
8
|
+
* require the L2 chain to have advanced to the message's checkpoint — it only confirms
|
|
9
|
+
* the message has been picked up from L1. Use this in tests that explicitly produce L2
|
|
10
|
+
* blocks afterwards to make the message consumable.
|
|
11
|
+
*/
|
|
12
|
+
export function waitForL1ToL2MessageSeen(
|
|
13
|
+
node: Pick<AztecNode, 'getL1ToL2MessageCheckpoint'>,
|
|
14
|
+
l1ToL2MessageHash: Fr,
|
|
15
|
+
opts: { timeoutSeconds: number },
|
|
16
|
+
) {
|
|
17
|
+
return retryUntil(
|
|
18
|
+
async () => (await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash)) !== undefined,
|
|
19
|
+
`L1 to L2 message ${l1ToL2MessageHash.toString()} seen`,
|
|
20
|
+
opts.timeoutSeconds,
|
|
21
|
+
1,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
4
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
5
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
6
|
-
import {
|
|
5
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
7
8
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
8
9
|
import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
|
|
10
|
+
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
9
11
|
|
|
10
12
|
import type { TokenSimulator } from './token_simulator.js';
|
|
11
13
|
|
|
@@ -28,7 +30,7 @@ export class LendingAccount {
|
|
|
28
30
|
* @returns Key in public space
|
|
29
31
|
*/
|
|
30
32
|
public key() {
|
|
31
|
-
return
|
|
33
|
+
return poseidon2Hash([this.address, this.secret]);
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -91,29 +93,45 @@ export class LendingSimulator {
|
|
|
91
93
|
public stableCoin: TokenSimulator,
|
|
92
94
|
) {}
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
prepare() {
|
|
95
97
|
this.accumulator = BASE;
|
|
96
|
-
|
|
97
|
-
this.time = Number(await this.rollup.getTimestampForSlot(slot));
|
|
98
|
+
this.time = 0;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Advances the simulator's accumulator and clock to match a block timestamp observed on chain.
|
|
103
|
+
* Call this BEFORE applying any accumulator-sensitive mutation (borrow/repay) so the mutation
|
|
104
|
+
* sees the same accumulator as the contract did during execution.
|
|
105
|
+
*/
|
|
106
|
+
observeBlockTimestamp(ts: number) {
|
|
107
|
+
const diff = ts - this.time;
|
|
108
|
+
if (diff > 0) {
|
|
109
|
+
this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(diff)), BASE);
|
|
110
|
+
}
|
|
111
|
+
this.time = ts;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async progressSlots(diff: number, _dateProvider?: TestDateProvider, node?: AztecNode & AztecNodeDebug) {
|
|
101
115
|
if (diff <= 1) {
|
|
102
116
|
return;
|
|
103
117
|
}
|
|
104
118
|
|
|
105
|
-
const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
this.time = ts;
|
|
119
|
+
const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.lastBlockTimestamp()));
|
|
120
|
+
const targetSlot = SlotNumber(slot + diff);
|
|
121
|
+
const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
|
|
109
122
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
123
|
+
// Queue-aware warp under AutomineSequencer: atomic warp + mineBlock that advances L2 time to the
|
|
124
|
+
// target slot. The cheat code routes through the AutomineSequencer queue when one is installed,
|
|
125
|
+
// and otherwise falls back to a manual warp + mineBlock loop.
|
|
126
|
+
if (node) {
|
|
127
|
+
await this.cc.warpL2TimeAtLeastTo(node, ts);
|
|
128
|
+
} else {
|
|
129
|
+
await this.cc.eth.warp(ts - this.ethereumSlotDuration);
|
|
114
130
|
}
|
|
115
|
-
|
|
116
|
-
|
|
131
|
+
|
|
132
|
+
// Mark the latest checkpoint as proven so the rollup does not reorg pending checkpoints when
|
|
133
|
+
// time jumps far enough forward to cross an unproven epoch boundary.
|
|
134
|
+
await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
|
|
117
135
|
}
|
|
118
136
|
|
|
119
137
|
depositPrivate(from: AztecAddress, onBehalfOf: Fr, amount: bigint) {
|
|
@@ -184,14 +202,16 @@ export class LendingSimulator {
|
|
|
184
202
|
|
|
185
203
|
expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
|
|
186
204
|
|
|
187
|
-
const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
|
|
205
|
+
const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
|
|
188
206
|
|
|
189
207
|
const interestAccumulator = asset['interest_accumulator'];
|
|
190
208
|
expect(interestAccumulator).toEqual(this.accumulator);
|
|
191
209
|
expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
|
|
192
210
|
|
|
193
211
|
for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
|
|
194
|
-
const privatePos = await this.lendingContract.methods
|
|
212
|
+
const { result: privatePos } = await this.lendingContract.methods
|
|
213
|
+
.get_position(key)
|
|
214
|
+
.simulate({ from: this.account.address });
|
|
195
215
|
expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
|
|
196
216
|
expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
|
|
197
217
|
expect(privatePos['debt']).toEqual(
|