@aztec/end-to-end 0.0.1-commit.d3ec352c → 0.0.1-commit.d431d1c

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 (141) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +21 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +14 -15
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +110 -138
  7. package/dest/bench/client_flows/data_extractor.js +3 -1
  8. package/dest/bench/utils.d.ts +6 -6
  9. package/dest/bench/utils.d.ts.map +1 -1
  10. package/dest/bench/utils.js +18 -11
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  12. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  13. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +98 -113
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -13
  15. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  16. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +91 -71
  17. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
  18. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  19. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  20. package/dest/e2e_epochs/epochs_test.d.ts +3 -2
  21. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  22. package/dest/e2e_epochs/epochs_test.js +13 -11
  23. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  24. package/dest/e2e_fees/fees_test.d.ts +18 -15
  25. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  26. package/dest/e2e_fees/fees_test.js +126 -141
  27. package/dest/e2e_l1_publisher/write_json.d.ts +3 -3
  28. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  29. package/dest/e2e_l1_publisher/write_json.js +19 -15
  30. package/dest/e2e_multi_validator/utils.js +1 -1
  31. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  32. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  33. package/dest/e2e_nested_contract/nested_contract_test.js +32 -40
  34. package/dest/e2e_p2p/inactivity_slash_test.d.ts +4 -4
  35. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  36. package/dest/e2e_p2p/inactivity_slash_test.js +6 -9
  37. package/dest/e2e_p2p/p2p_network.d.ts +13 -11
  38. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  39. package/dest/e2e_p2p/p2p_network.js +116 -111
  40. package/dest/e2e_p2p/shared.d.ts +2 -2
  41. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  42. package/dest/e2e_p2p/shared.js +4 -4
  43. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  44. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  45. package/dest/e2e_token_contract/token_contract_test.js +90 -92
  46. package/dest/fixtures/e2e_prover_test.d.ts +10 -18
  47. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  48. package/dest/fixtures/e2e_prover_test.js +88 -103
  49. package/dest/fixtures/fixtures.d.ts +2 -3
  50. package/dest/fixtures/fixtures.d.ts.map +1 -1
  51. package/dest/fixtures/fixtures.js +1 -2
  52. package/dest/fixtures/get_acvm_config.js +1 -1
  53. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  54. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  55. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  56. package/dest/fixtures/setup.d.ts +216 -0
  57. package/dest/fixtures/setup.d.ts.map +1 -0
  58. package/dest/fixtures/setup.js +684 -0
  59. package/dest/fixtures/setup_p2p_test.js +3 -3
  60. package/dest/fixtures/utils.d.ts +5 -638
  61. package/dest/fixtures/utils.d.ts.map +1 -1
  62. package/dest/fixtures/utils.js +4 -647
  63. package/dest/fixtures/web3signer.js +1 -1
  64. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  65. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  66. package/dest/fixtures/with_telemetry_utils.js +2 -2
  67. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  68. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  69. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  70. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  71. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  72. package/dest/quality_of_service/prometheus_client.js +67 -0
  73. package/dest/shared/cross_chain_test_harness.d.ts +16 -4
  74. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  75. package/dest/shared/cross_chain_test_harness.js +3 -3
  76. package/dest/shared/gas_portal_test_harness.d.ts +12 -2
  77. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  78. package/dest/shared/index.d.ts +2 -2
  79. package/dest/shared/index.d.ts.map +1 -1
  80. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  81. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  82. package/dest/shared/uniswap_l1_l2.js +43 -23
  83. package/dest/simulators/lending_simulator.d.ts +6 -2
  84. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  85. package/dest/simulators/lending_simulator.js +1 -1
  86. package/dest/spartan/setup_test_wallets.d.ts +4 -3
  87. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  88. package/dest/spartan/setup_test_wallets.js +2 -1
  89. package/dest/spartan/tx_metrics.d.ts +52 -0
  90. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  91. package/dest/spartan/tx_metrics.js +248 -0
  92. package/dest/spartan/utils.d.ts +51 -12
  93. package/dest/spartan/utils.d.ts.map +1 -1
  94. package/dest/spartan/utils.js +262 -102
  95. package/package.json +40 -39
  96. package/src/bench/client_flows/benchmark.ts +24 -2
  97. package/src/bench/client_flows/client_flows_benchmark.ts +150 -200
  98. package/src/bench/client_flows/data_extractor.ts +1 -1
  99. package/src/bench/utils.ts +22 -14
  100. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +107 -142
  101. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -125
  102. package/src/e2e_deploy_contract/deploy_test.ts +21 -14
  103. package/src/e2e_epochs/epochs_test.ts +26 -13
  104. package/src/e2e_fees/bridging_race.notest.ts +3 -6
  105. package/src/e2e_fees/fees_test.ts +177 -216
  106. package/src/e2e_l1_publisher/write_json.ts +22 -17
  107. package/src/e2e_multi_validator/utils.ts +1 -1
  108. package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
  109. package/src/e2e_p2p/inactivity_slash_test.ts +9 -12
  110. package/src/e2e_p2p/p2p_network.ts +174 -183
  111. package/src/e2e_p2p/shared.ts +11 -6
  112. package/src/e2e_token_contract/token_contract_test.ts +105 -118
  113. package/src/fixtures/e2e_prover_test.ts +112 -144
  114. package/src/fixtures/fixtures.ts +1 -3
  115. package/src/fixtures/get_acvm_config.ts +1 -1
  116. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  117. package/src/fixtures/setup.ts +1010 -0
  118. package/src/fixtures/setup_p2p_test.ts +3 -3
  119. package/src/fixtures/utils.ts +27 -966
  120. package/src/fixtures/web3signer.ts +1 -1
  121. package/src/fixtures/with_telemetry_utils.ts +2 -2
  122. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  123. package/src/quality_of_service/prometheus_client.ts +113 -0
  124. package/src/shared/cross_chain_test_harness.ts +6 -10
  125. package/src/shared/gas_portal_test_harness.ts +1 -1
  126. package/src/shared/index.ts +1 -1
  127. package/src/shared/uniswap_l1_l2.ts +53 -67
  128. package/src/simulators/lending_simulator.ts +2 -2
  129. package/src/spartan/setup_test_wallets.ts +9 -2
  130. package/src/spartan/tx_metrics.ts +231 -0
  131. package/src/spartan/utils.ts +308 -45
  132. package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
  133. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  134. package/dest/fixtures/setup_l1_contracts.js +0 -17
  135. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  136. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  137. package/dest/fixtures/snapshot_manager.js +0 -505
  138. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  139. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  140. package/src/fixtures/setup_l1_contracts.ts +0 -26
  141. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -2,7 +2,9 @@ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
