@aztec/end-to-end 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +336 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +77 -0
- package/dest/bench/utils.d.ts +12 -38
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
- 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 +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +20 -25
- 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 +51 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +65 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +233 -49
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +63 -0
- package/dest/e2e_fees/fees_test.d.ts +27 -12
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +106 -109
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +58 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +10 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +276 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +188 -133
- package/dest/e2e_p2p/shared.d.ts +43 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +164 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/fixtures/e2e_prover_test.d.ts +61 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +108 -112
- package/dest/fixtures/fixtures.d.ts +6 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +5 -5
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +3 -15
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +82 -22
- package/dest/fixtures/snapshot_manager.d.ts +20 -14
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +154 -140
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +28 -12
- package/dest/fixtures/utils.d.ts +95 -54
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +456 -389
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +42 -35
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +29 -31
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +16 -13
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +149 -117
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -11
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +16 -17
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +26 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +202 -58
- package/dest/spartan/tx_metrics.d.ts +39 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +95 -0
- package/dest/spartan/utils.d.ts +129 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +559 -151
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +450 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +70 -107
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +299 -65
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +151 -141
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +29 -19
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +274 -171
- package/src/e2e_p2p/shared.ts +251 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +113 -160
- package/src/fixtures/fixtures.ts +5 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup_p2p_test.ts +127 -39
- package/src/fixtures/snapshot_manager.ts +196 -162
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +562 -475
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +112 -80
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +187 -192
- package/src/simulators/lending_simulator.ts +15 -16
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +252 -93
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +641 -146
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/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/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '@aztec/
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
type ViemPublicClient,
|
|
16
|
-
type ViemWalletClient,
|
|
17
|
-
deployL1Contract,
|
|
18
|
-
extractEvent,
|
|
19
|
-
} from '@aztec/ethereum';
|
|
20
|
-
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
21
|
-
import { InboxAbi, RollupAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
1
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
6
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
7
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
8
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
9
|
+
import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
10
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
11
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
12
|
+
import { extractEvent } from '@aztec/ethereum/utils';
|
|
13
|
+
import { sha256ToField } from '@aztec/foundation/crypto/sha256';
|
|
14
|
+
import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
22
15
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
16
|
+
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
17
|
+
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
18
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
23
19
|
|
|
24
20
|
import { jest } from '@jest/globals';
|
|
25
21
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
26
22
|
|
|
27
|
-
import {
|
|
23
|
+
import { ensureAccountContractsPublished } from '../fixtures/utils.js';
|
|
28
24
|
import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
29
25
|
|
|
30
26
|
// PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
|
|
@@ -34,38 +30,33 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
|
34
30
|
// anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
|
|
35
31
|
// For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
|
|
36
32
|
|
|
37
|
-
// docs:start:uniswap_l1_l2_test_setup_const
|
|
38
33
|
const TIMEOUT = 360_000;
|
|
39
34
|
|
|
40
35
|
/** Objects to be returned by the uniswap setup function */
|
|
41
36
|
export type UniswapSetupContext = {
|
|
42
37
|
/** Aztec Node instance */
|
|
43
38
|
aztecNode: AztecNode;
|
|
44
|
-
/** The Private eXecution Environment (PXE). */
|
|
45
|
-
pxe: PXE;
|
|
46
39
|
/** Logger instance named as the current test. */
|
|
47
40
|
logger: Logger;
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/** The owner
|
|
53
|
-
|
|
41
|
+
/** The L1 wallet client, extended with public actions. */
|
|
42
|
+
l1Client: ExtendedViemWalletClient;
|
|
43
|
+
/** The wallet. */
|
|
44
|
+
wallet: TestWallet;
|
|
45
|
+
/** The owner address. */
|
|
46
|
+
ownerAddress: AztecAddress;
|
|
54
47
|
/** The sponsor wallet. */
|
|
55
|
-
|
|
48
|
+
sponsorAddress: AztecAddress;
|
|
56
49
|
/** */
|
|
57
|
-
deployL1ContractsValues:
|
|
50
|
+
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
58
51
|
/** Cheat codes instance. */
|
|
59
52
|
cheatCodes: CheatCodes;
|
|
60
53
|
};
|
|
61
|
-
// docs:end:uniswap_l1_l2_test_setup_const
|
|
62
54
|
|
|
63
55
|
export const uniswapL1L2TestSuite = (
|
|
64
56
|
setup: () => Promise<UniswapSetupContext>,
|
|
65
57
|
cleanup: () => Promise<void>,
|
|
66
58
|
expectedForkBlockNumber = 17514288,
|
|
67
59
|
) => {
|
|
68
|
-
// docs:start:uniswap_l1_l2_test_beforeAll
|
|
69
60
|
describe('uniswap_trade_on_l1_from_l2', () => {
|
|
70
61
|
jest.setTimeout(TIMEOUT);
|
|
71
62
|
|
|
@@ -73,25 +64,22 @@ export const uniswapL1L2TestSuite = (
|
|
|
73
64
|
const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
|
|
74
65
|
|
|
75
66
|
let aztecNode: AztecNode;
|
|
76
|
-
let pxe: PXE;
|
|
77
67
|
let logger: Logger;
|
|
78
68
|
|
|
79
|
-
let
|
|
80
|
-
let publicClient: ViemPublicClient;
|
|
69
|
+
let l1Client: ExtendedViemWalletClient;
|
|
81
70
|
|
|
82
|
-
let
|
|
71
|
+
let wallet: TestWallet;
|
|
83
72
|
let ownerAddress: AztecAddress;
|
|
84
73
|
let ownerEthAddress: EthAddress;
|
|
85
74
|
// does transactions on behalf of owner on Aztec:
|
|
86
|
-
let
|
|
87
|
-
// let sponsorAddress: AztecAddress;
|
|
75
|
+
let sponsorAddress: AztecAddress;
|
|
88
76
|
|
|
89
77
|
let daiCrossChainHarness: CrossChainTestHarness;
|
|
90
78
|
let wethCrossChainHarness: CrossChainTestHarness;
|
|
91
79
|
|
|
92
|
-
let deployL1ContractsValues:
|
|
93
|
-
let rollup:
|
|
94
|
-
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi,
|
|
80
|
+
let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
81
|
+
let rollup: RollupContract;
|
|
82
|
+
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
|
|
95
83
|
let uniswapPortalAddress: EthAddress;
|
|
96
84
|
let uniswapL2Contract: UniswapContract;
|
|
97
85
|
|
|
@@ -100,43 +88,30 @@ export const uniswapL1L2TestSuite = (
|
|
|
100
88
|
const minimumOutputAmount = 0n;
|
|
101
89
|
|
|
102
90
|
let cheatCodes: CheatCodes;
|
|
103
|
-
|
|
91
|
+
let version: number;
|
|
104
92
|
beforeAll(async () => {
|
|
105
|
-
({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
publicClient,
|
|
110
|
-
walletClient,
|
|
111
|
-
ownerWallet,
|
|
112
|
-
sponsorWallet,
|
|
113
|
-
deployL1ContractsValues,
|
|
114
|
-
cheatCodes,
|
|
115
|
-
} = await setup());
|
|
116
|
-
|
|
117
|
-
if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
|
|
93
|
+
({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } =
|
|
94
|
+
await setup());
|
|
95
|
+
|
|
96
|
+
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
118
97
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
119
98
|
}
|
|
120
99
|
|
|
121
|
-
rollup =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
ownerAddress = ownerWallet.getAddress();
|
|
128
|
-
// sponsorAddress = sponsorWallet.getAddress();
|
|
129
|
-
ownerEthAddress = EthAddress.fromString((await walletClient.getAddresses())[0]);
|
|
100
|
+
rollup = new RollupContract(
|
|
101
|
+
deployL1ContractsValues.l1Client,
|
|
102
|
+
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
103
|
+
);
|
|
104
|
+
version = Number(await rollup.getVersion());
|
|
105
|
+
ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
130
106
|
|
|
131
|
-
await
|
|
107
|
+
await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
|
|
132
108
|
|
|
133
109
|
logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
|
|
134
110
|
daiCrossChainHarness = await CrossChainTestHarness.new(
|
|
135
111
|
aztecNode,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
ownerWallet,
|
|
112
|
+
deployL1ContractsValues.l1Client,
|
|
113
|
+
wallet,
|
|
114
|
+
ownerAddress,
|
|
140
115
|
logger,
|
|
141
116
|
DAI_ADDRESS,
|
|
142
117
|
);
|
|
@@ -144,31 +119,29 @@ export const uniswapL1L2TestSuite = (
|
|
|
144
119
|
logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
|
|
145
120
|
wethCrossChainHarness = await CrossChainTestHarness.new(
|
|
146
121
|
aztecNode,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
ownerWallet,
|
|
122
|
+
l1Client,
|
|
123
|
+
wallet,
|
|
124
|
+
ownerAddress,
|
|
151
125
|
logger,
|
|
152
126
|
WETH9_ADDRESS,
|
|
153
127
|
);
|
|
154
128
|
|
|
155
129
|
logger.info('Deploy Uniswap portal on L1 and L2...');
|
|
156
|
-
uniswapPortalAddress = await deployL1Contract(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
UniswapPortalAbi,
|
|
160
|
-
UniswapPortalBytecode,
|
|
161
|
-
).then(({ address }) => address);
|
|
130
|
+
uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(
|
|
131
|
+
({ address }) => address,
|
|
132
|
+
);
|
|
162
133
|
|
|
163
134
|
uniswapPortal = getContract({
|
|
164
135
|
address: uniswapPortalAddress.toString(),
|
|
165
136
|
abi: UniswapPortalAbi,
|
|
166
|
-
client:
|
|
137
|
+
client: l1Client,
|
|
167
138
|
});
|
|
168
139
|
// deploy l2 uniswap contract and attach to portal
|
|
169
|
-
uniswapL2Contract = await UniswapContract.deploy(
|
|
140
|
+
uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress)
|
|
141
|
+
.send({ from: ownerAddress })
|
|
142
|
+
.deployed();
|
|
170
143
|
|
|
171
|
-
const registryAddress = (await
|
|
144
|
+
const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
172
145
|
|
|
173
146
|
await uniswapPortal.write.initialize(
|
|
174
147
|
[registryAddress.toString(), uniswapL2Contract.address.toString()],
|
|
@@ -177,13 +150,12 @@ export const uniswapL1L2TestSuite = (
|
|
|
177
150
|
|
|
178
151
|
// Give me some WETH so I can deposit to L2 and do the swap...
|
|
179
152
|
logger.info('Getting some weth');
|
|
180
|
-
const hash = await
|
|
181
|
-
await
|
|
153
|
+
const hash = await l1Client.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
|
|
154
|
+
await l1Client.waitForTransactionReceipt({ hash });
|
|
182
155
|
|
|
183
156
|
const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
184
157
|
expect(wethBalance).toBe(parseEther('1000'));
|
|
185
158
|
});
|
|
186
|
-
// docs:end:uniswap_l1_l2_test_beforeAll
|
|
187
159
|
|
|
188
160
|
afterAll(async () => {
|
|
189
161
|
await cleanup();
|
|
@@ -218,7 +190,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
218
190
|
// 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
219
191
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
220
192
|
const nonceForWETHTransferToPublicApproval = new Fr(1n);
|
|
221
|
-
await
|
|
193
|
+
const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
|
|
222
194
|
caller: uniswapL2Contract.address,
|
|
223
195
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
224
196
|
ownerAddress,
|
|
@@ -244,7 +216,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
244
216
|
secretHashForDepositingSwappedDai,
|
|
245
217
|
ownerEthAddress,
|
|
246
218
|
)
|
|
247
|
-
.send()
|
|
219
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
|
|
248
220
|
.wait();
|
|
249
221
|
|
|
250
222
|
const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
|
|
@@ -259,13 +231,13 @@ export const uniswapL1L2TestSuite = (
|
|
|
259
231
|
ownerEthAddress.toBuffer32(),
|
|
260
232
|
]);
|
|
261
233
|
|
|
262
|
-
const swapPrivateLeaf =
|
|
263
|
-
uniswapL2Contract.address,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
new Fr(
|
|
267
|
-
|
|
268
|
-
|
|
234
|
+
const swapPrivateLeaf = computeL2ToL1MessageHash({
|
|
235
|
+
l2Sender: uniswapL2Contract.address,
|
|
236
|
+
l1Recipient: EthAddress.fromString(uniswapPortal.address),
|
|
237
|
+
content: swapPrivateContent,
|
|
238
|
+
rollupVersion: new Fr(version),
|
|
239
|
+
chainId: new Fr(l1Client.chain.id),
|
|
240
|
+
});
|
|
269
241
|
|
|
270
242
|
const withdrawContent = sha256ToField([
|
|
271
243
|
Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
|
|
@@ -274,13 +246,13 @@ export const uniswapL1L2TestSuite = (
|
|
|
274
246
|
uniswapPortalAddress.toBuffer32(),
|
|
275
247
|
]);
|
|
276
248
|
|
|
277
|
-
const withdrawLeaf =
|
|
278
|
-
wethCrossChainHarness.l2Bridge.address,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
new Fr(
|
|
282
|
-
|
|
283
|
-
|
|
249
|
+
const withdrawLeaf = computeL2ToL1MessageHash({
|
|
250
|
+
l2Sender: wethCrossChainHarness.l2Bridge.address,
|
|
251
|
+
l1Recipient: wethCrossChainHarness.tokenPortalAddress,
|
|
252
|
+
content: withdrawContent,
|
|
253
|
+
rollupVersion: new Fr(version),
|
|
254
|
+
chainId: new Fr(l1Client.chain.id),
|
|
255
|
+
});
|
|
284
256
|
|
|
285
257
|
// ensure that user's funds were burnt
|
|
286
258
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
@@ -288,25 +260,32 @@ export const uniswapL1L2TestSuite = (
|
|
|
288
260
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
289
261
|
|
|
290
262
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
291
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
263
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
292
264
|
|
|
293
265
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
294
266
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
295
267
|
const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
|
|
296
268
|
daiCrossChainHarness.tokenPortalAddress,
|
|
297
269
|
);
|
|
298
|
-
|
|
299
|
-
|
|
270
|
+
const swapResult = await computeL2ToL1MembershipWitness(
|
|
271
|
+
aztecNode,
|
|
300
272
|
l2UniswapInteractionReceipt.blockNumber!,
|
|
301
273
|
swapPrivateLeaf,
|
|
302
274
|
);
|
|
303
|
-
const
|
|
275
|
+
const withdrawResult = await computeL2ToL1MembershipWitness(
|
|
276
|
+
aztecNode,
|
|
304
277
|
l2UniswapInteractionReceipt.blockNumber!,
|
|
305
278
|
withdrawLeaf,
|
|
306
279
|
);
|
|
307
280
|
|
|
281
|
+
const swapPrivateL2MessageIndex = swapResult!.leafIndex;
|
|
282
|
+
const swapPrivateSiblingPath = swapResult!.siblingPath;
|
|
283
|
+
|
|
284
|
+
const withdrawL2MessageIndex = withdrawResult!.leafIndex;
|
|
285
|
+
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
286
|
+
|
|
308
287
|
const withdrawMessageMetadata = {
|
|
309
|
-
|
|
288
|
+
_checkpointNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
|
|
310
289
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
311
290
|
_path: withdrawSiblingPath
|
|
312
291
|
.toBufferArray()
|
|
@@ -314,7 +293,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
314
293
|
};
|
|
315
294
|
|
|
316
295
|
const swapPrivateMessageMetadata = {
|
|
317
|
-
|
|
296
|
+
_checkpointNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
|
|
318
297
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
319
298
|
_path: swapPrivateSiblingPath
|
|
320
299
|
.toBufferArray()
|
|
@@ -333,7 +312,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
333
312
|
] as const;
|
|
334
313
|
|
|
335
314
|
// this should also insert a message into the inbox.
|
|
336
|
-
const txReceipt = await daiCrossChainHarness.
|
|
315
|
+
const txReceipt = await daiCrossChainHarness.l1Client.waitForTransactionReceipt({
|
|
337
316
|
hash: await uniswapPortal.write.swapPrivate(swapArgs),
|
|
338
317
|
});
|
|
339
318
|
|
|
@@ -525,7 +504,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
525
504
|
// );
|
|
526
505
|
|
|
527
506
|
// const withdrawMessageMetadata = {
|
|
528
|
-
//
|
|
507
|
+
// _checkpointNumber: BigInt(uniswapL2Interaction.blockNumber!),
|
|
529
508
|
// _leafIndex: BigInt(withdrawL2MessageIndex),
|
|
530
509
|
// _path: withdrawSiblingPath
|
|
531
510
|
// .toBufferArray()
|
|
@@ -533,7 +512,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
533
512
|
// };
|
|
534
513
|
|
|
535
514
|
// const swapPrivateMessageMetadata = {
|
|
536
|
-
//
|
|
515
|
+
// _checkpointNumber: BigInt(uniswapL2Interaction.blockNumber!),
|
|
537
516
|
// _leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
538
517
|
// _path: swapPrivateSiblingPath
|
|
539
518
|
// .toBufferArray()
|
|
@@ -620,14 +599,16 @@ export const uniswapL1L2TestSuite = (
|
|
|
620
599
|
const expectedMessageHash = await computeAuthWitMessageHash(
|
|
621
600
|
{
|
|
622
601
|
caller: uniswapL2Contract.address,
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
602
|
+
call: await wethCrossChainHarness.l2Token.methods
|
|
603
|
+
.transfer_to_public(
|
|
604
|
+
ownerAddress,
|
|
605
|
+
uniswapL2Contract.address,
|
|
606
|
+
wethAmountToBridge,
|
|
607
|
+
nonceForWETHTransferToPublicApproval,
|
|
608
|
+
)
|
|
609
|
+
.getFunctionCall(),
|
|
629
610
|
},
|
|
630
|
-
|
|
611
|
+
await wallet.getChainInfo(),
|
|
631
612
|
);
|
|
632
613
|
|
|
633
614
|
await expect(
|
|
@@ -643,7 +624,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
643
624
|
Fr.random(),
|
|
644
625
|
ownerEthAddress,
|
|
645
626
|
)
|
|
646
|
-
.
|
|
627
|
+
.simulate({ from: ownerAddress }),
|
|
647
628
|
).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
|
|
648
629
|
});
|
|
649
630
|
|
|
@@ -655,7 +636,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
655
636
|
// 2. owner gives uniswap approval to transfer the funds to public:
|
|
656
637
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
657
638
|
const nonceForWETHTransferToPublicApproval = new Fr(3n);
|
|
658
|
-
await
|
|
639
|
+
const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
|
|
659
640
|
caller: uniswapL2Contract.address,
|
|
660
641
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
661
642
|
ownerAddress,
|
|
@@ -680,7 +661,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
680
661
|
Fr.random(),
|
|
681
662
|
ownerEthAddress,
|
|
682
663
|
)
|
|
683
|
-
.
|
|
664
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] })
|
|
665
|
+
.wait(),
|
|
684
666
|
).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
685
667
|
});
|
|
686
668
|
|
|
@@ -692,7 +674,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
692
674
|
|
|
693
675
|
// 2. Give approval to uniswap to transfer funds to itself
|
|
694
676
|
const nonceForWETHTransferApproval = new Fr(2n);
|
|
695
|
-
const validateActionInteraction = await
|
|
677
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
678
|
+
ownerAddress,
|
|
696
679
|
{
|
|
697
680
|
caller: uniswapL2Contract.address,
|
|
698
681
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -723,7 +706,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
723
706
|
ownerEthAddress,
|
|
724
707
|
Fr.ZERO, // nonce for swap -> doesn't matter
|
|
725
708
|
)
|
|
726
|
-
.send()
|
|
709
|
+
.send({ from: ownerAddress })
|
|
727
710
|
.wait();
|
|
728
711
|
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
729
712
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
@@ -736,32 +719,35 @@ export const uniswapL1L2TestSuite = (
|
|
|
736
719
|
const nonceForWETHTransferApproval = new Fr(3n);
|
|
737
720
|
const nonceForSwap = new Fr(3n);
|
|
738
721
|
const secretHashForDepositingSwappedDai = new Fr(4n);
|
|
739
|
-
const action = uniswapL2Contract
|
|
740
|
-
|
|
741
|
-
.
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
722
|
+
const action = uniswapL2Contract.methods.swap_public(
|
|
723
|
+
ownerAddress,
|
|
724
|
+
wethCrossChainHarness.l2Bridge.address,
|
|
725
|
+
wethAmountToBridge,
|
|
726
|
+
daiCrossChainHarness.l2Bridge.address,
|
|
727
|
+
nonceForWETHTransferApproval,
|
|
728
|
+
uniswapFeeTier,
|
|
729
|
+
minimumOutputAmount,
|
|
730
|
+
ownerAddress,
|
|
731
|
+
secretHashForDepositingSwappedDai,
|
|
732
|
+
ownerEthAddress,
|
|
733
|
+
nonceForSwap,
|
|
734
|
+
);
|
|
735
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
736
|
+
ownerAddress,
|
|
737
|
+
{ caller: approvedUser, action },
|
|
738
|
+
true,
|
|
739
|
+
);
|
|
755
740
|
await validateActionInteraction.send().wait();
|
|
756
741
|
|
|
757
|
-
await expect(action.simulate()).rejects.toThrow(/unauthorized/);
|
|
742
|
+
await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
|
|
758
743
|
});
|
|
759
744
|
|
|
760
745
|
it("uniswap can't pull funds without transfer approval", async () => {
|
|
761
746
|
// swap should fail since no transfer approval to uniswap:
|
|
762
747
|
const nonceForWETHTransferApproval = new Fr(4n);
|
|
763
748
|
|
|
764
|
-
const validateActionInteraction = await
|
|
749
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
750
|
+
ownerAddress,
|
|
765
751
|
{
|
|
766
752
|
caller: uniswapL2Contract.address,
|
|
767
753
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -790,7 +776,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
790
776
|
ownerEthAddress,
|
|
791
777
|
Fr.ZERO,
|
|
792
778
|
)
|
|
793
|
-
.simulate(),
|
|
779
|
+
.simulate({ from: ownerAddress }),
|
|
794
780
|
).rejects.toThrow(/unauthorized/);
|
|
795
781
|
});
|
|
796
782
|
|
|
@@ -803,7 +789,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
803
789
|
// Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
804
790
|
logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
|
|
805
791
|
const nonceForWETHTransferToPublicApproval = new Fr(4n);
|
|
806
|
-
await
|
|
792
|
+
const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
|
|
807
793
|
caller: uniswapL2Contract.address,
|
|
808
794
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
809
795
|
ownerAddress,
|
|
@@ -830,7 +816,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
830
816
|
secretHashForDepositingSwappedDai,
|
|
831
817
|
ownerEthAddress,
|
|
832
818
|
)
|
|
833
|
-
.send()
|
|
819
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
|
|
834
820
|
.wait();
|
|
835
821
|
|
|
836
822
|
const swapPrivateContent = sha256ToField([
|
|
@@ -847,13 +833,13 @@ export const uniswapL1L2TestSuite = (
|
|
|
847
833
|
ownerEthAddress.toBuffer32(),
|
|
848
834
|
]);
|
|
849
835
|
|
|
850
|
-
const swapPrivateLeaf =
|
|
851
|
-
uniswapL2Contract.address,
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
new Fr(
|
|
855
|
-
|
|
856
|
-
|
|
836
|
+
const swapPrivateLeaf = computeL2ToL1MessageHash({
|
|
837
|
+
l2Sender: uniswapL2Contract.address,
|
|
838
|
+
l1Recipient: EthAddress.fromString(uniswapPortal.address),
|
|
839
|
+
content: swapPrivateContent,
|
|
840
|
+
rollupVersion: new Fr(version),
|
|
841
|
+
chainId: new Fr(l1Client.chain.id),
|
|
842
|
+
});
|
|
857
843
|
|
|
858
844
|
const withdrawContent = sha256ToField([
|
|
859
845
|
Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
|
|
@@ -862,25 +848,29 @@ export const uniswapL1L2TestSuite = (
|
|
|
862
848
|
uniswapPortalAddress.toBuffer32(),
|
|
863
849
|
]);
|
|
864
850
|
|
|
865
|
-
const withdrawLeaf =
|
|
866
|
-
wethCrossChainHarness.l2Bridge.address,
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
new Fr(
|
|
870
|
-
|
|
871
|
-
|
|
851
|
+
const withdrawLeaf = computeL2ToL1MessageHash({
|
|
852
|
+
l2Sender: wethCrossChainHarness.l2Bridge.address,
|
|
853
|
+
l1Recipient: wethCrossChainHarness.tokenPortalAddress,
|
|
854
|
+
content: withdrawContent,
|
|
855
|
+
rollupVersion: new Fr(version),
|
|
856
|
+
chainId: new Fr(l1Client.chain.id),
|
|
857
|
+
});
|
|
872
858
|
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
);
|
|
877
|
-
const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
|
|
859
|
+
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber!, swapPrivateLeaf);
|
|
860
|
+
const withdrawResult = await computeL2ToL1MembershipWitness(
|
|
861
|
+
aztecNode,
|
|
878
862
|
withdrawReceipt.blockNumber!,
|
|
879
863
|
withdrawLeaf,
|
|
880
864
|
);
|
|
881
865
|
|
|
866
|
+
const swapPrivateL2MessageIndex = swapResult!.leafIndex;
|
|
867
|
+
const swapPrivateSiblingPath = swapResult!.siblingPath;
|
|
868
|
+
|
|
869
|
+
const withdrawL2MessageIndex = withdrawResult!.leafIndex;
|
|
870
|
+
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
871
|
+
|
|
882
872
|
const withdrawMessageMetadata = {
|
|
883
|
-
|
|
873
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
884
874
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
885
875
|
_path: withdrawSiblingPath
|
|
886
876
|
.toBufferArray()
|
|
@@ -888,7 +878,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
888
878
|
};
|
|
889
879
|
|
|
890
880
|
const swapPrivateMessageMetadata = {
|
|
891
|
-
|
|
881
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
892
882
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
893
883
|
_path: swapPrivateSiblingPath
|
|
894
884
|
.toBufferArray()
|
|
@@ -899,7 +889,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
899
889
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
900
890
|
|
|
901
891
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
902
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
892
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
903
893
|
|
|
904
894
|
// On L1 call swap_public!
|
|
905
895
|
logger.info('call swap_public on L1');
|
|
@@ -927,7 +917,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
927
917
|
|
|
928
918
|
// Owner gives uniswap approval to transfer funds on its behalf
|
|
929
919
|
const nonceForWETHTransferApproval = new Fr(5n);
|
|
930
|
-
const validateActionInteraction = await
|
|
920
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
921
|
+
ownerAddress,
|
|
931
922
|
{
|
|
932
923
|
caller: uniswapL2Contract.address,
|
|
933
924
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -957,7 +948,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
957
948
|
ownerEthAddress,
|
|
958
949
|
Fr.ZERO,
|
|
959
950
|
)
|
|
960
|
-
.send()
|
|
951
|
+
.send({ from: ownerAddress })
|
|
961
952
|
.wait();
|
|
962
953
|
|
|
963
954
|
const swapPublicContent = sha256ToField([
|
|
@@ -977,13 +968,13 @@ export const uniswapL1L2TestSuite = (
|
|
|
977
968
|
ownerEthAddress.toBuffer32(),
|
|
978
969
|
]);
|
|
979
970
|
|
|
980
|
-
const swapPublicLeaf =
|
|
981
|
-
uniswapL2Contract.address,
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
new Fr(
|
|
985
|
-
|
|
986
|
-
|
|
971
|
+
const swapPublicLeaf = computeL2ToL1MessageHash({
|
|
972
|
+
l2Sender: uniswapL2Contract.address,
|
|
973
|
+
l1Recipient: EthAddress.fromString(uniswapPortal.address),
|
|
974
|
+
content: swapPublicContent,
|
|
975
|
+
rollupVersion: new Fr(version),
|
|
976
|
+
chainId: new Fr(l1Client.chain.id),
|
|
977
|
+
});
|
|
987
978
|
|
|
988
979
|
const withdrawContent = sha256ToField([
|
|
989
980
|
Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
|
|
@@ -992,25 +983,29 @@ export const uniswapL1L2TestSuite = (
|
|
|
992
983
|
uniswapPortalAddress.toBuffer32(),
|
|
993
984
|
]);
|
|
994
985
|
|
|
995
|
-
const withdrawLeaf =
|
|
996
|
-
wethCrossChainHarness.l2Bridge.address,
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
new Fr(
|
|
1000
|
-
|
|
1001
|
-
|
|
986
|
+
const withdrawLeaf = computeL2ToL1MessageHash({
|
|
987
|
+
l2Sender: wethCrossChainHarness.l2Bridge.address,
|
|
988
|
+
l1Recipient: wethCrossChainHarness.tokenPortalAddress,
|
|
989
|
+
content: withdrawContent,
|
|
990
|
+
rollupVersion: new Fr(version),
|
|
991
|
+
chainId: new Fr(l1Client.chain.id),
|
|
992
|
+
});
|
|
1002
993
|
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
);
|
|
1007
|
-
const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
|
|
994
|
+
const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber!, swapPublicLeaf);
|
|
995
|
+
const withdrawResult = await computeL2ToL1MembershipWitness(
|
|
996
|
+
aztecNode,
|
|
1008
997
|
withdrawReceipt.blockNumber!,
|
|
1009
998
|
withdrawLeaf,
|
|
1010
999
|
);
|
|
1011
1000
|
|
|
1001
|
+
const swapPublicL2MessageIndex = swapResult!.leafIndex;
|
|
1002
|
+
const swapPublicSiblingPath = swapResult!.siblingPath;
|
|
1003
|
+
|
|
1004
|
+
const withdrawL2MessageIndex = withdrawResult!.leafIndex;
|
|
1005
|
+
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
1006
|
+
|
|
1012
1007
|
const withdrawMessageMetadata = {
|
|
1013
|
-
|
|
1008
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
1014
1009
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
1015
1010
|
_path: withdrawSiblingPath
|
|
1016
1011
|
.toBufferArray()
|
|
@@ -1018,7 +1013,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1018
1013
|
};
|
|
1019
1014
|
|
|
1020
1015
|
const swapPublicMessageMetadata = {
|
|
1021
|
-
|
|
1016
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
1022
1017
|
_leafIndex: BigInt(swapPublicL2MessageIndex),
|
|
1023
1018
|
_path: swapPublicSiblingPath
|
|
1024
1019
|
.toBufferArray()
|
|
@@ -1029,7 +1024,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1029
1024
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
1030
1025
|
|
|
1031
1026
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
1032
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
1027
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
1033
1028
|
|
|
1034
1029
|
// Call swap_private on L1
|
|
1035
1030
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|