@aztec/end-to-end 0.81.0 → 0.82.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 (64) hide show
  1. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -2
  2. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  3. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +7 -7
  4. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -1
  5. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  6. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -18
  7. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -0
  8. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  9. package/dest/e2e_deploy_contract/deploy_test.js +2 -0
  10. package/dest/e2e_epochs/epochs_test.d.ts +1 -2
  11. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  12. package/dest/e2e_epochs/epochs_test.js +7 -6
  13. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  14. package/dest/e2e_fees/fees_test.js +20 -29
  15. package/dest/e2e_prover/e2e_prover_test.d.ts +2 -0
  16. package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -1
  17. package/dest/e2e_prover/e2e_prover_test.js +7 -8
  18. package/dest/e2e_token_contract/token_contract_test.d.ts +2 -1
  19. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  20. package/dest/e2e_token_contract/token_contract_test.js +3 -1
  21. package/dest/fixtures/snapshot_manager.d.ts +4 -2
  22. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  23. package/dest/fixtures/snapshot_manager.js +17 -16
  24. package/dest/fixtures/utils.d.ts +5 -5
  25. package/dest/fixtures/utils.d.ts.map +1 -1
  26. package/dest/fixtures/utils.js +13 -8
  27. package/dest/shared/capture_private_execution_steps.d.ts +7 -0
  28. package/dest/shared/capture_private_execution_steps.d.ts.map +1 -0
  29. package/dest/shared/capture_private_execution_steps.js +40 -0
  30. package/dest/shared/cross_chain_test_harness.d.ts +2 -2
  31. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  32. package/dest/shared/cross_chain_test_harness.js +16 -4
  33. package/dest/shared/gas_portal_test_harness.d.ts +11 -1
  34. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  35. package/dest/shared/gas_portal_test_harness.js +27 -12
  36. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  37. package/dest/shared/uniswap_l1_l2.js +24 -16
  38. package/dest/simulators/lending_simulator.d.ts +3 -5
  39. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  40. package/dest/simulators/lending_simulator.js +5 -13
  41. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  42. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  43. package/dest/spartan/setup_test_wallets.js +6 -4
  44. package/dest/spartan/utils.d.ts +18 -5
  45. package/dest/spartan/utils.d.ts.map +1 -1
  46. package/dest/spartan/utils.js +8 -5
  47. package/package.json +33 -31
  48. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +9 -5
  49. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +3 -19
  50. package/src/e2e_deploy_contract/deploy_test.ts +3 -0
  51. package/src/e2e_epochs/epochs_test.ts +6 -5
  52. package/src/e2e_fees/fees_test.ts +21 -28
  53. package/src/e2e_prover/e2e_prover_test.ts +8 -7
  54. package/src/e2e_token_contract/token_contract_test.ts +4 -2
  55. package/src/fixtures/snapshot_manager.ts +24 -10
  56. package/src/fixtures/utils.ts +25 -9
  57. package/src/guides/up_quick_start.sh +1 -2
  58. package/src/shared/capture_private_execution_steps.ts +43 -0
  59. package/src/shared/cross_chain_test_harness.ts +14 -3
  60. package/src/shared/gas_portal_test_harness.ts +29 -9
  61. package/src/shared/uniswap_l1_l2.ts +16 -16
  62. package/src/simulators/lending_simulator.ts +7 -12
  63. package/src/spartan/setup_test_wallets.ts +7 -7
  64. package/src/spartan/utils.ts +8 -5
