@aztec/end-to-end 0.0.1-commit.5476d83 → 0.0.1-commit.59e663cd

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