@aztec/end-to-end 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a

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 (240) 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 +13 -14
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +131 -138
  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 +31 -19
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +9 -8
  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 +107 -113
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +16 -11
  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 +5 -4
  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 +15 -7
  24. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  25. package/dest/e2e_epochs/epochs_test.js +87 -40
  26. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  27. package/dest/e2e_fees/fees_test.d.ts +14 -14
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +134 -145
  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 +30 -40
  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 +11 -9
  40. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  41. package/dest/e2e_p2p/p2p_network.js +133 -109
  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 +177 -0
  45. package/dest/e2e_p2p/shared.d.ts +20 -6
  46. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  47. package/dest/e2e_p2p/shared.js +42 -22
  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 +19 -10
  55. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  56. package/dest/e2e_token_contract/token_contract_test.js +100 -92
  57. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  58. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  59. package/dest/fixtures/authwit_proxy.js +30 -0
  60. package/dest/fixtures/e2e_prover_test.d.ts +11 -17
  61. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  62. package/dest/fixtures/e2e_prover_test.js +112 -128
  63. package/dest/fixtures/elu_monitor.d.ts +21 -0
  64. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  65. package/dest/fixtures/elu_monitor.js +102 -0
  66. package/dest/fixtures/fixtures.d.ts +6 -2
  67. package/dest/fixtures/fixtures.d.ts.map +1 -1
  68. package/dest/fixtures/fixtures.js +7 -1
  69. package/dest/fixtures/ha_setup.d.ts +71 -0
  70. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  71. package/dest/fixtures/ha_setup.js +116 -0
  72. package/dest/fixtures/index.d.ts +2 -1
  73. package/dest/fixtures/index.d.ts.map +1 -1
  74. package/dest/fixtures/index.js +1 -0
  75. package/dest/fixtures/setup.d.ts +234 -0
  76. package/dest/fixtures/setup.d.ts.map +1 -0
  77. package/dest/fixtures/setup.js +605 -0
  78. package/dest/fixtures/setup_p2p_test.d.ts +16 -9
  79. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  80. package/dest/fixtures/setup_p2p_test.js +40 -29
  81. package/dest/fixtures/token_utils.d.ts +2 -2
  82. package/dest/fixtures/token_utils.d.ts.map +1 -1
  83. package/dest/fixtures/token_utils.js +12 -8
  84. package/dest/fixtures/utils.d.ts +5 -194
  85. package/dest/fixtures/utils.d.ts.map +1 -1
  86. package/dest/fixtures/utils.js +4 -619
  87. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  88. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  89. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  90. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  91. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  92. package/dest/quality_of_service/prometheus_client.js +67 -0
  93. package/dest/shared/cross_chain_test_harness.d.ts +16 -6
  94. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  95. package/dest/shared/cross_chain_test_harness.js +26 -26
  96. package/dest/shared/gas_portal_test_harness.d.ts +11 -1
  97. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  98. package/dest/shared/gas_portal_test_harness.js +3 -3
  99. package/dest/shared/index.d.ts +3 -2
  100. package/dest/shared/index.d.ts.map +1 -1
  101. package/dest/shared/index.js +1 -0
  102. package/dest/shared/jest_setup.js +41 -1
  103. package/dest/shared/mock_state_view.d.ts +86 -0
  104. package/dest/shared/mock_state_view.d.ts.map +1 -0
  105. package/dest/shared/mock_state_view.js +186 -0
  106. package/dest/shared/submit-transactions.d.ts +4 -4
  107. package/dest/shared/submit-transactions.d.ts.map +1 -1
  108. package/dest/shared/submit-transactions.js +9 -11
  109. package/dest/shared/uniswap_l1_l2.d.ts +3 -28
  110. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  111. package/dest/shared/uniswap_l1_l2.js +57 -37
  112. package/dest/simulators/lending_simulator.d.ts +5 -1
  113. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  114. package/dest/simulators/lending_simulator.js +4 -4
  115. package/dest/simulators/token_simulator.d.ts +1 -1
  116. package/dest/simulators/token_simulator.d.ts.map +1 -1
  117. package/dest/simulators/token_simulator.js +3 -24
  118. package/dest/spartan/setup_test_wallets.d.ts +12 -4
  119. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  120. package/dest/spartan/setup_test_wallets.js +94 -36
  121. package/dest/spartan/tx_metrics.d.ts +51 -2
  122. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  123. package/dest/spartan/tx_metrics.js +334 -7
  124. package/dest/spartan/utils/bot.d.ts +28 -0
  125. package/dest/spartan/utils/bot.d.ts.map +1 -0
  126. package/dest/spartan/utils/bot.js +142 -0
  127. package/dest/spartan/utils/chaos.d.ts +79 -0
  128. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  129. package/dest/spartan/utils/chaos.js +142 -0
  130. package/dest/spartan/utils/clients.d.ts +39 -0
  131. package/dest/spartan/utils/clients.d.ts.map +1 -0
  132. package/dest/spartan/utils/clients.js +90 -0
  133. package/dest/spartan/utils/config.d.ts +42 -0
  134. package/dest/spartan/utils/config.d.ts.map +1 -0
  135. package/dest/spartan/utils/config.js +22 -0
  136. package/dest/spartan/utils/health.d.ts +63 -0
  137. package/dest/spartan/utils/health.d.ts.map +1 -0
  138. package/dest/spartan/utils/health.js +202 -0
  139. package/dest/spartan/utils/helm.d.ts +15 -0
  140. package/dest/spartan/utils/helm.d.ts.map +1 -0
  141. package/dest/spartan/utils/helm.js +47 -0
  142. package/dest/spartan/utils/index.d.ts +10 -0
  143. package/dest/spartan/utils/index.d.ts.map +1 -0
  144. package/dest/spartan/utils/index.js +20 -0
  145. package/dest/spartan/utils/k8s.d.ts +128 -0
  146. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  147. package/dest/spartan/utils/k8s.js +381 -0
  148. package/dest/spartan/utils/nodes.d.ts +40 -0
  149. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  150. package/dest/spartan/utils/nodes.js +461 -0
  151. package/dest/spartan/utils/scripts.d.ts +30 -0
  152. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  153. package/dest/spartan/utils/scripts.js +81 -0
  154. package/dest/spartan/utils.d.ts +2 -231
  155. package/dest/spartan/utils.d.ts.map +1 -1
  156. package/dest/spartan/utils.js +1 -853
  157. package/dest/test-wallet/test_wallet.d.ts +83 -0
  158. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  159. package/dest/test-wallet/test_wallet.js +214 -0
  160. package/dest/test-wallet/utils.d.ts +41 -0
  161. package/dest/test-wallet/utils.d.ts.map +1 -0
  162. package/dest/test-wallet/utils.js +71 -0
  163. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  164. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  165. package/dest/test-wallet/wallet_worker_script.js +48 -0
  166. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  167. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  168. package/dest/test-wallet/worker_wallet.js +151 -0
  169. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  170. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  171. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  172. package/package.json +47 -43
  173. package/src/bench/client_flows/benchmark.ts +24 -2
  174. package/src/bench/client_flows/client_flows_benchmark.ts +149 -211
  175. package/src/bench/client_flows/config.ts +9 -1
  176. package/src/bench/client_flows/data_extractor.ts +1 -1
  177. package/src/bench/utils.ts +36 -21
  178. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +120 -145
  179. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +127 -117
  180. package/src/e2e_deploy_contract/deploy_test.ts +22 -15
  181. package/src/e2e_epochs/epochs_test.ts +130 -94
  182. package/src/e2e_fees/bridging_race.notest.ts +4 -10
  183. package/src/e2e_fees/fees_test.ts +171 -227
  184. package/src/e2e_l1_publisher/write_json.ts +16 -16
  185. package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
  186. package/src/e2e_p2p/inactivity_slash_test.ts +3 -3
  187. package/src/e2e_p2p/p2p_network.ts +197 -167
  188. package/src/e2e_p2p/reqresp/utils.ts +235 -0
  189. package/src/e2e_p2p/shared.ts +72 -28
  190. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  191. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  192. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  193. package/src/e2e_token_contract/token_contract_test.ts +121 -119
  194. package/src/fixtures/authwit_proxy.ts +50 -0
  195. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  196. package/src/fixtures/e2e_prover_test.ts +133 -172
  197. package/src/fixtures/elu_monitor.ts +126 -0
  198. package/src/fixtures/fixtures.ts +11 -1
  199. package/src/fixtures/ha_setup.ts +186 -0
  200. package/src/fixtures/index.ts +1 -0
  201. package/src/fixtures/setup.ts +897 -0
  202. package/src/fixtures/setup_p2p_test.ts +40 -44
  203. package/src/fixtures/token_utils.ts +10 -6
  204. package/src/fixtures/utils.ts +27 -907
  205. package/src/guides/up_quick_start.sh +3 -3
  206. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  207. package/src/quality_of_service/prometheus_client.ts +113 -0
  208. package/src/shared/cross_chain_test_harness.ts +27 -43
  209. package/src/shared/gas_portal_test_harness.ts +2 -2
  210. package/src/shared/index.ts +2 -1
  211. package/src/shared/jest_setup.ts +51 -1
  212. package/src/shared/mock_state_view.ts +188 -0
  213. package/src/shared/submit-transactions.ts +11 -16
  214. package/src/shared/uniswap_l1_l2.ts +64 -83
  215. package/src/simulators/lending_simulator.ts +6 -4
  216. package/src/simulators/token_simulator.ts +6 -30
  217. package/src/spartan/setup_test_wallets.ts +128 -27
  218. package/src/spartan/tx_metrics.ts +256 -10
  219. package/src/spartan/utils/bot.ts +188 -0
  220. package/src/spartan/utils/chaos.ts +253 -0
  221. package/src/spartan/utils/clients.ts +100 -0
  222. package/src/spartan/utils/config.ts +28 -0
  223. package/src/spartan/utils/health.ts +255 -0
  224. package/src/spartan/utils/helm.ts +84 -0
  225. package/src/spartan/utils/index.ts +68 -0
  226. package/src/spartan/utils/k8s.ts +535 -0
  227. package/src/spartan/utils/nodes.ts +543 -0
  228. package/src/spartan/utils/scripts.ts +99 -0
  229. package/src/spartan/utils.ts +1 -1077
  230. package/src/test-wallet/test_wallet.ts +306 -0
  231. package/src/test-wallet/utils.ts +112 -0
  232. package/src/test-wallet/wallet_worker_script.ts +60 -0
  233. package/src/test-wallet/worker_wallet.ts +213 -0
  234. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  235. package/dest/fixtures/snapshot_manager.d.ts +0 -93
  236. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  237. package/dest/fixtures/snapshot_manager.js +0 -493
  238. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  239. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  240. package/src/fixtures/snapshot_manager.ts +0 -651
