@aztec/end-to-end 1.2.1 → 2.0.0-nightly.20250814

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 (119) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +4 -2
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +33 -15
  7. package/dest/bench/utils.d.ts.map +1 -1
  8. package/dest/bench/utils.js +7 -4
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -3
  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 +59 -24
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +3 -2
  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 +13 -10
  15. package/dest/e2e_deploy_contract/deploy_test.d.ts +1 -1
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  17. package/dest/e2e_deploy_contract/deploy_test.js +7 -6
  18. package/dest/e2e_epochs/epochs_test.d.ts +16 -2
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +65 -7
  21. package/dest/e2e_fees/bridging_race.notest.js +3 -1
  22. package/dest/e2e_fees/fees_test.d.ts +5 -4
  23. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  24. package/dest/e2e_fees/fees_test.js +44 -59
  25. package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
  26. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  27. package/dest/e2e_nested_contract/nested_contract_test.js +17 -12
  28. package/dest/e2e_p2p/p2p_network.d.ts +7 -4
  29. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  30. package/dest/e2e_p2p/p2p_network.js +43 -22
  31. package/dest/e2e_p2p/shared.d.ts +3 -3
  32. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  33. package/dest/e2e_p2p/shared.js +16 -12
  34. package/dest/e2e_token_contract/token_contract_test.d.ts +8 -4
  35. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  36. package/dest/e2e_token_contract/token_contract_test.js +48 -23
  37. package/dest/fixtures/e2e_prover_test.d.ts +1 -1
  38. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  39. package/dest/fixtures/e2e_prover_test.js +27 -10
  40. package/dest/fixtures/setup_p2p_test.d.ts +4 -1
  41. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  42. package/dest/fixtures/setup_p2p_test.js +39 -8
  43. package/dest/fixtures/snapshot_manager.d.ts +3 -1
  44. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  45. package/dest/fixtures/snapshot_manager.js +20 -17
  46. package/dest/fixtures/token_utils.d.ts +3 -3
  47. package/dest/fixtures/token_utils.d.ts.map +1 -1
  48. package/dest/fixtures/token_utils.js +14 -10
  49. package/dest/fixtures/utils.d.ts +23 -8
  50. package/dest/fixtures/utils.d.ts.map +1 -1
  51. package/dest/fixtures/utils.js +88 -56
  52. package/dest/integration_l1_publisher/write_json.d.ts +8 -0
  53. package/dest/integration_l1_publisher/write_json.d.ts.map +1 -0
  54. package/dest/integration_l1_publisher/write_json.js +57 -0
  55. package/dest/sample-dapp/connect.d.mts +2 -0
  56. package/dest/sample-dapp/connect.d.mts.map +1 -0
  57. package/dest/sample-dapp/connect.js +1 -1
  58. package/dest/sample-dapp/contracts.d.mts +3 -0
  59. package/dest/sample-dapp/contracts.d.mts.map +1 -0
  60. package/dest/sample-dapp/contracts.js +1 -1
  61. package/dest/sample-dapp/deploy.d.mts +3 -0
  62. package/dest/sample-dapp/deploy.d.mts.map +1 -0
  63. package/dest/sample-dapp/deploy.js +4 -1
  64. package/dest/sample-dapp/index.d.mts +2 -0
  65. package/dest/sample-dapp/index.d.mts.map +1 -0
  66. package/dest/sample-dapp/index.js +18 -8
  67. package/dest/shared/cross_chain_test_harness.d.ts +6 -3
  68. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  69. package/dest/shared/cross_chain_test_harness.js +50 -20
  70. package/dest/shared/gas_portal_test_harness.d.ts +3 -3
  71. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  72. package/dest/shared/gas_portal_test_harness.js +21 -6
  73. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  74. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  75. package/dest/shared/uniswap_l1_l2.js +45 -22
  76. package/dest/simulators/lending_simulator.d.ts +1 -1
  77. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  78. package/dest/simulators/lending_simulator.js +6 -2
  79. package/dest/simulators/token_simulator.d.ts +2 -1
  80. package/dest/simulators/token_simulator.d.ts.map +1 -1
  81. package/dest/simulators/token_simulator.js +12 -4
  82. package/dest/spartan/setup_test_wallets.d.ts +7 -0
  83. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  84. package/dest/spartan/setup_test_wallets.js +96 -11
  85. package/dest/spartan/utils.d.ts +23 -3
  86. package/dest/spartan/utils.d.ts.map +1 -1
  87. package/dest/spartan/utils.js +9 -6
  88. package/package.json +36 -36
  89. package/src/bench/client_flows/benchmark.ts +8 -3
  90. package/src/bench/client_flows/client_flows_benchmark.ts +23 -14
  91. package/src/bench/utils.ts +5 -4
  92. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +47 -26
  93. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +14 -9
  94. package/src/e2e_deploy_contract/deploy_test.ts +7 -7
  95. package/src/e2e_epochs/epochs_test.ts +97 -25
  96. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  97. package/src/e2e_fees/fees_test.ts +55 -82
  98. package/src/e2e_nested_contract/nested_contract_test.ts +16 -11
  99. package/src/e2e_p2p/p2p_network.ts +51 -26
  100. package/src/e2e_p2p/shared.ts +14 -12
  101. package/src/e2e_token_contract/token_contract_test.ts +38 -36
  102. package/src/fixtures/e2e_prover_test.ts +17 -10
  103. package/src/fixtures/setup_p2p_test.ts +51 -9
  104. package/src/fixtures/snapshot_manager.ts +24 -17
  105. package/src/fixtures/token_utils.ts +14 -9
  106. package/src/fixtures/utils.ts +116 -57
  107. package/src/guides/up_quick_start.sh +1 -1
  108. package/src/integration_l1_publisher/write_json.ts +74 -0
  109. package/src/sample-dapp/connect.mjs +1 -1
  110. package/src/sample-dapp/contracts.mjs +1 -1
  111. package/src/sample-dapp/deploy.mjs +3 -3
  112. package/src/sample-dapp/index.mjs +11 -8
  113. package/src/shared/cross_chain_test_harness.ts +31 -18
  114. package/src/shared/gas_portal_test_harness.ts +17 -7
  115. package/src/shared/uniswap_l1_l2.ts +28 -24
  116. package/src/simulators/lending_simulator.ts +3 -3
  117. package/src/simulators/token_simulator.ts +12 -3
  118. package/src/spartan/setup_test_wallets.ts +130 -19
  119. package/src/spartan/utils.ts +10 -3
