@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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 (181) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +61 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +336 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +77 -0
  13. package/dest/bench/utils.d.ts +12 -38
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +26 -66
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +20 -25
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +51 -70
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +13 -19
  25. package/dest/e2e_epochs/epochs_test.d.ts +65 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +233 -49
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +63 -0
  31. package/dest/e2e_fees/fees_test.d.ts +27 -12
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +106 -109
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +58 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +10 -7
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +276 -23
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +188 -133
  49. package/dest/e2e_p2p/shared.d.ts +43 -7
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +164 -19
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +50 -26
  55. package/dest/fixtures/e2e_prover_test.d.ts +61 -0
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +108 -112
  58. package/dest/fixtures/fixtures.d.ts +6 -8
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +5 -5
  61. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +3 -15
  64. package/dest/fixtures/get_bb_config.d.ts +2 -2
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/index.d.ts +1 -1
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  69. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  70. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  71. package/dest/fixtures/logging.d.ts +1 -1
  72. package/dest/fixtures/setup_p2p_test.d.ts +15 -14
  73. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  74. package/dest/fixtures/setup_p2p_test.js +82 -22
  75. package/dest/fixtures/snapshot_manager.d.ts +20 -14
  76. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  77. package/dest/fixtures/snapshot_manager.js +154 -140
  78. package/dest/fixtures/token_utils.d.ts +10 -4
  79. package/dest/fixtures/token_utils.d.ts.map +1 -1
  80. package/dest/fixtures/token_utils.js +28 -12
  81. package/dest/fixtures/utils.d.ts +95 -54
  82. package/dest/fixtures/utils.d.ts.map +1 -1
  83. package/dest/fixtures/utils.js +456 -389
  84. package/dest/fixtures/web3signer.d.ts +5 -0
  85. package/dest/fixtures/web3signer.d.ts.map +1 -0
  86. package/dest/fixtures/web3signer.js +53 -0
  87. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  88. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  89. package/dest/fixtures/with_telemetry_utils.js +2 -2
  90. package/dest/index.d.ts +1 -1
  91. package/dest/quality_of_service/alert_checker.d.ts +2 -2
  92. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  93. package/dest/shared/cross_chain_test_harness.d.ts +42 -35
  94. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  95. package/dest/shared/cross_chain_test_harness.js +104 -50
  96. package/dest/shared/gas_portal_test_harness.d.ts +29 -31
  97. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  98. package/dest/shared/gas_portal_test_harness.js +51 -30
  99. package/dest/shared/index.d.ts +1 -1
  100. package/dest/shared/jest_setup.d.ts +1 -1
  101. package/dest/shared/jest_setup.js +1 -1
  102. package/dest/shared/submit-transactions.d.ts +6 -4
  103. package/dest/shared/submit-transactions.d.ts.map +1 -1
  104. package/dest/shared/submit-transactions.js +8 -7
  105. package/dest/shared/uniswap_l1_l2.d.ts +16 -13
  106. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  107. package/dest/shared/uniswap_l1_l2.js +149 -117
  108. package/dest/simulators/index.d.ts +1 -1
  109. package/dest/simulators/lending_simulator.d.ts +7 -11
  110. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  111. package/dest/simulators/lending_simulator.js +16 -17
  112. package/dest/simulators/token_simulator.d.ts +6 -3
  113. package/dest/simulators/token_simulator.d.ts.map +1 -1
  114. package/dest/simulators/token_simulator.js +16 -13
  115. package/dest/spartan/setup_test_wallets.d.ts +26 -11
  116. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  117. package/dest/spartan/setup_test_wallets.js +202 -58
  118. package/dest/spartan/tx_metrics.d.ts +39 -0
  119. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  120. package/dest/spartan/tx_metrics.js +95 -0
  121. package/dest/spartan/utils.d.ts +129 -313
  122. package/dest/spartan/utils.d.ts.map +1 -1
  123. package/dest/spartan/utils.js +559 -151
  124. package/package.json +65 -58
  125. package/src/bench/client_flows/benchmark.ts +341 -0
  126. package/src/bench/client_flows/client_flows_benchmark.ts +450 -0
  127. package/src/bench/client_flows/config.ts +61 -0
  128. package/src/bench/client_flows/data_extractor.ts +89 -0
  129. package/src/bench/utils.ts +22 -76
  130. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
  131. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +70 -107
  132. package/src/e2e_deploy_contract/deploy_test.ts +24 -39
  133. package/src/e2e_epochs/epochs_test.ts +299 -65
  134. package/src/e2e_fees/bridging_race.notest.ts +80 -0
  135. package/src/e2e_fees/fees_test.ts +151 -141
  136. package/src/e2e_l1_publisher/write_json.ts +77 -0
  137. package/src/e2e_multi_validator/utils.ts +258 -0
  138. package/src/e2e_nested_contract/nested_contract_test.ts +29 -19
  139. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  140. package/src/e2e_p2p/p2p_network.ts +274 -171
  141. package/src/e2e_p2p/shared.ts +251 -29
  142. package/src/e2e_token_contract/token_contract_test.ts +43 -39
  143. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  144. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +113 -160
  145. package/src/fixtures/fixtures.ts +5 -7
  146. package/src/fixtures/get_acvm_config.ts +4 -12
  147. package/src/fixtures/get_bb_config.ts +18 -13
  148. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  149. package/src/fixtures/setup_p2p_test.ts +127 -39
  150. package/src/fixtures/snapshot_manager.ts +196 -162
  151. package/src/fixtures/token_utils.ts +32 -15
  152. package/src/fixtures/utils.ts +562 -475
  153. package/src/fixtures/web3signer.ts +63 -0
  154. package/src/fixtures/with_telemetry_utils.ts +2 -2
  155. package/src/guides/up_quick_start.sh +7 -15
  156. package/src/quality_of_service/alert_checker.ts +1 -1
  157. package/src/shared/cross_chain_test_harness.ts +112 -80
  158. package/src/shared/gas_portal_test_harness.ts +59 -50
  159. package/src/shared/jest_setup.ts +1 -1
  160. package/src/shared/submit-transactions.ts +12 -8
  161. package/src/shared/uniswap_l1_l2.ts +187 -192
  162. package/src/simulators/lending_simulator.ts +15 -16
  163. package/src/simulators/token_simulator.ts +21 -13
  164. package/src/spartan/DEVELOP.md +128 -0
  165. package/src/spartan/setup_test_wallets.ts +252 -93
  166. package/src/spartan/tx_metrics.ts +130 -0
  167. package/src/spartan/utils.ts +641 -146
  168. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  169. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  170. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  171. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  172. package/dest/fixtures/setup_l1_contracts.js +0 -17
  173. package/dest/sample-dapp/connect.js +0 -12
  174. package/dest/sample-dapp/contracts.js +0 -10
  175. package/dest/sample-dapp/deploy.js +0 -35
  176. package/dest/sample-dapp/index.js +0 -98
  177. package/src/fixtures/setup_l1_contracts.ts +0 -27
  178. package/src/sample-dapp/connect.mjs +0 -16
  179. package/src/sample-dapp/contracts.mjs +0 -14
  180. package/src/sample-dapp/deploy.mjs +0 -40
  181. package/src/sample-dapp/index.mjs +0 -128