3
  import type { AztecNode } from '@aztec/aztec.js/node';
4
4
  import { CheatCodes } from '@aztec/aztec/testing';
5
- import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client } from '@aztec/ethereum';
5
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
6
+ import { RollupContract } from '@aztec/ethereum/contracts';
7
+ import type { DeployAztecL1ContractsArgs } from '@aztec/ethereum/deploy-aztec-l1-contracts';
6
8
  import { ChainMonitor } from '@aztec/ethereum/test';
7
9
  import { BlockNumber } from '@aztec/foundation/branded-types';
8
10
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -17,31 +19,26 @@ import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
17
19
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
18
20
  import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
19
21
  import { GasSettings } from '@aztec/stdlib/gas';
22
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
20
23
  import { TestWallet } from '@aztec/test-wallet/server';
21
24
 
22
25
  import { getContract } from 'viem';
23
26
 
24
27
  import { MNEMONIC } from '../fixtures/fixtures.js';
25
28
  import {
26
- type ISnapshotManager,
27
- type SubsystemsContext,
28
- createSnapshotManager,
29
+ type EndToEndContext,
30
+ type SetupOptions,
29
31
  deployAccounts,
30
- } from '../fixtures/snapshot_manager.js';
32
+ publicDeployAccounts,
33
+ setup,
34
+ teardown,
35
+ } from '../fixtures/setup.js';
31
36
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
32
- import {
33
- type BalancesFn,
34
- type SetupOptions,
35
- ensureAccountContractsPublished,
36
- getBalancesFn,
37
- setupSponsoredFPC,
38
- } from '../fixtures/utils.js';
37
+ import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
39
38
  import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