@@ -1,7 +1,7 @@
1
1
  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
- import { CheatCodes } from '@aztec/aztec/testing';
4
+ import { CheatCodes, getTokenAllowedSetupFunctions } from '@aztec/aztec/testing';
5
5
  import { createExtendedL1Client } from '@aztec/ethereum/client';
6
6
  import { RollupContract } from '@aztec/ethereum/contracts';
7
7
  import type { DeployAztecL1ContractsArgs } from '@aztec/ethereum/deploy-aztec-l1-contracts';
@@ -20,31 +20,25 @@ 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
22
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
23
- import { TestWallet } from '@aztec/test-wallet/server';
24
23
 
25
24
  import { getContract } from 'viem';
26
25
 
27
26
  import { MNEMONIC } from '../fixtures/fixtures.js';
28
27
  import {
29
- type ISnapshotManager,
30
- type SubsystemsContext,
31
- createSnapshotManager,
28
+ type EndToEndContext,
29
+ type SetupOptions,
32
30
  deployAccounts,
33
- } from '../fixtures/snapshot_manager.js';
31
+ publicDeployAccounts,
32
+ setup,
33
+ teardown,
34
+ } from '../fixtures/setup.js';
34
35
  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';
36
+ import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
42
37
  import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
43
-
44
- const { E2E_DATA_PATH: dataPath } = process.env;
38
+ import { TestWallet } from '../test-wallet/test_wallet.js';
45
39
 
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,26 +100,32 @@ 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();
120
-
121
- this.rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
122
- this.chainMonitor = new ChainMonitor(this.rollupContract, context.dateProvider, this.logger, 200).start();
106
+ this.logger.verbose('Setting up fresh context...');
107
+ // Token allowlist entries are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
108
+ const tokenAllowList = await getTokenAllowedSetupFunctions();
109
+ this.context = await setup(0, {
110
+ startProverNode: true,
111
+ ...this.setupOptions,
112
+ fundSponsoredFPC: true,
113
+ skipAccountDeployment: true,
114
+ l1ContractsArgs: { ...this.setupOptions },
115
+ txPublicSetupAllowListExtend: [...(this.setupOptions.txPublicSetupAllowListExtend ?? []), ...tokenAllowList],
116
+ });
117
+
118
+ this.rollupContract = RollupContract.getFromConfig(this.context.config);
119
+ this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider, this.logger, 200).start();
120
+
121
+ await this.applyBaseSetup();
123
122
 