@@ -1,28 +1,26 @@
1
- import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import {
3
- type AccountWallet,
4
- type AztecAddress,
5
- type AztecNode,
6
- ChainMonitor,
7
- CheatCodes,
8
- type Logger,
9
- type PXE,
10
- createLogger,
11
- sleep,
12
- } from '@aztec/aztec.js';
13
- import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
14
- import { type DeployL1ContractsArgs, RollupContract, createL1Clients } from '@aztec/ethereum';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
+ import type { AztecNode } from '@aztec/aztec.js/node';
4
+ import { CheatCodes } from '@aztec/aztec/testing';
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';
8
+ import { ChainMonitor } from '@aztec/ethereum/test';
9
+ import { BlockNumber } from '@aztec/foundation/branded-types';
15
10
  import { EthAddress } from '@aztec/foundation/eth-address';
16
- import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
11
+ import { sleep } from '@aztec/foundation/sleep';
12
+ import { TestERC20Abi } from '@aztec/l1-artifacts';
17
13
  import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
18
- import { CounterContract } from '@aztec/noir-contracts.js/Counter';
19
14
  import { FPCContract } from '@aztec/noir-contracts.js/FPC';
20
15
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
16
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
21
17
  import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
18
+ import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
22
19
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
23
20
  import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
24
- import { computePartialAddress } from '@aztec/stdlib/contract';
25
21
  import { GasSettings } from '@aztec/stdlib/gas';
