@aztec/end-to-end 0.0.1-commit.c7c42ec → 0.0.1-commit.d1f2d6c

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 (166) 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 +12 -13
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +118 -133
  7. package/dest/bench/client_flows/data_extractor.js +3 -1
  8. package/dest/bench/utils.d.ts +9 -8
  9. package/dest/bench/utils.d.ts.map +1 -1
  10. package/dest/bench/utils.js +17 -12
  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 +96 -112
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +15 -10
  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 +89 -70
  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 +1 -1
  21. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  22. package/dest/e2e_epochs/epochs_test.js +5 -2
  23. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  24. package/dest/e2e_fees/fees_test.d.ts +13 -13
  25. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  26. package/dest/e2e_fees/fees_test.js +123 -141
  27. package/dest/e2e_l1_publisher/write_json.d.ts +2 -2
  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_nested_contract/nested_contract_test.d.ts +6 -9
  31. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  32. package/dest/e2e_nested_contract/nested_contract_test.js +31 -39
  33. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  34. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  35. package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
  36. package/dest/e2e_p2p/p2p_network.d.ts +7 -6
  37. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  38. package/dest/e2e_p2p/p2p_network.js +109 -103
  39. package/dest/e2e_p2p/shared.d.ts +6 -6
  40. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  41. package/dest/e2e_p2p/shared.js +11 -18
  42. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  43. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  44. package/dest/e2e_token_contract/token_contract_test.js +89 -91
  45. package/dest/fixtures/e2e_prover_test.d.ts +8 -14
  46. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  47. package/dest/fixtures/e2e_prover_test.js +85 -94
  48. package/dest/fixtures/setup.d.ts +216 -0
  49. package/dest/fixtures/setup.d.ts.map +1 -0
  50. package/dest/fixtures/setup.js +684 -0
  51. package/dest/fixtures/token_utils.d.ts +1 -1
  52. package/dest/fixtures/token_utils.d.ts.map +1 -1
  53. package/dest/fixtures/token_utils.js +7 -4
  54. package/dest/fixtures/utils.d.ts +5 -194
  55. package/dest/fixtures/utils.d.ts.map +1 -1
  56. package/dest/fixtures/utils.js +4 -619
  57. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  58. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  59. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  60. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  61. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  62. package/dest/quality_of_service/prometheus_client.js +67 -0
  63. package/dest/shared/cross_chain_test_harness.d.ts +16 -6
  64. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  65. package/dest/shared/cross_chain_test_harness.js +13 -13
  66. package/dest/shared/gas_portal_test_harness.d.ts +11 -1
  67. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  68. package/dest/shared/gas_portal_test_harness.js +1 -1
  69. package/dest/shared/index.d.ts +2 -2
  70. package/dest/shared/index.d.ts.map +1 -1
  71. package/dest/shared/submit-transactions.d.ts +3 -3
  72. package/dest/shared/submit-transactions.d.ts.map +1 -1
  73. package/dest/shared/submit-transactions.js +9 -11
  74. package/dest/shared/uniswap_l1_l2.d.ts +3 -28
  75. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  76. package/dest/shared/uniswap_l1_l2.js +51 -33
  77. package/dest/simulators/lending_simulator.d.ts +5 -1
  78. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  79. package/dest/simulators/lending_simulator.js +2 -2
  80. package/dest/spartan/setup_test_wallets.d.ts +4 -3
  81. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  82. package/dest/spartan/setup_test_wallets.js +61 -34
  83. package/dest/spartan/tx_metrics.d.ts +17 -2
  84. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  85. package/dest/spartan/tx_metrics.js +183 -6
  86. package/dest/spartan/utils/bot.d.ts +27 -0
  87. package/dest/spartan/utils/bot.d.ts.map +1 -0
  88. package/dest/spartan/utils/bot.js +141 -0
  89. package/dest/spartan/utils/chaos.d.ts +79 -0
  90. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  91. package/dest/spartan/utils/chaos.js +142 -0
  92. package/dest/spartan/utils/clients.d.ts +39 -0
  93. package/dest/spartan/utils/clients.d.ts.map +1 -0
  94. package/dest/spartan/utils/clients.js +90 -0
  95. package/dest/spartan/utils/config.d.ts +36 -0
  96. package/dest/spartan/utils/config.d.ts.map +1 -0
  97. package/dest/spartan/utils/config.js +20 -0
  98. package/dest/spartan/utils/health.d.ts +63 -0
  99. package/dest/spartan/utils/health.d.ts.map +1 -0
  100. package/dest/spartan/utils/health.js +202 -0
  101. package/dest/spartan/utils/helm.d.ts +15 -0
  102. package/dest/spartan/utils/helm.d.ts.map +1 -0
  103. package/dest/spartan/utils/helm.js +47 -0
  104. package/dest/spartan/utils/index.d.ts +9 -0
  105. package/dest/spartan/utils/index.d.ts.map +1 -0
  106. package/dest/spartan/utils/index.js +18 -0
  107. package/dest/spartan/utils/k8s.d.ts +98 -0
  108. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  109. package/dest/spartan/utils/k8s.js +257 -0
  110. package/dest/spartan/utils/nodes.d.ts +31 -0
  111. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  112. package/dest/spartan/utils/nodes.js +290 -0
  113. package/dest/spartan/utils/scripts.d.ts +16 -0
  114. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  115. package/dest/spartan/utils/scripts.js +66 -0
  116. package/dest/spartan/utils.d.ts +2 -253
  117. package/dest/spartan/utils.d.ts.map +1 -1
  118. package/dest/spartan/utils.js +1 -892
  119. package/package.json +40 -39
  120. package/src/bench/client_flows/benchmark.ts +24 -2
  121. package/src/bench/client_flows/client_flows_benchmark.ts +138 -204
  122. package/src/bench/client_flows/data_extractor.ts +1 -1
  123. package/src/bench/utils.ts +20 -14
  124. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -142
  125. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +127 -116
  126. package/src/e2e_deploy_contract/deploy_test.ts +21 -14
  127. package/src/e2e_epochs/epochs_test.ts +31 -26
  128. package/src/e2e_fees/bridging_race.notest.ts +3 -9
  129. package/src/e2e_fees/fees_test.ts +172 -220
  130. package/src/e2e_l1_publisher/write_json.ts +21 -16
  131. package/src/e2e_nested_contract/nested_contract_test.ts +33 -56
  132. package/src/e2e_p2p/inactivity_slash_test.ts +5 -5
  133. package/src/e2e_p2p/p2p_network.ts +171 -168
  134. package/src/e2e_p2p/shared.ts +16 -25
  135. package/src/e2e_token_contract/token_contract_test.ts +103 -118
  136. package/src/fixtures/e2e_prover_test.ts +98 -133
  137. package/src/fixtures/setup.ts +1006 -0
  138. package/src/fixtures/token_utils.ts +6 -5
  139. package/src/fixtures/utils.ts +27 -907
  140. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  141. package/src/quality_of_service/prometheus_client.ts +113 -0
  142. package/src/shared/cross_chain_test_harness.ts +16 -36
  143. package/src/shared/gas_portal_test_harness.ts +1 -1
  144. package/src/shared/index.ts +1 -1
  145. package/src/shared/submit-transactions.ts +9 -15
  146. package/src/shared/uniswap_l1_l2.ts +58 -77
  147. package/src/simulators/lending_simulator.ts +2 -2
  148. package/src/spartan/setup_test_wallets.ts +79 -25
  149. package/src/spartan/tx_metrics.ts +129 -9
  150. package/src/spartan/utils/bot.ts +185 -0
  151. package/src/spartan/utils/chaos.ts +253 -0
  152. package/src/spartan/utils/clients.ts +100 -0
  153. package/src/spartan/utils/config.ts +26 -0
  154. package/src/spartan/utils/health.ts +255 -0
  155. package/src/spartan/utils/helm.ts +84 -0
  156. package/src/spartan/utils/index.ts +62 -0
  157. package/src/spartan/utils/k8s.ts +375 -0
  158. package/src/spartan/utils/nodes.ts +323 -0
  159. package/src/spartan/utils/scripts.ts +63 -0
  160. package/src/spartan/utils.ts +1 -1158
  161. package/dest/fixtures/snapshot_manager.d.ts +0 -93
  162. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  163. package/dest/fixtures/snapshot_manager.js +0 -493
  164. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  165. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  166. package/src/fixtures/snapshot_manager.ts +0 -651
