@aztec/end-to-end 4.0.0-devnet.2-patch.3 → 4.0.0-devnet.3-patch.0

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 (97) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +17 -10
  4. package/dest/bench/utils.d.ts +1 -1
  5. package/dest/bench/utils.d.ts.map +1 -1
  6. package/dest/bench/utils.js +6 -3
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +14 -14
  10. package/dest/e2e_epochs/epochs_test.d.ts +3 -1
  11. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  12. package/dest/e2e_epochs/epochs_test.js +5 -2
  13. package/dest/e2e_fees/fees_test.d.ts +1 -1
  14. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  15. package/dest/e2e_fees/fees_test.js +13 -6
  16. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  17. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  19. package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
  20. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  21. package/dest/e2e_p2p/inactivity_slash_test.js +1 -0
  22. package/dest/e2e_p2p/p2p_network.d.ts +3 -2
  23. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  24. package/dest/e2e_p2p/p2p_network.js +21 -4
  25. package/dest/e2e_p2p/shared.d.ts +15 -1
  26. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  27. package/dest/e2e_p2p/shared.js +25 -2
  28. package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
  29. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  30. package/dest/e2e_token_contract/token_contract_test.js +11 -11
  31. package/dest/fixtures/authwit_proxy.d.ts +3 -3
  32. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  33. package/dest/fixtures/e2e_prover_test.d.ts +1 -1
  34. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  35. package/dest/fixtures/e2e_prover_test.js +6 -6
  36. package/dest/fixtures/setup.d.ts +8 -5
  37. package/dest/fixtures/setup.d.ts.map +1 -1
  38. package/dest/fixtures/setup.js +16 -12
  39. package/dest/fixtures/token_utils.d.ts +2 -2
  40. package/dest/fixtures/token_utils.d.ts.map +1 -1
  41. package/dest/fixtures/token_utils.js +5 -4
  42. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  43. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  44. package/dest/shared/cross_chain_test_harness.js +13 -13
  45. package/dest/shared/gas_portal_test_harness.js +2 -2
  46. package/dest/shared/submit-transactions.d.ts +1 -1
  47. package/dest/shared/submit-transactions.d.ts.map +1 -1
  48. package/dest/shared/submit-transactions.js +1 -1
  49. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  50. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  51. package/dest/shared/uniswap_l1_l2.js +14 -17
  52. package/dest/simulators/lending_simulator.d.ts +1 -1
  53. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  54. package/dest/simulators/lending_simulator.js +4 -4
  55. package/dest/simulators/token_simulator.d.ts +1 -1
  56. package/dest/simulators/token_simulator.d.ts.map +1 -1
  57. package/dest/simulators/token_simulator.js +2 -2
  58. package/dest/spartan/setup_test_wallets.d.ts +4 -2
  59. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  60. package/dest/spartan/setup_test_wallets.js +28 -15
  61. package/dest/spartan/utils/index.d.ts +2 -1
  62. package/dest/spartan/utils/index.d.ts.map +1 -1
  63. package/dest/spartan/utils/index.js +2 -0
  64. package/dest/test-wallet/test_wallet.d.ts +10 -17
  65. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  66. package/dest/test-wallet/test_wallet.js +48 -49
  67. package/dest/test-wallet/wallet_worker_script.js +41 -33
  68. package/dest/test-wallet/worker_wallet.d.ts +4 -4
  69. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  70. package/dest/test-wallet/worker_wallet.js +53 -5
  71. package/dest/test-wallet/worker_wallet_schema.d.ts +8 -5
  72. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  73. package/package.json +40 -40
  74. package/src/bench/client_flows/client_flows_benchmark.ts +39 -31
  75. package/src/bench/utils.ts +7 -2
  76. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +18 -14
  77. package/src/e2e_epochs/epochs_test.ts +14 -2
  78. package/src/e2e_fees/fees_test.ts +13 -6
  79. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  80. package/src/e2e_p2p/inactivity_slash_test.ts +1 -0
  81. package/src/e2e_p2p/p2p_network.ts +28 -2
  82. package/src/e2e_p2p/shared.ts +45 -2
  83. package/src/e2e_token_contract/token_contract_test.ts +16 -8
  84. package/src/fixtures/e2e_prover_test.ts +11 -5
  85. package/src/fixtures/setup.ts +25 -16
  86. package/src/fixtures/token_utils.ts +6 -3
  87. package/src/shared/cross_chain_test_harness.ts +13 -9
  88. package/src/shared/gas_portal_test_harness.ts +1 -1
  89. package/src/shared/submit-transactions.ts +4 -1
  90. package/src/shared/uniswap_l1_l2.ts +35 -28
  91. package/src/simulators/lending_simulator.ts +8 -4
  92. package/src/simulators/token_simulator.ts +6 -2
  93. package/src/spartan/setup_test_wallets.ts +61 -17
  94. package/src/spartan/utils/index.ts +3 -0
  95. package/src/test-wallet/test_wallet.ts +61 -66
  96. package/src/test-wallet/wallet_worker_script.ts +47 -30
  97. package/src/test-wallet/worker_wallet.ts +55 -7