22
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
23
+ import { TestWallet } from '@aztec/test-wallet/server';
26
24
 
27
25
  import { getContract } from 'viem';
28
26
 
@@ -37,9 +35,9 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
37
35
  import {
38
36
  type BalancesFn,
39
37
  type SetupOptions,
40
- ensureAccountsPubliclyDeployed,
38
+ ensureAccountContractsPublished,
41
39
  getBalancesFn,
42
- setupCanonicalFeeJuice,
40
+ setupSponsoredFPC,
43
41
  } from '../fixtures/utils.js';
44
42
  import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
45
43
 
@@ -51,21 +49,21 @@ const { E2E_DATA_PATH: dataPath } = process.env;
51
49
  * PublicDeployAccounts: Deploys the accounts publicly.
52
50
  * DeployFeeJuice: Deploys the Fee Juice contract.
53
51
  * FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
52
+ * SponsoredFPCSetup: Deploys Sponsored FPC contract, and bridges gas from L1.
54
53
  * FundAlice: Mints private and public bananas to Alice.
55
54
  * SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
56
55
  */
57
56
  export class FeesTest {
58
57
  private snapshotManager: ISnapshotManager;
59
- private wallets: AccountWallet[] = [];
58
+ private accounts: AztecAddress[] = [];
60
59
 
61
60
  public logger: Logger;
62
- public pxe!: PXE;
63
61
  public aztecNode!: AztecNode;
62
+ public aztecNodeAdmin!: AztecNodeAdmin;
64
63
  public cheatCodes!: CheatCodes;
65
64
 
66
- public aliceWallet!: AccountWallet;
65
+ public wallet!: TestWallet;
67
66
  public aliceAddress!: AztecAddress;
68
- public bobWallet!: AccountWallet;
69
67
  public bobAddress!: AztecAddress;
70
68
  public sequencerAddress!: AztecAddress;
71
69
  public coinbase!: EthAddress;
@@ -74,9 +72,12 @@ export class FeesTest {
74
72
 
75
73
  public gasSettings!: GasSettings;
76
74
 
75
+ public rollupContract!: RollupContract;
76
+
77
77
  public feeJuiceContract!: FeeJuiceContract;
78
78
  public bananaCoin!: BananaCoin;
79
79
  public bananaFPC!: FPCContract;
80
+ public sponsoredFPC!: SponsoredFPCContract;
80
81
  public counterContract!: CounterContract;
81
82
  public subscriptionContract!: AppSubscriptionContract;
82
83
  public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
@@ -89,7 +90,7 @@ export class FeesTest {
89
90
  public getGasBalanceFn!: BalancesFn;
90
91
  public getBananaPublicBalanceFn!: BalancesFn;
91
92
  public getBananaPrivateBalanceFn!: BalancesFn;
92
- public getProverFee!: (blockNumber: number) => Promise<bigint>;
93
+ public getProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
93
94
 
94
95
  public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
95
96
  public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
@@ -98,11 +99,13 @@ export class FeesTest {
98
99
  constructor(
99
100
  testName: string,
100
101
  private numberOfAccounts = 3,
101
- setupOptions: Partial<SetupOptions & DeployL1ContractsArgs> = {},
102
+ setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
102
103
  ) {
103
104
  if (!numberOfAccounts) {
104
105
  throw new Error('There must be at least 1 initial account.');
105
106
  }
107
+ setupOptions.coinbase ??= EthAddress.random();
108
+ this.coinbase = setupOptions.coinbase!;
106
109
  this.logger = createLogger(`e2e:e2e_fees:${testName}`);
107
110
  this.snapshotManager = createSnapshotManager(
108
111
  `e2e_fees/${testName}-${numberOfAccounts}`,
@@ -114,16 +117,15 @@ export class FeesTest {
114
117
 
115
118
  async setup() {
116
119
  const context = await this.snapshotManager.setup();
117
- await context.aztecNode.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });
118
120
 
119
- const rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
120
- this.chainMonitor = new ChainMonitor(rollupContract, this.logger, 200).start();
121
+ this.rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
122
+ this.chainMonitor = new ChainMonitor(this.rollupContract, context.dateProvider, this.logger, 200).start();
121
123
 
122
124
  return this;
123
125
  }
124
126
 
125
127
  async teardown() {
126
- this.chainMonitor.stop();
128
+ await this.chainMonitor.stop();
127
129
  await this.snapshotManager.teardown();
128
130
  }
129
131
 
@@ -138,19 +140,41 @@ export class FeesTest {
138
140
  }
139
141
  }
140
142
 
141
- async mintAndBridgeFeeJuice(address: AztecAddress, amount: bigint) {
142
- const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, address);
143
+ async getBlockRewards() {
144
+ const blockReward = await this.rollupContract.getCheckpointReward();
145
+ const rewardConfig = await this.rollupContract.getRewardConfig();
146
+
147
+ const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(
148
+ EthAddress.fromString(rewardConfig.rewardDistributor),
149
+ );
150
+
151
+ const toDistribute = balance > blockReward ? blockReward : balance;
152
+ const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
153
+ const proverBlockRewards = toDistribute - sequencerBlockRewards;
154
+
155
+ return { sequencerBlockRewards, proverBlockRewards };
156
+ }
157
+
158
+ async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
159
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
143
160
  const { claimSecret: secret, messageLeafIndex: index } = claim;
144
- await this.feeJuiceContract.methods.claim(address, amount, secret, index).send().wait();
161
+ await this.feeJuiceContract.methods
162
+ .claim(recipient, claim.claimAmount, secret, index)
163
+ .send({ from: minter })
164
+ .wait();
145
165
  }
146
166
 
147
167
  /** Alice mints bananaCoin tokens privately to the target address and redeems them. */
148
168
  async mintPrivateBananas(amount: bigint, address: AztecAddress) {
149
- const balanceBefore = await this.bananaCoin.methods.balance_of_private(address).simulate();
169
+ const balanceBefore = await this.bananaCoin.methods
170
+ .balance_of_private(address)
171
+ .simulate({ from: this.aliceAddress });
150
172
 
151
- await mintTokensToPrivate(this.bananaCoin, this.aliceWallet, address, amount);
173
+ await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
152
174
 
153
- const balanceAfter = await this.bananaCoin.methods.balance_of_private(address).simulate();
175
+ const balanceAfter = await this.bananaCoin.methods
176
+ .balance_of_private(address)
177
+ .simulate({ from: this.aliceAddress });
154
178
  expect(balanceAfter).toEqual(balanceBefore + amount);
155
179
  }
156
180
 
@@ -165,66 +189,52 @@ export class FeesTest {
165
189
  await this.snapshotManager.snapshot(
166
190
  'initial_accounts',
167
191
  deployAccounts(this.numberOfAccounts, this.logger),
168
- async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig }) => {
169
- this.pxe = pxe;
192
+ async ({ deployedAccounts }, { wallet, aztecNode, cheatCodes }) => {
193
+ this.wallet = wallet;
170
194
  this.aztecNode = aztecNode;
195
+ this.aztecNodeAdmin = aztecNode;
171
196
  this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) });
172
- this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
173
- this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
174
- this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
175
- [this.aliceWallet, this.bobWallet] = this.wallets.slice(0, 2);
176
- [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.wallets.map(w => w.getAddress());
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);
177
201
 
178
202
  // We set Alice as the FPC admin to avoid the need for deployment of another account.
179
203
  this.fpcAdmin = this.aliceAddress;
180
204
 
181
205
  const canonicalFeeJuice = await getCanonicalFeeJuice();
182
- this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.aliceWallet);
183
- if (this.numberOfAccounts > 1) {
184
- const bobInstance = (await this.bobWallet.getContractMetadata(this.bobAddress)).contractInstance;
185
- await this.aliceWallet.registerAccount(deployedAccounts[1].secret, await computePartialAddress(bobInstance!));
186
- }
187
- this.coinbase = EthAddress.random();
188
-
189
- const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, MNEMONIC);
190
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
191
- aztecNode: aztecNode,
192
- pxeService: pxe,
193
- publicClient: publicClient,
194
- walletClient: walletClient,
195
- wallet: this.aliceWallet,
196
- logger: this.logger,
197
- });
206
+ this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
198
207
  },
