@aztec/end-to-end 4.0.0-nightly.20260113 → 4.0.0-nightly.20260115

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 (80) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +12 -13
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +104 -134
  4. package/dest/bench/utils.d.ts +1 -1
  5. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  6. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +98 -113
  8. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +6 -7
  9. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +65 -62
  11. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
  12. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  13. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  14. package/dest/e2e_epochs/epochs_test.js +1 -1
  15. package/dest/e2e_fees/bridging_race.notest.js +2 -4
  16. package/dest/e2e_fees/fees_test.d.ts +13 -13
  17. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  18. package/dest/e2e_fees/fees_test.js +122 -140
  19. package/dest/e2e_l1_publisher/write_json.d.ts +1 -1
  20. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  21. package/dest/e2e_l1_publisher/write_json.js +1 -0
  22. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  23. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  24. package/dest/e2e_nested_contract/nested_contract_test.js +32 -40
  25. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  26. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  27. package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
  28. package/dest/e2e_p2p/p2p_network.d.ts +7 -6
  29. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  30. package/dest/e2e_p2p/p2p_network.js +106 -103
  31. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  32. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  33. package/dest/e2e_token_contract/token_contract_test.js +90 -92
  34. package/dest/fixtures/e2e_prover_test.d.ts +8 -14
  35. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  36. package/dest/fixtures/e2e_prover_test.js +82 -93
  37. package/dest/fixtures/setup.d.ts +216 -0
  38. package/dest/fixtures/setup.d.ts.map +1 -0
  39. package/dest/fixtures/setup.js +683 -0
  40. package/dest/fixtures/utils.d.ts +5 -191
  41. package/dest/fixtures/utils.d.ts.map +1 -1
  42. package/dest/fixtures/utils.js +4 -615
  43. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  44. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  45. package/dest/quality_of_service/prometheus_client.js +67 -0
  46. package/dest/shared/cross_chain_test_harness.d.ts +12 -1
  47. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  48. package/dest/shared/gas_portal_test_harness.d.ts +11 -1
  49. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  50. package/dest/simulators/lending_simulator.d.ts +5 -1
  51. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  52. package/dest/spartan/tx_metrics.d.ts +4 -1
  53. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  54. package/dest/spartan/tx_metrics.js +21 -1
  55. package/dest/spartan/utils.d.ts +5 -1
  56. package/dest/spartan/utils.d.ts.map +1 -1
  57. package/dest/spartan/utils.js +25 -8
  58. package/package.json +39 -39
  59. package/src/bench/client_flows/client_flows_benchmark.ts +142 -195
  60. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +107 -142
  61. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +99 -106
  62. package/src/e2e_deploy_contract/deploy_test.ts +21 -14
  63. package/src/e2e_epochs/epochs_test.ts +1 -1
  64. package/src/e2e_fees/bridging_race.notest.ts +2 -5
  65. package/src/e2e_fees/fees_test.ts +171 -213
  66. package/src/e2e_l1_publisher/write_json.ts +1 -0
  67. package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
  68. package/src/e2e_p2p/inactivity_slash_test.ts +5 -5
  69. package/src/e2e_p2p/p2p_network.ts +165 -167
  70. package/src/e2e_token_contract/token_contract_test.ts +105 -118
  71. package/src/fixtures/e2e_prover_test.ts +107 -136
  72. package/src/fixtures/setup.ts +1009 -0
  73. package/src/fixtures/utils.ts +27 -901
  74. package/src/quality_of_service/prometheus_client.ts +113 -0
  75. package/src/spartan/tx_metrics.ts +21 -1
  76. package/src/spartan/utils.ts +26 -8
  77. package/dest/fixtures/snapshot_manager.d.ts +0 -93
  78. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  79. package/dest/fixtures/snapshot_manager.js +0 -488
  80. package/src/fixtures/snapshot_manager.ts +0 -646
@@ -26,25 +26,19 @@ import { getContract } from 'viem';
26
26
 
27
27
  import { MNEMONIC } from '../fixtures/fixtures.js';
