@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.023c3e5

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.
Files changed (240) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +62 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +281 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +321 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +79 -0
  13. package/dest/bench/utils.d.ts +16 -41
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +41 -72
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +114 -102
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +104 -104
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +26 -27
  25. package/dest/e2e_epochs/epochs_test.d.ts +71 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +260 -54
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  31. package/dest/e2e_fees/fees_test.d.ts +38 -23
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +162 -183
  34. package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +56 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +281 -27
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +237 -175
  49. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  50. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  51. package/dest/e2e_p2p/reqresp/utils.js +153 -0
  52. package/dest/e2e_p2p/shared.d.ts +44 -8
  53. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  54. package/dest/e2e_p2p/shared.js +165 -27
  55. package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
  56. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  57. package/dest/e2e_token_contract/token_contract_test.js +96 -74
  58. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  59. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  60. package/dest/fixtures/e2e_prover_test.js +278 -0
  61. package/dest/fixtures/fixtures.d.ts +6 -8
  62. package/dest/fixtures/fixtures.d.ts.map +1 -1
  63. package/dest/fixtures/fixtures.js +5 -5
  64. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  65. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_acvm_config.js +3 -15
  67. package/dest/fixtures/get_bb_config.d.ts +2 -2
  68. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  69. package/dest/fixtures/get_bb_config.js +10 -17
  70. package/dest/fixtures/index.d.ts +1 -1
  71. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  72. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  73. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  74. package/dest/fixtures/logging.d.ts +1 -1
  75. package/dest/fixtures/setup.d.ts +218 -0
  76. package/dest/fixtures/setup.d.ts.map +1 -0
  77. package/dest/fixtures/setup.js +695 -0
  78. package/dest/fixtures/setup_p2p_test.d.ts +15 -15
  79. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  80. package/dest/fixtures/setup_p2p_test.js +96 -31
  81. package/dest/fixtures/token_utils.d.ts +10 -4
  82. package/dest/fixtures/token_utils.d.ts.map +1 -1
  83. package/dest/fixtures/token_utils.js +31 -12
  84. package/dest/fixtures/utils.d.ts +5 -153
  85. package/dest/fixtures/utils.d.ts.map +1 -1
  86. package/dest/fixtures/utils.js +4 -552
  87. package/dest/fixtures/web3signer.d.ts +5 -0
  88. package/dest/fixtures/web3signer.d.ts.map +1 -0
  89. package/dest/fixtures/web3signer.js +53 -0
  90. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  91. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  92. package/dest/fixtures/with_telemetry_utils.js +2 -2
  93. package/dest/index.d.ts +1 -1
  94. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  95. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  96. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  97. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  98. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  99. package/dest/quality_of_service/prometheus_client.js +67 -0
  100. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  101. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  102. package/dest/shared/cross_chain_test_harness.js +105 -51
  103. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  104. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  105. package/dest/shared/gas_portal_test_harness.js +51 -30
  106. package/dest/shared/index.d.ts +2 -2
  107. package/dest/shared/index.d.ts.map +1 -1
  108. package/dest/shared/jest_setup.d.ts +1 -1
  109. package/dest/shared/jest_setup.js +1 -1
  110. package/dest/shared/submit-transactions.d.ts +6 -4
  111. package/dest/shared/submit-transactions.d.ts.map +1 -1
  112. package/dest/shared/submit-transactions.js +15 -16
  113. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  114. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  115. package/dest/shared/uniswap_l1_l2.js +176 -126
  116. package/dest/simulators/index.d.ts +1 -1
  117. package/dest/simulators/lending_simulator.d.ts +7 -7
  118. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  119. package/dest/simulators/lending_simulator.js +17 -18
  120. package/dest/simulators/token_simulator.d.ts +6 -3
  121. package/dest/simulators/token_simulator.d.ts.map +1 -1
  122. package/dest/simulators/token_simulator.js +16 -13
  123. package/dest/spartan/setup_test_wallets.d.ts +27 -11
  124. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  125. package/dest/spartan/setup_test_wallets.js +233 -62
  126. package/dest/spartan/tx_metrics.d.ts +88 -0
  127. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  128. package/dest/spartan/tx_metrics.js +422 -0
  129. package/dest/spartan/utils/bot.d.ts +27 -0
  130. package/dest/spartan/utils/bot.d.ts.map +1 -0
  131. package/dest/spartan/utils/bot.js +141 -0
  132. package/dest/spartan/utils/chaos.d.ts +79 -0
  133. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  134. package/dest/spartan/utils/chaos.js +142 -0
  135. package/dest/spartan/utils/clients.d.ts +39 -0
  136. package/dest/spartan/utils/clients.d.ts.map +1 -0
  137. package/dest/spartan/utils/clients.js +90 -0
  138. package/dest/spartan/utils/config.d.ts +36 -0
  139. package/dest/spartan/utils/config.d.ts.map +1 -0
  140. package/dest/spartan/utils/config.js +20 -0
  141. package/dest/spartan/utils/health.d.ts +63 -0
  142. package/dest/spartan/utils/health.d.ts.map +1 -0
  143. package/dest/spartan/utils/health.js +202 -0
  144. package/dest/spartan/utils/helm.d.ts +15 -0
  145. package/dest/spartan/utils/helm.d.ts.map +1 -0
  146. package/dest/spartan/utils/helm.js +47 -0
  147. package/dest/spartan/utils/index.d.ts +9 -0
  148. package/dest/spartan/utils/index.d.ts.map +1 -0
  149. package/dest/spartan/utils/index.js +18 -0
  150. package/dest/spartan/utils/k8s.d.ts +126 -0
  151. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  152. package/dest/spartan/utils/k8s.js +375 -0
  153. package/dest/spartan/utils/nodes.d.ts +41 -0
  154. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  155. package/dest/spartan/utils/nodes.js +461 -0
  156. package/dest/spartan/utils/scripts.d.ts +16 -0
  157. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  158. package/dest/spartan/utils/scripts.js +66 -0
  159. package/dest/spartan/utils.d.ts +2 -415
  160. package/dest/spartan/utils.d.ts.map +1 -1
  161. package/dest/spartan/utils.js +1 -445
  162. package/package.json +66 -58
  163. package/src/bench/client_flows/benchmark.ts +363 -0
  164. package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
  165. package/src/bench/client_flows/config.ts +61 -0
  166. package/src/bench/client_flows/data_extractor.ts +89 -0
  167. package/src/bench/utils.ts +41 -85
  168. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
  169. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
  170. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  171. package/src/e2e_epochs/epochs_test.ts +341 -81
  172. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  173. package/src/e2e_fees/fees_test.ts +220 -258
  174. package/src/e2e_l1_publisher/write_json.ts +77 -0
  175. package/src/e2e_multi_validator/utils.ts +258 -0
  176. package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
  177. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  178. package/src/e2e_p2p/p2p_network.ts +341 -234
  179. package/src/e2e_p2p/reqresp/utils.ts +207 -0
  180. package/src/e2e_p2p/shared.ts +260 -39
  181. package/src/e2e_token_contract/token_contract_test.ts +115 -126
  182. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  183. package/src/fixtures/e2e_prover_test.ts +336 -0
  184. package/src/fixtures/fixtures.ts +5 -7
  185. package/src/fixtures/get_acvm_config.ts +4 -12
  186. package/src/fixtures/get_bb_config.ts +18 -13
  187. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  188. package/src/fixtures/setup.ts +1017 -0
  189. package/src/fixtures/setup_p2p_test.ts +133 -50
  190. package/src/fixtures/token_utils.ts +33 -15
  191. package/src/fixtures/utils.ts +27 -820
  192. package/src/fixtures/web3signer.ts +63 -0
  193. package/src/fixtures/with_telemetry_utils.ts +2 -2
  194. package/src/guides/up_quick_start.sh +7 -15
  195. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  196. package/src/quality_of_service/prometheus_client.ts +113 -0
  197. package/src/shared/cross_chain_test_harness.ts +103 -91
  198. package/src/shared/gas_portal_test_harness.ts +59 -50
  199. package/src/shared/index.ts +1 -1
  200. package/src/shared/jest_setup.ts +1 -1
  201. package/src/shared/submit-transactions.ts +18 -20
  202. package/src/shared/uniswap_l1_l2.ts +197 -221
  203. package/src/simulators/lending_simulator.ts +16 -17
  204. package/src/simulators/token_simulator.ts +21 -13
  205. package/src/spartan/DEVELOP.md +128 -0
  206. package/src/spartan/setup_test_wallets.ts +308 -95
  207. package/src/spartan/tx_metrics.ts +376 -0
  208. package/src/spartan/utils/bot.ts +185 -0
  209. package/src/spartan/utils/chaos.ts +253 -0
  210. package/src/spartan/utils/clients.ts +100 -0
  211. package/src/spartan/utils/config.ts +26 -0
  212. package/src/spartan/utils/health.ts +255 -0
  213. package/src/spartan/utils/helm.ts +84 -0
  214. package/src/spartan/utils/index.ts +64 -0
  215. package/src/spartan/utils/k8s.ts +527 -0
  216. package/src/spartan/utils/nodes.ts +538 -0
  217. package/src/spartan/utils/scripts.ts +63 -0
  218. package/src/spartan/utils.ts +1 -582
  219. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  220. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  221. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  222. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  223. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  224. package/dest/fixtures/setup_l1_contracts.js +0 -17
  225. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  226. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  227. package/dest/fixtures/snapshot_manager.js +0 -479
  228. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  229. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  230. package/dest/sample-dapp/connect.js +0 -12
  231. package/dest/sample-dapp/contracts.js +0 -10
  232. package/dest/sample-dapp/deploy.js +0 -35
  233. package/dest/sample-dapp/index.js +0 -98
  234. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  235. package/src/fixtures/setup_l1_contracts.ts +0 -27
  236. package/src/fixtures/snapshot_manager.ts +0 -617
  237. package/src/sample-dapp/connect.mjs +0 -16
  238. package/src/sample-dapp/contracts.mjs +0 -14
  239. package/src/sample-dapp/deploy.mjs +0 -40
  240. package/src/sample-dapp/index.mjs +0 -128