199
208
  );
200
209
  }
201
210
 
202
211
  async applyPublicDeployAccountsSnapshot() {
203
212
  await this.snapshotManager.snapshot('public_deploy_accounts', () =>
204
- ensureAccountsPubliclyDeployed(this.aliceWallet, this.wallets),
213
+ ensureAccountContractsPublished(this.wallet, this.accounts),
205
214
  );
206
215
  }
207
216
 
208
217
  async applySetupFeeJuiceSnapshot() {
209
218
  await this.snapshotManager.snapshot(
210
219
  'setup_fee_juice',
211
- async context => {
212
- await setupCanonicalFeeJuice(context.pxe);
213
- },
220
+ async () => {},
214
221
  async (_data, context) => {
215
222
  this.context = context;
216
223
 
217
- this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.aliceWallet);
224
+ this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
218
225
 
219
- this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
226
+ this.getGasBalanceFn = getBalancesFn(
227
+ '⛽',
228
+ this.feeJuiceContract.methods.balance_of_public,
229
+ this.aliceAddress,
230
+ this.logger,
231
+ );
220
232
 
221
- const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
222
233
  this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
223
234
  aztecNode: context.aztecNode,
224
- pxeService: context.pxe,
225
- publicClient: publicClient,
226
- walletClient: walletClient,
227
- wallet: this.aliceWallet,
235
+ aztecNodeAdmin: context.aztecNode,
236
+ l1Client: context.deployL1ContractsValues.l1Client,
237
+ wallet: this.wallet,
228
238
  logger: this.logger,
229
239
  });