124
123
  return this;
125
124
  }
126
125
 
127
126
  async teardown() {
128
127
  await this.chainMonitor.stop();
129
- await this.snapshotManager.teardown();
128
+ await teardown(this.context);
130
129
  }
131
130
 
132
131
  setIsMarkingAsProven(b: boolean) {
@@ -144,9 +143,7 @@ export class FeesTest {
144
143
  const blockReward = await this.rollupContract.getCheckpointReward();
145
144
  const rewardConfig = await this.rollupContract.getRewardConfig();
146
145
 
147
- const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(
148
- EthAddress.fromString(rewardConfig.rewardDistributor),
149
- );
146
+ const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
150
147
 
151
148
  const toDistribute = balance > blockReward ? blockReward : balance;
152
149
  const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
@@ -158,230 +155,177 @@ export class FeesTest {
158
155
  async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
159
156
  const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
160
157
  const { claimSecret: secret, messageLeafIndex: index } = claim;
161
- await this.feeJuiceContract.methods
162
- .claim(recipient, claim.claimAmount, secret, index)
163
- .send({ from: minter })
164
- .wait();
158
+ await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
165
159
  }
166
160
 
167
161
  /** Alice mints bananaCoin tokens privately to the target address and redeems them. */
168
162
  async mintPrivateBananas(amount: bigint, address: AztecAddress) {
169
- const balanceBefore = await this.bananaCoin.methods
163
+ const { result: balanceBefore } = await this.bananaCoin.methods
170
164
  .balance_of_private(address)
171
- .simulate({ from: this.aliceAddress });
165
+ .simulate({ from: address });
172
166
 
173
167
  await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
174
168
 
175
- const balanceAfter = await this.bananaCoin.methods
169
+ const { result: balanceAfter } = await this.bananaCoin.methods
176
170
  .balance_of_private(address)
177
- .simulate({ from: this.aliceAddress });
171
+ .simulate({ from: address });
178
172
  expect(balanceAfter).toEqual(balanceBefore + amount);
179
173
  }
180
174
 
181
- public async applyBaseSnapshots() {
182
- await this.applyInitialAccountsSnapshot();
183
- await this.applyPublicDeployAccountsSnapshot();
184
- await this.applySetupFeeJuiceSnapshot();
185
- await this.applyDeployBananaTokenSnapshot();
175
+ public async applyBaseSetup() {
176
+ await this.applyInitialAccounts();
177
+ await this.applyPublicDeployAccounts();
178
+ await this.applySetupFeeJuice();
179
+ await this.applyDeployBananaToken();
186
180
  }
187
181
 
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
- );
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);
209
207
  }