@@ -81,24 +81,28 @@ export class TokenContractTest {
81
81
  await publicDeployAccounts(this.wallet, [this.adminAddress, this.account1Address]);
82
82
 
83
83
  this.logger.verbose(`Deploying TokenContract...`);
84
- this.asset = await TokenContract.deploy(
84
+ ({ contract: this.asset } = await TokenContract.deploy(
85
85
  this.wallet,
86
86
  this.adminAddress,
87
87
  TokenContractTest.TOKEN_NAME,
88
88
  TokenContractTest.TOKEN_SYMBOL,
89
89
  TokenContractTest.TOKEN_DECIMALS,
90
- ).send({ from: this.adminAddress });
90
+ ).send({ from: this.adminAddress }));
91
91
  this.logger.verbose(`Token deployed to ${this.asset.address}`);
92
92
 
93
93
  this.logger.verbose(`Deploying bad account...`);
94
- this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({ from: this.adminAddress });
94
+ ({ contract: this.badAccount } = await InvalidAccountContract.deploy(this.wallet).send({
95
+ from: this.adminAddress,
96
+ }));
95
97
  this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
96
98
 
97
99
  // Deploy a proxy contract for "on behalf of other" tests. The note owner must be the tx sender
98
100
  // (so their notes are in scope), but msg_sender in the target must differ from the note owner
99
101
  // to trigger authwit validation. The proxy forwards calls so that msg_sender != tx sender.
100
102
  this.logger.verbose(`Deploying generic proxy...`);
101
- this.authwitProxy = await GenericProxyContract.deploy(this.wallet).send({ from: this.adminAddress });
103
+ ({ contract: this.authwitProxy } = await GenericProxyContract.deploy(this.wallet).send({
104
+ from: this.adminAddress,
105
+ }));
102
106
  this.logger.verbose(`Deployed to ${this.authwitProxy.address}.`);
103
107
 
104
108
  this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
@@ -106,7 +110,7 @@ export class TokenContractTest {
106
110
  this.account1Address,
107
111
  ]);
108
112
 
109
- expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
113
+ expect((await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).result).toBe(
110
114
  this.adminAddress.toBigInt(),
111
115
  );
112
116
  }
@@ -140,7 +144,9 @@ export class TokenContractTest {
140
144
  await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress });
141
145
  tokenSim.mintPublic(adminAddress, amount);
142
146
 
143
- const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({ from: adminAddress });
147
+ const { result: publicBalance } = await asset.methods
148
+ .balance_of_public(adminAddress)
149
+ .simulate({ from: adminAddress });
144
150
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
145
151
  expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
146
152
 