230
240
  },
@@ -235,14 +245,28 @@ export class FeesTest {
235
245
  await this.snapshotManager.snapshot(
236
246
  'deploy_banana_token',
237
247
  async () => {
238
- const bananaCoin = await BananaCoin.deploy(this.aliceWallet, this.aliceAddress, 'BC', 'BC', 18n)
239
- .send()
248
+ const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
249
+ .send({ from: this.aliceAddress })
240
250
  .deployed();
241
251
  this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
242
252
  return { bananaCoinAddress: bananaCoin.address };
243
253
  },
244
- async ({ bananaCoinAddress }) => {
245
- this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.aliceWallet);
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();
246
270
  },
247
271
  );
248
272
  }
@@ -252,16 +276,16 @@ export class FeesTest {
252
276
  'fpc_setup',
253
277
  async context => {
254
278
  const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
255
- expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPubliclyDeployed).toBe(true);
279
+ expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
256
280
 
257
281
  const bananaCoin = this.bananaCoin;
258
- const bananaFPC = await FPCContract.deploy(this.aliceWallet, bananaCoin.address, this.fpcAdmin)
259
- .send()
282
+ const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
283
+ .send({ from: this.aliceAddress })
260
284
  .deployed();
261
285
 
262
286
  this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
263
287
 
264
- await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(FEE_FUNDING_FOR_TESTER_ACCOUNT, bananaFPC.address);
288
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
265
289
 
266
290
  return {
267
291
  bananaFPCAddress: bananaFPC.address,
@@ -270,53 +294,69 @@ export class FeesTest {
270
294
  rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
271
295
  };
272
296
  },
273
- async (data, context) => {
274
- const bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.aliceWallet);
297
+ (data, context) => {
298
+ const bananaFPC = FPCContract.at(data.bananaFPCAddress, this.wallet);
275
299
  this.bananaFPC = bananaFPC;
276
300
 
277
- const logger = this.logger;
278
- this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, logger);
279
- this.getBananaPrivateBalanceFn = getBalancesFn(
280
- '🍌.private',
281
- this.bananaCoin.methods.balance_of_private,
282
- logger,
283
- );
284
-
285
301
  this.getCoinbaseBalance = async () => {
286
- const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
302
+ const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
287
303
  const gasL1 = getContract({
288
304
  address: data.l1FeeJuiceAddress.toString(),
289
305
  abi: TestERC20Abi,
290
- client: walletClient,
306
+ client: l1Client,
291
307
  });
292
308
  return await gasL1.read.balanceOf([this.coinbase.toString()]);
293
309
  };
294
310
 
295
311
  this.getCoinbaseSequencerRewards = async () => {
296
- const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
297
- const rollup = getContract({
298
- address: data.rollupAddress.toString(),
299
- abi: RollupAbi,
300
- client: walletClient,
301
- });
302
-
303
- return await rollup.read.getSequencerRewards([this.coinbase.toString()]);
312
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
304
313
  };
305
314
 
306
- this.getProverFee = async (blockNumber: number) => {
307
- const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
308
- const rollup = getContract({
309
- address: data.rollupAddress.toString(),
310
- abi: RollupAbi,
311
- client: walletClient,
312
- });
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;
313
321
 
314
- const provingCostPerMana = await rollup.read.getProvingCostPerManaInFeeAsset();
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();
315
334
 
316
- const block = await this.pxe.getBlock(blockNumber);
317
335
  const mana = block!.header.totalManaUsed.toBigInt();
318
- return mana * provingCostPerMana;
336
+ return mulDiv(mana * proverCost, price, 10n ** 9n);
319
337
  };
338
+ return Promise.resolve();
339
+ },
340
+ );
341
+ }
342
+
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();
320
360
  },