@@ -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() {
@@ -144,9 +140,7 @@ export class FeesTest {
144
140
  const blockReward = await this.rollupContract.getCheckpointReward();
145
141
  const rewardConfig = await this.rollupContract.getRewardConfig();
146
142
 
147
- const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(
148
- EthAddress.fromString(rewardConfig.rewardDistributor),
149
- );
143
+ const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
150
144
 
151
145
  const toDistribute = balance > blockReward ? blockReward : balance;
152
146
  const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
@@ -158,10 +152,7 @@ export class FeesTest {
158
152
  async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
159
153
  const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
160
154
  const { claimSecret: secret, messageLeafIndex: index } = claim;
161
- await this.feeJuiceContract.methods
162
- .claim(recipient, claim.claimAmount, secret, index)
163
- .send({ from: minter })
164
- .wait();
155
+ await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
165
156
  }
166
157
 
167
158
  /** Alice mints bananaCoin tokens privately to the target address and redeems them. */
@@ -178,210 +169,171 @@ export class FeesTest {
178
169
  expect(balanceAfter).toEqual(balanceBefore + amount);
179
170
  }
180
171
 
181
- public async applyBaseSnapshots() {
182
- await this.applyInitialAccountsSnapshot();
183
- await this.applyPublicDeployAccountsSnapshot();
184
- await this.applySetupFeeJuiceSnapshot();
185
- await this.applyDeployBananaTokenSnapshot();
172
+ public async applyBaseSetup() {
173
+ await this.applyInitialAccounts();
174
+ await this.applyPublicDeployAccounts();
175
+ await this.applySetupFeeJuice();
176
+ await this.applyDeployBananaToken();
186
177
  }
187
178
 
188
- async applyInitialAccountsSnapshot() {
189
- await this.snapshotManager.snapshot(
190
- 'initial_accounts',
191
- deployAccounts(this.numberOfAccounts, this.logger),
192
- async ({ deployedAccounts }, { wallet, aztecNode, cheatCodes }) => {
193
- this.wallet = wallet;
194
- this.aztecNode = aztecNode;
195
- this.aztecNodeAdmin = aztecNode;
196
- this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) });
197
- this.cheatCodes = 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
- },
208
- );
179
+ async applyInitialAccounts() {
180
+ this.logger.info('Applying initial accounts setup');
181
+
182
+ const { deployedAccounts } = await deployAccounts(
183
+ this.numberOfAccounts,
184
+ this.logger,
185
+ )({
186
+ wallet: this.context.wallet,
187
+ initialFundedAccounts: this.context.initialFundedAccounts,
188
+ });
189
+
190
+ this.wallet = this.context.wallet;
191
+ this.aztecNode = this.context.aztecNodeService!;
192
+ this.aztecNodeAdmin = this.context.aztecNodeService!;
193
+ this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
194
+ this.cheatCodes = this.context.cheatCodes;
195
+ this.accounts = deployedAccounts.map(a => a.address);
196
+ this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
197
+ [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
198
+
199
+ // We set Alice as the FPC admin to avoid the need for deployment of another account.
200
+ this.fpcAdmin = this.aliceAddress;
201
+
202
+ const canonicalFeeJuice = await getCanonicalFeeJuice();
203
+ this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
209
204
  }
210
205
 
211
- async applyPublicDeployAccountsSnapshot() {
212
- await this.snapshotManager.snapshot('public_deploy_accounts', () =>
213
- ensureAccountContractsPublished(this.wallet, this.accounts),
214
- );
206
+ async applyPublicDeployAccounts() {
207
+ this.logger.info('Applying public deploy accounts setup');
208
+ await publicDeployAccounts(this.wallet, this.accounts);
215
209
  }
216
210
 
217
- async applySetupFeeJuiceSnapshot() {
218
- await this.snapshotManager.snapshot(
219
- 'setup_fee_juice',
220
- async () => {},
221
- async (_data, context) => {
222
- this.context = context;
223
-
224
- this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
225
-
226
- this.getGasBalanceFn = getBalancesFn(
227
- '⛽',
228
- this.feeJuiceContract.methods.balance_of_public,
229
- this.aliceAddress,
230
- this.logger,
231
- );
232
-
233
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
234
- aztecNode: context.aztecNode,
235
- aztecNodeAdmin: context.aztecNode,
236
- l1Client: context.deployL1ContractsValues.l1Client,
237
- wallet: this.wallet,
238
- logger: this.logger,
239
- });
240
- },
211
+ async applySetupFeeJuice() {
212
+ this.logger.info('Applying fee juice setup');
213
+
214
+ this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
215
+
216
+ this.getGasBalanceFn = getBalancesFn(
217
+ '⛽',
218
+ this.feeJuiceContract.methods.balance_of_public,
219
+ this.aliceAddress,
220
+ this.logger,
241
221
  );
222
+
223
+ this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
224
+ aztecNode: this.context.aztecNodeService!,
225
+ aztecNodeAdmin: this.context.aztecNodeService!,
226
+ l1Client: this.context.deployL1ContractsValues.l1Client,
227
+ wallet: this.wallet,
228
+ logger: this.logger,
229
+ });
242
230
  }
243
231
 
244
- async applyDeployBananaTokenSnapshot() {
245
- await this.snapshotManager.snapshot(
246
- 'deploy_banana_token',
247
- async () => {
248
- const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
249
- .send({ from: this.aliceAddress })
250
- .deployed();
251
- this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
252
- return { bananaCoinAddress: bananaCoin.address };
253
- },
254
- ({ bananaCoinAddress }) => {
255
- this.bananaCoin = BananaCoin.at(bananaCoinAddress, this.wallet);
256
- const logger = this.logger;
257
- this.getBananaPublicBalanceFn = getBalancesFn(
258
- '🍌.public',
259
- this.bananaCoin.methods.balance_of_public,
260
- this.aliceAddress,
261
- logger,
262
- );
263
- this.getBananaPrivateBalanceFn = getBalancesFn(
264
- '🍌.private',
265
- this.bananaCoin.methods.balance_of_private,
266
- this.aliceAddress,
267
- logger,
268
- );
269
- return Promise.resolve();
270
- },
232
+ async applyDeployBananaToken() {
233
+ this.logger.info('Applying deploy banana token setup');
234
+
235
+ const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
236
+ from: this.aliceAddress,
237
+ });
238
+ this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
239
+
240
+ this.bananaCoin = bananaCoin;
241
+ this.getBananaPublicBalanceFn = getBalancesFn(
242
+ '🍌.public',
243
+ this.bananaCoin.methods.balance_of_public,
244
+ this.aliceAddress,
245
+ this.logger,
246
+ );
247
+ this.getBananaPrivateBalanceFn = getBalancesFn(
248
+ '🍌.private',
249
+ this.bananaCoin.methods.balance_of_private,
250
+ this.aliceAddress,
251
+ this.logger,
271
252
  );
272
253
  }
273
254
 
274
- public async applyFPCSetupSnapshot() {
275
- await this.snapshotManager.snapshot(
276
- 'fpc_setup',
277
- async context => {
278
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
279
- expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
280
-
281
- const bananaCoin = this.bananaCoin;
282
- const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
283
- .send({ from: this.aliceAddress })
284
- .deployed();
285
-
286
- this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
287
-
288
- await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
289
-
290
- return {
291
- bananaFPCAddress: bananaFPC.address,
292
- feeJuiceAddress: feeJuiceContract.address,
293
- l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress,
294
- rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
295
- };
296
- },
297
- (data, context) => {
298
- const bananaFPC = FPCContract.at(data.bananaFPCAddress, this.wallet);
299
- this.bananaFPC = bananaFPC;
300
-
301
- this.getCoinbaseBalance = async () => {
302
- const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
303
- const gasL1 = getContract({
304
- address: data.l1FeeJuiceAddress.toString(),
305
- abi: TestERC20Abi,
306
- client: l1Client,
307
- });
308
- return await gasL1.read.balanceOf([this.coinbase.toString()]);
309
- };
310
-
311
- this.getCoinbaseSequencerRewards = async () => {
312
- return await this.rollupContract.getSequencerRewards(this.coinbase);
313
- };
314
-
315
- this.getProverFee = async (blockNumber: BlockNumber) => {
316
- const block = await this.aztecNode.getBlock(blockNumber);
317
-
318
- // @todo @lherskind As we deal with #13601
319
- // Right now the value is from `FeeLib.sol`
320
- const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
321
-
322
- // We round up
323
- const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
324
-
325
- const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
326
- const proverCost =
327
- mulDiv(
328
- mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await this.rollupContract.getEpochDuration()),
329
- 1n,
330
- await this.rollupContract.getManaTarget(),
331
- ) + (await this.rollupContract.getProvingCostPerMana());
332
-
333
- const price = await this.rollupContract.getFeeAssetPerEth();
334
-
335
- const mana = block!.header.totalManaUsed.toBigInt();
336
- return mulDiv(mana * proverCost, price, 10n ** 9n);
337
- };
338
- return Promise.resolve();
339
- },
340
- );
255
+ public async applyFPCSetup() {
256
+ this.logger.info('Applying FPC setup');
257
+
258
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
259
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
260
+
261
+ const bananaCoin = this.bananaCoin;
262
+ const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
263
+ from: this.aliceAddress,
264
+ });
265
+
266
+ this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
267
+
268
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
269
+
270
+ this.bananaFPC = bananaFPC;
271
+
272
+ const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
273
+
274
+ this.getCoinbaseBalance = async () => {
275
+ const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
276
+ const gasL1 = getContract({
277
+ address: l1FeeJuiceAddress.toString(),
278
+ abi: TestERC20Abi,
279
+ client: l1Client,
280
+ });
281
+ return await gasL1.read.balanceOf([this.coinbase.toString()]);
282
+ };
283
+
284
+ this.getCoinbaseSequencerRewards = async () => {
285
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
286
+ };
287
+
288
+ this.getProverFee = async (blockNumber: BlockNumber) => {
289
+ const block = await this.aztecNode.getBlock(blockNumber);
290
+
291
+ // @todo @lherskind As we deal with #13601
292
+ // Right now the value is from `FeeLib.sol`
293
+ const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
294
+
295
+ // We round up
296
+ const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
297
+
298
+ const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
299
+ const proverCost =
300
+ mulDiv(
301
+ mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
302
+ 1n,
303
+ await this.rollupContract.getManaTarget(),
304
+ ) + (await this.rollupContract.getProvingCostPerMana());
305
+
306
+ const price = await this.rollupContract.getEthPerFeeAsset();
307
+
308
+ const mana = block!.header.totalManaUsed.toBigInt();
309
+ return mulDiv(mana * proverCost, 10n ** 12n, price);
310
+ };
341
311
  }