210
208
 
211
- async applyPublicDeployAccountsSnapshot() {
212
- await this.snapshotManager.snapshot('public_deploy_accounts', () =>
213
- ensureAccountContractsPublished(this.wallet, this.accounts),
214
- );
209
+ async applyPublicDeployAccounts() {
210
+ this.logger.info('Applying public deploy accounts setup');
211
+ await publicDeployAccounts(this.wallet, this.accounts);
215
212
  }
216
213
 
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
- },
241
- );
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('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
220
+
221
+ this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
222
+ aztecNode: this.context.aztecNodeService,
223
+ aztecNodeAdmin: this.context.aztecNodeService,
224
+ l1Client: this.context.deployL1ContractsValues.l1Client,
225
+ wallet: this.wallet,
226
+ logger: this.logger,
227
+ });
242
228
  }
243
229
 
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
- },
230
+ async applyDeployBananaToken() {
231
+ this.logger.info('Applying deploy banana token setup');
232
+
233
+ const { contract: bananaCoin } = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
234
+ from: this.aliceAddress,
235
+ });
236
+ this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
237
+
238
+ this.bananaCoin = bananaCoin;
239
+ this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, this.logger);
240
+ this.getBananaPrivateBalanceFn = getBalancesFn(
241
+ '🍌.private',
242
+ this.bananaCoin.methods.balance_of_private,
243
+ this.logger,
271
244
  );
