@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-devnet.3

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 (137) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.d.ts +16 -12
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
  6. package/dest/bench/utils.d.ts +2 -11
  7. package/dest/bench/utils.d.ts.map +1 -1
  8. package/dest/bench/utils.js +10 -34
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -8
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +31 -33
  15. package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  17. package/dest/e2e_deploy_contract/deploy_test.js +9 -18
  18. package/dest/e2e_epochs/epochs_test.d.ts +9 -3
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +19 -13
  21. package/dest/e2e_fees/bridging_race.notest.js +12 -9
  22. package/dest/e2e_fees/fees_test.d.ts +5 -5
  23. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  24. package/dest/e2e_fees/fees_test.js +26 -33
  25. package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
  26. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  27. package/dest/e2e_l1_publisher/write_json.js +5 -5
  28. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  29. package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
  30. package/dest/e2e_multi_validator/utils.js +3 -9
  31. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
  32. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  33. package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
  34. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  35. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  36. package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
  37. package/dest/e2e_p2p/p2p_network.d.ts +22 -8
  38. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  39. package/dest/e2e_p2p/p2p_network.js +36 -15
  40. package/dest/e2e_p2p/shared.d.ts +12 -13
  41. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  42. package/dest/e2e_p2p/shared.js +54 -54
  43. package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
  44. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  45. package/dest/e2e_token_contract/token_contract_test.js +14 -17
  46. package/dest/fixtures/e2e_prover_test.d.ts +8 -6
  47. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  48. package/dest/fixtures/e2e_prover_test.js +42 -51
  49. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  50. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  51. package/dest/fixtures/get_bb_config.d.ts +1 -1
  52. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  53. package/dest/fixtures/get_bb_config.js +2 -2
  54. package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
  55. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  56. package/dest/fixtures/setup_l1_contracts.js +2 -2
  57. package/dest/fixtures/setup_p2p_test.d.ts +10 -9
  58. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  59. package/dest/fixtures/setup_p2p_test.js +38 -20
  60. package/dest/fixtures/snapshot_manager.d.ts +10 -7
  61. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  62. package/dest/fixtures/snapshot_manager.js +60 -47
  63. package/dest/fixtures/token_utils.d.ts +6 -4
  64. package/dest/fixtures/token_utils.d.ts.map +1 -1
  65. package/dest/fixtures/token_utils.js +11 -15
  66. package/dest/fixtures/utils.d.ts +26 -28
  67. package/dest/fixtures/utils.d.ts.map +1 -1
  68. package/dest/fixtures/utils.js +83 -109
  69. package/dest/fixtures/web3signer.d.ts +5 -0
  70. package/dest/fixtures/web3signer.d.ts.map +1 -0
  71. package/dest/fixtures/web3signer.js +53 -0
  72. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  73. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  74. package/dest/shared/cross_chain_test_harness.d.ts +16 -10
  75. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  76. package/dest/shared/cross_chain_test_harness.js +13 -15
  77. package/dest/shared/gas_portal_test_harness.d.ts +9 -6
  78. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  79. package/dest/shared/gas_portal_test_harness.js +10 -7
  80. package/dest/shared/jest_setup.js +1 -1
  81. package/dest/shared/submit-transactions.d.ts +5 -3
  82. package/dest/shared/submit-transactions.d.ts.map +1 -1
  83. package/dest/shared/submit-transactions.js +8 -7
  84. package/dest/shared/uniswap_l1_l2.d.ts +9 -6
  85. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  86. package/dest/shared/uniswap_l1_l2.js +29 -45
  87. package/dest/simulators/lending_simulator.d.ts +2 -1
  88. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  89. package/dest/simulators/lending_simulator.js +3 -2
  90. package/dest/simulators/token_simulator.d.ts +3 -1
  91. package/dest/simulators/token_simulator.d.ts.map +1 -1
  92. package/dest/simulators/token_simulator.js +2 -2
  93. package/dest/spartan/setup_test_wallets.d.ts +19 -13
  94. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  95. package/dest/spartan/setup_test_wallets.js +108 -85
  96. package/dest/spartan/utils.d.ts +68 -3
  97. package/dest/spartan/utils.d.ts.map +1 -1
  98. package/dest/spartan/utils.js +312 -49
  99. package/package.json +39 -38
  100. package/src/bench/client_flows/benchmark.ts +6 -6
  101. package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
  102. package/src/bench/client_flows/data_extractor.ts +1 -1
  103. package/src/bench/utils.ts +9 -37
  104. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
  105. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
  106. package/src/e2e_deploy_contract/deploy_test.ts +17 -35
  107. package/src/e2e_epochs/epochs_test.ts +22 -19
  108. package/src/e2e_fees/bridging_race.notest.ts +14 -9
  109. package/src/e2e_fees/fees_test.ts +29 -40
  110. package/src/e2e_l1_publisher/write_json.ts +8 -6
  111. package/src/e2e_multi_validator/utils.ts +4 -10
  112. package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
  113. package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
  114. package/src/e2e_p2p/p2p_network.ts +110 -71
  115. package/src/e2e_p2p/shared.ts +57 -56
  116. package/src/e2e_token_contract/token_contract_test.ts +17 -17
  117. package/src/fixtures/e2e_prover_test.ts +52 -88
  118. package/src/fixtures/get_acvm_config.ts +1 -1
  119. package/src/fixtures/get_bb_config.ts +3 -2
  120. package/src/fixtures/setup_l1_contracts.ts +3 -3
  121. package/src/fixtures/setup_p2p_test.ts +60 -27
  122. package/src/fixtures/snapshot_manager.ts +80 -72
  123. package/src/fixtures/token_utils.ts +13 -21
  124. package/src/fixtures/utils.ts +95 -145
  125. package/src/fixtures/web3signer.ts +63 -0
  126. package/src/guides/up_quick_start.sh +2 -10
  127. package/src/quality_of_service/alert_checker.ts +1 -1
  128. package/src/shared/cross_chain_test_harness.ts +18 -29
  129. package/src/shared/gas_portal_test_harness.ts +12 -19
  130. package/src/shared/jest_setup.ts +1 -1
  131. package/src/shared/submit-transactions.ts +12 -8
  132. package/src/shared/uniswap_l1_l2.ts +61 -67
  133. package/src/simulators/lending_simulator.ts +3 -2
  134. package/src/simulators/token_simulator.ts +5 -2
  135. package/src/spartan/DEVELOP.md +8 -3
  136. package/src/spartan/setup_test_wallets.ts +133 -126
  137. package/src/spartan/utils.ts +373 -48