28
28
  import {
29
- type ISnapshotManager,
30
- type SubsystemsContext,
31
- createSnapshotManager,
29
+ type EndToEndContext,
30
+ type SetupOptions,
32
31
  deployAccounts,
33
- } from '../fixtures/snapshot_manager.js';
32
+ publicDeployAccounts,
33
+ setup,
34
+ teardown,
35
+ } from '../fixtures/setup.js';
34
36
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
35
- import {
36
- type BalancesFn,
37
- type SetupOptions,
38
- ensureAccountContractsPublished,
39
- getBalancesFn,
40
- setupSponsoredFPC,
41
- } from '../fixtures/utils.js';
37
+ import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
42
38
  import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
43
39
 
44
- const { E2E_DATA_PATH: dataPath } = process.env;
45
-
46
40
  /**
47
- * Test fixture for testing fees. Provides the following snapshots:
41
+ * Test fixture for testing fees. Provides the following setup steps:
48
42
  * InitialAccounts: Initializes 3 Schnorr account contracts.
49
43
  * PublicDeployAccounts: Deploys the accounts publicly.
50
44
  * DeployFeeJuice: Deploys the Fee Juice contract.
@@ -54,8 +48,8 @@ const { E2E_DATA_PATH: dataPath } = process.env;
54
48
  * SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
55
49
  */