342
312
 
343
- public async applySponsoredFPCSetupSnapshot() {
344
- await this.snapshotManager.snapshot(
345
- 'sponsored_fpc_setup',
346
- async context => {
347
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
348
- expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
349
-
350
- const sponsoredFPC = await setupSponsoredFPC(this.wallet);
351
- this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
352
-
353
- return {
354
- sponsoredFPCAddress: sponsoredFPC.address,
355
- };
356
- },
357
- data => {
358
- this.sponsoredFPC = SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
359
- return Promise.resolve();
360
- },
361
- );
313
+ public async applySponsoredFPCSetup() {
314
+ this.logger.info('Applying sponsored FPC setup');
315
+
316
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
317
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
318
+
319
+ const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
320
+ this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
321
+
322
+ this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
362
323
  }
363
324
 
364
325
  public async applyFundAliceWithBananas() {
365
- await this.snapshotManager.snapshot(
366
- 'fund_alice',
367
- async () => {
368
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
369
- await this.bananaCoin.methods
370
- .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
371
- .send({ from: this.aliceAddress })
372
- .wait();
373
- },
374
- () => Promise.resolve(),
375
- );
326
+ this.logger.info('Applying fund Alice with bananas setup');
327
+
328
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
329
+ await this.bananaCoin.methods
330
+ .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
331
+ .send({ from: this.aliceAddress });
376
332
  }
377
333
 
378
334
  public async applyFundAliceWithPrivateBananas() {
379
- await this.snapshotManager.snapshot(
380
- 'fund_alice_with_private_bananas',
381
- async () => {
382
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
383
- },
384
- () => Promise.resolve(),
385
- );
335
+ this.logger.info('Applying fund Alice with private bananas setup');
336
+
337
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
386
338
  }
387
339
  }
@@ -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 { L2Block } from '@aztec/stdlib/block';
6
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
6
7
 
7
8
  import { writeFile } from 'fs/promises';
8
9
 
@@ -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
  };