@@ -1,24 +1,21 @@
1
- // docs:start:cross_chain_test_harness
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { EthAddress } from '@aztec/aztec.js/addresses';
3
+ import { AuthWitness } from '@aztec/aztec.js/authorization';
2
4
  import {
3
- type AccountWallet,
4
- AuthWitness,
5
- type AztecAddress,
6
- type AztecNode,
7
- EthAddress,
8
- type FieldsOf,
9
- Fr,
10
5
  type L1TokenManager,
11
6
  L1TokenPortalManager,
12
7
  type L2AmountClaim,
13
8
  type L2AmountClaimWithRecipient,
14
- type Logger,
15
- type PXE,
16
- type SiblingPath,
17
- type TxReceipt,
18
- type Wallet,
19
- retryUntil,
20
- } from '@aztec/aztec.js';
9
+ } from '@aztec/aztec.js/ethereum';
10
+ import { Fr } from '@aztec/aztec.js/fields';
11
+ import type { Logger } from '@aztec/aztec.js/log';
12
+ import type { AztecNode } from '@aztec/aztec.js/node';
13
+ import type { SiblingPath } from '@aztec/aztec.js/trees';
14
+ import type { TxReceipt } from '@aztec/aztec.js/tx';
15
+ import type { Wallet } from '@aztec/aztec.js/wallet';
21
16
  import { type ExtendedViemWalletClient, type L1ContractAddresses, deployL1Contract } from '@aztec/ethereum';
17
+ import { retryUntil } from '@aztec/foundation/retry';
18
+ import type { FieldsOf } from '@aztec/foundation/types';
22
19
  import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
23
20
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
24
21
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
@@ -27,7 +24,6 @@ import { type Hex, getContract } from 'viem';
27
24
 
28
25
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
29
26
 