321
361
  );
322
362
  }
@@ -326,7 +366,10 @@ export class FeesTest {
326
366
  'fund_alice',
327
367
  async () => {
328
368
  await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
329
- await this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send().wait();
369
+ await this.bananaCoin.methods
370
+ .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
371
+ .send({ from: this.aliceAddress })
372
+ .wait();
330
373
  },
331
374
  () => Promise.resolve(),
332
375
  );
@@ -341,37 +384,4 @@ export class FeesTest {
341
384
  () => Promise.resolve(),
342
385
  );
343
386
  }
344
-
345
- public async applySetupSubscription() {
346
- await this.snapshotManager.snapshot(
347
- 'setup_subscription',
348
- async () => {
349
- const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed();
350
-
351
- // Deploy subscription contract, that allows subscriptions for SUBSCRIPTION_AMOUNT of bananas
352
- const subscriptionContract = await AppSubscriptionContract.deploy(
353
- this.bobWallet,
354
- counterContract.address,
355
- this.bobAddress,
356
- this.bananaCoin.address,
357
- this.SUBSCRIPTION_AMOUNT,
358
- this.APP_SPONSORED_TX_GAS_LIMIT,
359
- )
360
- .send()
361
- .deployed();
362
-
363
- // Mint some Fee Juice to the subscription contract
364
- // Could also use bridgeFromL1ToL2 from the harness, but this is more direct
365
- await this.mintAndBridgeFeeJuice(subscriptionContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT);
366
- return {
367
- counterContractAddress: counterContract.address,
368
- subscriptionContractAddress: subscriptionContract.address,
369
- };
370
- },
371
- async ({ counterContractAddress, subscriptionContractAddress }) => {
372
- this.counterContract = await CounterContract.at(counterContractAddress, this.bobWallet);
373
- this.subscriptionContract = await AppSubscriptionContract.at(subscriptionContractAddress, this.bobWallet);
374
- },
375
- );
376
- }
377
387
  }