@@ -12,13 +12,14 @@ import {
12
12
  import { CheatCodes } from '@aztec/aztec.js/testing';
13
13
  import {
14
14
  type DeployL1ContractsReturnType,
15
+ RollupContract,
15
16
  type ViemPublicClient,
16
17
  type ViemWalletClient,
17
18
  deployL1Contract,
18
19
  extractEvent,
19
20
  } from '@aztec/ethereum';
20
21
  import { sha256ToField } from '@aztec/foundation/crypto';
21
- import { InboxAbi, RollupAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
22
+ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
22
23
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
23
24
 
24
25
  import { jest } from '@jest/globals';
@@ -90,7 +91,7 @@ export const uniswapL1L2TestSuite = (
90
91
  let wethCrossChainHarness: CrossChainTestHarness;
91
92
 
92
93
  let deployL1ContractsValues: DeployL1ContractsReturnType;
93
- let rollup: GetContractReturnType<typeof RollupAbi, ViemWalletClient>;
94
+ let rollup: RollupContract;
94
95
  let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ViemWalletClient>;
95
96
  let uniswapPortalAddress: EthAddress;
96
97
  let uniswapL2Contract: UniswapContract;
@@ -118,11 +119,10 @@ export const uniswapL1L2TestSuite = (
118
119
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
119
120
  }
120
121
 
121
- rollup = getContract({
122
- address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
123
- abi: RollupAbi,
124
- client: deployL1ContractsValues.walletClient,
125
- });
122
+ rollup = new RollupContract(
123
+ deployL1ContractsValues.publicClient,
124
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
125
+ );
126
126
 
127
127
  ownerAddress = ownerWallet.getAddress();
128
128
  // sponsorAddress = sponsorWallet.getAddress();
@@ -218,7 +218,7 @@ export const uniswapL1L2TestSuite = (
218
218
  // 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
219
219
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
220
220
  const nonceForWETHTransferToPublicApproval = new Fr(1n);
221
- await ownerWallet.createAuthWit({
221
+ const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
222
222
  caller: uniswapL2Contract.address,
223
223
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
224
224
  ownerAddress,
@@ -244,7 +244,7 @@ export const uniswapL1L2TestSuite = (
244
244
  secretHashForDepositingSwappedDai,
245
245
  ownerEthAddress,
246
246
  )
247
- .send()
247
+ .send({ authWitnesses: [transferToPublicAuhtwit] })
248
248
  .wait();
249
249
 
250
250
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
@@ -288,7 +288,7 @@ export const uniswapL1L2TestSuite = (
288
288
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
289
289
 
290
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());
291
+ await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
292
292
 
293
293
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
294
294
  logger.info('Execute withdraw and swap on the uniswapPortal!');
@@ -655,7 +655,7 @@ export const uniswapL1L2TestSuite = (
655
655
  // 2. owner gives uniswap approval to transfer the funds to public:
656
656
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
657
657
  const nonceForWETHTransferToPublicApproval = new Fr(3n);
658
- await ownerWallet.createAuthWit({
658
+ const transferToPublicAuthwith = await ownerWallet.createAuthWit({
659
659
  caller: uniswapL2Contract.address,
660
660
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
661
661
  ownerAddress,
@@ -680,7 +680,7 @@ export const uniswapL1L2TestSuite = (
680
680
  Fr.random(),
681
681
  ownerEthAddress,
682
682
  )
683
- .prove(),
683
+ .prove({ authWitnesses: [transferToPublicAuthwith] }),
684
684
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
685
685
  });
686
686
 
@@ -803,7 +803,7 @@ export const uniswapL1L2TestSuite = (
803
803
  // Owner gives uniswap approval to transfer the funds to public to self on its behalf
804
804
  logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
805
805
  const nonceForWETHTransferToPublicApproval = new Fr(4n);
806
- await ownerWallet.createAuthWit({
806
+ const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
807
807
  caller: uniswapL2Contract.address,
808
808
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
809
809
  ownerAddress,
@@ -830,7 +830,7 @@ export const uniswapL1L2TestSuite = (
830
830
  secretHashForDepositingSwappedDai,
831
831
  ownerEthAddress,
832
832
  )
833
- .send()
833
+ .send({ authWitnesses: [transferToPublicAuhtwit] })
834
834
  .wait();
835
835
 
836
836
  const swapPrivateContent = sha256ToField([
@@ -899,7 +899,7 @@ export const uniswapL1L2TestSuite = (
899
899
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
900
900
 
901
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());
902
+ await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
903
903
 
904
904
  // On L1 call swap_public!
905
905
  logger.info('call swap_public on L1');
@@ -1029,7 +1029,7 @@ export const uniswapL1L2TestSuite = (
1029
1029
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1030
1030
 
1031
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());
1032
+ await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
1033
1033
 
1034
1034
  // Call swap_private on L1
1035
1035
  logger.info('Execute withdraw and swap on the uniswapPortal!');
@@ -1,14 +1,11 @@
1
1
  // Convenience struct to hold an account's address and secret that can easily be passed around.
2
2
  import { AztecAddress, Fr } from '@aztec/aztec.js';
3
3
  import { CheatCodes } from '@aztec/aztec.js/testing';
4
+ import type { RollupContract } from '@aztec/ethereum';
4
5
  import { pedersenHash } from '@aztec/foundation/crypto';
5
6
  import type { TestDateProvider } from '@aztec/foundation/timer';
6
- import type { RollupAbi } from '@aztec/l1-artifacts';
7
7
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
8
8
 
9
- import type { Account, GetContractReturnType, HttpTransport, WalletClient } from 'viem';
10
- import type * as chains from 'viem/chains';
11
-
12
9
  import type { TokenSimulator } from './token_simulator.js';
13
10
 
14
11
  /**
@@ -84,7 +81,7 @@ export class LendingSimulator {
84
81
  private rate: bigint,
85
82
  private ethereumSlotDuration: number,
86
83
  /** the rollup contract */
87
- public rollup: GetContractReturnType<typeof RollupAbi, WalletClient<HttpTransport, chains.Chain, Account>>,
84
+ public rollup: RollupContract,
88
85
  /** the lending contract */
89
86
  public lendingContract: LendingContract,
90
87
  /** the collateral asset used in the lending contract */
@@ -95,10 +92,8 @@ export class LendingSimulator {
95
92
 
96
93
  async prepare() {
97
94
  this.accumulator = BASE;
98
- const slot = await this.rollup.read.getSlotAt([
99
- BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration),
100
- ]);
101
- this.time = Number(await this.rollup.read.getTimestampForSlot([slot]));
95
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration));
96
+ this.time = Number(await this.rollup.getTimestampForSlot(slot));
102
97
  }
103
98
 
104
99
  async progressSlots(diff: number, dateProvider?: TestDateProvider) {
@@ -106,8 +101,8 @@ export class LendingSimulator {
106
101
  return;
107
102
  }
108
103
 
109
- const slot = await this.rollup.read.getSlotAt([BigInt(await this.cc.eth.timestamp())]);
110
- const ts = Number(await this.rollup.read.getTimestampForSlot([slot + BigInt(diff)]));
104
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
105
+ const ts = Number(await this.rollup.getTimestampForSlot(slot + BigInt(diff)));
111
106
  const timeDiff = ts - this.time;
112
107
  this.time = ts;
113
108
 
@@ -116,7 +111,7 @@ export class LendingSimulator {
116
111
  if (dateProvider) {
117
112
  dateProvider.setTime(this.time * 1000);
118
113
  }
119
- await this.cc.rollup.markAsProven(await this.rollup.read.getPendingBlockNumber());
114
+ await this.cc.rollup.markAsProven(await this.rollup.getBlockNumber());
120
115
  this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
121
116
  }
122
117
 
@@ -15,6 +15,7 @@ import {
15
15
  import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
16
16
  import type { Logger } from '@aztec/foundation/log';
17
17
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
18
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
18
19
 
19
20
  export interface TestWallets {
20
21
  pxe: PXE;
@@ -55,7 +56,6 @@ export async function deployTestWalletWithTokens(
55
56
  mintAmount: bigint,
56
57
  logger: Logger,
57
58
  numberOfFundedWallets = 1,
58
- initialFeeJuice = 10n ** 22n,
59
59
  ): Promise<TestWallets> {
60
60
  const pxe = await createCompatibleClient(pxeUrl, logger);
61
61
  const node = createAztecNodeClient(nodeUrl);
@@ -70,9 +70,7 @@ export async function deployTestWalletWithTokens(
70
70
  const fundedAccounts = await Promise.all(funded.map(a => getSchnorrAccount(pxe, a.secret, a.signingKey, a.salt)));
71
71
 
72
72
  const claims = await Promise.all(
73
- fundedAccounts.map(a =>
74
- bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, pxe, a.getAddress(), initialFeeJuice, logger),
75
- ),
73
+ fundedAccounts.map(a => bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, pxe, a.getAddress(), undefined, logger)),
76
74
  );
77
75
 
78
76
  // Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
@@ -101,15 +99,17 @@ async function bridgeL1FeeJuice(
101
99
  mnemonicOrPrivateKey: string,
102
100
  pxe: PXE,
103
101
  recipient: AztecAddress,
104
- amount: bigint,
102
+ amount: bigint | undefined,
105
103
  log: Logger,
106
104
  ) {
107
105
  const { l1ChainId } = await pxe.getNodeInfo();
108
106
  const chain = createEthereumChain(l1RpcUrls, l1ChainId);
109
107
  const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
110
108
 
109
+ // docs:start:bridge_fee_juice
111
110
  const portal = await L1FeeJuicePortalManager.new(pxe, publicClient, walletClient, log);
112
111
  const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
112
+ // docs:end:bridge_fee_juice
113
113
 
114
114
  const isSynced = async () => await pxe.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
115
115
  await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
@@ -118,9 +118,9 @@ async function bridgeL1FeeJuice(
118
118
  return claim;
119
119
  }
120
120
 
121
- async function advanceL2Block(node: AztecNode) {
121
+ async function advanceL2Block(node: AztecNode, nodeAdmin?: AztecNodeAdmin) {
122
122
  const initialBlockNumber = await node.getBlockNumber();
123
- await node!.flushTxs();
123
+ await nodeAdmin?.flushTxs();
124
124
  await retryUntil(async () => (await node.getBlockNumber()) >= initialBlockNumber + 1);
125
125
  }
126
126
 
@@ -1,8 +1,9 @@
1
- import { createAztecNodeClient, createLogger, sleep } from '@aztec/aztec.js';
1
+ import { createLogger, sleep } from '@aztec/aztec.js';
2
2
  import type { RollupCheatCodes } from '@aztec/aztec.js/testing';
3
3
  import type { Logger } from '@aztec/foundation/log';
4
4
  import { makeBackoff, retry } from '@aztec/foundation/retry';
5
5
  import type { SequencerConfig } from '@aztec/sequencer-client';
6
+ import { createAztecNodeAdminClient } from '@aztec/stdlib/interfaces/client';
6
7
 
7
8
  import { ChildProcess, exec, execSync, spawn } from 'child_process';
8
9
  import path from 'path';
@@ -36,6 +37,7 @@ const k8sLocalConfigSchema = z.object({
36
37
  INSTANCE_NAME: z.string().min(1, 'INSTANCE_NAME env variable must be set'),
37
38
  NAMESPACE: z.string().min(1, 'NAMESPACE env variable must be set'),
38
39
  CONTAINER_NODE_PORT: z.coerce.number().default(8080),
40
+ CONTAINER_NODE_ADMIN_PORT: z.coerce.number().default(8880),
39
41
  CONTAINER_SEQUENCER_PORT: z.coerce.number().default(8080),
40
42
  CONTAINER_PROVER_NODE_PORT: z.coerce.number().default(8080),
41
43
  CONTAINER_PXE_PORT: z.coerce.number().default(8080),
@@ -59,6 +61,7 @@ const k8sGCloudConfigSchema = k8sLocalConfigSchema.extend({
59
61
  const directConfigSchema = z.object({
60
62
  PXE_URL: z.string().url('PXE_URL must be a valid URL'),
61
63
  NODE_URL: z.string().url('NODE_URL must be a valid URL'),
64
+ NODE_ADMIN_URL: z.string().url('NODE_ADMIN_URL must be a valid URL'),
62
65
  ETHEREUM_HOSTS: ethereumHostsSchema,
63
66
  K8S: z.literal('false'),
64
67
  });
@@ -559,7 +562,7 @@ export async function runAlertCheck(config: EnvConfig, alerts: AlertConfig[], lo
559
562
  }
560
563
 
561
564
  export async function updateSequencerConfig(url: string, config: Partial<SequencerConfig>) {
562
- const node = createAztecNodeClient(url);
565
+ const node = createAztecNodeAdminClient(url);
563
566
  // Retry incase the port forward is not ready yet
564
567
  await retry(() => node.setConfig(config), 'Update sequencer config', makeBackoff([1, 3, 6]), logger);
565
568
  }
@@ -570,7 +573,7 @@ export async function getSequencers(namespace: string) {
570
573
  return stdout.split(' ');
571
574
  }
572
575
 
573
- export async function updateK8sSequencersConfig(args: {
576
+ async function updateK8sSequencersConfig(args: {
574
577
  containerPort: number;
575
578
  namespace: string;
576
579
  config: Partial<SequencerConfig>;
@@ -593,12 +596,12 @@ export async function updateK8sSequencersConfig(args: {
593
596
  export async function updateSequencersConfig(env: EnvConfig, config: Partial<SequencerConfig>) {
594
597
  if (isK8sConfig(env)) {
595
598
  await updateK8sSequencersConfig({
596
- containerPort: env.CONTAINER_NODE_PORT,
599
+ containerPort: env.CONTAINER_NODE_ADMIN_PORT,
597
600
  namespace: env.NAMESPACE,
598
601
  config,
599
602
  });
600
603
  } else {
601
- await updateSequencerConfig(env.NODE_URL, config);
604
+ await updateSequencerConfig(env.NODE_ADMIN_URL, config);
602
605
  }
603
606
  }
604
607