40
39
 
41
- const { E2E_DATA_PATH: dataPath } = process.env;
42
-
43
40
  /**
44
- * Test fixture for testing fees. Provides the following snapshots:
41
+ * Test fixture for testing fees. Provides the following setup steps:
45
42
  * InitialAccounts: Initializes 3 Schnorr account contracts.
46
43
  * PublicDeployAccounts: Deploys the accounts publicly.
47
44
  * DeployFeeJuice: Deploys the Fee Juice contract.
@@ -51,11 +48,12 @@ const { E2E_DATA_PATH: dataPath } = process.env;
51
48
  * SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
52
49
  */
53
50
  export class FeesTest {
54
- private snapshotManager: ISnapshotManager;
55
51
  private accounts: AztecAddress[] = [];
52
+ public context!: EndToEndContext;
56
53
 
57
54
  public logger: Logger;
58
55
  public aztecNode!: AztecNode;
56
+ public aztecNodeAdmin!: AztecNodeAdmin;
59
57
  public cheatCodes!: CheatCodes;
60
58
 
61
59
  public wallet!: TestWallet;
@@ -78,7 +76,6 @@ export class FeesTest {
78
76
  public subscriptionContract!: AppSubscriptionContract;
79
77
  public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
80
78
 
81
- public context!: SubsystemsContext;
82
79
  public chainMonitor!: ChainMonitor;
83
80
 
84
81
  public getCoinbaseBalance!: () => Promise<bigint>;
@@ -95,7 +92,7 @@ export class FeesTest {
95
92
  constructor(
96
93
  testName: string,
97
94
  private numberOfAccounts = 3,
98
- setupOptions: Partial<SetupOptions & DeployL1ContractsArgs> = {},
95
+ private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
99
96
  ) {
100
97
  if (!numberOfAccounts) {
101
98
  throw new Error('There must be at least 1 initial account.');
@@ -103,30 +100,33 @@ export class FeesTest {
103
100
  setupOptions.coinbase ??= EthAddress.random();
104
101
  this.coinbase = setupOptions.coinbase!;
105
102
  this.logger = createLogger(`e2e:e2e_fees:${testName}`);
106
- this.snapshotManager = createSnapshotManager(
107
- `e2e_fees/${testName}-${numberOfAccounts}`,
108
- dataPath,
109
- { startProverNode: true, ...setupOptions },
110
- { ...setupOptions },
111
- );
112
103
  }
113
104
 
114
105
  async setup() {
115
- 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
+ });
116
114
 
117
- this.rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
118
- 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();
119
119
 
120
120
  return this;
121
121
  }
122
122
 
123
123
  async teardown() {
124
124
  await this.chainMonitor.stop();
125
- await this.snapshotManager.teardown();
125
+ await teardown(this.context);
126
126
  }
127
127
 
128
128
  setIsMarkingAsProven(b: boolean) {
129
- this.context.watcher.setIsMarkingAsProven(b);
129
+ this.context.watcher!.setIsMarkingAsProven(b);
130
130
  }
131
131
 
132
132
  async catchUpProvenChain() {
@@ -140,9 +140,7 @@ export class FeesTest {
140
140
  const blockReward = await this.rollupContract.getCheckpointReward();
141
141
  const rewardConfig = await this.rollupContract.getRewardConfig();
142
142
 
143
- const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(
144
- EthAddress.fromString(rewardConfig.rewardDistributor),
145
- );
143
+ const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
146
144
 
147
145
  const toDistribute = balance > blockReward ? blockReward : balance;
148
146
  const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
@@ -174,209 +172,172 @@ export class FeesTest {
174
172
  expect(balanceAfter).toEqual(balanceBefore + amount);
175
173
  }
176
174
 
177
- public async applyBaseSnapshots() {
178
- await this.applyInitialAccountsSnapshot();
179
- await this.applyPublicDeployAccountsSnapshot();
180
- await this.applySetupFeeJuiceSnapshot();
181
- await this.applyDeployBananaTokenSnapshot();
175
+ public async applyBaseSetup() {
176
+ await this.applyInitialAccounts();
177
+ await this.applyPublicDeployAccounts();
178
+ await this.applySetupFeeJuice();
179
+ await this.applyDeployBananaToken();
182
180
  }
183
181
 
184
- async applyInitialAccountsSnapshot() {
185
- await this.snapshotManager.snapshot(
186
- 'initial_accounts',
187
- deployAccounts(this.numberOfAccounts, this.logger),
188
- async ({ deployedAccounts }, { wallet, aztecNode, cheatCodes }) => {
189
- this.wallet = wallet;
190
- this.aztecNode = aztecNode;
191
- this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) });
192
- this.cheatCodes = cheatCodes;
193
- this.accounts = deployedAccounts.map(a => a.address);
194
- this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
195
- [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
196
-
197
- // We set Alice as the FPC admin to avoid the need for deployment of another account.
198
- this.fpcAdmin = this.aliceAddress;
199
-
200
- const canonicalFeeJuice = await getCanonicalFeeJuice();
201
- this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
202
- },
203
- );
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);
204
207
  }
205
208
 
206
- async applyPublicDeployAccountsSnapshot() {
207
- await this.snapshotManager.snapshot('public_deploy_accounts', () =>
208
- ensureAccountContractsPublished(this.wallet, this.accounts),
209
- );
209
+ async applyPublicDeployAccounts() {
210
+ this.logger.info('Applying public deploy accounts setup');
211
+ await publicDeployAccounts(this.wallet, this.accounts);
210
212
  }
211
213
 
212
- async applySetupFeeJuiceSnapshot() {
213
- await this.snapshotManager.snapshot(
214
- 'setup_fee_juice',
215
- async () => {},
216
- async (_data, context) => {
217
- this.context = context;
218
-
219
- this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
220
-
221
- this.getGasBalanceFn = getBalancesFn(
222
- '⛽',
223
- this.feeJuiceContract.methods.balance_of_public,
224
- this.aliceAddress,
225
- this.logger,
226
- );
227
-
228
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
229
- aztecNode: context.aztecNode,
230
- aztecNodeAdmin: context.aztecNode,
231
- l1Client: context.deployL1ContractsValues.l1Client,
232
- wallet: this.wallet,
233
- logger: this.logger,
234
- });
235
- },
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,
236
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
+ });
237
233
  }
238
234
 
239
- async applyDeployBananaTokenSnapshot() {
240
- await this.snapshotManager.snapshot(
241
- 'deploy_banana_token',
242
- async () => {
243
- const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
244
- .send({ from: this.aliceAddress })
245
- .deployed();
246
- this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
247
- return { bananaCoinAddress: bananaCoin.address };
248
- },
249
- ({ bananaCoinAddress }) => {
250
- this.bananaCoin = BananaCoin.at(bananaCoinAddress, this.wallet);
251
- const logger = this.logger;
252
- this.getBananaPublicBalanceFn = getBalancesFn(
253
- '🍌.public',
254
- this.bananaCoin.methods.balance_of_public,
255
- this.aliceAddress,
256
- logger,
257
- );
258
- this.getBananaPrivateBalanceFn = getBalancesFn(
259
- '🍌.private',
260
- this.bananaCoin.methods.balance_of_private,
261
- this.aliceAddress,
262
- logger,
263
- );
264
- return Promise.resolve();
265
- },
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,
266
255
  );
267
256
  }
268
257
 
269
- public async applyFPCSetupSnapshot() {
270
- await this.snapshotManager.snapshot(
271
- 'fpc_setup',
272
- async context => {
273
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
274
- expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
275
-
276
- const bananaCoin = this.bananaCoin;
277
- const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
278
- .send({ from: this.aliceAddress })
279
- .deployed();
280
-
281
- this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
282
-
283
- await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
284
-
285
- return {
286
- bananaFPCAddress: bananaFPC.address,
287
- feeJuiceAddress: feeJuiceContract.address,
288
- l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress,
289
- rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
290
- };
291
- },
292
- (data, context) => {
293
- const bananaFPC = FPCContract.at(data.bananaFPCAddress, this.wallet);
294
- this.bananaFPC = bananaFPC;
295
-
296
- this.getCoinbaseBalance = async () => {
297
- const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
298
- const gasL1 = getContract({
299
- address: data.l1FeeJuiceAddress.toString(),
300
- abi: TestERC20Abi,
301
- client: l1Client,
302
- });
303
- return await gasL1.read.balanceOf([this.coinbase.toString()]);
304
- };
305
-
306
- this.getCoinbaseSequencerRewards = async () => {
307
- return await this.rollupContract.getSequencerRewards(this.coinbase);
308
- };
309
-
310
- this.getProverFee = async (blockNumber: BlockNumber) => {
311
- const block = await this.aztecNode.getBlock(blockNumber);
312
-
313
- // @todo @lherskind As we deal with #13601
314
- // Right now the value is from `FeeLib.sol`
315
- const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
316
-
317
- // We round up
318
- const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
319
-
320
- const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
321
- const proverCost =
322
- mulDiv(
323
- mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await this.rollupContract.getEpochDuration()),
324
- 1n,
325
- await this.rollupContract.getManaTarget(),
326
- ) + (await this.rollupContract.getProvingCostPerMana());
327
-
328
- const price = await this.rollupContract.getFeeAssetPerEth();
329
-
330
- const mana = block!.header.totalManaUsed.toBigInt();
331
- return mulDiv(mana * proverCost, price, 10n ** 9n);
332
- };
333
- return Promise.resolve();
334
- },
335
- );
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
+ };
336
314
  }