@@ -148,11 +154,13 @@ export class TokenContractTest {
148
154
  await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
149
155
  tokenSim.mintPrivate(adminAddress, amount);
150
156
 
151
- const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({ from: adminAddress });
157
+ const { result: privateBalance } = await asset.methods
158
+ .balance_of_private(adminAddress)
159
+ .simulate({ from: adminAddress });
152
160
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
153
161
  expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
154
162
 
155
- const totalSupply = await asset.methods.total_supply().simulate({ from: adminAddress });
163
+ const { result: totalSupply } = await asset.methods.total_supply().simulate({ from: adminAddress });
156
164
  this.logger.verbose(`Total supply: ${totalSupply}`);
157
165
  expect(totalSupply).toEqual(tokenSim.totalSupply);
158
166
 
@@ -106,7 +106,9 @@ export class FullProverTest {
106
106
  await publicDeployAccounts(this.wallet, this.accounts.slice(0, 2));
107
107
 
108
108
  this.logger.info('Applying base setup: deploying token contract');
109
- const { contract: asset, instance } = await TokenContract.deploy(
109
+ const {
110
+ receipt: { contract: asset, instance },
111
+ } = await TokenContract.deploy(
110
112
  this.wallet,
111
113
  this.accounts[0],
112
114
  FullProverTest.TOKEN_NAME,
@@ -121,7 +123,7 @@ export class FullProverTest {
121
123
 
122
124
  this.tokenSim = new TokenSimulator(this.fakeProofsAsset, this.wallet, this.accounts[0], this.logger, this.accounts);
123
125
 
124
- expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0] })).toBe(
126
+ expect((await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0] })).result).toBe(
125
127
  this.accounts[0].toBigInt(),
126
128
  );
127
129
  }
@@ -310,16 +312,20 @@ export class FullProverTest {
310
312
  } = this;
311
313
  tokenSim.mintPublic(address, publicAmount);
312
314
 
313
- const publicBalance = await fakeProofsAsset.methods.balance_of_public(address).simulate({ from: address });
315
+ const { result: publicBalance } = await fakeProofsAsset.methods
316
+ .balance_of_public(address)
317
+ .simulate({ from: address });
314
318
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
315
319
  expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
316
320
 
317
321
  tokenSim.mintPrivate(address, publicAmount);
318
- const privateBalance = await fakeProofsAsset.methods.balance_of_private(address).simulate({ from: address });
322
+ const { result: privateBalance } = await fakeProofsAsset.methods
323
+ .balance_of_private(address)
324
+ .simulate({ from: address });
319
325
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
320
326
  expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
321
327
 
322
- const totalSupply = await fakeProofsAsset.methods.total_supply().simulate({ from: address });
328
+ const { result: totalSupply } = await fakeProofsAsset.methods.total_supply().simulate({ from: address });
323
329
  this.logger.verbose(`Total supply: ${totalSupply}`);
324
330
  expect(totalSupply).toEqual(tokenSim.totalSupply);
325
331
  }
