@aztec/end-to-end 3.0.3 → 4.0.0-devnet.1-patch.0

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