337
315
 
338
- public async applySponsoredFPCSetupSnapshot() {
339
- await this.snapshotManager.snapshot(
340
- 'sponsored_fpc_setup',
341
- async context => {
342
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
343
- expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
344
-
345
- const sponsoredFPC = await setupSponsoredFPC(this.wallet);
346
- this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
347
-
348
- return {
349
- sponsoredFPCAddress: sponsoredFPC.address,
350
- };
351
- },
352
- data => {
353
- this.sponsoredFPC = SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
354
- return Promise.resolve();
355
- },
356
- );
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);
357
326
  }
358
327
 
359
328
  public async applyFundAliceWithBananas() {
360
- await this.snapshotManager.snapshot(
361
- 'fund_alice',
362
- async () => {
363
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
364
- await this.bananaCoin.methods
365
- .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
366
- .send({ from: this.aliceAddress })
367
- .wait();
368
- },
369
- () => Promise.resolve(),
370
- );
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();
371
336
  }
372
337
 
373
338
  public async applyFundAliceWithPrivateBananas() {
374
- await this.snapshotManager.snapshot(
375
- 'fund_alice_with_private_bananas',
376
- async () => {
377
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
378
- },
379
- () => Promise.resolve(),
380
- );
339
+ this.logger.info('Applying fund Alice with private bananas setup');
340
+
341
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
381
342
  }