@@ -8,15 +8,9 @@ import {
8
8
  createLogger,
9
9
  sleep,
10
10
  } from '@aztec/aztec.js';
11
- import { CheatCodes } from '@aztec/aztec.js/testing';
11
+ import { CheatCodes } from '@aztec/aztec/testing';
12
12
  import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
13
- import {
14
- type DeployL1ContractsArgs,
15
- RollupContract,
16
- createExtendedL1Client,
17
- getPublicClient,
18
- l1Artifacts,
19
- } from '@aztec/ethereum';
13
+ import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client } from '@aztec/ethereum';
20
14
  import { ChainMonitor } from '@aztec/ethereum/test';
21
15
  import { EthAddress } from '@aztec/foundation/eth-address';
22
16
  import { TestERC20Abi } from '@aztec/l1-artifacts';
@@ -43,7 +37,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
43
37
  import {
44
38
  type BalancesFn,
45
39
  type SetupOptions,
46
- ensureAccountsPubliclyDeployed,
40
+ ensureAccountContractsPublished,
47
41
  getBalancesFn,
48
42
  setupSponsoredFPC,
49
43
  } from '../fixtures/utils.js';
@@ -64,6 +58,7 @@ const { E2E_DATA_PATH: dataPath } = process.env;
64
58
  export class FeesTest {
65
59
  private snapshotManager: ISnapshotManager;
66
60
  private wallets: AccountWallet[] = [];
61
+ private accounts: AztecAddress[] = [];
67
62
 
68
63
  public logger: Logger;
69
64
  public pxe!: PXE;
@@ -81,6 +76,8 @@ export class FeesTest {
81
76
 
82
77
  public gasSettings!: GasSettings;
83
78
 
79
+ public rollupContract!: RollupContract;
80
+
84
81
  public feeJuiceContract!: FeeJuiceContract;
85
82
  public bananaCoin!: BananaCoin;
86
83
  public bananaFPC!: FPCContract;
@@ -124,8 +121,8 @@ export class FeesTest {
124
121
  const context = await this.snapshotManager.setup();
125
122
  await context.aztecNode.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });
126
123
 
127
- const rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
128
- this.chainMonitor = new ChainMonitor(rollupContract, this.logger, 200).start();
124
+ this.rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
125
+ this.chainMonitor = new ChainMonitor(this.rollupContract, context.dateProvider, this.logger, 200).start();
129
126
 
130
127
  return this;
131
128
  }
@@ -147,16 +144,10 @@ export class FeesTest {
147
144
  }
148
145
 