@@ -1,6 +1,7 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
2
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
+ import { NO_FROM } from '@aztec/aztec.js/account';
4
5
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
5
6
  import {
6
7
  BatchCall,
@@ -29,7 +30,7 @@ import {
29
30
  deployAztecL1Contracts,
30
31
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
31
32
  import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
32
- import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
33
+ import { type Anvil, EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
33
34
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
34
35
  import { SecretValue } from '@aztec/foundation/config';
35
36
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -49,7 +50,6 @@ import type { SequencerClient } from '@aztec/sequencer-client';
49
50
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
50
51
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
51
52
  import { tryStop } from '@aztec/stdlib/interfaces/server';
52
- import type { P2PClientType } from '@aztec/stdlib/p2p';
53
53
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
54
54
  import {
55
55
  type TelemetryClient,
@@ -61,7 +61,6 @@ import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
61
61
  import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
62
62
  import { getGenesisValues } from '@aztec/world-state/testing';
63
63
 
64
- import type { Anvil } from '@viem/anvil';
65
64
  import fs from 'fs/promises';
66
65
  import { tmpdir } from 'os';
67
66
  import path from 'path';
@@ -186,6 +185,11 @@ export type SetupOptions = {
186
185
  anvilAccounts?: number;
187
186
  /** Port to start anvil (defaults to 8545) */
188
187
  anvilPort?: number;
188
+ /**
189
+ * Number of slots per epoch for Anvil's finality simulation.
190
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
191
+ */
192
+ anvilSlotsInAnEpoch?: number;
189
193
  /** Key to use for publishing L1 contracts */
190
194
  l1PublisherKey?: SecretValue<`0x${string}`>;
191
195
  /** ZkPassport configuration (domain, scope, mock verifier) */
@@ -298,6 +302,8 @@ export async function setup(
298
302
  config.dataDirectory = directoryToCleanup;
299
303
  }
300
304
 
305
+ const dateProvider = new TestDateProvider();
306
+
301
307
  if (!config.l1RpcUrls?.length) {
302
308
  if (!isAnvilTestChain(chain.id)) {
303
309
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
@@ -306,6 +312,8 @@ export async function setup(
306
312
  l1BlockTime: opts.ethereumSlotDuration,
307
313
  accounts: opts.anvilAccounts,
308
314
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
315
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
316
+ dateProvider,
309
317
  });
310
318
  anvil = res.anvil;
311
319
  config.l1RpcUrls = [res.rpcUrl];
@@ -317,8 +325,6 @@ export async function setup(
317
325
  logger.info(`Logging metrics to ${filename}`);
318
326
  setupMetricsLogger(filename);
319
327
  }
320
-
321
- const dateProvider = new TestDateProvider();
322
328
  const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
323
329
 
324
330
  if (opts.stateLoad) {
@@ -414,11 +420,12 @@ export async function setup(
414
420
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
415
421
  }
416
422
 
417
- // Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
418
- // In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
419
- // warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
420
- // slot from its dateProvider and cannot propose blocks.
421
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
423
+ // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
424
+ // ahead of system time due to the local-network watcher warping time forward on each filled slot.
425
+ // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
426
+ if (!anvil) {
427
+ dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
428
+ }
422
429
 
423
430
  if (opts.l2StartTime) {
424
431
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
@@ -456,7 +463,7 @@ export async function setup(
456
463
  }
457
464
 
458
465
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
459
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
466
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
460
467
 
461
468
  if (opts.mockGossipSubNetwork) {
462
469
  mockGossipSubNetwork = new MockGossipSubNetwork();
@@ -503,7 +510,7 @@ export async function setup(
503
510
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
504
511
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
505
512
 
506
- const p2pClientDeps: Partial<P2PClientDeps<P2PClientType.Full>> = {
513
+ const p2pClientDeps: Partial<P2PClientDeps> = {
507
514
  p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
508
515
  rpcTxProviders: [aztecNodeService],
509
516
  };
@@ -719,7 +726,7 @@ export function createAndSyncProverNode(
719
726
  deps: {
720
727
  telemetry?: TelemetryClient;
721
728
  dateProvider: DateProvider;
722
- p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
729
+ p2pClientDeps?: P2PClientDeps;
723
730
  },
724
731
  options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
725
732
  ): Promise<{ proverNode: AztecNodeService }> {
@@ -754,7 +761,9 @@ export function getBalancesFn(
754
761
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
755
762
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
756
763
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
757
- const b = await Promise.all(addresses.map(address => method(address).simulate({ from: address })));
764
+ const b = await Promise.all(
765
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
766
+ );
758
767
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
759
768
  logger.verbose(debugString);
760
769
  return b;
@@ -840,7 +849,7 @@ export const deployAccounts =
840
849
  );
841
850
  const deployMethod = await accountManager.getDeployMethod();
842
851
  await deployMethod.send({
843
- from: AztecAddress.ZERO,
852
+ from: NO_FROM,
844
853
  skipClassPublication: i !== 0, // Publish the contract class at most once.
845
854
  });
846
855
  }
@@ -872,7 +881,7 @@ export async function publicDeployAccounts(
872
881
 
873
882
  const batch = new BatchCall(wallet, calls);
874
883
 
875
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
884
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
876
885
  if (waitUntilProven) {
877
886
  if (!node) {
878
887
  throw new Error('Need to provide an AztecNode to wait for proven.');
@@ -6,7 +6,9 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
6
 
7
7
  export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
8
8
  logger.info(`Deploying Token contract...`);
9
- const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
9
+ const {
10
+ receipt: { contract, instance },
11
+ } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
12
  from: admin,
11
13
  wait: { returnReceipt: true },
12
14
  });
@@ -25,8 +27,9 @@ export async function mintTokensToPrivate(
25
27
  minter: AztecAddress,
26
28
  recipient: AztecAddress,
27
29
  amount: bigint,
30
+ additionalScopes?: AztecAddress[],
28
31
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
32
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
33
  }
31
34
 
32
35
  export async function expectTokenBalance(
@@ -38,7 +41,7 @@ export async function expectTokenBalance(
38
41
  ) {
39
42
  // Then check the balance
40
43
  const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
44
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
45
  logger.info(`Account ${owner} balance: ${balance}`);
43
46
  expect(balance).toBe(expectedBalance);
44
47
  }
@@ -73,22 +73,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
73
73
  });
74
74
 
75
75
  // deploy l2 token
76
- const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({ from: owner });
76
+ const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
77
+ from: owner,
78
+ });
77
79
 
78
80
  // deploy l2 token bridge and attach to the portal
79
- const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({ from: owner });
81
+ const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
82
+ from: owner,
83
+ });
80
84
 
81
- if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
85
+ if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
82
86
  throw new Error(`Token admin is not ${owner}`);
83
87
  }
84
88
 
85
- if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
89
+ if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
86
90
  throw new Error(`Bridge token is not ${token.address}`);
87
91
  }
88
92
 
89
93
  // make the bridge a minter on the token:
90
94
  await token.methods.set_minter(bridge.address, true).send({ from: owner });
91
- if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
95
+ if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
92
96
  throw new Error(`Bridge is not a minter`);
93
97
  }
94
98
 
@@ -269,7 +273,7 @@ export class CrossChainTestHarness {
269
273
  authwitNonce: Fr = Fr.ZERO,
270
274
  authWitness: AuthWitness,
271
275
  ): Promise<TxReceipt> {
272
- const withdrawReceipt = await this.l2Bridge.methods
276
+ const { receipt: withdrawReceipt } = await this.l2Bridge.methods
273
277
  .exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
274
278
  .send({ authWitnesses: [authWitness], from: this.ownerAddress });
275
279
 
@@ -277,7 +281,7 @@ export class CrossChainTestHarness {
277
281
  }
278
282
 
279
283
  async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
280
- const withdrawReceipt = await this.l2Bridge.methods
284
+ const { receipt: withdrawReceipt } = await this.l2Bridge.methods
281
285
  .exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
282
286
  .send({ from: this.ownerAddress });
283
287
 
@@ -285,7 +289,7 @@ export class CrossChainTestHarness {
285
289
  }
286
290
 
287
291
  async getL2PrivateBalanceOf(owner: AztecAddress) {
288
- return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
292
+ return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
289
293
  }
290
294
 
291
295
  async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -295,7 +299,7 @@ export class CrossChainTestHarness {
295
299
  }
296
300
 
297
301
  async getL2PublicBalanceOf(owner: AztecAddress) {
298
- return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
302
+ return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
299
303
  }
300
304
 
301
305
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -131,7 +131,7 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
131
131
  }
132
132
 
133
133
  async getL2PublicBalanceOf(owner: AztecAddress) {
134
- return await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner });
134
+ return (await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner })).result;
135
135
  }