382
343
  }
@@ -1,8 +1,9 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import type { L2Block } from '@aztec/aztec.js/block';
3
2
  import { Fr } from '@aztec/aztec.js/fields';
4
3
  import { BatchedBlob, Blob, getEthBlobEvaluationInputs, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
5
4
  import { EthAddress } from '@aztec/foundation/eth-address';
5
+ import { L2BlockNew } from '@aztec/stdlib/block';
6
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
6
7
 
7
8
  import { writeFile } from 'fs/promises';
8
9
 
@@ -14,7 +15,7 @@ const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA;
14
15
  */
15
16
  export async function writeJson(
16
17
  fileName: string,
17
- block: L2Block,
18
+ block: L2BlockNew,
18
19
  l1ToL2Content: Fr[],
19
20
  blobs: Blob[],
20
21
  batchedBlob: BatchedBlob,
@@ -32,6 +33,12 @@ export async function writeJson(
32
33
  return `0x${buffer.toString('hex').padStart(size, '0')}`;
33
34
  };
34
35
 
36
+ // Create a checkpoint header for this block
37
+ const checkpointHeader = CheckpointHeader.random({
38
+ slotNumber: block.slot,
39
+ timestamp: block.timestamp,
40
+ });
41
+
35
42
  const jsonObject = {
36
43
  populate: {
37
44
  l1ToL2Content: l1ToL2Content.map(value => asHex(value)),
@@ -50,24 +57,22 @@ export async function writeJson(
50
57
  checkpointNumber: block.number,
51
58
  body: `0x${block.body.toBuffer().toString('hex')}`,
52
59
  header: {
53
- lastArchiveRoot: asHex(block.header.lastArchive.root),
54
- blockHeadersHash: asHex(block.header.blockHeadersHash),
55
- contentCommitment: {
56
- blobsHash: asHex(block.header.contentCommitment.blobsHash),
57
- inHash: asHex(block.header.contentCommitment.inHash),
58
- outHash: asHex(block.header.contentCommitment.outHash),
59
- },
60
- slotNumber: Number(block.header.globalVariables.slotNumber),
61
- timestamp: Number(block.header.globalVariables.timestamp),
62
- coinbase: asHex(block.header.globalVariables.coinbase, 40),
63
- feeRecipient: asHex(block.header.globalVariables.feeRecipient),
60
+ lastArchiveRoot: asHex(checkpointHeader.lastArchiveRoot),
61
+ blockHeadersHash: asHex(checkpointHeader.blockHeadersHash),
62
+ blobsHash: asHex(checkpointHeader.blobsHash),
63
+ inHash: asHex(checkpointHeader.inHash),
64
+ outHash: asHex(checkpointHeader.epochOutHash),
65
+ slotNumber: Number(checkpointHeader.slotNumber),
66
+ timestamp: Number(checkpointHeader.timestamp),
67
+ coinbase: asHex(checkpointHeader.coinbase, 40),
68
+ feeRecipient: asHex(checkpointHeader.feeRecipient),
64
69
  gasFees: {
65
- feePerDaGas: Number(block.header.globalVariables.gasFees.feePerDaGas),
66
- feePerL2Gas: Number(block.header.globalVariables.gasFees.feePerL2Gas),
70
+ feePerDaGas: Number(checkpointHeader.gasFees.feePerDaGas),
71
+ feePerL2Gas: Number(checkpointHeader.gasFees.feePerL2Gas),
67
72
  },
68
- totalManaUsed: block.header.totalManaUsed.toNumber(),
73
+ totalManaUsed: checkpointHeader.totalManaUsed.toNumber(),
69
74
  },
70
- headerHash: asHex(block.getCheckpointHeader().hash()),
75
+ headerHash: asHex(checkpointHeader.hash()),
71
76
  numTxs: block.body.txEffects.length,
72
77
  },
73
78
  };
@@ -1,5 +1,5 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import { getAddressFromPrivateKey } from '@aztec/ethereum';
2
+ import { getAddressFromPrivateKey } from '@aztec/ethereum/account';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import type { EthPrivateKey } from '@aztec/node-keystore';
5
5