30
- // docs:start:deployAndInitializeTokenAndBridgeContracts
31
27
  /**
32
28
  * Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
33
29
  * @param wallet - the wallet instance
@@ -112,7 +108,6 @@ export async function deployAndInitializeTokenAndBridgeContracts(
112
108
 
113
109
  return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
114
110
  }
115
- // docs:end:deployAndInitializeTokenAndBridgeContracts
116
111
 
117
112
  export type CrossChainContext = {
118
113
  l2Token: AztecAddress;
@@ -132,15 +127,14 @@ export type CrossChainContext = {
132
127
  export class CrossChainTestHarness {
133
128
  static async new(
134
129
  aztecNode: AztecNode,
135
- pxeService: PXE,
136
130
  l1Client: ExtendedViemWalletClient,
137
- wallet: AccountWallet,
131
+ wallet: Wallet,
138
132
  ownerAddress: AztecAddress,
139
133
  logger: Logger,
140
134
  underlyingERC20Address: EthAddress,
141
135
  ): Promise<CrossChainTestHarness> {
142
136
  const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
143
- const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
137
+ const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
144
138
 
145
139
  // Deploy and initialize all required contracts
146
140
  logger.info('Deploying and initializing token, portal and its bridge...');
@@ -148,14 +142,13 @@ export class CrossChainTestHarness {
148
142
  wallet,
149
143
  l1Client,
150
144
  l1ContractAddresses.registryAddress,
151
- wallet.getAddress(),
145
+ ownerAddress,
152
146
  underlyingERC20Address,
153
147
  );
154
148
  logger.info('Deployed and initialized token, portal and its bridge.');
155
149
 
156
150
  return new CrossChainTestHarness(
157
151
  aztecNode,
158
- pxeService,
159
152
  logger,
160
153
  token,
161
154
  bridge,
@@ -175,8 +168,6 @@ export class CrossChainTestHarness {
175
168
  constructor(
176
169
  /** Aztec node instance. */
177
170
  public aztecNode: AztecNode,
178
- /** Private eXecution Environment (PXE). */
179
- public pxeService: PXE,
180
171
  /** Logger. */
181
172
  public logger: Logger,
182
173
 
@@ -198,8 +189,8 @@ export class CrossChainTestHarness {
198
189
  /** Deployment addresses for all L1 contracts */
199
190
  public readonly l1ContractAddresses: L1ContractAddresses,
200
191
 
201
- /** Wallet of the owner. */
202
- public readonly ownerWallet: AccountWallet,
192
+ /** Wallet to simulate and send txs from. */
193
+ public readonly wallet: Wallet,
203
194
 
204
195
  /** Owner of the l2 token and bridge */
205
196
  public readonly ownerAddress: AztecAddress,
@@ -213,7 +204,6 @@ export class CrossChainTestHarness {
213
204
  this.logger,
214
205
  );
215
206
  this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
216
- this.ownerAddress = this.ownerWallet.getAddress();
217
207
  }
218
208
 
219
209
  async mintTokensOnL1(amount: bigint) {
@@ -246,7 +236,7 @@ export class CrossChainTestHarness {
246
236
  }
247
237
 
248
238
  async mintTokensPrivateOnL2(amount: bigint) {
249
- await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerWallet, this.ownerAddress, amount);
239
+ await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
250
240
  }
251
241
 
252
242
  async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
@@ -389,4 +379,3 @@ export class CrossChainTestHarness {
389
379
  };
390
380
  }
391
381
  }
392
- // docs:end:cross_chain_test_harness
@@ -1,17 +1,11 @@
1
- import {
2
- type AztecAddress,
3
- type AztecNode,
4
- EthAddress,
5
- Fr,
6
- L1FeeJuicePortalManager,
7
- type L1TokenManager,
8
- type L2AmountClaim,
9
- type Logger,
10
- type PXE,
11
- type Wallet,
12
- retryUntil,
13
- } from '@aztec/aztec.js';
1
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
2
+ import { L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim } from '@aztec/aztec.js/ethereum';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import type { Logger } from '@aztec/aztec.js/log';
5
+ import type { AztecNode } from '@aztec/aztec.js/node';
6
+ import type { Wallet } from '@aztec/aztec.js/wallet';
14
7
  import type { ExtendedViemWalletClient } from '@aztec/ethereum';