@@ -1,30 +1,28 @@
1
- import {
2
- type AccountWallet,
3
- AztecAddress,
4
- type AztecNode,
5
- type CheatCodes,
6
- EthAddress,
7
- Fr,
8
- type Logger,
9
- type PXE,
10
- computeAuthWitMessageHash,
11
- generateClaimSecret,
12
- } from '@aztec/aztec.js';
13
- import {
14
- type DeployL1ContractsReturnType,
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 { waitForProven } from '@aztec/aztec.js/contracts';
4
+ import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import type { Logger } from '@aztec/aztec.js/log';
7
+ import type { AztecNode } from '@aztec/aztec.js/node';
8
+ import { CheatCodes } from '@aztec/aztec/testing';
9
+ import { RollupContract } from '@aztec/ethereum/contracts';
10
+ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
11
+ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
12
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
13
+ import { extractEvent } from '@aztec/ethereum/utils';
14
+ import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
15
+ import { sha256ToField } from '@aztec/foundation/crypto/sha256';
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 { ensureAccountsPubliclyDeployed } from '../fixtures/utils.js';
25
+ import { type EndToEndContext, 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,13 @@ 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
- /** Objects to be returned by the uniswap setup function */
41
- export type UniswapSetupContext = {
42
- /** Aztec Node instance */
43
- aztecNode: AztecNode;
44
- /** The Private eXecution Environment (PXE). */
45
- pxe: PXE;
46
- /** Logger instance named as the current test. */
47
- logger: Logger;
48
- /** Viem Public client instance. */
49
- publicClient: ViemPublicClient;
50
- /** Viem Wallet Client instance. */
51
- walletClient: ViemWalletClient;
52
- /** The owner wallet. */
53
- ownerWallet: AccountWallet;
54
- /** The sponsor wallet. */
55
- sponsorWallet: AccountWallet;
56
- /** */
57
- deployL1ContractsValues: DeployL1ContractsReturnType;
58
- /** Cheat codes instance. */
59
- cheatCodes: CheatCodes;
60
- };
61
- // docs:end:uniswap_l1_l2_test_setup_const
62
-
63
37
  export const uniswapL1L2TestSuite = (
64
- setup: () => Promise<UniswapSetupContext>,
38
+ setup: () => Promise<EndToEndContext>,
65
39
  cleanup: () => Promise<void>,
66
40
  expectedForkBlockNumber = 17514288,
67
41
  ) => {
68
- // docs:start:uniswap_l1_l2_test_beforeAll
69
42
  describe('uniswap_trade_on_l1_from_l2', () => {
70
43
  jest.setTimeout(TIMEOUT);
71
44
 
@@ -73,25 +46,22 @@ export const uniswapL1L2TestSuite = (
73
46
  const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
74
47
 
75
48
  let aztecNode: AztecNode;
76
- let pxe: PXE;
77
49
  let logger: Logger;
78
50
 
79
- let walletClient: ViemWalletClient;
80
- let publicClient: ViemPublicClient;
51
+ let l1Client: ExtendedViemWalletClient;
81
52
 
82
- let ownerWallet: AccountWallet;
53
+ let wallet: TestWallet;
83
54
  let ownerAddress: AztecAddress;
84
55
  let ownerEthAddress: EthAddress;
85
56
  // does transactions on behalf of owner on Aztec:
86
- let sponsorWallet: AccountWallet;
87
- // let sponsorAddress: AztecAddress;
57
+ let sponsorAddress: AztecAddress;
88
58
 
89
59
  let daiCrossChainHarness: CrossChainTestHarness;
90
60
  let wethCrossChainHarness: CrossChainTestHarness;
91
61
 
92
- let deployL1ContractsValues: DeployL1ContractsReturnType;
93
- let rollup: GetContractReturnType<typeof RollupAbi, ViemWalletClient>;
94
- let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ViemWalletClient>;
62
+ let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
63
+ let rollup: RollupContract;
64
+ let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
95
65
  let uniswapPortalAddress: EthAddress;
96
66
  let uniswapL2Contract: UniswapContract;
97
67
 
@@ -100,43 +70,41 @@ export const uniswapL1L2TestSuite = (
100
70
  const minimumOutputAmount = 0n;
101
71
 
102
72
  let cheatCodes: CheatCodes;
103
-
73
+ let version: number;
104
74
  beforeAll(async () => {
75
+ const t = await setup();
105
76
  ({
106
77
  aztecNode,
107
- pxe,
108
78
  logger,
109
- publicClient,
110
- walletClient,
111
- ownerWallet,
112
- sponsorWallet,
113
79
  deployL1ContractsValues,
114
80
  cheatCodes,
115
- } = await setup());
81
+ wallet,
82
+ accounts: [ownerAddress, sponsorAddress],
83
+ } = t);
84
+
85
+ l1Client = deployL1ContractsValues.l1Client;
86
+
87
+ t.watcher?.setIsMarkingAsProven(false);
116
88
 
117
- if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
89
+ if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
118
90
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
119
91
  }
120
92
 
121
- rollup = getContract({
122
- address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
123
- abi: RollupAbi,
124
- client: deployL1ContractsValues.walletClient,
125
- });
126
-
127
- ownerAddress = ownerWallet.getAddress();
128
- // sponsorAddress = sponsorWallet.getAddress();
129
- ownerEthAddress = EthAddress.fromString((await walletClient.getAddresses())[0]);
93
+ rollup = new RollupContract(
94
+ deployL1ContractsValues.l1Client,
95
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
96
+ );
97
+ version = Number(await rollup.getVersion());
98
+ ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
130
99
 
131
- await ensureAccountsPubliclyDeployed(ownerWallet, [ownerWallet, sponsorWallet]);
100
+ await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
132
101
 
133
102
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
134
103
  daiCrossChainHarness = await CrossChainTestHarness.new(
135
104
  aztecNode,
136
- pxe,
137
- publicClient,
138
- walletClient,
139
- ownerWallet,
105
+ deployL1ContractsValues.l1Client,
106
+ wallet,
107
+ ownerAddress,
140
108
  logger,
141
109
  DAI_ADDRESS,
142
110
  );
@@ -144,31 +112,27 @@ export const uniswapL1L2TestSuite = (
144
112
  logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
145
113
  wethCrossChainHarness = await CrossChainTestHarness.new(
146
114
  aztecNode,
147
- pxe,
148
- publicClient,
149
- walletClient,
150
- ownerWallet,
115
+ l1Client,
116
+ wallet,
117
+ ownerAddress,
151
118
  logger,
152
119
  WETH9_ADDRESS,
153
120
  );
154
121
 
155
122
  logger.info('Deploy Uniswap portal on L1 and L2...');
156
- uniswapPortalAddress = await deployL1Contract(
157
- walletClient,
158
- publicClient,
159
- UniswapPortalAbi,
160
- UniswapPortalBytecode,
161
- ).then(({ address }) => address);
123
+ uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(
124
+ ({ address }) => address,
125
+ );
162
126
 
163
127
  uniswapPortal = getContract({
164
128
  address: uniswapPortalAddress.toString(),
165
129
  abi: UniswapPortalAbi,
166
- client: walletClient,
130
+ client: l1Client,
167
131
  });
168
132
  // deploy l2 uniswap contract and attach to portal
169
- uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send().deployed();
133
+ uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({ from: ownerAddress });
170
134
 
171
- const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
135
+ const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
172
136
 
173
137
  await uniswapPortal.write.initialize(
174
138
  [registryAddress.toString(), uniswapL2Contract.address.toString()],
@@ -177,13 +141,12 @@ export const uniswapL1L2TestSuite = (
177
141
 
178
142
  // Give me some WETH so I can deposit to L2 and do the swap...
179
143
  logger.info('Getting some weth');
180
- const hash = await walletClient.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
181
- await publicClient.waitForTransactionReceipt({ hash });
144
+ const hash = await l1Client.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
145
+ await l1Client.waitForTransactionReceipt({ hash });
182
146
 
183
147
  const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
184
148
  expect(wethBalance).toBe(parseEther('1000'));
185
149
  });
186
- // docs:end:uniswap_l1_l2_test_beforeAll
187
150
 
188
151
  afterAll(async () => {
189
152
  await cleanup();
@@ -218,7 +181,7 @@ export const uniswapL1L2TestSuite = (
218
181
  // 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
219
182
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
220
183
  const nonceForWETHTransferToPublicApproval = new Fr(1n);
221
- await ownerWallet.createAuthWit({
184
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
222
185
  caller: uniswapL2Contract.address,
223
186
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
224
187
  ownerAddress,
@@ -244,8 +207,7 @@ export const uniswapL1L2TestSuite = (
244
207
  secretHashForDepositingSwappedDai,
245
208
  ownerEthAddress,
246
209
  )
247
- .send()
248
- .wait();
210
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
249
211
 
250
212
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
251
213
  const swapPrivateContent = sha256ToField([
@@ -259,13 +221,13 @@ export const uniswapL1L2TestSuite = (
259
221
  ownerEthAddress.toBuffer32(),
260
222
  ]);
261
223
 
262
- const swapPrivateLeaf = sha256ToField([
263
- uniswapL2Contract.address,
264
- new Fr(1), // aztec version
265
- EthAddress.fromString(uniswapPortal.address).toBuffer32(),
266
- new Fr(publicClient.chain.id), // chain id
267
- swapPrivateContent,
268
- ]);
224
+ const swapPrivateLeaf = computeL2ToL1MessageHash({
225
+ l2Sender: uniswapL2Contract.address,
226
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
227
+ content: swapPrivateContent,
228
+ rollupVersion: new Fr(version),
229
+ chainId: new Fr(l1Client.chain.id),
230
+ });
269
231
 
270
232
  const withdrawContent = sha256ToField([
271
233
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -274,39 +236,41 @@ export const uniswapL1L2TestSuite = (
274
236
  uniswapPortalAddress.toBuffer32(),
275
237
  ]);
276
238
 
277
- const withdrawLeaf = sha256ToField([
278
- wethCrossChainHarness.l2Bridge.address,
279
- new Fr(1), // aztec version
280
- wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
281
- new Fr(publicClient.chain.id), // chain id
282
- withdrawContent,
283
- ]);
239
+ const withdrawLeaf = computeL2ToL1MessageHash({
240
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
241
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
242
+ content: withdrawContent,
243
+ rollupVersion: new Fr(version),
244
+ chainId: new Fr(l1Client.chain.id),
245
+ });
284
246
 
285
247
  // ensure that user's funds were burnt
286
248
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
287
249
  // ensure that uniswap contract didn't eat the funds.
288
250
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
289
251
 
290
- // 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.read.getPendingBlockNumber());
252
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
253
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(l2UniswapInteractionReceipt.blockNumber!);
254
+ const epoch = await rollup.getEpochNumberForCheckpoint(checkpointNumber);
255
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
256
+ await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
292
257
 
293
258
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
294
259
  logger.info('Execute withdraw and swap on the uniswapPortal!');
295
260
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
296
261
  daiCrossChainHarness.tokenPortalAddress,
297
262
  );
263
+ const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
264
+ const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
298
265
 
299
- const [swapPrivateL2MessageIndex, swapPrivateSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
300
- l2UniswapInteractionReceipt.blockNumber!,
301
- swapPrivateLeaf,
302
- );
303
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
304
- l2UniswapInteractionReceipt.blockNumber!,
305
- withdrawLeaf,
306
- );
266
+ const swapPrivateL2MessageIndex = swapResult!.leafIndex;
267
+ const swapPrivateSiblingPath = swapResult!.siblingPath;
268
+
269
+ const withdrawL2MessageIndex = withdrawResult!.leafIndex;
270
+ const withdrawSiblingPath = withdrawResult!.siblingPath;
307
271
 
308
272
  const withdrawMessageMetadata = {
309
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
273
+ _epoch: BigInt(epoch),
310
274
  _leafIndex: BigInt(withdrawL2MessageIndex),
311
275
  _path: withdrawSiblingPath
312
276
  .toBufferArray()
@@ -314,7 +278,7 @@ export const uniswapL1L2TestSuite = (
314
278
  };
315
279
 
316
280
  const swapPrivateMessageMetadata = {
317
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
281
+ _epoch: BigInt(epoch),
318
282
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
319
283
  _path: swapPrivateSiblingPath
320
284
  .toBufferArray()
@@ -333,7 +297,7 @@ export const uniswapL1L2TestSuite = (
333
297
  ] as const;
334
298
 
335
299
  // this should also insert a message into the inbox.
336
- const txReceipt = await daiCrossChainHarness.publicClient.waitForTransactionReceipt({
300
+ const txReceipt = await daiCrossChainHarness.l1Client.waitForTransactionReceipt({
337
301
  hash: await uniswapPortal.write.swapPrivate(swapArgs),
338
302
  });
339
303
 
@@ -461,10 +425,10 @@ export const uniswapL1L2TestSuite = (
461
425
  // ownerEthAddress,
462
426
  // nonceForSwap,
463
427
  // );
464
- // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send().wait();
428
+ // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
465
429
 
466
430
  // // 4.2 Call swap_public from user2 on behalf of owner
467
- // const uniswapL2Interaction = await action.send().wait();
431
+ // const uniswapL2Interaction = await action.send();
468
432
 
469
433
  // const swapPublicContent = sha256ToField([
470
434
  // Buffer.from(
@@ -525,7 +489,7 @@ export const uniswapL1L2TestSuite = (
525
489
  // );
526
490
 
527
491
  // const withdrawMessageMetadata = {
528
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
492
+ // _epoch: epoch,
529
493
  // _leafIndex: BigInt(withdrawL2MessageIndex),
530
494
  // _path: withdrawSiblingPath
531
495
  // .toBufferArray()
@@ -533,7 +497,7 @@ export const uniswapL1L2TestSuite = (
533
497
  // };
534
498
 
535
499
  // const swapPrivateMessageMetadata = {
536
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
500
+ // _epoch: epoch,
537
501
  // _leafIndex: BigInt(swapPrivateL2MessageIndex),
538
502
  // _path: swapPrivateSiblingPath
539
503
  // .toBufferArray()
@@ -620,14 +584,16 @@ export const uniswapL1L2TestSuite = (
620
584
  const expectedMessageHash = await computeAuthWitMessageHash(
621
585
  {
622
586
  caller: uniswapL2Contract.address,
623
- action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
624
- ownerAddress,
625
- uniswapL2Contract.address,
626
- wethAmountToBridge,
627
- nonceForWETHTransferToPublicApproval,
628
- ),
587
+ call: await wethCrossChainHarness.l2Token.methods
588
+ .transfer_to_public(
589
+ ownerAddress,
590
+ uniswapL2Contract.address,
591
+ wethAmountToBridge,
592
+ nonceForWETHTransferToPublicApproval,
593
+ )
594
+ .getFunctionCall(),
629
595
  },
630
- { chainId: ownerWallet.getChainId(), version: ownerWallet.getVersion() },
596
+ await wallet.getChainInfo(),
631
597
  );
632
598
 
633
599
  await expect(
@@ -643,7 +609,7 @@ export const uniswapL1L2TestSuite = (
643
609
  Fr.random(),
644
610
  ownerEthAddress,
645
611
  )
646
- .prove(),
612
+ .simulate({ from: ownerAddress }),
647
613
  ).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
648
614
  });
649
615
 
@@ -655,7 +621,7 @@ export const uniswapL1L2TestSuite = (
655
621
  // 2. owner gives uniswap approval to transfer the funds to public:
656
622
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
657
623
  const nonceForWETHTransferToPublicApproval = new Fr(3n);
658
- await ownerWallet.createAuthWit({
624
+ const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
659
625
  caller: uniswapL2Contract.address,
660
626
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
661
627
  ownerAddress,
@@ -680,7 +646,7 @@ export const uniswapL1L2TestSuite = (
680
646
  Fr.random(),
681
647
  ownerEthAddress,
682
648
  )
683
- .prove(),
649
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
684
650
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
685
651
  });
686
652
 
@@ -692,7 +658,8 @@ export const uniswapL1L2TestSuite = (
692
658
 
693
659
  // 2. Give approval to uniswap to transfer funds to itself
694
660
  const nonceForWETHTransferApproval = new Fr(2n);
695
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
661
+ const validateActionInteraction = await wallet.setPublicAuthWit(
662
+ ownerAddress,
696
663
  {
697
664
  caller: uniswapL2Contract.address,
698
665
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -704,7 +671,7 @@ export const uniswapL1L2TestSuite = (
704
671
  },
705
672
  true,
706
673
  );
707
- await validateActionInteraction.send().wait();
674
+ await validateActionInteraction.send();
708
675
 
709
676
  // No approval to call `swap` but should work even without it:
710
677
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -723,8 +690,7 @@ export const uniswapL1L2TestSuite = (
723
690
  ownerEthAddress,
724
691
  Fr.ZERO, // nonce for swap -> doesn't matter
725
692
  )
726
- .send()
727
- .wait();
693
+ .send({ from: ownerAddress });
728
694
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
729
695
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
730
696
  });
@@ -736,32 +702,35 @@ export const uniswapL1L2TestSuite = (
736
702
  const nonceForWETHTransferApproval = new Fr(3n);
737
703
  const nonceForSwap = new Fr(3n);
738
704
  const secretHashForDepositingSwappedDai = new Fr(4n);
739
- const action = uniswapL2Contract
740
- .withWallet(sponsorWallet)
741
- .methods.swap_public(
742
- ownerAddress,
743
- wethCrossChainHarness.l2Bridge.address,
744
- wethAmountToBridge,
745
- daiCrossChainHarness.l2Bridge.address,
746
- nonceForWETHTransferApproval,
747
- uniswapFeeTier,
748
- minimumOutputAmount,
749
- ownerAddress,
750
- secretHashForDepositingSwappedDai,
751
- ownerEthAddress,
752
- nonceForSwap,
753
- );
754
- const validateActionInteraction = await ownerWallet.setPublicAuthWit({ caller: approvedUser, action }, true);
755
- await validateActionInteraction.send().wait();
705
+ const action = uniswapL2Contract.methods.swap_public(
706
+ ownerAddress,
707
+ wethCrossChainHarness.l2Bridge.address,
708
+ wethAmountToBridge,
709
+ daiCrossChainHarness.l2Bridge.address,
710
+ nonceForWETHTransferApproval,
711
+ uniswapFeeTier,
712
+ minimumOutputAmount,
713
+ ownerAddress,
714
+ secretHashForDepositingSwappedDai,
715
+ ownerEthAddress,
716
+ nonceForSwap,
717
+ );
718
+ const validateActionInteraction = await wallet.setPublicAuthWit(
719
+ ownerAddress,
720
+ { caller: approvedUser, action },
721
+ true,
722
+ );
723
+ await validateActionInteraction.send();
756
724
 
757
- await expect(action.simulate()).rejects.toThrow(/unauthorized/);
725
+ await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
758
726
  });
759
727
 
760
728
  it("uniswap can't pull funds without transfer approval", async () => {
761
729
  // swap should fail since no transfer approval to uniswap:
762
730
  const nonceForWETHTransferApproval = new Fr(4n);
763
731
 
764
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
732
+ const validateActionInteraction = await wallet.setPublicAuthWit(
733
+ ownerAddress,
765
734
  {
766
735
  caller: uniswapL2Contract.address,
767
736
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -773,7 +742,7 @@ export const uniswapL1L2TestSuite = (
773
742
  },
774
743
  true,
775
744
  );
776
- await validateActionInteraction.send().wait();
745
+ await validateActionInteraction.send();
777
746
 
778
747
  await expect(
779
748
  uniswapL2Contract.methods
@@ -790,7 +759,7 @@ export const uniswapL1L2TestSuite = (
790
759
  ownerEthAddress,
791
760
  Fr.ZERO,
792
761
  )
793
- .simulate(),
762
+ .simulate({ from: ownerAddress }),
794
763
  ).rejects.toThrow(/unauthorized/);
795
764
  });
796
765
 
@@ -803,7 +772,7 @@ export const uniswapL1L2TestSuite = (
803
772
  // Owner gives uniswap approval to transfer the funds to public to self on its behalf
804
773
  logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
805
774
  const nonceForWETHTransferToPublicApproval = new Fr(4n);
806
- await ownerWallet.createAuthWit({
775
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
807
776
  caller: uniswapL2Contract.address,
808
777
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
809
778
  ownerAddress,
@@ -830,8 +799,7 @@ export const uniswapL1L2TestSuite = (
830
799
  secretHashForDepositingSwappedDai,
831
800
  ownerEthAddress,
832
801
  )
833
- .send()
834
- .wait();
802
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
835
803
 
836
804
  const swapPrivateContent = sha256ToField([
837
805
  Buffer.from(
@@ -847,13 +815,13 @@ export const uniswapL1L2TestSuite = (
847
815
  ownerEthAddress.toBuffer32(),
848
816
  ]);
849
817
 
850
- const swapPrivateLeaf = sha256ToField([
851
- uniswapL2Contract.address,
852
- new Fr(1), // aztec version
853
- EthAddress.fromString(uniswapPortal.address).toBuffer32(),
854
- new Fr(publicClient.chain.id), // chain id
855
- swapPrivateContent,
856
- ]);
818
+ const swapPrivateLeaf = computeL2ToL1MessageHash({
819
+ l2Sender: uniswapL2Contract.address,
820
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
821
+ content: swapPrivateContent,
822
+ rollupVersion: new Fr(version),
823
+ chainId: new Fr(l1Client.chain.id),
824
+ });
857
825
 
858
826
  const withdrawContent = sha256ToField([
859
827
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -862,25 +830,28 @@ export const uniswapL1L2TestSuite = (
862
830
  uniswapPortalAddress.toBuffer32(),
863
831
  ]);
864
832
 
865
- const withdrawLeaf = sha256ToField([
866
- wethCrossChainHarness.l2Bridge.address,
867
- new Fr(1), // aztec version
868
- wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
869
- new Fr(publicClient.chain.id), // chain id
870
- withdrawContent,
871
- ]);
833
+ const withdrawLeaf = computeL2ToL1MessageHash({
834
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
835
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
836
+ content: withdrawContent,
837
+ rollupVersion: new Fr(version),
838
+ chainId: new Fr(l1Client.chain.id),
839
+ });
872
840
 
873
- const [swapPrivateL2MessageIndex, swapPrivateSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
874
- withdrawReceipt.blockNumber!,
875
- swapPrivateLeaf,
876
- );
877
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
878
- withdrawReceipt.blockNumber!,
879
- withdrawLeaf,
841
+ const epoch = await rollup.getEpochNumberForCheckpoint(
842
+ CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
880
843
  );
844
+ const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
845
+ const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
846
+
847
+ const swapPrivateL2MessageIndex = swapResult!.leafIndex;
848
+ const swapPrivateSiblingPath = swapResult!.siblingPath;
849
+
850
+ const withdrawL2MessageIndex = withdrawResult!.leafIndex;
851
+ const withdrawSiblingPath = withdrawResult!.siblingPath;
881
852
 
882
853
  const withdrawMessageMetadata = {
883
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
854
+ _epoch: BigInt(epoch),
884
855
  _leafIndex: BigInt(withdrawL2MessageIndex),
885
856
  _path: withdrawSiblingPath
886
857
  .toBufferArray()
@@ -888,7 +859,7 @@ export const uniswapL1L2TestSuite = (
888
859
  };
889
860
 
890
861
  const swapPrivateMessageMetadata = {
891
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
862
+ _epoch: BigInt(epoch),
892
863
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
893
864
  _path: swapPrivateSiblingPath
894
865
  .toBufferArray()
@@ -898,8 +869,9 @@ export const uniswapL1L2TestSuite = (
898
869
  // ensure that user's funds were burnt
899
870
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
900
871
 
901
- // 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.read.getPendingBlockNumber());
872
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
873
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
874
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
903
875
 
904
876
  // On L1 call swap_public!
905
877
  logger.info('call swap_public on L1');
@@ -927,7 +899,8 @@ export const uniswapL1L2TestSuite = (
927
899
 
928
900
  // Owner gives uniswap approval to transfer funds on its behalf
929
901
  const nonceForWETHTransferApproval = new Fr(5n);
930
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
902
+ const validateActionInteraction = await wallet.setPublicAuthWit(
903
+ ownerAddress,
931
904
  {
932
905
  caller: uniswapL2Contract.address,
933
906
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -939,7 +912,7 @@ export const uniswapL1L2TestSuite = (
939
912
  },
940
913
  true,
941
914
  );
942
- await validateActionInteraction.send().wait();
915
+ await validateActionInteraction.send();
943
916
 
944
917
  // Call swap_public on L2
945
918
  const secretHashForDepositingSwappedDai = Fr.random();
@@ -957,8 +930,7 @@ export const uniswapL1L2TestSuite = (
957
930
  ownerEthAddress,
958
931
  Fr.ZERO,
959
932
  )
960
- .send()
961
- .wait();
933
+ .send({ from: ownerAddress });
962
934
 
963
935
  const swapPublicContent = sha256ToField([
964
936
  Buffer.from(
@@ -977,13 +949,13 @@ export const uniswapL1L2TestSuite = (
977
949
  ownerEthAddress.toBuffer32(),
978
950
  ]);
979
951
 
980
- const swapPublicLeaf = sha256ToField([
981
- uniswapL2Contract.address,
982
- new Fr(1), // aztec version
983
- EthAddress.fromString(uniswapPortal.address).toBuffer32(),
984
- new Fr(publicClient.chain.id), // chain id
985
- swapPublicContent,
986
- ]);
952
+ const swapPublicLeaf = computeL2ToL1MessageHash({
953
+ l2Sender: uniswapL2Contract.address,
954
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
955
+ content: swapPublicContent,
956
+ rollupVersion: new Fr(version),
957
+ chainId: new Fr(l1Client.chain.id),
958
+ });
987
959
 
988
960
  const withdrawContent = sha256ToField([
989
961
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -992,25 +964,28 @@ export const uniswapL1L2TestSuite = (
992
964
  uniswapPortalAddress.toBuffer32(),
993
965
  ]);
994
966
 
995
- const withdrawLeaf = sha256ToField([
996
- wethCrossChainHarness.l2Bridge.address,
997
- new Fr(1), // aztec version
998
- wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
999
- new Fr(publicClient.chain.id), // chain id
1000
- withdrawContent,
1001
- ]);
967
+ const withdrawLeaf = computeL2ToL1MessageHash({
968
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
969
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
970
+ content: withdrawContent,
971
+ rollupVersion: new Fr(version),
972
+ chainId: new Fr(l1Client.chain.id),
973
+ });
1002
974
 
1003
- const [swapPublicL2MessageIndex, swapPublicSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
1004
- withdrawReceipt.blockNumber!,
1005
- swapPublicLeaf,
1006
- );
1007
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
1008
- withdrawReceipt.blockNumber!,
1009
- withdrawLeaf,
975
+ const epoch = await rollup.getEpochNumberForCheckpoint(
976
+ CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
1010
977
  );
978
+ const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
979
+ const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
980
+
981
+ const swapPublicL2MessageIndex = swapResult!.leafIndex;
982
+ const swapPublicSiblingPath = swapResult!.siblingPath;
983
+
984
+ const withdrawL2MessageIndex = withdrawResult!.leafIndex;
985
+ const withdrawSiblingPath = withdrawResult!.siblingPath;
1011
986
 
1012
987
  const withdrawMessageMetadata = {
1013
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
988
+ _epoch: BigInt(epoch),
1014
989
  _leafIndex: BigInt(withdrawL2MessageIndex),
1015
990
  _path: withdrawSiblingPath
1016
991
  .toBufferArray()
@@ -1018,7 +993,7 @@ export const uniswapL1L2TestSuite = (
1018
993
  };
1019
994
 
1020
995
  const swapPublicMessageMetadata = {
1021
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
996
+ _epoch: BigInt(epoch),
1022
997
  _leafIndex: BigInt(swapPublicL2MessageIndex),
1023
998
  _path: swapPublicSiblingPath
1024
999
  .toBufferArray()
@@ -1028,8 +1003,9 @@ export const uniswapL1L2TestSuite = (
1028
1003
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1029
1004
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1030
1005
 
1031
- // 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.read.getPendingBlockNumber());
1006
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
1007
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
1008
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1033
1009
 
1034
1010
  // Call swap_private on L1
1035
1011
  logger.info('Execute withdraw and swap on the uniswapPortal!');