149
146
  async getBlockRewards() {
150
- const rewardDistributor = getContract({
151
- address: this.context.deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
152
- abi: l1Artifacts.rewardDistributor.contractAbi,
153
- client: this.context.deployL1ContractsValues.l1Client,
154
- });
155
-
156
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
147
+ const blockReward = await this.rollupContract.getBlockReward();
157
148
 
158
149
  const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(
159
- EthAddress.fromString(rewardDistributor.address),
150
+ this.context.deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress,
160
151
  );
161
152
 
162
153
  const toDistribute = balance > blockReward ? blockReward : balance;
@@ -166,19 +157,23 @@ export class FeesTest {
166
157
  return { sequencerBlockRewards, proverBlockRewards };
167
158
  }
168
159
 
169
- async mintAndBridgeFeeJuice(address: AztecAddress, amount: bigint) {
170
- const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, address);
160
+ async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress, amount: bigint) {
161
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, recipient);
171
162
  const { claimSecret: secret, messageLeafIndex: index } = claim;
172
- await this.feeJuiceContract.methods.claim(address, amount, secret, index).send().wait();
163
+ await this.feeJuiceContract.methods.claim(recipient, amount, secret, index).send({ from: minter }).wait();
173
164
  }
174
165
 
175
166
  /** Alice mints bananaCoin tokens privately to the target address and redeems them. */
176
167
  async mintPrivateBananas(amount: bigint, address: AztecAddress) {
177
- const balanceBefore = await this.bananaCoin.methods.balance_of_private(address).simulate();
168
+ const balanceBefore = await this.bananaCoin.methods
169
+ .balance_of_private(address)
170
+ .simulate({ from: this.aliceAddress });
178
171
 
179
- await mintTokensToPrivate(this.bananaCoin, this.aliceWallet, address, amount);
172
+ await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, this.aliceWallet, address, amount);
180
173
 
181
- const balanceAfter = await this.bananaCoin.methods.balance_of_private(address).simulate();
174
+ const balanceAfter = await this.bananaCoin.methods
175
+ .balance_of_private(address)
176
+ .simulate({ from: this.aliceAddress });
182
177
  expect(balanceAfter).toEqual(balanceBefore + amount);
183
178
  }
184
179
 