8
+ import { retryUntil } from '@aztec/foundation/retry';
15
9
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
16
10
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
17
11
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
@@ -27,7 +21,6 @@ export interface IGasBridgingTestHarness {
27
21
  export interface FeeJuicePortalTestingHarnessFactoryConfig {
28
22
  aztecNode: AztecNode;
29
23
  aztecNodeAdmin?: AztecNodeAdmin;
30
- pxeService: PXE;
31
24
  l1Client: ExtendedViemWalletClient;
32
25
  wallet: Wallet;
33
26
  logger: Logger;
@@ -38,10 +31,10 @@ export class FeeJuicePortalTestingHarnessFactory {
38
31
  private constructor(private config: FeeJuicePortalTestingHarnessFactoryConfig) {}
39
32
 
40
33
  private async createReal() {
41
- const { aztecNode, aztecNodeAdmin, pxeService, l1Client, wallet, logger } = this.config;
34
+ const { aztecNode, aztecNodeAdmin, l1Client, wallet, logger } = this.config;
42
35
 
43
36
  const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
44
- const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
37
+ const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
45
38
 
46
39
  const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
47
40
  const feeJuicePortalAddress = l1ContractAddresses.feeJuicePortalAddress;
@@ -55,7 +48,7 @@ export class FeeJuicePortalTestingHarnessFactory {
55
48
  return new GasBridgingTestHarness(
56
49
  aztecNode,
57
50
  aztecNodeAdmin,
58
- pxeService,
51
+ wallet,
59
52
  logger,
60
53
  gasL2,
61
54
  ethAccount,
@@ -85,8 +78,8 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
85
78
  public aztecNode: AztecNode,
86
79
  /** Aztec node admin interface */
87
80
  public aztecNodeAdmin: AztecNodeAdmin | undefined,
88
- /** Private eXecution Environment (PXE). */
89
- public pxeService: PXE,
81
+ /** Wallet. */
82
+ public wallet: Wallet,
90
83
  /** Logger. */
91
84
  public logger: Logger,
92
85
 
@@ -1,4 +1,4 @@
1
- import { createLogger } from '@aztec/aztec.js';
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
2
 
3
3
  import { beforeEach, expect } from '@jest/globals';
4
4
  import { basename } from 'path';
@@ -1,20 +1,24 @@
1
- import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
- import { Fr, GrumpkinScalar, type Logger, type SentTx, TxStatus, type Wallet } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { SentTx } from '@aztec/aztec.js/contracts';
3
+ import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields';
4
+ import type { Logger } from '@aztec/aztec.js/log';
5
+ import { TxStatus } from '@aztec/aztec.js/tx';
3
6
  import { times } from '@aztec/foundation/collection';
4
- import type { PXEService } from '@aztec/pxe/server';
7
+ import type { TestWallet } from '@aztec/test-wallet/server';
5
8
 
6
- // submits a set of transactions to the provided Private eXecution Environment (PXE)
9
+ // submits a set of transactions to the provided Wallet
7
10
  export const submitTxsTo = async (
8
- pxe: PXEService,
11
+ wallet: TestWallet,
12
+ submitter: AztecAddress,
9
13
  numTxs: number,
10
- wallet: Wallet,
11
14
  logger: Logger,
12
15
  ): Promise<SentTx[]> => {
13
16
  const txs: SentTx[] = [];
14
17
  await Promise.all(
15
18
  times(numTxs, async () => {
16
- const accountManager = await getSchnorrAccount(pxe, Fr.random(), GrumpkinScalar.random(), Fr.random());
17
- const tx = accountManager.deploy({ deployWallet: wallet });
19
+ const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
20
+ const deployMethod = await accountManager.getDeployMethod();
21
+ const tx = deployMethod.send({ from: submitter });
18
22
  const txHash = await tx.getTxHash();
19
23
 
20
24
  logger.info(`Tx sent with hash ${txHash}`);
@@ -1,14 +1,9 @@
1
- import {
2
- type AccountWallet,
3
- AztecAddress,
4
- type AztecNode,
5
- EthAddress,
6
- Fr,
7
- type Logger,
8
- type PXE,
9
- computeAuthWitMessageHash,
10
- generateClaimSecret,
11
- } 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';
12
7
  import { CheatCodes } from '@aztec/aztec/testing';
13
8
  import {
14
9
  type DeployL1ContractsReturnType,
@@ -22,6 +17,7 @@ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-art
22
17
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
23
18
  import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
24
19
  import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
20
+ import type { TestWallet } from '@aztec/test-wallet/server';
25
21
 
26
22
  import { jest } from '@jest/globals';
27
23
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
@@ -36,36 +32,33 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
36
32
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
37
33
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
38
34
 
39
- // docs:start:uniswap_l1_l2_test_setup_const
40
35
  const TIMEOUT = 360_000;
41
36
 
42
37
  /** Objects to be returned by the uniswap setup function */
43
38
  export type UniswapSetupContext = {
44
39
  /** Aztec Node instance */
45
40
  aztecNode: AztecNode;
46
- /** The Private eXecution Environment (PXE). */
47
- pxe: PXE;
48
41
  /** Logger instance named as the current test. */
49
42
  logger: Logger;
50
43
  /** The L1 wallet client, extended with public actions. */
51
44
  l1Client: ExtendedViemWalletClient;
52
- /** The owner wallet. */
53
- ownerWallet: AccountWallet;
45
+ /** The wallet. */
46
+ wallet: TestWallet;
47
+ /** The owner address. */
48
+ ownerAddress: AztecAddress;
54
49
  /** The sponsor wallet. */
55
- sponsorWallet: AccountWallet;
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,16 +66,14 @@ 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
71
  let l1Client: ExtendedViemWalletClient;
80
72
 
81
- let ownerWallet: AccountWallet;
73
+ let wallet: TestWallet;
82
74
  let ownerAddress: AztecAddress;
83
75
  let ownerEthAddress: EthAddress;
84
76
  // does transactions on behalf of owner on Aztec:
85
- let sponsorWallet: AccountWallet;
86
77
  let sponsorAddress: AztecAddress;
87
78
 
88
79
  let daiCrossChainHarness: CrossChainTestHarness;
@@ -101,7 +92,7 @@ export const uniswapL1L2TestSuite = (
101
92
  let cheatCodes: CheatCodes;
102
93
  let version: number;
103
94
  beforeAll(async () => {
104
- ({ aztecNode, pxe, logger, l1Client, ownerWallet, sponsorWallet, deployL1ContractsValues, cheatCodes } =
95
+ ({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } =
105
96
  await setup());
106
97
 
107
98
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
@@ -113,18 +104,15 @@ export const uniswapL1L2TestSuite = (
113
104
  deployL1ContractsValues.l1ContractAddresses.rollupAddress,
114
105
  );
115
106
  version = Number(await rollup.getVersion());
116
- ownerAddress = ownerWallet.getAddress();
117
- sponsorAddress = sponsorWallet.getAddress();
118
107
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
119
108
 
120
- await ensureAccountContractsPublished(ownerWallet, [ownerWallet, sponsorWallet]);
109
+ await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
121
110
 
122
111
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
123
112
  daiCrossChainHarness = await CrossChainTestHarness.new(
124
113
  aztecNode,
125
- pxe,
126
114
  deployL1ContractsValues.l1Client,
127
- ownerWallet,
115
+ wallet,
128
116
  ownerAddress,
129
117
  logger,
130
118
  DAI_ADDRESS,
@@ -133,9 +121,8 @@ export const uniswapL1L2TestSuite = (
133
121
  logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
134
122
  wethCrossChainHarness = await CrossChainTestHarness.new(
135
123
  aztecNode,
136
- pxe,
137
124
  l1Client,
138
- ownerWallet,
125
+ wallet,
139
126
  ownerAddress,
140
127
  logger,
141
128
  WETH9_ADDRESS,
@@ -152,11 +139,11 @@ export const uniswapL1L2TestSuite = (
152
139
  client: l1Client,
153
140
  });
154
141
  // deploy l2 uniswap contract and attach to portal
155
- uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress)
142
+ uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress)
156
143
  .send({ from: ownerAddress })
157
144
  .deployed();
158
145
 
159
- const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
146
+ const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
160
147
 
161
148
  await uniswapPortal.write.initialize(
162
149
  [registryAddress.toString(), uniswapL2Contract.address.toString()],
@@ -171,7 +158,6 @@ export const uniswapL1L2TestSuite = (
171
158
  const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
172
159
  expect(wethBalance).toBe(parseEther('1000'));
173
160
  });
174
- // docs:end:uniswap_l1_l2_test_beforeAll
175
161
 
176
162
  afterAll(async () => {
177
163
  await cleanup();
@@ -206,7 +192,7 @@ export const uniswapL1L2TestSuite = (
206
192
  // 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
207
193
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
208
194
  const nonceForWETHTransferToPublicApproval = new Fr(1n);
209
- const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
195
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
210
196
  caller: uniswapL2Contract.address,
211
197
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
212
198
  ownerAddress,
@@ -615,14 +601,16 @@ export const uniswapL1L2TestSuite = (
615
601
  const expectedMessageHash = await computeAuthWitMessageHash(
616
602
  {
617
603
  caller: uniswapL2Contract.address,
618
- action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
619
- ownerAddress,
620
- uniswapL2Contract.address,
621
- wethAmountToBridge,
622
- nonceForWETHTransferToPublicApproval,
623
- ),
604
+ call: await wethCrossChainHarness.l2Token.methods
605
+ .transfer_to_public(
606
+ ownerAddress,
607
+ uniswapL2Contract.address,
608
+ wethAmountToBridge,
609
+ nonceForWETHTransferToPublicApproval,
610
+ )
611
+ .getFunctionCall(),
624
612
  },
625
- { chainId: ownerWallet.getChainId(), version: ownerWallet.getVersion() },
613
+ await wallet.getChainInfo(),
626
614
  );
627
615
 
628
616
  await expect(
@@ -650,7 +638,7 @@ export const uniswapL1L2TestSuite = (
650
638
  // 2. owner gives uniswap approval to transfer the funds to public:
651
639
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
652
640
  const nonceForWETHTransferToPublicApproval = new Fr(3n);
653
- const transferToPublicAuthwith = await ownerWallet.createAuthWit({
641
+ const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
654
642
  caller: uniswapL2Contract.address,
655
643
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
656
644
  ownerAddress,
@@ -675,7 +663,8 @@ export const uniswapL1L2TestSuite = (
675
663
  Fr.random(),
676
664
  ownerEthAddress,
677
665
  )
678
- .prove({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
666
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] })
667
+ .wait(),
679
668
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
680
669
  });
681
670
 
@@ -687,7 +676,8 @@ export const uniswapL1L2TestSuite = (
687
676
 
688
677
  // 2. Give approval to uniswap to transfer funds to itself
689
678
  const nonceForWETHTransferApproval = new Fr(2n);
690
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
679
+ const validateActionInteraction = await wallet.setPublicAuthWit(
680
+ ownerAddress,
691
681
  {
692
682
  caller: uniswapL2Contract.address,
693
683
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -699,7 +689,7 @@ export const uniswapL1L2TestSuite = (
699
689
  },
700
690
  true,
701
691
  );
702
- await validateActionInteraction.send({ from: ownerAddress }).wait();
692
+ await validateActionInteraction.send().wait();
703
693
 
704
694
  // No approval to call `swap` but should work even without it:
705
695
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -731,23 +721,25 @@ export const uniswapL1L2TestSuite = (
731
721
  const nonceForWETHTransferApproval = new Fr(3n);
732
722
  const nonceForSwap = new Fr(3n);
733
723
  const secretHashForDepositingSwappedDai = new Fr(4n);
734
- const action = uniswapL2Contract
735
- .withWallet(sponsorWallet)
736
- .methods.swap_public(
737
- ownerAddress,
738
- wethCrossChainHarness.l2Bridge.address,
739
- wethAmountToBridge,
740
- daiCrossChainHarness.l2Bridge.address,
741
- nonceForWETHTransferApproval,
742
- uniswapFeeTier,
743
- minimumOutputAmount,
744
- ownerAddress,
745
- secretHashForDepositingSwappedDai,
746
- ownerEthAddress,
747
- nonceForSwap,
748
- );
749
- const validateActionInteraction = await ownerWallet.setPublicAuthWit({ caller: approvedUser, action }, true);
750
- await validateActionInteraction.send({ from: ownerAddress }).wait();
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
+ );
742
+ await validateActionInteraction.send().wait();
751
743
 
752
744
  await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
753
745
  });
@@ -756,7 +748,8 @@ export const uniswapL1L2TestSuite = (
756
748
  // swap should fail since no transfer approval to uniswap:
757
749
  const nonceForWETHTransferApproval = new Fr(4n);
758
750
 
759
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
751
+ const validateActionInteraction = await wallet.setPublicAuthWit(
752
+ ownerAddress,
760
753
  {
761
754
  caller: uniswapL2Contract.address,
762
755
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -768,7 +761,7 @@ export const uniswapL1L2TestSuite = (
768
761
  },
769
762
  true,
770
763
  );
771
- await validateActionInteraction.send({ from: ownerAddress }).wait();
764
+ await validateActionInteraction.send().wait();
772
765
 
773
766
  await expect(
774
767
  uniswapL2Contract.methods
@@ -798,7 +791,7 @@ export const uniswapL1L2TestSuite = (
798
791
  // Owner gives uniswap approval to transfer the funds to public to self on its behalf
799
792
  logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
800
793
  const nonceForWETHTransferToPublicApproval = new Fr(4n);
801
- const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
794
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
802
795
  caller: uniswapL2Contract.address,
803
796
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
804
797
  ownerAddress,
@@ -926,7 +919,8 @@ export const uniswapL1L2TestSuite = (
926
919
 
927
920
  // Owner gives uniswap approval to transfer funds on its behalf
928
921
  const nonceForWETHTransferApproval = new Fr(5n);
929
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
922
+ const validateActionInteraction = await wallet.setPublicAuthWit(
923
+ ownerAddress,
930
924
  {
931
925
  caller: uniswapL2Contract.address,
932
926
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -938,7 +932,7 @@ export const uniswapL1L2TestSuite = (
938
932
  },
939
933
  true,
940
934
  );
941
- await validateActionInteraction.send({ from: ownerAddress }).wait();
935
+ await validateActionInteraction.send().wait();
942
936
 
943
937
  // Call swap_public on L2
944
938
  const secretHashForDepositingSwappedDai = Fr.random();
@@ -1,5 +1,6 @@
1
1
  // Convenience struct to hold an account's address and secret that can easily be passed around.
2
- import { AztecAddress, Fr } from '@aztec/aztec.js';
2
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
3
+ import { Fr } from '@aztec/aztec.js/fields';
3
4
  import { CheatCodes } from '@aztec/aztec/testing';
4
5
  import type { RollupContract } from '@aztec/ethereum';
5
6
  import { pedersenHash } from '@aztec/foundation/crypto';
@@ -190,7 +191,7 @@ export class LendingSimulator {
190
191
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
191
192
 
192
193
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
193
- const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: key });
194
+ const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
194
195
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
195
196
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
196
197
  expect(privatePos['debt']).toEqual(
@@ -1,4 +1,7 @@
1
- import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { BatchCall } from '@aztec/aztec.js/contracts';
3
+ import type { Logger } from '@aztec/aztec.js/log';
4
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
5
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
3
6
 
4
7
  import chunk from 'lodash.chunk';
@@ -104,7 +107,7 @@ export class TokenSimulator {
104
107
 
105
108
  const results = (
106
109
  await Promise.all(
107
- chunk(calls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
110
+ chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
108
111
  )
109
112
  ).flat();
110
113
  expect(results[0]).toEqual(this.totalSupply);
@@ -60,10 +60,15 @@ The export is important there. The `AZTEC_DOCKER_IMAGE` env var is used as both:
60
60
  - the container that runs the rollup contract deployment
61
61
  - the containers for the aztec infrastructure (validators, provers, etc)
62
62
 
63
+ # Deploy Metrics
64
+ ```bash
65
+ ./spartan/bootstrap.sh metrics-kind
66
+ ```
67
+
63
68
  # Deploy stuff
64
69
 
65
70
  ```bash
66
- ./spartan/bootstrap.sh network_deploy scenario.local.env
71
+ ./spartan/bootstrap.sh network_deploy scenario.local
67
72
  ```
68
73
 
69
74
  That will take 1-3 minutes. But at the end you should have everything you need.
@@ -103,10 +108,10 @@ With the cluster running, you can now easily run tests.
103
108
 
104
109
  ```bash
105
110
  # run one
106
- ./spartan/bootstrap.sh single_test scenario.local.env spartan/smoke.test.ts
111
+ ./spartan/bootstrap.sh single_test scenario.local spartan/smoke.test.ts
107
112
 
108
113
  # run all (serially)
109
- ./spartan/bootstrap.sh network_tests scenario.local.env
114
+ ./spartan/bootstrap.sh network_tests scenario.local
110
115
  ```
111
116
 
112
117
  Right now, I recommend running the smoke test first, always, as it waits for the committee to exist.