@aztec/end-to-end 0.0.1-commit.9b94fc1 → 0.0.1-commit.9ee6fcc6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bench/client_flows/benchmark.d.ts +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +21 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +15 -16
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +136 -141
- 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.js +3 -1
- package/dest/bench/utils.d.ts +9 -8
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +31 -19
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +9 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +107 -113
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +20 -14
- 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 +92 -71
- package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -13
- package/dest/e2e_epochs/epochs_test.d.ts +27 -15
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +104 -52
- package/dest/e2e_fees/bridging_race.notest.js +4 -6
- package/dest/e2e_fees/fees_test.d.ts +21 -17
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +137 -145
- 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 +14 -16
- package/dest/e2e_multi_validator/utils.js +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +30 -40
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +4 -4
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +6 -9
- package/dest/e2e_p2p/p2p_network.d.ts +17 -14
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +141 -115
- 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 +190 -0
- package/dest/e2e_p2p/shared.d.ts +27 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +50 -22
- 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 +19 -10
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +100 -92
- 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 +30 -0
- package/dest/fixtures/e2e_prover_test.d.ts +16 -23
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +117 -138
- 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 +6 -3
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +8 -3
- 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/setup.d.ts +239 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +608 -0
- package/dest/fixtures/setup_p2p_test.d.ts +16 -9
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +43 -32
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +12 -8
- package/dest/fixtures/utils.d.ts +5 -637
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -647
- 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/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 +18 -6
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +27 -27
- package/dest/shared/gas_portal_test_harness.d.ts +12 -2
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +3 -3
- 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.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 +58 -39
- package/dest/simulators/lending_simulator.d.ts +6 -2
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +6 -6
- 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 +15 -5
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +109 -38
- package/dest/spartan/tx_metrics.d.ts +88 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +422 -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 +45 -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 +76 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +214 -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 +71 -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 +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +151 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +48 -45
- package/src/bench/client_flows/benchmark.ts +24 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +156 -215
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +36 -21
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +120 -145
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -126
- package/src/e2e_deploy_contract/deploy_test.ts +22 -15
- package/src/e2e_epochs/epochs_test.ts +172 -111
- package/src/e2e_fees/bridging_race.notest.ts +5 -11
- package/src/e2e_fees/fees_test.ts +178 -228
- package/src/e2e_l1_publisher/write_json.ts +16 -16
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
- package/src/e2e_p2p/inactivity_slash_test.ts +7 -10
- package/src/e2e_p2p/p2p_network.ts +204 -181
- package/src/e2e_p2p/reqresp/utils.ts +256 -0
- package/src/e2e_p2p/shared.ts +87 -29
- 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 +121 -119
- package/src/fixtures/authwit_proxy.ts +50 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +141 -188
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +12 -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 +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/setup.ts +905 -0
- package/src/fixtures/setup_p2p_test.ts +43 -47
- package/src/fixtures/token_utils.ts +10 -6
- package/src/fixtures/utils.ts +27 -966
- package/src/fixtures/web3signer.ts +1 -1
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +3 -3
- 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 +30 -43
- package/src/shared/gas_portal_test_harness.ts +3 -3
- 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 +86 -102
- package/src/simulators/lending_simulator.ts +11 -7
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/DEVELOP.md +7 -0
- package/src/spartan/setup_test_wallets.ts +167 -27
- package/src/spartan/tx_metrics.ts +376 -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 +294 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +213 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
- 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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { EthCheatCodes } from '@aztec/aztec/testing';
|
|
3
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
4
|
+
/**
|
|
5
|
+
* Mock StateView contract for testing the Uniswap price oracle.
|
|
6
|
+
*
|
|
7
|
+
* Wraps a compiled Solidity contract that mimics the Uniswap V4 StateView's getSlot0 function.
|
|
8
|
+
* The mock allows setting return values dynamically for testing different price scenarios.
|
|
9
|
+
*
|
|
10
|
+
* Solidity source:
|
|
11
|
+
* ```solidity
|
|
12
|
+
* // SPDX-License-Identifier: Apache-2.0
|
|
13
|
+
* pragma solidity >=0.8.27;
|
|
14
|
+
*
|
|
15
|
+
* contract MockStateView {
|
|
16
|
+
* uint160 public sqrtPriceX96;
|
|
17
|
+
* int24 public tick;
|
|
18
|
+
* uint24 public protocolFee;
|
|
19
|
+
* uint24 public lpFee;
|
|
20
|
+
*
|
|
21
|
+
* function setReturnValues(
|
|
22
|
+
* uint160 _sqrtPriceX96,
|
|
23
|
+
* int24 _tick,
|
|
24
|
+
* uint24 _protocolFee,
|
|
25
|
+
* uint24 _lpFee
|
|
26
|
+
* ) external {
|
|
27
|
+
* sqrtPriceX96 = _sqrtPriceX96;
|
|
28
|
+
* tick = _tick;
|
|
29
|
+
* protocolFee = _protocolFee;
|
|
30
|
+
* lpFee = _lpFee;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* function getSlot0(bytes32 poolId) external view returns (uint160, int24, uint24, uint24) {
|
|
34
|
+
* return (sqrtPriceX96, tick, protocolFee, lpFee);
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class MockStateView {
|
|
40
|
+
private readonly address;
|
|
41
|
+
private readonly walletClient;
|
|
42
|
+
private readonly log;
|
|
43
|
+
private static readonly BYTECODE;
|
|
44
|
+
private static readonly ABI;
|
|
45
|
+
private constructor();
|
|
46
|
+
/**
|
|
47
|
+
* Deploys the mock StateView contract at the specified address using etch.
|
|
48
|
+
* @param ethCheatCodes - Cheat codes for etching bytecode
|
|
49
|
+
* @param walletClient - Wallet client for sending transactions
|
|
50
|
+
* @param address - Address to deploy the mock at (typically the real StateView address)
|
|
51
|
+
*/
|
|
52
|
+
static deploy(ethCheatCodes: EthCheatCodes, walletClient: ExtendedViemWalletClient, address: EthAddress): Promise<MockStateView>;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the price using the ethPerFeeAssetE12 format (same as rollup contract).
|
|
55
|
+
* Computes the corresponding sqrtPriceX96 internally.
|
|
56
|
+
*
|
|
57
|
+
* Math (from fee_asset_price_oracle.ts):
|
|
58
|
+
* ethPerFeeAssetE12 = 1e12 * 2^192 / sqrtPriceX96^2
|
|
59
|
+
*
|
|
60
|
+
* Inverted:
|
|
61
|
+
* sqrtPriceX96^2 = 1e12 * 2^192 / ethPerFeeAssetE12
|
|
62
|
+
* sqrtPriceX96 = sqrt(1e12 * 2^192 / ethPerFeeAssetE12)
|
|
63
|
+
*
|
|
64
|
+
* @param ethPerFeeAssetE12 - The price in ETH per fee asset, scaled by 1e12
|
|
65
|
+
*/
|
|
66
|
+
setEthPerFeeAsset(ethPerFeeAssetE12: bigint): Promise<import("viem").TransactionReceipt>;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the sqrtPriceX96 value directly (Uniswap's price encoding).
|
|
69
|
+
* @param sqrtPriceX96 - The sqrtPriceX96 value
|
|
70
|
+
* @param tick - The tick value (default 10)
|
|
71
|
+
* @param protocolFee - The protocol fee (default 0)
|
|
72
|
+
* @param lpFee - The LP fee (default 500)
|
|
73
|
+
*/
|
|
74
|
+
setSqrtPriceX96(sqrtPriceX96: bigint, tick?: number, protocolFee?: number, lpFee?: number): Promise<import("viem").TransactionReceipt>;
|
|
75
|
+
/**
|
|
76
|
+
* Converts ethPerFeeAssetE12 to sqrtPriceX96 (inverse of sqrtPriceX96ToEthPerFeeAssetE12).
|
|
77
|
+
*
|
|
78
|
+
* Math:
|
|
79
|
+
* sqrtPriceX96 = sqrt(1e12 * 2^192 / ethPerFeeAssetE12)
|
|
80
|
+
*/
|
|
81
|
+
ethPerFeeAssetE12ToSqrtPriceX96(ethPerFeeAssetE12: bigint): bigint;
|
|
82
|
+
/** Integer square root using Newton's method */
|
|
83
|
+
bigintSqrt(n: bigint): bigint;
|
|
84
|
+
}
|
|
85
|
+
export declare function diffInBps(a: bigint, b: bigint): bigint;
|
|
86
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja19zdGF0ZV92aWV3LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2hhcmVkL21vY2tfc3RhdGVfdmlldy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFFdkQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUl0RTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQWtDRztBQUNILHFCQUFhLGFBQWE7SUFxRHRCLE9BQU8sQ0FBQyxRQUFRLENBQUMsT0FBTztJQUN4QixPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBdER0QixPQUFPLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQ20rRTtJQUNuZ0YsT0FBTyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsR0FBRyxDQStDaEI7SUFFWCxPQUFPLGVBSUg7SUFFSjs7Ozs7T0FLRztJQUNILE9BQWEsTUFBTSxDQUNqQixhQUFhLEVBQUUsYUFBYSxFQUM1QixZQUFZLEVBQUUsd0JBQXdCLEVBQ3RDLE9BQU8sRUFBRSxVQUFVLEdBQ2xCLE9BQU8sQ0FBQyxhQUFhLENBQUMsQ0FHeEI7SUFFRDs7Ozs7Ozs7Ozs7O09BWUc7SUFDRyxpQkFBaUIsQ0FBQyxpQkFBaUIsRUFBRSxNQUFNLDhDQUdoRDtJQUVEOzs7Ozs7T0FNRztJQUNHLGVBQWUsQ0FBQyxZQUFZLEVBQUUsTUFBTSxFQUFFLElBQUksR0FBRSxNQUFXLEVBQUUsV0FBVyxHQUFFLE1BQVUsRUFBRSxLQUFLLEdBQUUsTUFBWSw4Q0FVMUc7SUFFRDs7Ozs7T0FLRztJQUNILCtCQUErQixDQUFDLGlCQUFpQixFQUFFLE1BQU0sR0FBRyxNQUFNLENBT2pFO0lBRUQsZ0RBQWdEO0lBQ2hELFVBQVUsQ0FBQyxDQUFDLEVBQUUsTUFBTSxHQUFHLE1BQU0sQ0FjNUI7Q0FDRjtBQUVELHdCQUFnQixTQUFTLENBQUMsQ0FBQyxFQUFFLE1BQU0sRUFBRSxDQUFDLEVBQUUsTUFBTSxHQUFHLE1BQU0sQ0FFdEQifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock_state_view.d.ts","sourceRoot":"","sources":["../../src/shared/mock_state_view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,aAAa;IAqDtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAtDtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CACm+E;IACngF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CA+ChB;IAEX,OAAO,eAIH;IAEJ;;;;;OAKG;IACH,OAAa,MAAM,CACjB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,wBAAwB,EACtC,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC,CAGxB;IAED;;;;;;;;;;;;OAYG;IACG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,8CAGhD;IAED;;;;;;OAMG;IACG,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,GAAE,MAAW,EAAE,WAAW,GAAE,MAAU,EAAE,KAAK,GAAE,MAAY,8CAU1G;IAED;;;;;OAKG;IACH,+BAA+B,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAOjE;IAED,gDAAgD;IAChD,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAc5B;CACF;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Mock StateView contract for testing the Uniswap price oracle.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a compiled Solidity contract that mimics the Uniswap V4 StateView's getSlot0 function.
|
|
7
|
+
* The mock allows setting return values dynamically for testing different price scenarios.
|
|
8
|
+
*
|
|
9
|
+
* Solidity source:
|
|
10
|
+
* ```solidity
|
|
11
|
+
* // SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
* pragma solidity >=0.8.27;
|
|
13
|
+
*
|
|
14
|
+
* contract MockStateView {
|
|
15
|
+
* uint160 public sqrtPriceX96;
|
|
16
|
+
* int24 public tick;
|
|
17
|
+
* uint24 public protocolFee;
|
|
18
|
+
* uint24 public lpFee;
|
|
19
|
+
*
|
|
20
|
+
* function setReturnValues(
|
|
21
|
+
* uint160 _sqrtPriceX96,
|
|
22
|
+
* int24 _tick,
|
|
23
|
+
* uint24 _protocolFee,
|
|
24
|
+
* uint24 _lpFee
|
|
25
|
+
* ) external {
|
|
26
|
+
* sqrtPriceX96 = _sqrtPriceX96;
|
|
27
|
+
* tick = _tick;
|
|
28
|
+
* protocolFee = _protocolFee;
|
|
29
|
+
* lpFee = _lpFee;
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* function getSlot0(bytes32 poolId) external view returns (uint160, int24, uint24, uint24) {
|
|
33
|
+
* return (sqrtPriceX96, tick, protocolFee, lpFee);
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/ export class MockStateView {
|
|
38
|
+
address;
|
|
39
|
+
walletClient;
|
|
40
|
+
log;
|
|
41
|
+
static BYTECODE = '0x608060405234801561000f575f5ffd5b5060043610610060575f3560e01c80633eaf5d9f14610064578063704ce43e146100825780638db791d2146100a0578063b0e21e8a146100be578063b52e4bdd146100dc578063c815641c146100f8575b5f5ffd5b61006c61012b565b60405161007991906102ab565b60405180910390f35b61008a61013d565b60405161009791906102e1565b60405180910390f35b6100a8610151565b6040516100b59190610328565b60405180910390f35b6100c6610175565b6040516100d391906102e1565b60405180910390f35b6100f660048036038101906100f191906103c3565b610189565b005b610112600480360381019061010d919061045a565b61022b565b6040516101229493929190610485565b60405180910390f35b5f60149054906101000a900460020b81565b5f601a9054906101000a900462ffffff1681565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f60179054906101000a900462ffffff1681565b835f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550825f60146101000a81548162ffffff021916908360020b62ffffff160217905550815f60176101000a81548162ffffff021916908362ffffff160217905550805f601a6101000a81548162ffffff021916908362ffffff16021790555050505050565b5f5f5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff165f60149054906101000a900460020b5f60179054906101000a900462ffffff165f601a9054906101000a900462ffffff1693509350935093509193509193565b5f8160020b9050919050565b6102a581610290565b82525050565b5f6020820190506102be5f83018461029c565b92915050565b5f62ffffff82169050919050565b6102db816102c4565b82525050565b5f6020820190506102f45f8301846102d2565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b610322816102fa565b82525050565b5f60208201905061033b5f830184610319565b92915050565b5f5ffd5b61034e816102fa565b8114610358575f5ffd5b50565b5f8135905061036981610345565b92915050565b61037881610290565b8114610382575f5ffd5b50565b5f813590506103938161036f565b92915050565b6103a2816102c4565b81146103ac575f5ffd5b50565b5f813590506103bd81610399565b92915050565b5f5f5f5f608085870312156103db576103da610341565b5b5f6103e88782880161035b565b94505060206103f987828801610385565b935050604061040a878288016103af565b925050606061041b878288016103af565b91505092959194509250565b5f819050919050565b61043981610427565b8114610443575f5ffd5b50565b5f8135905061045481610430565b92915050565b5f6020828403121561046f5761046e610341565b5b5f61047c84828501610446565b91505092915050565b5f6080820190506104985f830187610319565b6104a5602083018661029c565b6104b260408301856102d2565b6104bf60608301846102d2565b9594505050505056fea2646970667358221220f8b1bfff284535bc078368ed34bd5e78981644845f3c9c1f5a4b8448c976805464736f6c634300081f0033';
|
|
42
|
+
static ABI = [
|
|
43
|
+
{
|
|
44
|
+
type: 'function',
|
|
45
|
+
name: 'setReturnValues',
|
|
46
|
+
inputs: [
|
|
47
|
+
{
|
|
48
|
+
name: '_sqrtPriceX96',
|
|
49
|
+
type: 'uint160'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: '_tick',
|
|
53
|
+
type: 'int24'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: '_protocolFee',
|
|
57
|
+
type: 'uint24'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: '_lpFee',
|
|
61
|
+
type: 'uint24'
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
outputs: [],
|
|
65
|
+
stateMutability: 'nonpayable'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
inputs: [
|
|
69
|
+
{
|
|
70
|
+
internalType: 'bytes32',
|
|
71
|
+
name: 'poolId',
|
|
72
|
+
type: 'bytes32'
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
name: 'getSlot0',
|
|
76
|
+
outputs: [
|
|
77
|
+
{
|
|
78
|
+
internalType: 'uint160',
|
|
79
|
+
name: '',
|
|
80
|
+
type: 'uint160'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
internalType: 'int24',
|
|
84
|
+
name: '',
|
|
85
|
+
type: 'int24'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
internalType: 'uint24',
|
|
89
|
+
name: '',
|
|
90
|
+
type: 'uint24'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
internalType: 'uint24',
|
|
94
|
+
name: '',
|
|
95
|
+
type: 'uint24'
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
stateMutability: 'view',
|
|
99
|
+
type: 'function'
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
constructor(address, walletClient, log = createLogger('mock-state-view')){
|
|
103
|
+
this.address = address;
|
|
104
|
+
this.walletClient = walletClient;
|
|
105
|
+
this.log = log;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deploys the mock StateView contract at the specified address using etch.
|
|
109
|
+
* @param ethCheatCodes - Cheat codes for etching bytecode
|
|
110
|
+
* @param walletClient - Wallet client for sending transactions
|
|
111
|
+
* @param address - Address to deploy the mock at (typically the real StateView address)
|
|
112
|
+
*/ static async deploy(ethCheatCodes, walletClient, address) {
|
|
113
|
+
await ethCheatCodes.etch(address, MockStateView.BYTECODE);
|
|
114
|
+
return new MockStateView(address, walletClient);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sets the price using the ethPerFeeAssetE12 format (same as rollup contract).
|
|
118
|
+
* Computes the corresponding sqrtPriceX96 internally.
|
|
119
|
+
*
|
|
120
|
+
* Math (from fee_asset_price_oracle.ts):
|
|
121
|
+
* ethPerFeeAssetE12 = 1e12 * 2^192 / sqrtPriceX96^2
|
|
122
|
+
*
|
|
123
|
+
* Inverted:
|
|
124
|
+
* sqrtPriceX96^2 = 1e12 * 2^192 / ethPerFeeAssetE12
|
|
125
|
+
* sqrtPriceX96 = sqrt(1e12 * 2^192 / ethPerFeeAssetE12)
|
|
126
|
+
*
|
|
127
|
+
* @param ethPerFeeAssetE12 - The price in ETH per fee asset, scaled by 1e12
|
|
128
|
+
*/ async setEthPerFeeAsset(ethPerFeeAssetE12) {
|
|
129
|
+
const sqrtPriceX96 = this.ethPerFeeAssetE12ToSqrtPriceX96(ethPerFeeAssetE12);
|
|
130
|
+
return await this.setSqrtPriceX96(sqrtPriceX96);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Sets the sqrtPriceX96 value directly (Uniswap's price encoding).
|
|
134
|
+
* @param sqrtPriceX96 - The sqrtPriceX96 value
|
|
135
|
+
* @param tick - The tick value (default 10)
|
|
136
|
+
* @param protocolFee - The protocol fee (default 0)
|
|
137
|
+
* @param lpFee - The LP fee (default 500)
|
|
138
|
+
*/ async setSqrtPriceX96(sqrtPriceX96, tick = 10, protocolFee = 0, lpFee = 500) {
|
|
139
|
+
const contract = getContract({
|
|
140
|
+
address: this.address.toString(),
|
|
141
|
+
abi: MockStateView.ABI,
|
|
142
|
+
client: this.walletClient
|
|
143
|
+
});
|
|
144
|
+
const hash = await contract.write.setReturnValues([
|
|
145
|
+
sqrtPriceX96,
|
|
146
|
+
tick,
|
|
147
|
+
protocolFee,
|
|
148
|
+
lpFee
|
|
149
|
+
]);
|
|
150
|
+
this.log.info(`Set sqrtPriceX96 to ${sqrtPriceX96}`);
|
|
151
|
+
return await this.walletClient.waitForTransactionReceipt({
|
|
152
|
+
hash
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Converts ethPerFeeAssetE12 to sqrtPriceX96 (inverse of sqrtPriceX96ToEthPerFeeAssetE12).
|
|
157
|
+
*
|
|
158
|
+
* Math:
|
|
159
|
+
* sqrtPriceX96 = sqrt(1e12 * 2^192 / ethPerFeeAssetE12)
|
|
160
|
+
*/ ethPerFeeAssetE12ToSqrtPriceX96(ethPerFeeAssetE12) {
|
|
161
|
+
if (ethPerFeeAssetE12 === 0n) {
|
|
162
|
+
throw new Error('Cannot convert zero ethPerFeeAssetE12');
|
|
163
|
+
}
|
|
164
|
+
const Q192 = 2n ** 192n;
|
|
165
|
+
const sqrtPriceSquared = 10n ** 12n * Q192 / ethPerFeeAssetE12;
|
|
166
|
+
return this.bigintSqrt(sqrtPriceSquared);
|
|
167
|
+
}
|
|
168
|
+
/** Integer square root using Newton's method */ bigintSqrt(n) {
|
|
169
|
+
if (n < 0n) {
|
|
170
|
+
throw new Error('Cannot compute sqrt of negative number');
|
|
171
|
+
}
|
|
172
|
+
if (n === 0n) {
|
|
173
|
+
return 0n;
|
|
174
|
+
}
|
|
175
|
+
let x = n;
|
|
176
|
+
let y = (x + 1n) / 2n;
|
|
177
|
+
while(y < x){
|
|
178
|
+
x = y;
|
|
179
|
+
y = (x + n / x) / 2n;
|
|
180
|
+
}
|
|
181
|
+
return x;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
export function diffInBps(a, b) {
|
|
185
|
+
return (a - b) * 10000n / b;
|
|
186
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import type { SentTx } from '@aztec/aztec.js/contracts';
|
|
3
2
|
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
4
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
5
|
+
export declare const submitTxsTo: (wallet: TestWallet, submitter: AztecAddress, numTxs: number, logger: Logger) => Promise<TxHash[]>;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3VibWl0LXRyYW5zYWN0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoYXJlZC9zdWJtaXQtdHJhbnNhY3Rpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUd6RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEVBQUUsTUFBTSxFQUE0QixNQUFNLG9CQUFvQixDQUFDO0FBR3RFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBR2hFLGVBQU8sTUFBTSxXQUFXLG9HQXFCdkIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-transactions.d.ts","sourceRoot":"","sources":["../../src/shared/submit-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"submit-transactions.d.ts","sourceRoot":"","sources":["../../src/shared/submit-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAA4B,MAAM,oBAAoB,CAAC;AAGtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,WAAW,oGAqBvB,CAAC"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
1
2
|
import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields';
|
|
2
3
|
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
3
4
|
import { times } from '@aztec/foundation/collection';
|
|
4
5
|
// submits a set of transactions to the provided Wallet
|
|
5
6
|
export const submitTxsTo = async (wallet, submitter, numTxs, logger)=>{
|
|
6
|
-
const
|
|
7
|
+
const txHashes = [];
|
|
7
8
|
await Promise.all(times(numTxs, async ()=>{
|
|
8
9
|
const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
|
|
9
10
|
const deployMethod = await accountManager.getDeployMethod();
|
|
10
|
-
const
|
|
11
|
-
from: submitter
|
|
11
|
+
const { txHash } = await deployMethod.send({
|
|
12
|
+
from: submitter,
|
|
13
|
+
wait: NO_WAIT
|
|
12
14
|
});
|
|
13
|
-
const txHash = await tx.getTxHash();
|
|
14
15
|
logger.info(`Tx sent with hash ${txHash}`);
|
|
15
|
-
const receipt = await
|
|
16
|
-
expect(receipt).
|
|
17
|
-
status: TxStatus.PENDING,
|
|
18
|
-
error: ''
|
|
19
|
-
}));
|
|
16
|
+
const receipt = await wallet.getTxReceipt(txHash);
|
|
17
|
+
expect(receipt.status).toBe(TxStatus.PENDING);
|
|
20
18
|
logger.info(`Receipt received for ${txHash}`);
|
|
21
|
-
|
|
19
|
+
txHashes.push(txHash);
|
|
22
20
|
}));
|
|
23
|
-
return
|
|
21
|
+
return txHashes;
|
|
24
22
|
};
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { CheatCodes } from '@aztec/aztec/testing';
|
|
5
|
-
import { type DeployL1ContractsReturnType, type ExtendedViemWalletClient } from '@aztec/ethereum';
|
|
6
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
7
|
-
/** Objects to be returned by the uniswap setup function */
|
|
8
|
-
export type UniswapSetupContext = {
|
|
9
|
-
/** Aztec Node instance */
|
|
10
|
-
aztecNode: AztecNode;
|
|
11
|
-
/** Logger instance named as the current test. */
|
|
12
|
-
logger: Logger;
|
|
13
|
-
/** The L1 wallet client, extended with public actions. */
|
|
14
|
-
l1Client: ExtendedViemWalletClient;
|
|
15
|
-
/** The wallet. */
|
|
16
|
-
wallet: TestWallet;
|
|
17
|
-
/** The owner address. */
|
|
18
|
-
ownerAddress: AztecAddress;
|
|
19
|
-
/** The sponsor wallet. */
|
|
20
|
-
sponsorAddress: AztecAddress;
|
|
21
|
-
/** */
|
|
22
|
-
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
23
|
-
/** Cheat codes instance. */
|
|
24
|
-
cheatCodes: CheatCodes;
|
|
25
|
-
};
|
|
26
|
-
export declare const uniswapL1L2TestSuite: (setup: () => Promise<UniswapSetupContext>, cleanup: () => Promise<void>, expectedForkBlockNumber?: number) => void;
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pc3dhcF9sMV9sMi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoYXJlZC91bmlzd2FwX2wxX2wyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQWMsTUFBTSwyQkFBMkIsQ0FBQztBQUlyRSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxFQUNMLEtBQUssMkJBQTJCLEVBQ2hDLEtBQUssd0JBQXdCLEVBSTlCLE1BQU0saUJBQWlCLENBQUM7QUFNekIsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFpQjVELDJEQUEyRDtBQUMzRCxNQUFNLE1BQU0sbUJBQW1CLEdBQUc7SUFDaEMsMEJBQTBCO0lBQzFCLFNBQVMsRUFBRSxTQUFTLENBQUM7SUFDckIsaURBQWlEO0lBQ2pELE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDZiwwREFBMEQ7SUFDMUQsUUFBUSxFQUFFLHdCQUF3QixDQUFDO0lBQ25DLGtCQUFrQjtJQUNsQixNQUFNLEVBQUUsVUFBVSxDQUFDO0lBQ25CLHlCQUF5QjtJQUN6QixZQUFZLEVBQUUsWUFBWSxDQUFDO0lBQzNCLDBCQUEwQjtJQUMxQixjQUFjLEVBQUUsWUFBWSxDQUFDO0lBQzdCLE9BQU87SUFDUCx1QkFBdUIsRUFBRSwyQkFBMkIsQ0FBQztJQUNyRCw0QkFBNEI7SUFDNUIsVUFBVSxFQUFFLFVBQVUsQ0FBQztDQUN4QixDQUFDO0FBRUYsZUFBTyxNQUFNLG9CQUFvQixxSEFtK0JoQyxDQUFDIn0=
|
|
1
|
+
import { type EndToEndContext } from '../fixtures/utils.js';
|
|
2
|
+
export declare const uniswapL1L2TestSuite: (setup: () => Promise<EndToEndContext>, cleanup: () => Promise<void>, expectedForkBlockNumber?: number) => void;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pc3dhcF9sMV9sMi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoYXJlZC91bmlzd2FwX2wxX2wyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXVCQSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQW1DLE1BQU0sc0JBQXNCLENBQUM7QUFhN0YsZUFBTyxNQUFNLG9CQUFvQixpSEF1K0JoQyxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,eAAe,EAAmC,MAAM,sBAAsB,CAAC;AAa7F,eAAO,MAAM,oBAAoB,iHAu+BhC,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
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
|
-
import { RollupContract
|
|
6
|
-
import {
|
|
6
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
8
|
+
import { extractEvent } from '@aztec/ethereum/utils';
|
|
9
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
10
|
+
import { sha256ToField } from '@aztec/foundation/crypto/sha256';
|
|
7
11
|
import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
8
12
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
9
13
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
@@ -45,7 +49,10 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
45
49
|
let cheatCodes;
|
|
46
50
|
let version;
|
|
47
51
|
beforeAll(async ()=>{
|
|
48
|
-
|
|
52
|
+
const t = await setup();
|
|
53
|
+
({ aztecNode, logger, deployL1ContractsValues, cheatCodes, wallet, accounts: [ownerAddress, sponsorAddress] } = t);
|
|
54
|
+
l1Client = deployL1ContractsValues.l1Client;
|
|
55
|
+
t.watcher.setIsMarkingAsProven(false);
|
|
49
56
|
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
50
57
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
51
58
|
}
|
|
@@ -68,9 +75,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
68
75
|
client: l1Client
|
|
69
76
|
});
|
|
70
77
|
// deploy l2 uniswap contract and attach to portal
|
|
71
|
-
uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
|
|
78
|
+
({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
|
|
72
79
|
from: ownerAddress
|
|
73
|
-
})
|
|
80
|
+
}));
|
|
74
81
|
const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
75
82
|
await uniswapPortal.write.initialize([
|
|
76
83
|
registryAddress.toString(),
|
|
@@ -117,12 +124,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
117
124
|
// 4. Swap on L1 - sends L2 to L1 message to withdraw WETH to L1 and another message to swap assets.
|
|
118
125
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
119
126
|
const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
120
|
-
const l2UniswapInteractionReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
|
|
127
|
+
const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
|
|
121
128
|
from: ownerAddress,
|
|
122
129
|
authWitnesses: [
|
|
123
130
|
transferToPublicAuhtwit
|
|
124
131
|
]
|
|
125
|
-
})
|
|
132
|
+
});
|
|
126
133
|
const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
|
|
127
134
|
const swapPrivateContent = sha256ToField([
|
|
128
135
|
Buffer.from(toFunctionSelector(swapPrivateFunction).substring(2), 'hex'),
|
|
@@ -158,24 +165,28 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
158
165
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
159
166
|
// ensure that uniswap contract didn't eat the funds.
|
|
160
167
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
161
|
-
// Since the outbox is only consumable when the
|
|
162
|
-
await
|
|
168
|
+
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
|
|
169
|
+
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, swapPrivateLeaf, l2UniswapInteractionReceipt.txHash);
|
|
170
|
+
const { epochNumber: epoch } = swapResult;
|
|
171
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
|
|
172
|
+
await waitForProven(aztecNode, l2UniswapInteractionReceipt, {
|
|
173
|
+
provenTimeout: 300
|
|
174
|
+
});
|
|
163
175
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
164
176
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
165
177
|
const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(daiCrossChainHarness.tokenPortalAddress);
|
|
166
|
-
const
|
|
167
|
-
const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, l2UniswapInteractionReceipt.blockNumber, withdrawLeaf);
|
|
178
|
+
const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, l2UniswapInteractionReceipt.txHash);
|
|
168
179
|
const swapPrivateL2MessageIndex = swapResult.leafIndex;
|
|
169
180
|
const swapPrivateSiblingPath = swapResult.siblingPath;
|
|
170
181
|
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
171
182
|
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
172
183
|
const withdrawMessageMetadata = {
|
|
173
|
-
|
|
184
|
+
_epoch: BigInt(epoch),
|
|
174
185
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
175
186
|
_path: withdrawSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
176
187
|
};
|
|
177
188
|
const swapPrivateMessageMetadata = {
|
|
178
|
-
|
|
189
|
+
_epoch: BigInt(epoch),
|
|
179
190
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
180
191
|
_path: swapPrivateSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
181
192
|
};
|
|
@@ -302,9 +313,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
302
313
|
// ownerEthAddress,
|
|
303
314
|
// nonceForSwap,
|
|
304
315
|
// );
|
|
305
|
-
// await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send()
|
|
316
|
+
// await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
|
|
306
317
|
// // 4.2 Call swap_public from user2 on behalf of owner
|
|
307
|
-
// const uniswapL2Interaction = await action.send()
|
|
318
|
+
// const uniswapL2Interaction = await action.send();
|
|
308
319
|
// const swapPublicContent = sha256ToField([
|
|
309
320
|
// Buffer.from(
|
|
310
321
|
// toFunctionSelector('swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)').substring(
|
|
@@ -357,14 +368,14 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
357
368
|
// withdrawLeaf,
|
|
358
369
|
// );
|
|
359
370
|
// const withdrawMessageMetadata = {
|
|
360
|
-
//
|
|
371
|
+
// _epoch: epoch,
|
|
361
372
|
// _leafIndex: BigInt(withdrawL2MessageIndex),
|
|
362
373
|
// _path: withdrawSiblingPath
|
|
363
374
|
// .toBufferArray()
|
|
364
375
|
// .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
|
|
365
376
|
// };
|
|
366
377
|
// const swapPrivateMessageMetadata = {
|
|
367
|
-
//
|
|
378
|
+
// _epoch: epoch,
|
|
368
379
|
// _leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
369
380
|
// _path: swapPrivateSiblingPath
|
|
370
381
|
// .toBufferArray()
|
|
@@ -461,7 +472,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
461
472
|
authWitnesses: [
|
|
462
473
|
transferToPublicAuthwith
|
|
463
474
|
]
|
|
464
|
-
})
|
|
475
|
+
})).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
465
476
|
});
|
|
466
477
|
// edge cases for public flow:
|
|
467
478
|
it("I don't need approval to call swap_public if I'm swapping on my own behalf", async ()=>{
|
|
@@ -473,12 +484,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
473
484
|
caller: uniswapL2Contract.address,
|
|
474
485
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
|
|
475
486
|
}, true);
|
|
476
|
-
await validateActionInteraction.send()
|
|
487
|
+
await validateActionInteraction.send();
|
|
477
488
|
// No approval to call `swap` but should work even without it:
|
|
478
489
|
const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
479
490
|
await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
|
|
480
491
|
from: ownerAddress
|
|
481
|
-
})
|
|
492
|
+
});
|
|
482
493
|
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
483
494
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
484
495
|
});
|
|
@@ -493,7 +504,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
493
504
|
caller: approvedUser,
|
|
494
505
|
action
|
|
495
506
|
}, true);
|
|
496
|
-
await validateActionInteraction.send()
|
|
507
|
+
await validateActionInteraction.send();
|
|
497
508
|
await expect(action.simulate({
|
|
498
509
|
from: sponsorAddress
|
|
499
510
|
})).rejects.toThrow(/unauthorized/);
|
|
@@ -505,7 +516,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
505
516
|
caller: uniswapL2Contract.address,
|
|
506
517
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
|
|
507
518
|
}, true);
|
|
508
|
-
await validateActionInteraction.send()
|
|
519
|
+
await validateActionInteraction.send();
|
|
509
520
|
await expect(uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, new Fr(420), uniswapFeeTier, minimumOutputAmount, ownerAddress, Fr.random(), ownerEthAddress, Fr.ZERO).simulate({
|
|
510
521
|
from: ownerAddress
|
|
511
522
|
})).rejects.toThrow(/unauthorized/);
|
|
@@ -526,12 +537,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
526
537
|
// Swap
|
|
527
538
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
528
539
|
const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
529
|
-
const withdrawReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
|
|
540
|
+
const { receipt: withdrawReceipt } = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
|
|
530
541
|
from: ownerAddress,
|
|
531
542
|
authWitnesses: [
|
|
532
543
|
transferToPublicAuhtwit
|
|
533
544
|
]
|
|
534
|
-
})
|
|
545
|
+
});
|
|
535
546
|
const swapPrivateContent = sha256ToField([
|
|
536
547
|
Buffer.from(toFunctionSelector('swap_private(address,uint256,uint24,address,uint256,bytes32,address)').substring(2), 'hex'),
|
|
537
548
|
wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
|
|
@@ -562,26 +573,30 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
562
573
|
rollupVersion: new Fr(version),
|
|
563
574
|
chainId: new Fr(l1Client.chain.id)
|
|
564
575
|
});
|
|
565
|
-
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.
|
|
566
|
-
const
|
|
576
|
+
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, swapPrivateLeaf, withdrawReceipt.txHash);
|
|
577
|
+
const { epochNumber: epoch } = swapResult;
|
|
578
|
+
const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash);
|
|
567
579
|
const swapPrivateL2MessageIndex = swapResult.leafIndex;
|
|
568
580
|
const swapPrivateSiblingPath = swapResult.siblingPath;
|
|
569
581
|
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
570
582
|
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
571
583
|
const withdrawMessageMetadata = {
|
|
572
|
-
|
|
584
|
+
_epoch: BigInt(epoch),
|
|
573
585
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
574
586
|
_path: withdrawSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
575
587
|
};
|
|
576
588
|
const swapPrivateMessageMetadata = {
|
|
577
|
-
|
|
589
|
+
_epoch: BigInt(epoch),
|
|
578
590
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
579
591
|
_path: swapPrivateSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
580
592
|
};
|
|
581
593
|
// ensure that user's funds were burnt
|
|
582
594
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
583
|
-
// Since the outbox is only consumable when the
|
|
584
|
-
await cheatCodes.rollup.
|
|
595
|
+
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
|
|
596
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
|
|
597
|
+
await waitForProven(aztecNode, withdrawReceipt, {
|
|
598
|
+
provenTimeout: 300
|
|
599
|
+
});
|
|
585
600
|
// On L1 call swap_public!
|
|
586
601
|
logger.info('call swap_public on L1');
|
|
587
602
|
const swapArgs = [
|
|
@@ -611,12 +626,12 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
611
626
|
caller: uniswapL2Contract.address,
|
|
612
627
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferApproval)
|
|
613
628
|
}, true);
|
|
614
|
-
await validateActionInteraction.send()
|
|
629
|
+
await validateActionInteraction.send();
|
|
615
630
|
// Call swap_public on L2
|
|
616
631
|
const secretHashForDepositingSwappedDai = Fr.random();
|
|
617
|
-
const withdrawReceipt = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
|
|
632
|
+
const { receipt: withdrawReceipt } = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
|
|
618
633
|
from: ownerAddress
|
|
619
|
-
})
|
|
634
|
+
});
|
|
620
635
|
const swapPublicContent = sha256ToField([
|
|
621
636
|
Buffer.from(toFunctionSelector('swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)').substring(2), 'hex'),
|
|
622
637
|
wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
|
|
@@ -648,26 +663,30 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
648
663
|
rollupVersion: new Fr(version),
|
|
649
664
|
chainId: new Fr(l1Client.chain.id)
|
|
650
665
|
});
|
|
651
|
-
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.
|
|
652
|
-
const
|
|
666
|
+
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, swapPublicLeaf, withdrawReceipt.txHash);
|
|
667
|
+
const { epochNumber: epoch } = swapResult;
|
|
668
|
+
const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash);
|
|
653
669
|
const swapPublicL2MessageIndex = swapResult.leafIndex;
|
|
654
670
|
const swapPublicSiblingPath = swapResult.siblingPath;
|
|
655
671
|
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
656
672
|
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
657
673
|
const withdrawMessageMetadata = {
|
|
658
|
-
|
|
674
|
+
_epoch: BigInt(epoch),
|
|
659
675
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
660
676
|
_path: withdrawSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
661
677
|
};
|
|
662
678
|
const swapPublicMessageMetadata = {
|
|
663
|
-
|
|
679
|
+
_epoch: BigInt(epoch),
|
|
664
680
|
_leafIndex: BigInt(swapPublicL2MessageIndex),
|
|
665
681
|
_path: swapPublicSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
666
682
|
};
|
|
667
683
|
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
668
684
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
669
|
-
// Since the outbox is only consumable when the
|
|
670
|
-
await cheatCodes.rollup.
|
|
685
|
+
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
|
|
686
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
|
|
687
|
+
await waitForProven(aztecNode, withdrawReceipt, {
|
|
688
|
+
provenTimeout: 300
|
|
689
|
+
});
|
|
671
690
|
// Call swap_private on L1
|
|
672
691
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
673
692
|
const swapArgs = [
|