@@ -0,0 +1,77 @@
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { L2Block } from '@aztec/aztec.js/block';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { BatchedBlob, Blob, getEthBlobEvaluationInputs, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
5
+ import { EthAddress } from '@aztec/foundation/eth-address';
6
+
7
+ import { writeFile } from 'fs/promises';
8
+
9
+ const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA;
10
+
11
+ /**
12
+ * Creates a json object that can be used to test the solidity contract.
13
+ * The json object must be put into
14
+ */
15
+ export async function writeJson(
16
+ fileName: string,
17
+ block: L2Block,
18
+ l1ToL2Content: Fr[],
19
+ blobs: Blob[],
20
+ batchedBlob: BatchedBlob,
21
+ recipientAddress: AztecAddress,
22
+ deployerAddress: `0x${string}`,
23
+ ): Promise<void> {
24
+ if (!AZTEC_GENERATE_TEST_DATA) {
25
+ return;
26
+ }
27
+ // Path relative to the package.json in the end-to-end folder
28
+ const path = `../../l1-contracts/test/fixtures/${fileName}.json`;
29
+
30
+ const asHex = (value: Fr | Buffer | EthAddress | AztecAddress, size = 64) => {
31
+ const buffer = Buffer.isBuffer(value) ? value : value.toBuffer();
32
+ return `0x${buffer.toString('hex').padStart(size, '0')}`;
33
+ };
34
+
35
+ const jsonObject = {
36
+ populate: {
37
+ l1ToL2Content: l1ToL2Content.map(value => asHex(value)),
38
+ recipient: asHex(recipientAddress.toField()),
39
+ sender: deployerAddress,
40
+ },
41
+ messages: {
42
+ l2ToL1Messages: block.body.txEffects.flatMap(txEffect => txEffect.l2ToL1Msgs).map(value => asHex(value)),
43
+ },
44
+ checkpoint: {
45
+ // The json formatting in forge is a bit brittle, so we convert Fr to a number in the few values below.
46
+ // This should not be a problem for testing as long as the values are not larger than u32.
47
+ archive: asHex(block.archive.root),
48
+ blobCommitments: getPrefixedEthBlobCommitments(blobs),
49
+ batchedBlobInputs: getEthBlobEvaluationInputs(batchedBlob),
50
+ checkpointNumber: block.number,
51
+ body: `0x${block.body.toBuffer().toString('hex')}`,
52
+ 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),
64
+ gasFees: {
65
+ feePerDaGas: Number(block.header.globalVariables.gasFees.feePerDaGas),
66
+ feePerL2Gas: Number(block.header.globalVariables.gasFees.feePerL2Gas),
67
+ },
68
+ totalManaUsed: block.header.totalManaUsed.toNumber(),
69
+ },
70
+ headerHash: asHex(block.getCheckpointHeader().hash()),
71
+ numTxs: block.body.txEffects.length,
72
+ },
73
+ };
74
+
75
+ const output = JSON.stringify(jsonObject, null, 2);
76
+ await writeFile(path, output, 'utf8');
77
+ }