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