136
136
 
137
137
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -19,7 +19,10 @@ export const submitTxsTo = async (
19
19
  times(numTxs, async () => {
20
20
  const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
21
21
  const deployMethod = await accountManager.getDeployMethod();
22
- const txHash = await deployMethod.send({ from: submitter, wait: NO_WAIT });
22
+ const { txHash } = await deployMethod.send({
23
+ from: submitter,
24
+ wait: NO_WAIT,
25
+ });
23
26
 
24
27
  logger.info(`Tx sent with hash ${txHash}`);
25
28
  const receipt: TxReceipt = await wallet.getTxReceipt(txHash);
@@ -130,7 +130,9 @@ export const uniswapL1L2TestSuite = (
130
130
  client: l1Client,
131
131
  });
132
132
  // deploy l2 uniswap contract and attach to portal
133
- uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({ from: ownerAddress });
133
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
134
+ from: ownerAddress,
135
+ }));
134
136
 
135
137
  const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
136
138
 
@@ -195,7 +197,7 @@ export const uniswapL1L2TestSuite = (
195
197
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
196
198
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
197
199
 
198
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
200
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
199
201
  .swap_private(
200
202
  wethCrossChainHarness.l2Token.address,
201
203
  wethCrossChainHarness.l2Bridge.address,
@@ -250,8 +252,12 @@ export const uniswapL1L2TestSuite = (
250
252
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
251
253
 
252
254
  // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
253
- const block = await aztecNode.getBlock(l2UniswapInteractionReceipt.blockNumber!);
254
- const epoch = await rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
255
+ const swapResult = (await computeL2ToL1MembershipWitness(
256
+ aztecNode,
257
+ swapPrivateLeaf,
258
+ l2UniswapInteractionReceipt.txHash,
259
+ ))!;
260
+ const { epochNumber: epoch } = swapResult;
255
261
  await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
256
262
  await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
257
263
 
@@ -260,14 +266,17 @@ export const uniswapL1L2TestSuite = (
260
266
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
261
267
  daiCrossChainHarness.tokenPortalAddress,
262
268
  );
263
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
264
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
269
+ const withdrawResult = (await computeL2ToL1MembershipWitness(
270
+ aztecNode,
271
+ withdrawLeaf,
272
+ l2UniswapInteractionReceipt.txHash,
273
+ ))!;
265
274
 
266
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
267
- const swapPrivateSiblingPath = swapResult!.siblingPath;
275
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
276
+ const swapPrivateSiblingPath = swapResult.siblingPath;
268
277
 
269
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
270
- const withdrawSiblingPath = withdrawResult!.siblingPath;
278
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
279
+ const withdrawSiblingPath = withdrawResult.siblingPath;
271
280
 
272
281
  const withdrawMessageMetadata = {
273
282
  _epoch: BigInt(epoch),
@@ -787,7 +796,7 @@ export const uniswapL1L2TestSuite = (
787
796
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
788
797
 
789
798
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
790
- const withdrawReceipt = await uniswapL2Contract.methods
799
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
791
800
  .swap_private(
792
801
  wethCrossChainHarness.l2Token.address,
793
802
  wethCrossChainHarness.l2Bridge.address,
@@ -838,16 +847,15 @@ export const uniswapL1L2TestSuite = (
838
847
  chainId: new Fr(l1Client.chain.id),
839
848
  });
840
849
 
841
- const block = await aztecNode.getBlock(withdrawReceipt.blockNumber!);
842
- const epoch = await rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
843
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
844
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
850
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, swapPrivateLeaf, withdrawReceipt.txHash))!;
851
+ const { epochNumber: epoch } = swapResult;
852
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash))!;
845
853
 
846
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
847
- const swapPrivateSiblingPath = swapResult!.siblingPath;
854
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
855
+ const swapPrivateSiblingPath = swapResult.siblingPath;
848
856
 
849
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
850
- const withdrawSiblingPath = withdrawResult!.siblingPath;
857
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
858
+ const withdrawSiblingPath = withdrawResult.siblingPath;
851
859
 
852
860
  const withdrawMessageMetadata = {
853
861
  _epoch: BigInt(epoch),
@@ -915,7 +923,7 @@ export const uniswapL1L2TestSuite = (
915
923
 
916
924
  // Call swap_public on L2
917
925
  const secretHashForDepositingSwappedDai = Fr.random();
918
- const withdrawReceipt = await uniswapL2Contract.methods
926
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
919
927
  .swap_public(
920
928
  ownerAddress,
921
929
  wethCrossChainHarness.l2Bridge.address,
@@ -971,16 +979,15 @@ export const uniswapL1L2TestSuite = (
971
979
  chainId: new Fr(l1Client.chain.id),
972
980
  });
973
981
 
974
- const block = await aztecNode.getBlock(withdrawReceipt.blockNumber!);
975
- const epoch = await rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
976
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
977
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
982
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, swapPublicLeaf, withdrawReceipt.txHash))!;
983
+ const { epochNumber: epoch } = swapResult;
984
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash))!;
978
985
 