@@ -201,8 +196,9 @@ export class FeesTest {
201
196
  this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
202
197
  this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
203
198
  this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
199
+ this.accounts = this.wallets.map(w => w.getAddress());
204
200
  [this.aliceWallet, this.bobWallet] = this.wallets.slice(0, 2);
205
- [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.wallets.map(w => w.getAddress());
201
+ [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts;
206
202
 
207
203
  // We set Alice as the FPC admin to avoid the need for deployment of another account.
208
204
  this.fpcAdmin = this.aliceAddress;
@@ -216,7 +212,7 @@ export class FeesTest {
216
212
 
217
213
  async applyPublicDeployAccountsSnapshot() {
218
214
  await this.snapshotManager.snapshot('public_deploy_accounts', () =>
219
- ensureAccountsPubliclyDeployed(this.aliceWallet, this.wallets),
215
+ ensureAccountContractsPublished(this.aliceWallet, this.wallets),
220
216
  );
221
217
  }
222
218
 
@@ -229,7 +225,12 @@ export class FeesTest {
229
225
 
230
226
  this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.aliceWallet);
231
227
 
232
- this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
228
+ this.getGasBalanceFn = getBalancesFn(
229
+ '⛽',
230
+ this.feeJuiceContract.methods.balance_of_public,
231
+ this.aliceAddress,
232
+ this.logger,
233
+ );
233
234
 
234
235
  this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
235
236
  aztecNode: context.aztecNode,
@@ -248,7 +249,7 @@ export class FeesTest {
248
249
  'deploy_banana_token',
249
250
  async () => {
250
251
  const bananaCoin = await BananaCoin.deploy(this.aliceWallet, this.aliceAddress, 'BC', 'BC', 18n)
251
- .send()
252
+ .send({ from: this.aliceAddress })
252
253
  .deployed();
253
254
  this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
254
255
  return { bananaCoinAddress: bananaCoin.address };
@@ -256,10 +257,16 @@ export class FeesTest {
256
257
  async ({ bananaCoinAddress }) => {
257
258
  this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.aliceWallet);
258
259
  const logger = this.logger;
259
- this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, logger);
260
+ this.getBananaPublicBalanceFn = getBalancesFn(
261
+ '🍌.public',
262
+ this.bananaCoin.methods.balance_of_public,
263
+ this.aliceAddress,
264
+ logger,
265
+ );
260
266
  this.getBananaPrivateBalanceFn = getBalancesFn(
261
267
  '🍌.private',
262
268
  this.bananaCoin.methods.balance_of_private,
269
+ this.aliceAddress,
263
270
  logger,
264
271
  );
265
272
  },
@@ -271,16 +278,20 @@ export class FeesTest {
271
278
  'fpc_setup',
272
279
  async context => {
273
280
  const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
274
- expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPubliclyDeployed).toBe(true);
281
+ expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
275
282
 
276
283
  const bananaCoin = this.bananaCoin;
277
284
  const bananaFPC = await FPCContract.deploy(this.aliceWallet, bananaCoin.address, this.fpcAdmin)
278
- .send()
285
+ .send({ from: this.aliceAddress })
279
286
  .deployed();
280
287
 
281
288
  this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
282
289
 
283
- await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(FEE_FUNDING_FOR_TESTER_ACCOUNT, bananaFPC.address);
290
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(
291
+ FEE_FUNDING_FOR_TESTER_ACCOUNT,
292
+ bananaFPC.address,
293
+ this.aliceAddress,
294
+ );
284
295
 
285
296
  return {
286
297
  bananaFPCAddress: bananaFPC.address,
@@ -304,20 +315,12 @@ export class FeesTest {
304
315
  };
305
316
 
306
317
  this.getCoinbaseSequencerRewards = async () => {
307
- const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
308
- const rollup = new RollupContract(l1Client, data.rollupAddress);
309
- return await rollup.getSequencerRewards(this.coinbase);
318
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
310
319
  };
311
320
 
312
321
  this.getProverFee = async (blockNumber: number) => {
313
322
  const block = await this.pxe.getBlock(blockNumber);
314
323
 
315
- const publicClient = getPublicClient({
316
- l1RpcUrls: context.aztecNodeConfig.l1RpcUrls,
317
- l1ChainId: context.aztecNodeConfig.l1ChainId,
318
- });
319
- const rollup = new RollupContract(publicClient, data.rollupAddress);
320
-
321
324
  // @todo @lherskind As we deal with #13601
322
325
  // Right now the value is from `FeeLib.sol`
323
326
  const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
@@ -325,15 +328,15 @@ export class FeesTest {
325
328
  // We round up
326
329
  const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
327
330
 
328
- const { baseFee } = await rollup.getL1FeesAt(block!.header.globalVariables.timestamp);
331
+ const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
329
332
  const proverCost =
330
333
  mulDiv(
331
- mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await rollup.getEpochDuration()),
334
+ mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await this.rollupContract.getEpochDuration()),
332
335
  1n,
333
- await rollup.getManaTarget(),
334
- ) + (await rollup.getProvingCostPerMana());
336
+ await this.rollupContract.getManaTarget(),
337
+ ) + (await this.rollupContract.getProvingCostPerMana());
335
338
 
336
- const price = await rollup.getFeeAssetPerEth();
339
+ const price = await this.rollupContract.getFeeAssetPerEth();
337
340
 
338
341
  const mana = block!.header.totalManaUsed.toBigInt();
339
342
  return mulDiv(mana * proverCost, price, 10n ** 9n);
@@ -347,7 +350,7 @@ export class FeesTest {
347
350
  'sponsored_fpc_setup',
348
351
  async context => {
349
352
  const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
350
- expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPubliclyDeployed).toBe(true);
353
+ expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
351
354
 
352
355
  const sponsoredFPC = await setupSponsoredFPC(context.pxe);
353
356
  this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
@@ -367,7 +370,10 @@ export class FeesTest {
367
370
  'fund_alice',
368
371
  async () => {
369
372
  await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
370
- await this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send().wait();
373
+ await this.bananaCoin.methods
374
+ .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
375
+ .send({ from: this.aliceAddress })
376
+ .wait();
371
377
  },
372
378
  () => Promise.resolve(),
373
379
  );
@@ -382,37 +388,4 @@ export class FeesTest {
382
388
  () => Promise.resolve(),
383
389
  );
384
390
  }
385
-
386
- public async applySetupSubscription() {
387
- await this.snapshotManager.snapshot(
388
- 'setup_subscription',
389
- async () => {
390
- const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed();
391
-
392
- // Deploy subscription contract, that allows subscriptions for SUBSCRIPTION_AMOUNT of bananas
393
- const subscriptionContract = await AppSubscriptionContract.deploy(
394
- this.bobWallet,
395
- counterContract.address,
396
- this.bobAddress,
397
- this.bananaCoin.address,
398
- this.SUBSCRIPTION_AMOUNT,
399
- this.APP_SPONSORED_TX_GAS_LIMIT,
400
- )
401
- .send()
402
- .deployed();
403
-
404
- // Mint some Fee Juice to the subscription contract
405
- // Could also use bridgeFromL1ToL2 from the harness, but this is more direct
406
- await this.mintAndBridgeFeeJuice(subscriptionContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT);
407
- return {
408
- counterContractAddress: counterContract.address,
409
- subscriptionContractAddress: subscriptionContract.address,
410
- };
411
- },
412
- async ({ counterContractAddress, subscriptionContractAddress }) => {
413
- this.counterContract = await CounterContract.at(counterContractAddress, this.bobWallet);
414
- this.subscriptionContract = await AppSubscriptionContract.at(subscriptionContractAddress, this.bobWallet);
415
- },
416
- );
417
- }
418
391
  }
@@ -1,5 +1,5 @@
1
1
  import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import { type AccountWallet, type CompleteAddress, type Logger, type PXE, createLogger } from '@aztec/aztec.js';
2
+ import { type AccountWallet, AztecAddress, type Logger, type PXE, createLogger } from '@aztec/aztec.js';
3
3
  import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
4
4
  import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
5
5
 
@@ -16,8 +16,8 @@ const { E2E_DATA_PATH: dataPath } = process.env;
16
16
  export class NestedContractTest {
17
17
  private snapshotManager: ISnapshotManager;
18
18
  logger: Logger;
19
- wallets: AccountWallet[] = [];
20
- accounts: CompleteAddress[] = [];
19
+ wallet!: AccountWallet;
20
+ defaultAccountAddress!: AztecAddress;
21
21
  pxe!: PXE;
22
22
 
23
23
  parentContract!: ParentContract;
@@ -41,9 +41,10 @@ export class NestedContractTest {
41
41
  'accounts',
42
42
  deployAccounts(this.numberOfAccounts, this.logger),
43
43
  async ({ deployedAccounts }, { pxe }) => {
44
- this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
45
- this.accounts = await pxe.getRegisteredAccounts();
46
- this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
44
+ const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
45
+ wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
46
+ [this.wallet] = wallets;
47
+ this.defaultAccountAddress = this.wallet.getAddress();
47
48
  this.pxe = pxe;
48
49
  },
49
50
  );
@@ -53,7 +54,7 @@ export class NestedContractTest {
53
54
  async () => {},
54
55
  async () => {
55
56
  this.logger.verbose(`Public deploy accounts...`);
56
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
57
+ await publicDeployAccounts(this.wallet, [this.defaultAccountAddress]);
57
58
  },
58
59
  );
59
60
  }
@@ -76,13 +77,17 @@ export class NestedContractTest {
76
77
  await this.snapshotManager.snapshot(
77
78
  'manual',
78
79
  async () => {
79
- const parentContract = await ParentContract.deploy(this.wallets[0]).send().deployed();
80
- const childContract = await ChildContract.deploy(this.wallets[0]).send().deployed();
80
+ const parentContract = await ParentContract.deploy(this.wallet)
81
+ .send({ from: this.defaultAccountAddress })
82
+ .deployed();
83
+ const childContract = await ChildContract.deploy(this.wallet)
84
+ .send({ from: this.defaultAccountAddress })
85
+ .deployed();
81
86
  return { parentContractAddress: parentContract.address, childContractAddress: childContract.address };
82
87
  },
83
88
  async ({ parentContractAddress, childContractAddress }) => {
84
- this.parentContract = await ParentContract.at(parentContractAddress, this.wallets[0]);
85
- this.childContract = await ChildContract.at(childContractAddress, this.wallets[0]);
89
+ this.parentContract = await ParentContract.at(parentContractAddress, this.wallet);
90
+ this.childContract = await ChildContract.at(childContractAddress, this.wallet);
86
91
  },
87
92
  );
88
93
  }
@@ -1,18 +1,20 @@
1
1
  import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
2
2
  import type { InitialAccountData } from '@aztec/accounts/testing';
3
3
  import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
4
- import { type AccountWalletWithSecretKey, EthAddress } from '@aztec/aztec.js';
4
+ import { type AccountWalletWithSecretKey, AztecAddress, EthAddress, Fr } from '@aztec/aztec.js';
5
5
  import {
6
6
  type ExtendedViemWalletClient,
7
+ GSEContract,
7
8
  L1TxUtils,
9
+ MultiAdderArtifact,
8
10
  type Operator,
9
11
  RollupContract,
10
12
  type ViemClient,
11
13
  deployL1Contract,
12
14
  getL1ContractsConfigEnvVars,
13
- l1Artifacts,
14
15
  } from '@aztec/ethereum';
15
16
  import { ChainMonitor } from '@aztec/ethereum/test';
17
+ import { SecretValue } from '@aztec/foundation/config';
16
18
  import { type Logger, createLogger } from '@aztec/foundation/log';
17
19
  import { RollupAbi, SlashFactoryAbi, SlasherAbi, SlashingProposerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
18
20
  import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
@@ -70,6 +72,7 @@ export class P2PNetworkTest {
70
72
  public prefilledPublicData: PublicDataTreeLeaf[] = [];
71
73
  // The re-execution test needs a wallet and a spam contract
72
74
  public wallet?: AccountWalletWithSecretKey;
75
+ public defaultAccountAddress?: AztecAddress;
73
76
  public spamContract?: SpamContract;
74
77
 
75
78
  public bootstrapNode?: BootstrapNode;
@@ -78,8 +81,9 @@ export class P2PNetworkTest {
78
81
  testName: string,
79
82
  public bootstrapNodeEnr: string,
80
83
  public bootNodePort: number,
81
- private numberOfNodes: number,
84
+ public numberOfValidators: number,
82
85
  initialValidatorConfig: AztecNodeConfig,
86
+ public numberOfNodes = 0,
83
87
  // If set enable metrics collection
84
88
  private metricsPort?: number,
85
89
  startProverNode?: boolean,
@@ -90,7 +94,10 @@ export class P2PNetworkTest {
90
94
  // Set up the base account and node private keys for the initial network deployment
91
95
  this.baseAccountPrivateKey = `0x${getPrivateKeyFromIndex(1)!.toString('hex')}`;
92
96
  this.baseAccount = privateKeyToAccount(this.baseAccountPrivateKey);
93
- this.attesterPrivateKeys = generatePrivateKeys(ATTESTER_PRIVATE_KEYS_START_INDEX, numberOfNodes);
97
+ this.attesterPrivateKeys = generatePrivateKeys(
98
+ ATTESTER_PRIVATE_KEYS_START_INDEX + numberOfNodes,
99
+ numberOfValidators,
100
+ );
94
101
  this.attesterPublicKeys = this.attesterPrivateKeys.map(privateKey => privateKeyToAccount(privateKey).address);
95
102
 
96
103
  const zkPassportParams = ZkPassportProofParams.random();
@@ -105,7 +112,7 @@ export class P2PNetworkTest {
105
112
  aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
106
113
  aztecProofSubmissionEpochs:
107
114
  initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
108
- aztecTargetCommitteeSize: numberOfNodes,
115
+ aztecTargetCommitteeSize: numberOfValidators,
109
116
  salt: 420,
110
117
  metricsPort: metricsPort,
111
118
  numberOfInitialFundedAccounts: 2,
@@ -118,7 +125,7 @@ export class P2PNetworkTest {
118
125
  aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
119
126
  aztecProofSubmissionEpochs:
120
127
  initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
121
- aztecTargetCommitteeSize: numberOfNodes,
128
+ aztecTargetCommitteeSize: numberOfValidators,
122
129
  initialValidators: [],
123
130
  zkPassportArgs: {
124
131
  mockZkPassportVerifier,
@@ -132,6 +139,7 @@ export class P2PNetworkTest {
132
139
  static async create({
133
140
  testName,
134
141
  numberOfNodes,
142
+ numberOfValidators,
135
143
  basePort,
136
144
  metricsPort,
137
145
  initialConfig,
@@ -140,6 +148,7 @@ export class P2PNetworkTest {
140
148
  }: {
141
149
  testName: string;
142
150
  numberOfNodes: number;
151
+ numberOfValidators: number;
143
152
  basePort?: number;
144
153
  metricsPort?: number;
145
154
  initialConfig?: Partial<AztecNodeConfig>;
@@ -160,8 +169,9 @@ export class P2PNetworkTest {
160
169
  testName,
161
170
  bootstrapNodeEnr,
162
171
  port,
163
- numberOfNodes,
172
+ numberOfValidators,
164
173
  initialValidatorConfig,
174
+ numberOfNodes,
165
175
  metricsPort,
166
176
  startProverNode,
167
177
  mockZkPassportVerifier,
@@ -192,12 +202,14 @@ export class P2PNetworkTest {
192
202
  getValidators() {
193
203
  const validators: Operator[] = [];
194
204
 
195
- for (let i = 0; i < this.numberOfNodes; i++) {
196
- const attester = privateKeyToAccount(this.attesterPrivateKeys[i]!);
205
+ for (let i = 0; i < this.numberOfValidators; i++) {
206
+ const keyIndex = i;
207
+ const attester = privateKeyToAccount(this.attesterPrivateKeys[keyIndex]!);
197
208
 
198
209
  validators.push({
199
210
  attester: EthAddress.fromString(attester.address),
200
211
  withdrawer: EthAddress.fromString(attester.address),
212
+ bn254SecretKey: new SecretValue(Fr.random().toBigInt()),
201
213
  });
202
214
 
203
215
  this.logger.info(`Adding attester ${attester.address} as validator`);
@@ -216,7 +228,7 @@ export class P2PNetworkTest {
216
228
  client: deployL1ContractsValues.l1Client,
217
229
  });
218
230
 
219
- this.logger.verbose(`Adding ${this.numberOfNodes} validators`);
231
+ this.logger.info(`Adding ${this.numberOfValidators} validators`);
220
232
 
221
233
  const stakingAsset = getContract({
222
234
  address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
@@ -226,18 +238,18 @@ export class P2PNetworkTest {
226
238
 
227
239
  const { address: multiAdderAddress } = await deployL1Contract(
228
240
  deployL1ContractsValues.l1Client,
229
- l1Artifacts.multiAdder.contractAbi,
230
- l1Artifacts.multiAdder.contractBytecode,
241
+ MultiAdderArtifact.contractAbi,
242
+ MultiAdderArtifact.contractBytecode,
231
243
  [rollup.address, deployL1ContractsValues.l1Client.account.address],
232
244
  );
233
245
 
234
246
  const multiAdder = getContract({
235
247
  address: multiAdderAddress.toString(),
236
- abi: l1Artifacts.multiAdder.contractAbi,
248
+ abi: MultiAdderArtifact.contractAbi,
237
249
  client: deployL1ContractsValues.l1Client,
238
250
  });
239
251
 
240
- const stakeNeeded = l1ContractsConfig.depositAmount * BigInt(this.numberOfNodes);
252
+ const stakeNeeded = l1ContractsConfig.activationThreshold * BigInt(this.numberOfValidators);
241
253
  await Promise.all(
242
254
  [await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
243
255
  deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
@@ -247,16 +259,25 @@ export class P2PNetworkTest {
247
259
  const { validators } = this.getValidators();
248
260
  this.validators = validators;
249
261
 
262
+ const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
263
+ if (!gseAddress) {
264
+ throw new Error('GSE contract not deployed');
265
+ }
266
+
267
+ const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
268
+
269
+ const makeValidatorTuples = async (validator: Operator) => {
270
+ const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
271
+ return {
272
+ attester: validator.attester.toString() as `0x${string}`,
273
+ withdrawer: validator.withdrawer.toString() as `0x${string}`,
274
+ ...registrationTuple,
275
+ };
276
+ };
277
+ const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
278
+
250
279
  await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
251
- hash: await multiAdder.write.addValidators([
252
- this.validators.map(
253
- v =>
254
- ({
255
- attester: v.attester.toString() as `0x${string}`,
256
- withdrawer: v.withdrawer.toString() as `0x${string}`,
257
- }) as const,
258
- ),
259
- ]),
280
+ hash: await multiAdder.write.addValidators([validatorTuples]),
260
281
  });
261
282
 
262
283
  const timestamp = await cheatCodes.rollup.advanceToEpoch(2n, { updateDateProvider: dateProvider });
@@ -279,6 +300,7 @@ export class P2PNetworkTest {
279
300
  this.deployedAccounts = deployedAccounts;
280
301
  const [account] = deployedAccounts;
281
302
  this.wallet = await getSchnorrWalletWithSecretKey(pxe, account.secret, account.signingKey, account.salt);
303
+ this.defaultAccountAddress = this.wallet.getAddress();
282
304
  },
283
305
  );
284
306
  }
@@ -291,7 +313,9 @@ export class P2PNetworkTest {
291
313
  throw new Error('Call snapshot t.setupAccount before deploying account contract');
292
314
  }
293
315
 
294
- const spamContract = await SpamContract.deploy(this.wallet).send().deployed();
316
+ const spamContract = await SpamContract.deploy(this.wallet)
317
+ .send({ from: this.defaultAccountAddress! })
318
+ .deployed();
295
319
  return { contractAddress: spamContract.address };
296
320
  },
297
321
  async ({ contractAddress }) => {
@@ -305,7 +329,7 @@ export class P2PNetworkTest {
305
329
 
306
330
  async removeInitialNode() {
307
331
  await this.snapshotManager.snapshot(
308
- 'remove-inital-validator',
332
+ 'remove-initial-validator',
309
333
  async ({ deployL1ContractsValues, aztecNode, dateProvider }) => {
310
334
  // Send and await a tx to make sure we mine a block for the warp to correctly progress.
311
335
  const { receipt } = await this._sendDummyTx(deployL1ContractsValues.l1Client);
@@ -340,7 +364,8 @@ export class P2PNetworkTest {
340
364
  const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
341
365
  this.prefilledPublicData = prefilledPublicData;
342
366
 
343
- this.monitor = new ChainMonitor(RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues)).start();
367
+ const rollupContract = RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues);
368
+ this.monitor = new ChainMonitor(rollupContract, this.ctx.dateProvider).start();
344
369
  this.monitor.on('l1-block', ({ timestamp }) => this.ctx.dateProvider.setTime(Number(timestamp) * 1000));
345
370
  }
346
371
 
@@ -2,15 +2,16 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
2
  import type { InitialAccountData } from '@aztec/accounts/testing';
3
3
  import type { AztecNodeService } from '@aztec/aztec-node';
4
4
  import {
5
+ AztecAddress,
5
6
  Fr,
6
7
  type Logger,
7
8
  ProvenTx,
8
9
  type SentTx,
9
10
  TxStatus,
10
- getContractInstanceFromDeployParams,
11
+ getContractInstanceFromInstantiationParams,
11
12
  retryUntil,
12
13
  } from '@aztec/aztec.js';
13
- import type { RollupCheatCodes } from '@aztec/aztec.js/testing';
14
+ import type { RollupCheatCodes } from '@aztec/aztec/testing';
14
15
  import type { RollupContract, ViemClient } from '@aztec/ethereum';
15
16
  import { timesAsync } from '@aztec/foundation/collection';
16
17
  import type { SlashFactoryAbi } from '@aztec/l1-artifacts/SlashFactoryAbi';
@@ -28,6 +29,7 @@ import { submitTxsTo } from '../shared/submit-transactions.js';
28
29
  // submits a set of transactions to the provided Private eXecution Environment (PXE)
29
30
  export const submitComplexTxsTo = async (
30
31
  logger: Logger,
32
+ from: AztecAddress,
31
33
  spamContract: SpamContract,
32
34
  numTxs: number,
33
35
  opts: { callPublic?: boolean } = {},
@@ -37,10 +39,10 @@ export const submitComplexTxsTo = async (
37
39
  const seed = 1234n;
38
40
  const spamCount = 15;
39
41
  for (let i = 0; i < numTxs; i++) {
40
- const tx = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic).send();
42
+ const tx = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic).send({ from });
41
43
  const txHash = await tx.getTxHash();
42
44
 
43
- logger.info(`Tx sent with hash ${txHash}`);
45
+ logger.info(`Tx sent with hash ${txHash.toString()}`);
44
46
  const receipt = await tx.getReceipt();
45
47
  expect(receipt).toEqual(
46
48
  expect.objectContaining({
@@ -48,7 +50,7 @@ export const submitComplexTxsTo = async (
48
50
  error: '',
49
51
  }),
50
52
  );
51
- logger.info(`Receipt received for ${txHash}`);
53
+ logger.info(`Receipt received for ${txHash.toString()}`);
52
54
  txs.push(tx);
53
55
  }
54
56
  return txs;
@@ -92,13 +94,13 @@ export async function createPXEServiceAndPrepareTransactions(
92
94
  await account.register();
93
95
  const wallet = await account.getWallet();
94
96
 
95
- const testContractInstance = await getContractInstanceFromDeployParams(TestContractArtifact, {});
97
+ const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {});
96
98
  await wallet.registerContract({ instance: testContractInstance, artifact: TestContractArtifact });
97
99
  const contract = await TestContract.at(testContractInstance.address, wallet);
98
100
 
99
101
  const txs = await timesAsync(numTxs, async () => {
100
- const tx = await contract.methods.emit_nullifier(Fr.random()).prove();
101
- const txHash = await tx.getTxHash();
102
+ const tx = await contract.methods.emit_nullifier(Fr.random()).prove({ from: account.getAddress() });
103
+ const txHash = tx.getTxHash();
102
104
  logger.info(`Tx prepared with hash ${txHash}`);
103
105
  return tx;
104
106
  });
@@ -112,16 +114,16 @@ export async function awaitProposalExecution(
112
114
  ) {
113
115
  await retryUntil(
114
116
  async () => {
115
- const events = await slashingProposer.getEvents.ProposalExecuted();
117
+ const events = await slashingProposer.getEvents.PayloadSubmitted();
116
118
  if (events.length === 0) {
117
119
  return false;
118
120
  }
119
121
  const event = events[0];
120
122
  const roundNumber = event.args.round;
121
- const proposal = event.args.proposal;
122
- return roundNumber && proposal;
123
+ const payload = event.args.payload;
124
+ return roundNumber && payload;
123
125
  },
124
- 'proposal executed',
126
+ 'payload submitted',
125
127
  timeoutSeconds,
126
128
  1,
127
129
  );