272
245
  }
273
246
 
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
- );
247
+ public async applyFPCSetup() {
248
+ this.logger.info('Applying FPC setup');
249
+
250
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
251
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
252
+
253
+ const bananaCoin = this.bananaCoin;
254
+ const { contract: bananaFPC } = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
255
+ from: this.aliceAddress,
256
+ });
257
+
258
+ this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
259
+
260
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
261
+
262
+ this.bananaFPC = bananaFPC;
263
+
264
+ const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
265
+
266
+ this.getCoinbaseBalance = async () => {
267
+ const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
268
+ const gasL1 = getContract({
269
+ address: l1FeeJuiceAddress.toString(),
270
+ abi: TestERC20Abi,
271
+ client: l1Client,
272
+ });
273
+ return await gasL1.read.balanceOf([this.coinbase.toString()]);
274
+ };
275
+
276
+ this.getCoinbaseSequencerRewards = async () => {
277
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
278
+ };
279
+
280
+ this.getProverFee = async (blockNumber: BlockNumber) => {
281
+ const block = await this.aztecNode.getBlock(blockNumber);
282
+
283
+ // @todo @lherskind As we deal with #13601
284
+ // Right now the value is from `FeeLib.sol`
285
+ const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
286
+
287
+ // We round up
288
+ const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
289
+
290
+ const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
291
+ const proverCost =
292
+ mulDiv(
293
+ mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
294
+ 1n,
295
+ await this.rollupContract.getManaTarget(),
296
+ ) + (await this.rollupContract.getProvingCostPerMana());
297
+
298
+ const price = await this.rollupContract.getEthPerFeeAsset();
299
+
300
+ const mana = block!.header.totalManaUsed.toBigInt();
301
+ return mulDiv(mana * proverCost, 10n ** 12n, price);
302
+ };
341
303
  }
342
304
 
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
- );
305
+ public async applySponsoredFPCSetup() {
306
+ this.logger.info('Applying sponsored FPC setup');
307
+
308
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
309
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
310
+
311
+ const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
312
+ this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
313
+
314
+ this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
362
315
  }
363
316
 
364
317
  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
- );
318
+ this.logger.info('Applying fund Alice with bananas setup');
319
+
320
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
321
+ await this.bananaCoin.methods
322
+ .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
323
+ .send({ from: this.aliceAddress });
376
324
  }
377
325
 
378
326
  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
- );
327
+ this.logger.info('Applying fund Alice with private bananas setup');
328
+
329
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
386
330
  }
387
331
  }
@@ -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
  };