979
- const swapPublicL2MessageIndex = swapResult!.leafIndex;
980
- const swapPublicSiblingPath = swapResult!.siblingPath;
986
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
987
+ const swapPublicSiblingPath = swapResult.siblingPath;
981
988
 
982
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
983
- const withdrawSiblingPath = withdrawResult!.siblingPath;
989
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
990
+ const withdrawSiblingPath = withdrawResult.siblingPath;
984
991
 
985
992
  const withdrawMessageMetadata = {
986
993
  _epoch: BigInt(epoch),
@@ -94,7 +94,9 @@ export class LendingSimulator {
94
94
 
95
95
  async prepare() {
96
96
  this.accumulator = BASE;
97
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration));
97
+ const slot = await this.rollup.getSlotAt(
98
+ BigInt(await this.cc.eth.lastBlockTimestamp()) + BigInt(this.ethereumSlotDuration),
99
+ );
98
100
  this.time = Number(await this.rollup.getTimestampForSlot(slot));
99
101
  }
100
102
 
@@ -103,7 +105,7 @@ export class LendingSimulator {
103
105
  return;
104
106
  }
105
107
 
106
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
108
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.lastBlockTimestamp()));
107
109
  const targetSlot = SlotNumber(slot + diff);
108
110
  const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
109
111
  const timeDiff = ts - this.time;