56
50
  export class FeesTest {
57
- private snapshotManager: ISnapshotManager;
58
51
  private accounts: AztecAddress[] = [];
52
+ public context!: EndToEndContext;
59
53
 
60
54
  public logger: Logger;
61
55
  public aztecNode!: AztecNode;
@@ -82,7 +76,6 @@ export class FeesTest {
82
76
  public subscriptionContract!: AppSubscriptionContract;
83
77
  public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
84
78
 
85
- public context!: SubsystemsContext;
86
79
  public chainMonitor!: ChainMonitor;
87
80
 
88
81
  public getCoinbaseBalance!: () => Promise<bigint>;
@@ -99,7 +92,7 @@ export class FeesTest {
99
92
  constructor(
100
93
  testName: string,
101
94
  private numberOfAccounts = 3,
102
- setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
95
+ private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
103
96
  ) {
104
97
  if (!numberOfAccounts) {
105
98
  throw new Error('There must be at least 1 initial account.');
@@ -107,30 +100,33 @@ export class FeesTest {
107
100
  setupOptions.coinbase ??= EthAddress.random();
108
101
  this.coinbase = setupOptions.coinbase!;
109
102
  this.logger = createLogger(`e2e:e2e_fees:${testName}`);
110
- this.snapshotManager = createSnapshotManager(
111
- `e2e_fees/${testName}-${numberOfAccounts}`,
112
- dataPath,
113
- { startProverNode: true, ...setupOptions },
114
- { ...setupOptions },
115
- );
116
103
  }
117
104
 
118
105
  async setup() {
119
- const context = await this.snapshotManager.setup();
106
+ this.logger.verbose('Setting up fresh context...');
107
+ this.context = await setup(0, {
108
+ startProverNode: true,
109
+ ...this.setupOptions,
110
+ fundSponsoredFPC: true,
111
+ skipAccountDeployment: true,
112
+ l1ContractsArgs: { ...this.setupOptions },
113
+ });
120
114
 
121
- this.rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
122
- this.chainMonitor = new ChainMonitor(this.rollupContract, context.dateProvider, this.logger, 200).start();
115
+ this.rollupContract = RollupContract.getFromConfig(this.context.config);
116
+ this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider!, this.logger, 200).start();
117
+
118
+ await this.applyBaseSetup();
123
119
 
124
120
  return this;
125
121
  }
126
122
 
127
123
  async teardown() {
128
124
  await this.chainMonitor.stop();
129
- await this.snapshotManager.teardown();
125
+ await teardown(this.context);
130
126
  }
131
127
 
132
128
  setIsMarkingAsProven(b: boolean) {
133
- this.context.watcher.setIsMarkingAsProven(b);
129
+ this.context.watcher!.setIsMarkingAsProven(b);
134
130
  }
135
131
 
136
132
  async catchUpProvenChain() {
@@ -176,210 +172,172 @@ export class FeesTest {
176
172
  expect(balanceAfter).toEqual(balanceBefore + amount);
177
173
  }
178
174
 
179
- public async applyBaseSnapshots() {
180
- await this.applyInitialAccountsSnapshot();
181
- await this.applyPublicDeployAccountsSnapshot();
182
- await this.applySetupFeeJuiceSnapshot();
183
- await this.applyDeployBananaTokenSnapshot();
175
+ public async applyBaseSetup() {
176
+ await this.applyInitialAccounts();
177
+ await this.applyPublicDeployAccounts();
178
+ await this.applySetupFeeJuice();
179
+ await this.applyDeployBananaToken();
184
180
  }
185
181
 
186
- async applyInitialAccountsSnapshot() {
187
- await this.snapshotManager.snapshot(
188
- 'initial_accounts',
189
- deployAccounts(this.numberOfAccounts, this.logger),
190
- async ({ deployedAccounts }, { wallet, aztecNode, cheatCodes }) => {
191
- this.wallet = wallet;
192
- this.aztecNode = aztecNode;
193
- this.aztecNodeAdmin = aztecNode;
194
- this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
195
- this.cheatCodes = cheatCodes;
196
- this.accounts = deployedAccounts.map(a => a.address);
197
- this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
198
- [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
199
-
200
- // We set Alice as the FPC admin to avoid the need for deployment of another account.
201
- this.fpcAdmin = this.aliceAddress;
202
-
203
- const canonicalFeeJuice = await getCanonicalFeeJuice();
204
- this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
205
- },
206
- );
182
+ async applyInitialAccounts() {
183
+ this.logger.info('Applying initial accounts setup');
184
+
185
+ const { deployedAccounts } = await deployAccounts(
186
+ this.numberOfAccounts,
187
+ this.logger,
188
+ )({
189
+ wallet: this.context.wallet,
190
+ initialFundedAccounts: this.context.initialFundedAccounts,
191
+ });
192
+
193
+ this.wallet = this.context.wallet;
194
+ this.aztecNode = this.context.aztecNodeService!;
195
+ this.aztecNodeAdmin = this.context.aztecNodeService!;
196
+ this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
197
+ this.cheatCodes = this.context.cheatCodes;
198
+ this.accounts = deployedAccounts.map(a => a.address);
199
+ this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
200
+ [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
201
+
202
+ // We set Alice as the FPC admin to avoid the need for deployment of another account.
203
+ this.fpcAdmin = this.aliceAddress;
204
+
205
+ const canonicalFeeJuice = await getCanonicalFeeJuice();
206
+ this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
207
207
  }
208
208
 
209
- async applyPublicDeployAccountsSnapshot() {
210
- await this.snapshotManager.snapshot('public_deploy_accounts', () =>
211
- ensureAccountContractsPublished(this.wallet, this.accounts),
212
- );
209
+ async applyPublicDeployAccounts() {
210
+ this.logger.info('Applying public deploy accounts setup');
211
+ await publicDeployAccounts(this.wallet, this.accounts);
213
212
  }
214
213
 
215
- async applySetupFeeJuiceSnapshot() {
216
- await this.snapshotManager.snapshot(
217
- 'setup_fee_juice',
218
- async () => {},
219
- async (_data, context) => {
220
- this.context = context;
221
-
222
- this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
223
-
224
- this.getGasBalanceFn = getBalancesFn(
225
- '⛽',
226
- this.feeJuiceContract.methods.balance_of_public,
227
- this.aliceAddress,
228
- this.logger,
229
- );
230
-
231
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
232
- aztecNode: context.aztecNode,
233
- aztecNodeAdmin: context.aztecNode,
234
- l1Client: context.deployL1ContractsValues.l1Client,
235
- wallet: this.wallet,
236
- logger: this.logger,
237
- });
238
- },
214
+ async applySetupFeeJuice() {
215
+ this.logger.info('Applying fee juice setup');
216
+
217
+ this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
218
+
219
+ this.getGasBalanceFn = getBalancesFn(
220
+ '⛽',
221
+ this.feeJuiceContract.methods.balance_of_public,
222
+ this.aliceAddress,
223
+ this.logger,
239
224
  );
225
+
226
+ this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
227
+ aztecNode: this.context.aztecNodeService!,
228
+ aztecNodeAdmin: this.context.aztecNodeService!,
229
+ l1Client: this.context.deployL1ContractsValues.l1Client,
230
+ wallet: this.wallet,
231
+ logger: this.logger,
232
+ });
240
233
  }
241
234
 
242
- async applyDeployBananaTokenSnapshot() {
243
- await this.snapshotManager.snapshot(
244
- 'deploy_banana_token',
245
- async () => {
246
- const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
247
- .send({ from: this.aliceAddress })
248
- .deployed();
249
- this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
250
- return { bananaCoinAddress: bananaCoin.address };
251
- },
252
- ({ bananaCoinAddress }) => {
253
- this.bananaCoin = BananaCoin.at(bananaCoinAddress, this.wallet);
254
- const logger = this.logger;
255
- this.getBananaPublicBalanceFn = getBalancesFn(
256
- '🍌.public',
257
- this.bananaCoin.methods.balance_of_public,
258
- this.aliceAddress,
259
- logger,
260
- );
261
- this.getBananaPrivateBalanceFn = getBalancesFn(
262
- '🍌.private',
263
- this.bananaCoin.methods.balance_of_private,
264
- this.aliceAddress,
265
- logger,
266
- );
267
- return Promise.resolve();
268
- },
235
+ async applyDeployBananaToken() {
236
+ this.logger.info('Applying deploy banana token setup');
237
+
238
+ const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
239
+ .send({ from: this.aliceAddress })
240
+ .deployed();
241
+ this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
242
+
243
+ this.bananaCoin = bananaCoin;
244
+ this.getBananaPublicBalanceFn = getBalancesFn(
245
+ '🍌.public',
246
+ this.bananaCoin.methods.balance_of_public,
247
+ this.aliceAddress,
248
+ this.logger,
249
+ );
250
+ this.getBananaPrivateBalanceFn = getBalancesFn(
251
+ '🍌.private',
252
+ this.bananaCoin.methods.balance_of_private,
253
+ this.aliceAddress,
254
+ this.logger,
269
255
  );
270
256
  }
271
257
 
272
- public async applyFPCSetupSnapshot() {
273
- await this.snapshotManager.snapshot(
274
- 'fpc_setup',
275
- async context => {
276
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
277
- expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
278
-
279
- const bananaCoin = this.bananaCoin;
280
- const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
281
- .send({ from: this.aliceAddress })
282
- .deployed();
283
-
284
- this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
285
-
286
- await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
287
-
288
- return {
289
- bananaFPCAddress: bananaFPC.address,
290
- feeJuiceAddress: feeJuiceContract.address,
291
- l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress,
292
- rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
293
- };
294
- },
295
- (data, context) => {
296
- const bananaFPC = FPCContract.at(data.bananaFPCAddress, this.wallet);
297
- this.bananaFPC = bananaFPC;
298
-
299
- this.getCoinbaseBalance = async () => {
300
- const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
301
- const gasL1 = getContract({
302
- address: data.l1FeeJuiceAddress.toString(),
303
- abi: TestERC20Abi,
304
- client: l1Client,
305
- });
306
- return await gasL1.read.balanceOf([this.coinbase.toString()]);
307
- };
308
-
309
- this.getCoinbaseSequencerRewards = async () => {
310
- return await this.rollupContract.getSequencerRewards(this.coinbase);
311
- };
312
-
313
- this.getProverFee = async (blockNumber: BlockNumber) => {
314
- const block = await this.aztecNode.getBlock(blockNumber);
315
-
316
- // @todo @lherskind As we deal with #13601
317
- // Right now the value is from `FeeLib.sol`
318
- const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
319
-
320
- // We round up
321
- const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
322
-
323
- const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
324
- const proverCost =
325
- mulDiv(
326
- mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
327
- 1n,
328
- await this.rollupContract.getManaTarget(),
329
- ) + (await this.rollupContract.getProvingCostPerMana());
330
-
331
- const price = await this.rollupContract.getFeeAssetPerEth();
332
-
333
- const mana = block!.header.totalManaUsed.toBigInt();
334
- return mulDiv(mana * proverCost, price, 10n ** 9n);
335
- };
336
- return Promise.resolve();
337
- },
338
- );
258
+ public async applyFPCSetup() {
259
+ this.logger.info('Applying FPC setup');
260
+
261
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
262
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
263
+
264
+ const bananaCoin = this.bananaCoin;
265
+ const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
266
+ .send({ from: this.aliceAddress })
267
+ .deployed();
268
+
269
+ this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
270
+
271
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
272
+
273
+ this.bananaFPC = bananaFPC;
274
+
275
+ const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
276
+
277
+ this.getCoinbaseBalance = async () => {
278
+ const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
279
+ const gasL1 = getContract({
280
+ address: l1FeeJuiceAddress.toString(),
281
+ abi: TestERC20Abi,
282
+ client: l1Client,
283
+ });
284
+ return await gasL1.read.balanceOf([this.coinbase.toString()]);
285
+ };
286
+
287
+ this.getCoinbaseSequencerRewards = async () => {
288
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
289
+ };
290
+
291
+ this.getProverFee = async (blockNumber: BlockNumber) => {
292
+ const block = await this.aztecNode.getBlock(blockNumber);
293
+
294
+ // @todo @lherskind As we deal with #13601
295
+ // Right now the value is from `FeeLib.sol`
296
+ const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
297
+
298
+ // We round up
299
+ const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
300
+
301
+ const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
302
+ const proverCost =
303
+ mulDiv(
304
+ mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
305
+ 1n,
306
+ await this.rollupContract.getManaTarget(),
307
+ ) + (await this.rollupContract.getProvingCostPerMana());
308
+
309
+ const price = await this.rollupContract.getFeeAssetPerEth();
310
+
311
+ const mana = block!.header.totalManaUsed.toBigInt();
312
+ return mulDiv(mana * proverCost, price, 10n ** 9n);
313
+ };
339
314
  }
340
315
 
341
- public async applySponsoredFPCSetupSnapshot() {
342
- await this.snapshotManager.snapshot(
343
- 'sponsored_fpc_setup',
344
- async context => {
345
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
346
- expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
347
-
348
- const sponsoredFPC = await setupSponsoredFPC(this.wallet);
349
- this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
350
-
351
- return {
352
- sponsoredFPCAddress: sponsoredFPC.address,
353
- };
354
- },
355
- data => {
356
- this.sponsoredFPC = SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
357
- return Promise.resolve();
358
- },
359
- );
316
+ public async applySponsoredFPCSetup() {
317
+ this.logger.info('Applying sponsored FPC setup');
318
+
319
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
320
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
321
+
322
+ const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
323
+ this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
324
+
325
+ this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
360
326
  }
361
327
 
362
328
  public async applyFundAliceWithBananas() {
363
- await this.snapshotManager.snapshot(
364
- 'fund_alice',
365
- async () => {
366
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
367
- await this.bananaCoin.methods
368
- .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
369
- .send({ from: this.aliceAddress })
370
- .wait();
371
- },
372
- () => Promise.resolve(),
373
- );
329
+ this.logger.info('Applying fund Alice with bananas setup');
330
+
331
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
332
+ await this.bananaCoin.methods
333
+ .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
334
+ .send({ from: this.aliceAddress })
335
+ .wait();
374
336
  }
375
337
 
376
338
  public async applyFundAliceWithPrivateBananas() {
377
- await this.snapshotManager.snapshot(
378
- 'fund_alice_with_private_bananas',
379
- async () => {
380
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
381
- },
382
- () => Promise.resolve(),
383
- );
339
+ this.logger.info('Applying fund Alice with private bananas setup');
340
+
341
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
384
342
  }
385
343
  }
@@ -54,6 +54,7 @@ export async function writeJson(
54
54
  blockHeadersHash: asHex(block.header.blockHeadersHash),
55
55
  blobsHash: asHex(block.header.blobsHash),
56
56
  inHash: asHex(block.header.inHash),
57
+ outHash: asHex(block.header.epochOutHash),
57
58
  slotNumber: Number(block.header.globalVariables.slotNumber),
58
59
  timestamp: Number(block.header.globalVariables.timestamp),
59
60
  coinbase: asHex(block.header.globalVariables.coinbase, 40),
@@ -6,17 +6,15 @@ import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
6
6
  import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
7
7
 
8
8
  import {
9
- type ISnapshotManager,
10
- type SubsystemsContext,
11
- createSnapshotManager,
9
+ type EndToEndContext,
12
10
  deployAccounts,
13
11
  publicDeployAccounts,
14
- } from '../fixtures/snapshot_manager.js';
15
-
16
- const { E2E_DATA_PATH: dataPath } = process.env;
12
+ setup,
13
+ teardown as teardownSubsystems,
14
+ } from '../fixtures/setup.js';
17
15
 
18
16
  export class NestedContractTest {
19
- private snapshotManager: ISnapshotManager;
17
+ context!: EndToEndContext;
20
18
  logger: Logger;
21
19
  wallet!: Wallet;
22
20
  defaultAccountAddress!: AztecAddress;
@@ -30,67 +28,48 @@ export class NestedContractTest {
30
28
  private numberOfAccounts = 1,
31
29
  ) {
32
30
  this.logger = createLogger(`e2e:e2e_nested_contract:${testName}`);
33
- this.snapshotManager = createSnapshotManager(`e2e_nested_contract/${testName}-${numberOfAccounts}`, dataPath);
34
31
  }
35
32
 
36
33
  /**
37
- * Adds two state shifts to snapshot manager.
38
- * 1. Add 3 accounts.
39
- * 2. Publicly deploy accounts
34
+ * Applies base setup by deploying accounts and publicly deploying them.
40
35
  */
41
- async applyBaseSnapshots() {
42
- await this.snapshotManager.snapshot(
43
- 'accounts',
44
- deployAccounts(this.numberOfAccounts, this.logger),
45
- ({ deployedAccounts }, { wallet, aztecNode }) => {
46
- this.wallet = wallet;
47
- [{ address: this.defaultAccountAddress }] = deployedAccounts;
48
- this.aztecNode = aztecNode;
49
- return Promise.resolve();
50
- },
51
- );
36
+ async applyBaseSetup() {
37
+ this.logger.info('Deploying accounts');
38
+ const { deployedAccounts } = await deployAccounts(
39
+ this.numberOfAccounts,
40
+ this.logger,
41
+ )({
42
+ wallet: this.context.wallet,
43
+ initialFundedAccounts: this.context.initialFundedAccounts,
44
+ });
45
+ this.wallet = this.context.wallet;
46
+ [{ address: this.defaultAccountAddress }] = deployedAccounts;
47
+ this.aztecNode = this.context.aztecNodeService!;
52
48
 
53
- await this.snapshotManager.snapshot(
54
- 'public_deploy',
55
- async () => {},
56
- async () => {
57
- this.logger.verbose(`Public deploy accounts...`);
58
- await publicDeployAccounts(this.wallet, [this.defaultAccountAddress]);
59
- },
60
- );
49
+ this.logger.info('Public deploy accounts');
50
+ await publicDeployAccounts(this.wallet, [this.defaultAccountAddress]);
61
51
  }
62
52
 
63
53
  async setup() {
64
- await this.snapshotManager.setup();
54
+ this.logger.info('Setting up fresh subsystems');
55
+ this.context = await setup(0, {
56
+ fundSponsoredFPC: true,
57
+ skipAccountDeployment: true,
58
+ });
59
+ await this.applyBaseSetup();
65
60
  }
66
61
 
67
62
  async teardown() {
68
- await this.snapshotManager.teardown();
63
+ await teardownSubsystems(this.context);
69
64
  }
70
65
 
71
- snapshot = <T>(
72
- name: string,
73
- apply: (context: SubsystemsContext) => Promise<T>,
74
- restore: (snapshotData: T, context: SubsystemsContext) => Promise<void> = () => Promise.resolve(),
75
- ): Promise<void> => this.snapshotManager.snapshot(name, apply, restore);
76
-
77
- async applyManualSnapshots() {
78
- await this.snapshotManager.snapshot(
79
- 'manual',
80
- async () => {
81
- const parentContract = await ParentContract.deploy(this.wallet)
82
- .send({ from: this.defaultAccountAddress })
83
- .deployed();
84
- const childContract = await ChildContract.deploy(this.wallet)
85
- .send({ from: this.defaultAccountAddress })
86
- .deployed();
87
- return { parentContractAddress: parentContract.address, childContractAddress: childContract.address };
88
- },
89
- ({ parentContractAddress, childContractAddress }) => {
90
- this.parentContract = ParentContract.at(parentContractAddress, this.wallet);
91
- this.childContract = ChildContract.at(childContractAddress, this.wallet);
92
- return Promise.resolve();
93
- },
94
- );
66
+ async applyManual() {
67
+ this.logger.info('Deploying parent and child contracts');
68
+ const parentContract = await ParentContract.deploy(this.wallet)
69
+ .send({ from: this.defaultAccountAddress })
70
+ .deployed();
71
+ const childContract = await ChildContract.deploy(this.wallet).send({ from: this.defaultAccountAddress }).deployed();
72
+ this.parentContract = parentContract;
73
+ this.childContract = childContract;
95
74
  }
96
75
  }
@@ -82,8 +82,8 @@ export class P2PInactivityTest {
82
82
  }
83
83
 
84
84
  public async setup() {
85
- await this.test.applyBaseSnapshots();
86
85
  await this.test.setup();
86
+ await this.test.applyBaseSetup();
87
87
 
88
88
  // Set slashing penalties for inactivity
89
89
  const { rollup } = await this.test.getContracts();
@@ -98,13 +98,13 @@ export class P2PInactivityTest {
98
98
  this.rollup = rollup;
99
99
 
100
100
  if (!this.keepInitialNode) {
101
- await this.test.ctx.aztecNode.stop();
101
+ await this.test.ctx.aztecNodeService!.stop();
102
102
  }
103
103
 
104
104
  // Create all active nodes
105
105
  this.activeNodes = await createNodes(
106
106
  this.test.ctx.aztecNodeConfig,
107
- this.test.ctx.dateProvider,
107
+ this.test.ctx.dateProvider!,
108
108
  this.test.bootstrapNodeEnr,
109
109
  NUM_NODES - this.inactiveNodeCount - Number(this.keepInitialNode),
110
110
  BOOT_NODE_UDP_PORT,
@@ -118,7 +118,7 @@ export class P2PInactivityTest {
118
118
  const inactiveConfig = { ...this.test.ctx.aztecNodeConfig, dontStartSequencer: true };
119
119
  this.inactiveNodes = await createNodes(
120
120
  inactiveConfig,
121
- this.test.ctx.dateProvider,
121
+ this.test.ctx.dateProvider!,
122
122
  this.test.bootstrapNodeEnr,
123
123
  this.inactiveNodeCount,
124
124
  BOOT_NODE_UDP_PORT,
@@ -129,7 +129,7 @@ export class P2PInactivityTest {
129
129
  );
130
130
 
131
131
  this.nodes = [
132
- ...(this.keepInitialNode ? [this.test.ctx.aztecNode] : []),
132
+ ...(this.keepInitialNode ? [this.test.ctx.aztecNodeService!] : []),
133
133
  ...this.activeNodes,
134
134
  ...this.inactiveNodes,
135
135
  ];