@@ -186,14 +188,16 @@ export class LendingSimulator {
186
188
 
187
189
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
188
190
 
189
- const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
191
+ const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
190
192
 
191
193
  const interestAccumulator = asset['interest_accumulator'];
192
194
  expect(interestAccumulator).toEqual(this.accumulator);
193
195
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
194
196
 
195
197
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
196
- const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
198
+ const { result: privatePos } = await this.lendingContract.methods
199
+ .get_position(key)
200
+ .simulate({ from: this.account.address });
197
201
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
198
202
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
199
203
  expect(privatePos['debt']).toEqual(
@@ -109,7 +109,9 @@ export class TokenSimulator {
109
109
  await Promise.all(
110
110
  chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
111
111
  )
112
- ).flat();
112
+ )
113
+ .flat()
114
+ .map(r => r.result);
113
115
  expect(results[0]).toEqual(this.totalSupply);
114
116
 
115
117
  // Check that all our balances match
@@ -123,7 +125,9 @@ export class TokenSimulator {
123
125
  const wallet = this.lookupProvider.get(address.toString());
124
126
  const asset = wallet ? this.token.withWallet(wallet) : this.token;
125
127
 
126
- const actualPrivateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
128
+ const { result: actualPrivateBalance } = await asset.methods
129
+ .balance_of_private(address)
130
+ .simulate({ from: address });
127
131
  expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
128
132
  }
129
133
  }