@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c

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 (156) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +60 -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 +69 -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 +315 -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 +99 -0
  13. package/dest/bench/utils.d.ts +10 -27
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +27 -43
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
  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 +66 -38
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
  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 +34 -53
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +9 -6
  25. package/dest/e2e_epochs/epochs_test.d.ts +56 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +222 -42
  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 +60 -0
  31. package/dest/e2e_fees/fees_test.d.ts +16 -5
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +87 -88
  34. package/dest/e2e_l1_publisher/write_json.d.ts +8 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +57 -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 +5 -5
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
  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 +132 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +56 -21
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +154 -125
  49. package/dest/e2e_p2p/shared.d.ts +41 -3
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +146 -6
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +51 -24
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
  58. package/dest/fixtures/fixtures.d.ts +5 -6
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +4 -3
  61. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  62. package/dest/fixtures/get_acvm_config.js +2 -14
  63. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  64. package/dest/fixtures/get_bb_config.js +8 -15
  65. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  66. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  67. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  68. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  69. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  70. package/dest/fixtures/setup_l1_contracts.js +3 -3
  71. package/dest/fixtures/setup_p2p_test.d.ts +14 -6
  72. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  73. package/dest/fixtures/setup_p2p_test.js +73 -21
  74. package/dest/fixtures/snapshot_manager.d.ts +8 -3
  75. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  76. package/dest/fixtures/snapshot_manager.js +120 -104
  77. package/dest/fixtures/token_utils.d.ts +4 -3
  78. package/dest/fixtures/token_utils.d.ts.map +1 -1
  79. package/dest/fixtures/token_utils.js +24 -7
  80. package/dest/fixtures/utils.d.ts +65 -22
  81. package/dest/fixtures/utils.d.ts.map +1 -1
  82. package/dest/fixtures/utils.js +439 -318
  83. package/dest/fixtures/web3signer.d.ts +5 -0
  84. package/dest/fixtures/web3signer.d.ts.map +1 -0
  85. package/dest/fixtures/web3signer.js +42 -0
  86. package/dest/shared/cross_chain_test_harness.d.ts +28 -18
  87. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  88. package/dest/shared/cross_chain_test_harness.js +97 -41
  89. package/dest/shared/gas_portal_test_harness.d.ts +23 -18
  90. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  91. package/dest/shared/gas_portal_test_harness.js +43 -25
  92. package/dest/shared/submit-transactions.d.ts.map +1 -1
  93. package/dest/shared/uniswap_l1_l2.d.ts +5 -6
  94. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  95. package/dest/shared/uniswap_l1_l2.js +136 -90
  96. package/dest/simulators/lending_simulator.d.ts +5 -6
  97. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  98. package/dest/simulators/lending_simulator.js +11 -15
  99. package/dest/simulators/token_simulator.d.ts +2 -1
  100. package/dest/simulators/token_simulator.d.ts.map +1 -1
  101. package/dest/simulators/token_simulator.js +16 -13
  102. package/dest/spartan/setup_test_wallets.d.ts +8 -1
  103. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  104. package/dest/spartan/setup_test_wallets.js +108 -22
  105. package/dest/spartan/utils.d.ts +60 -307
  106. package/dest/spartan/utils.d.ts.map +1 -1
  107. package/dest/spartan/utils.js +200 -115
  108. package/package.json +60 -56
  109. package/src/bench/client_flows/benchmark.ts +341 -0
  110. package/src/bench/client_flows/client_flows_benchmark.ts +422 -0
  111. package/src/bench/client_flows/config.ts +61 -0
  112. package/src/bench/client_flows/data_extractor.ts +111 -0
  113. package/src/bench/utils.ts +26 -52
  114. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
  115. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
  116. package/src/e2e_deploy_contract/deploy_test.ts +11 -8
  117. package/src/e2e_epochs/epochs_test.ts +276 -54
  118. package/src/e2e_fees/bridging_race.notest.ts +75 -0
  119. package/src/e2e_fees/fees_test.ts +121 -108
  120. package/src/e2e_l1_publisher/write_json.ts +74 -0
  121. package/src/e2e_multi_validator/utils.ts +258 -0
  122. package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
  123. package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
  124. package/src/e2e_p2p/p2p_network.ts +212 -144
  125. package/src/e2e_p2p/shared.ts +234 -14
  126. package/src/e2e_token_contract/token_contract_test.ts +42 -38
  127. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  128. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
  129. package/src/fixtures/fixtures.ts +4 -3
  130. package/src/fixtures/get_acvm_config.ts +2 -10
  131. package/src/fixtures/get_bb_config.ts +15 -11
  132. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  133. package/src/fixtures/setup_l1_contracts.ts +5 -6
  134. package/src/fixtures/setup_p2p_test.ts +112 -30
  135. package/src/fixtures/snapshot_manager.ts +150 -102
  136. package/src/fixtures/token_utils.ts +33 -8
  137. package/src/fixtures/utils.ts +530 -352
  138. package/src/fixtures/web3signer.ts +46 -0
  139. package/src/guides/up_quick_start.sh +4 -4
  140. package/src/shared/cross_chain_test_harness.ts +92 -52
  141. package/src/shared/gas_portal_test_harness.ts +47 -31
  142. package/src/shared/uniswap_l1_l2.ts +127 -124
  143. package/src/simulators/lending_simulator.ts +11 -15
  144. package/src/simulators/token_simulator.ts +17 -12
  145. package/src/spartan/DEVELOP.md +116 -0
  146. package/src/spartan/setup_test_wallets.ts +144 -29
  147. package/src/spartan/utils.ts +194 -116
  148. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  149. package/dest/sample-dapp/connect.js +0 -12
  150. package/dest/sample-dapp/contracts.js +0 -10
  151. package/dest/sample-dapp/deploy.js +0 -35
  152. package/dest/sample-dapp/index.js +0 -98
  153. package/src/sample-dapp/connect.mjs +0 -16
  154. package/src/sample-dapp/contracts.mjs +0 -14
  155. package/src/sample-dapp/deploy.mjs +0 -40
  156. package/src/sample-dapp/index.mjs +0 -128
@@ -0,0 +1,315 @@
1
+ import { EcdsaRAccountContractArtifact, getEcdsaRAccount } from '@aztec/accounts/ecdsa';
2
+ import { SchnorrAccountContractArtifact, getSchnorrAccount, getSchnorrWallet } from '@aztec/accounts/schnorr';
3
+ import { AccountWalletWithSecretKey, FeeJuicePaymentMethod, FeeJuicePaymentMethodWithClaim, PrivateFeePaymentMethod, SponsoredFeePaymentMethod, createLogger } from '@aztec/aztec.js';
4
+ import { CheatCodes } from '@aztec/aztec/testing';
5
+ import { RollupContract, createExtendedL1Client, deployL1Contract } from '@aztec/ethereum';
6
+ import { ChainMonitor } from '@aztec/ethereum/test';
7
+ import { randomBytes } from '@aztec/foundation/crypto';
8
+ import { EthAddress } from '@aztec/foundation/eth-address';
9
+ import { Fr } from '@aztec/foundation/fields';
10
+ import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
11
+ import { TestERC20Bytecode } from '@aztec/l1-artifacts/TestERC20Bytecode';
12
+ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
13
+ import { FPCContract } from '@aztec/noir-contracts.js/FPC';
14
+ import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
15
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
16
+ import { TokenContract as BananaCoin, TokenContract } from '@aztec/noir-contracts.js/Token';
17
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
18
+ import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
19
+ import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
20
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
21
+ import { MNEMONIC } from '../../fixtures/fixtures.js';
22
+ import { createSnapshotManager, deployAccounts } from '../../fixtures/snapshot_manager.js';
23
+ import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
24
+ import { setupSponsoredFPC } from '../../fixtures/utils.js';
25
+ import { CrossChainTestHarness } from '../../shared/cross_chain_test_harness.js';
26
+ import { FeeJuicePortalTestingHarnessFactory } from '../../shared/gas_portal_test_harness.js';
27
+ import { ProxyLogger } from './benchmark.js';
28
+ import { FULL_FLOWS_CONFIG, KEY_FLOWS_CONFIG } from './config.js';
29
+ const { E2E_DATA_PATH: dataPath, BENCHMARK_CONFIG } = process.env;
30
+ export class ClientFlowsBenchmark {
31
+ snapshotManager;
32
+ logger;
33
+ pxe;
34
+ aztecNode;
35
+ cheatCodes;
36
+ context;
37
+ chainMonitor;
38
+ feeJuiceBridgeTestHarness;
39
+ // The admin that aids in the setup of the test
40
+ adminWallet;
41
+ adminAddress;
42
+ // Aztec Node config
43
+ sequencerAddress;
44
+ coinbase;
45
+ // Contracts
46
+ feeJuiceContract;
47
+ // Asset in which fees are paid via FPC
48
+ bananaCoin;
49
+ bananaFPC;
50
+ // Random asset we want to trade
51
+ candyBarCoin;
52
+ // AMM contract
53
+ amm;
54
+ // Liquidity token for AMM
55
+ liquidityToken;
56
+ // Sponsored FPC contract
57
+ sponsoredFPC;
58
+ // PXE used by the benchmarking user. It can be set up with client-side proving enabled
59
+ userPXE;
60
+ realProofs = [
61
+ 'true',
62
+ '1'
63
+ ].includes(process.env.REAL_PROOFS ?? '');
64
+ paymentMethods = {
65
+ // eslint-disable-next-line camelcase
66
+ bridged_fee_juice: {
67
+ forWallet: this.getBridgedFeeJuicePaymentMethodForWallet.bind(this),
68
+ circuits: 2
69
+ },
70
+ // eslint-disable-next-line camelcase
71
+ private_fpc: {
72
+ forWallet: this.getPrivateFPCPaymentMethodForWallet.bind(this),
73
+ circuits: 2 + // FPC entrypoint + kernel inner
74
+ 2 + // BananaCoin transfer_to_public + kernel inner
75
+ 2 + // Account verify_private_authwit + kernel inner
76
+ 2
77
+ },
78
+ // eslint-disable-next-line camelcase
79
+ sponsored_fpc: {
80
+ forWallet: this.getSponsoredFPCPaymentMethodForWallet.bind(this),
81
+ circuits: 2
82
+ },
83
+ // eslint-disable-next-line camelcase
84
+ fee_juice: {
85
+ forWallet: this.getFeeJuicePaymentMethodForWallet.bind(this),
86
+ circuits: 0
87
+ }
88
+ };
89
+ config;
90
+ proxyLogger;
91
+ constructor(testName, setupOptions = {}){
92
+ this.logger = createLogger(`bench:client_flows${testName ? `:${testName}` : ''}`);
93
+ this.snapshotManager = createSnapshotManager(`bench_client_flows${testName ? `/${testName}` : ''}`, dataPath, {
94
+ startProverNode: true,
95
+ ...setupOptions
96
+ }, {
97
+ ...setupOptions
98
+ });
99
+ this.config = BENCHMARK_CONFIG === 'key_flows' ? KEY_FLOWS_CONFIG : FULL_FLOWS_CONFIG;
100
+ ProxyLogger.create();
101
+ this.proxyLogger = ProxyLogger.getInstance();
102
+ }
103
+ async setup() {
104
+ const context = await this.snapshotManager.setup();
105
+ await context.aztecNode.setConfig({
106
+ feeRecipient: this.sequencerAddress,
107
+ coinbase: this.coinbase
108
+ });
109
+ const rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
110
+ this.chainMonitor = new ChainMonitor(rollupContract, context.dateProvider, this.logger, 200).start();
111
+ return this;
112
+ }
113
+ async teardown() {
114
+ await this.chainMonitor.stop();
115
+ await this.snapshotManager.teardown();
116
+ }
117
+ async mintAndBridgeFeeJuice(address) {
118
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(address);
119
+ const { claimSecret: secret, messageLeafIndex: index } = claim;
120
+ await this.feeJuiceContract.methods.claim(address, claim.claimAmount, secret, index).send({
121
+ from: this.adminAddress
122
+ }).wait();
123
+ }
124
+ /** Admin mints bananaCoin tokens privately to the target address and redeems them. */ async mintPrivateBananas(amount, address) {
125
+ const balanceBefore = await this.bananaCoin.methods.balance_of_private(address).simulate({
126
+ from: this.adminAddress
127
+ });
128
+ await mintTokensToPrivate(this.bananaCoin, this.adminAddress, this.adminWallet, address, amount);
129
+ const balanceAfter = await this.bananaCoin.methods.balance_of_private(address).simulate({
130
+ from: this.adminAddress
131
+ });
132
+ expect(balanceAfter).toEqual(balanceBefore + amount);
133
+ }
134
+ async createBenchmarkingAccountManager(pxe, type) {
135
+ const benchysSecretKey = Fr.random();
136
+ const salt = Fr.random();
137
+ let benchysPrivateSigningKey;
138
+ let benchysAccountManager;
139
+ if (type === 'schnorr') {
140
+ benchysPrivateSigningKey = deriveSigningKey(benchysSecretKey);
141
+ benchysAccountManager = await getSchnorrAccount(pxe, benchysSecretKey, benchysPrivateSigningKey, salt);
142
+ } else if (type === 'ecdsar1') {
143
+ benchysPrivateSigningKey = randomBytes(32);
144
+ benchysAccountManager = await getEcdsaRAccount(pxe, benchysSecretKey, benchysPrivateSigningKey, salt);
145
+ } else {
146
+ throw new Error(`Unknown account type: ${type}`);
147
+ }
148
+ await benchysAccountManager.register();
149
+ return benchysAccountManager;
150
+ }
151
+ async applyBaseSnapshots() {
152
+ await this.applyInitialAccountsSnapshot();
153
+ await this.applySetupFeeJuiceSnapshot();
154
+ }
155
+ async applyInitialAccountsSnapshot() {
156
+ await this.snapshotManager.snapshot('initial_accounts', deployAccounts(2, this.logger), async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig })=>{
157
+ this.pxe = pxe;
158
+ this.aztecNode = aztecNode;
159
+ this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
160
+ const deployedWallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
161
+ [this.adminWallet] = deployedWallets;
162
+ this.adminAddress = this.adminWallet.getAddress();
163
+ this.sequencerAddress = deployedWallets[1].getAddress();
164
+ const canonicalFeeJuice = await getCanonicalFeeJuice();
165
+ this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.adminWallet);
166
+ this.coinbase = EthAddress.random();
167
+ const userPXEConfig = getPXEServiceConfig();
168
+ const l1Contracts = await aztecNode.getL1ContractAddresses();
169
+ const userPXEConfigWithContracts = {
170
+ ...userPXEConfig,
171
+ proverEnabled: this.realProofs,
172
+ l1Contracts
173
+ };
174
+ this.userPXE = await createPXEService(this.aztecNode, userPXEConfigWithContracts, {
175
+ loggers: {
176
+ prover: this.proxyLogger.createLogger('pxe:bb:wasm:bundle:proxied')
177
+ }
178
+ });
179
+ });
180
+ }
181
+ async applySetupFeeJuiceSnapshot() {
182
+ await this.snapshotManager.snapshot('setup_fee_juice', async ()=>{}, async (_data, context)=>{
183
+ this.context = context;
184
+ this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.adminWallet);
185
+ this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
186
+ aztecNode: context.aztecNode,
187
+ aztecNodeAdmin: context.aztecNode,
188
+ pxeService: context.pxe,
189
+ l1Client: context.deployL1ContractsValues.l1Client,
190
+ wallet: this.adminWallet,
191
+ logger: this.logger
192
+ });
193
+ });
194
+ }
195
+ async applyDeployBananaTokenSnapshot() {
196
+ await this.snapshotManager.snapshot('deploy_banana_token', async ()=>{
197
+ const bananaCoin = await BananaCoin.deploy(this.adminWallet, this.adminAddress, 'BC', 'BC', 18n).send({
198
+ from: this.adminAddress
199
+ }).deployed();
200
+ this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
201
+ return {
202
+ bananaCoinAddress: bananaCoin.address
203
+ };
204
+ }, async ({ bananaCoinAddress })=>{
205
+ this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.adminWallet);
206
+ });
207
+ }
208
+ async applyDeployCandyBarTokenSnapshot() {
209
+ await this.snapshotManager.snapshot('deploy_candy_bar_token', async ()=>{
210
+ const candyBarCoin = await TokenContract.deploy(this.adminWallet, this.adminAddress, 'CBC', 'CBC', 18n).send({
211
+ from: this.adminAddress
212
+ }).deployed();
213
+ this.logger.info(`CandyBarCoin deployed at ${candyBarCoin.address}`);
214
+ return {
215
+ candyBarCoinAddress: candyBarCoin.address
216
+ };
217
+ }, async ({ candyBarCoinAddress })=>{
218
+ this.candyBarCoin = await TokenContract.at(candyBarCoinAddress, this.adminWallet);
219
+ });
220
+ }
221
+ async applyFPCSetupSnapshot() {
222
+ await this.snapshotManager.snapshot('fpc_setup', async (context)=>{
223
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
224
+ expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
225
+ const bananaCoin = this.bananaCoin;
226
+ const bananaFPC = await FPCContract.deploy(this.adminWallet, bananaCoin.address, this.adminAddress).send({
227
+ from: this.adminAddress
228
+ }).deployed();
229
+ this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
230
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.adminAddress);
231
+ return {
232
+ bananaFPCAddress: bananaFPC.address
233
+ };
234
+ }, async (data)=>{
235
+ this.bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.adminWallet);
236
+ });
237
+ }
238
+ async applyDeploySponsoredFPCSnapshot() {
239
+ await this.snapshotManager.snapshot('deploy_sponsored_fpc', async ()=>{
240
+ const sponsoredFPC = await setupSponsoredFPC(this.pxe);
241
+ this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
242
+ return {
243
+ sponsoredFPCAddress: sponsoredFPC.address
244
+ };
245
+ }, async ({ sponsoredFPCAddress })=>{
246
+ this.sponsoredFPC = await SponsoredFPCContract.at(sponsoredFPCAddress, this.adminWallet);
247
+ });
248
+ }
249
+ async createCrossChainTestHarness(owner) {
250
+ const l1Client = createExtendedL1Client(this.context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
251
+ const underlyingERC20Address = await deployL1Contract(l1Client, TestERC20Abi, TestERC20Bytecode, [
252
+ 'Underlying',
253
+ 'UND',
254
+ l1Client.account.address
255
+ ]).then(({ address })=>address);
256
+ this.logger.verbose(`Setting up cross chain harness...`);
257
+ const crossChainTestHarness = await CrossChainTestHarness.new(this.aztecNode, this.pxe, l1Client, owner, owner.getAddress(), this.logger, underlyingERC20Address);
258
+ this.logger.verbose(`L2 token deployed to: ${crossChainTestHarness.l2Token.address}`);
259
+ return crossChainTestHarness;
260
+ }
261
+ async createAndFundBenchmarkingWallet(accountType) {
262
+ const benchysAccountManager = await this.createBenchmarkingAccountManager(this.pxe, accountType);
263
+ const benchysWallet = await benchysAccountManager.getWallet();
264
+ const benchysAddress = benchysAccountManager.getAddress();
265
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(benchysAddress);
266
+ const paymentMethod = new FeeJuicePaymentMethodWithClaim(benchysWallet, claim);
267
+ await benchysAccountManager.deploy({
268
+ fee: {
269
+ paymentMethod
270
+ }
271
+ }).wait();
272
+ // Register benchy on the user's PXE, where we're going to be interacting from
273
+ await this.userPXE.registerContract({
274
+ instance: benchysAccountManager.getInstance(),
275
+ artifact: accountType === 'ecdsar1' ? EcdsaRAccountContractArtifact : SchnorrAccountContractArtifact
276
+ });
277
+ await this.userPXE.registerAccount(benchysWallet.getSecretKey(), benchysWallet.getCompleteAddress().partialAddress);
278
+ const entrypoint = await benchysAccountManager.getAccount();
279
+ return new AccountWalletWithSecretKey(this.userPXE, entrypoint, benchysWallet.getSecretKey(), benchysAccountManager.salt);
280
+ }
281
+ async applyDeployAmmSnapshot() {
282
+ await this.snapshotManager.snapshot('deploy_amm', async ()=>{
283
+ const liquidityToken = await TokenContract.deploy(this.adminWallet, this.adminAddress, 'LPT', 'LPT', 18n).send({
284
+ from: this.adminAddress
285
+ }).deployed();
286
+ const amm = await AMMContract.deploy(this.adminWallet, this.bananaCoin.address, this.candyBarCoin.address, liquidityToken.address).send({
287
+ from: this.adminAddress
288
+ }).deployed();
289
+ this.logger.info(`AMM deployed at ${amm.address}`);
290
+ await liquidityToken.methods.set_minter(amm.address, true).send({
291
+ from: this.adminAddress
292
+ }).wait();
293
+ return {
294
+ ammAddress: amm.address,
295
+ liquidityTokenAddress: liquidityToken.address
296
+ };
297
+ }, async ({ ammAddress, liquidityTokenAddress })=>{
298
+ this.liquidityToken = await TokenContract.at(liquidityTokenAddress, this.adminWallet);
299
+ this.amm = await AMMContract.at(ammAddress, this.adminWallet);
300
+ });
301
+ }
302
+ async getBridgedFeeJuicePaymentMethodForWallet(wallet) {
303
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(wallet.getAddress());
304
+ return new FeeJuicePaymentMethodWithClaim(wallet, claim);
305
+ }
306
+ getPrivateFPCPaymentMethodForWallet(wallet) {
307
+ return Promise.resolve(new PrivateFeePaymentMethod(this.bananaFPC.address, wallet));
308
+ }
309
+ getSponsoredFPCPaymentMethodForWallet(_wallet) {
310
+ return Promise.resolve(new SponsoredFeePaymentMethod(this.sponsoredFPC.address));
311
+ }
312
+ getFeeJuicePaymentMethodForWallet(wallet) {
313
+ return Promise.resolve(new FeeJuicePaymentMethod(wallet.getAddress()));
314
+ }
315
+ }
@@ -0,0 +1,14 @@
1
+ import type { AccountType, BenchmarkingFeePaymentMethod } from './client_flows_benchmark.js';
2
+ export type ClientFlowConfig = {
3
+ accounts: AccountType[];
4
+ feePaymentMethods: BenchmarkingFeePaymentMethod[];
5
+ recursions?: number[];
6
+ };
7
+ type ClientFlows = 'accountDeployments' | 'deployments' | 'transfers' | 'bridging' | 'amm';
8
+ export type ClientFlowsConfig = {
9
+ [key in ClientFlows]: ClientFlowConfig;
10
+ };
11
+ export declare const KEY_FLOWS_CONFIG: ClientFlowsConfig;
12
+ export declare const FULL_FLOWS_CONFIG: ClientFlowsConfig;
13
+ export {};
14
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/bench/client_flows/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE7F,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,iBAAiB,EAAE,4BAA4B,EAAE,CAAC;IAClD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,KAAK,WAAW,GAAG,oBAAoB,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,KAAK,CAAC;AAE3F,MAAM,MAAM,iBAAiB,GAAG;KAC7B,GAAG,IAAI,WAAW,GAAG,gBAAgB;CACvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,iBAsB9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAsB/B,CAAC"}
@@ -0,0 +1,106 @@
1
+ export const KEY_FLOWS_CONFIG = {
2
+ accountDeployments: {
3
+ accounts: [
4
+ 'ecdsar1',
5
+ 'schnorr'
6
+ ],
7
+ feePaymentMethods: [
8
+ 'sponsored_fpc'
9
+ ]
10
+ },
11
+ deployments: {
12
+ accounts: [
13
+ 'ecdsar1',
14
+ 'schnorr'
15
+ ],
16
+ feePaymentMethods: [
17
+ 'sponsored_fpc'
18
+ ]
19
+ },
20
+ amm: {
21
+ accounts: [
22
+ 'ecdsar1'
23
+ ],
24
+ feePaymentMethods: [
25
+ 'sponsored_fpc'
26
+ ]
27
+ },
28
+ bridging: {
29
+ accounts: [
30
+ 'ecdsar1'
31
+ ],
32
+ feePaymentMethods: [
33
+ 'sponsored_fpc'
34
+ ]
35
+ },
36
+ transfers: {
37
+ accounts: [
38
+ 'ecdsar1'
39
+ ],
40
+ feePaymentMethods: [
41
+ 'sponsored_fpc',
42
+ 'private_fpc'
43
+ ],
44
+ recursions: [
45
+ 0,
46
+ 1
47
+ ]
48
+ }
49
+ };
50
+ export const FULL_FLOWS_CONFIG = {
51
+ accountDeployments: {
52
+ accounts: [
53
+ 'ecdsar1',
54
+ 'schnorr'
55
+ ],
56
+ feePaymentMethods: [
57
+ 'bridged_fee_juice',
58
+ 'sponsored_fpc'
59
+ ]
60
+ },
61
+ deployments: {
62
+ accounts: [
63
+ 'ecdsar1',
64
+ 'schnorr'
65
+ ],
66
+ feePaymentMethods: [
67
+ 'bridged_fee_juice',
68
+ 'sponsored_fpc'
69
+ ]
70
+ },
71
+ amm: {
72
+ accounts: [
73
+ 'ecdsar1',
74
+ 'schnorr'
75
+ ],
76
+ feePaymentMethods: [
77
+ 'sponsored_fpc',
78
+ 'private_fpc'
79
+ ]
80
+ },
81
+ bridging: {
82
+ accounts: [
83
+ 'ecdsar1',
84
+ 'schnorr'
85
+ ],
86
+ feePaymentMethods: [
87
+ 'sponsored_fpc',
88
+ 'private_fpc'
89
+ ]
90
+ },
91
+ transfers: {
92
+ accounts: [
93
+ 'ecdsar1',
94
+ 'schnorr'
95
+ ],
96
+ feePaymentMethods: [
97
+ 'sponsored_fpc',
98
+ 'private_fpc'
99
+ ],
100
+ recursions: [
101
+ 0,
102
+ 1,
103
+ 2
104
+ ]
105
+ }
106
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data_extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data_extractor.d.ts","sourceRoot":"","sources":["../../../src/bench/client_flows/data_extractor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,99 @@
1
+ import { BBNativePrivateKernelProver } from '@aztec/bb-prover/client/native';
2
+ import { BBWASMBundlePrivateKernelProver } from '@aztec/bb-prover/client/wasm/bundle';
3
+ import { createLogger, logger } from '@aztec/foundation/log';
4
+ import { Timer } from '@aztec/foundation/timer';
5
+ import { WASMSimulator } from '@aztec/simulator/client';
6
+ import { Decoder } from 'msgpackr';
7
+ import { readFile, readdir, writeFile } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+ import { ProxyLogger, generateBenchmark } from './benchmark.js';
10
+ async function createProver(config = {}, log) {
11
+ const simulator = new WASMSimulator();
12
+ if (!config.bbBinaryPath || !config.bbWorkingDirectory) {
13
+ return {
14
+ prover: new BBWASMBundlePrivateKernelProver(simulator, 16, log),
15
+ type: 'wasm'
16
+ };
17
+ } else {
18
+ const bbConfig = config;
19
+ return {
20
+ prover: await BBNativePrivateKernelProver.new({
21
+ bbSkipCleanup: false,
22
+ numConcurrentIVCVerifiers: 1,
23
+ bbIVCConcurrency: 1,
24
+ ...bbConfig
25
+ }, simulator, log),
26
+ type: 'native'
27
+ };
28
+ }
29
+ }
30
+ async function main() {
31
+ ProxyLogger.create();
32
+ const proxyLogger = ProxyLogger.getInstance();
33
+ const ivcFolder = process.env.CAPTURE_IVC_FOLDER;
34
+ if (!ivcFolder) {
35
+ throw new Error('CAPTURE_IVC_FOLDER is not set');
36
+ }
37
+ const flows = await readdir(ivcFolder);
38
+ logger.info(`Flows in ${ivcFolder}: \n${flows.map((flowName)=>`\t- ${flowName}`).join('\n')}`);
39
+ const { prover, type: proverType } = await createProver({
40
+ bbBinaryPath: process.env.BB_BINARY_PATH,
41
+ bbWorkingDirectory: process.env.BB_WORKING_DIRECTORY
42
+ }, proxyLogger.createLogger('bb:prover'));
43
+ const userLog = createLogger('client_ivc_flows:data_processor');
44
+ for (const flow of flows){
45
+ userLog.info(`Processing flow ${flow}`);
46
+ const ivcInputs = await readFile(join(ivcFolder, flow, 'ivc-inputs.msgpack'));
47
+ const stepsFromFile = new Decoder({
48
+ useRecords: false
49
+ }).unpack(ivcInputs);
50
+ const witnesses = await readFile(join(ivcFolder, flow, 'witnesses.json'));
51
+ const witnessStack = JSON.parse(witnesses.toString()).map((witnessMap)=>{
52
+ return new Map(Object.entries(witnessMap).map(([k, v])=>[
53
+ Number(k),
54
+ v
55
+ ]));
56
+ });
57
+ const profileFile = await readFile(join(ivcFolder, flow, 'profile.json'));
58
+ const profile = JSON.parse(profileFile.toString());
59
+ const privateExecutionSteps = profile.steps.map((step, i)=>({
60
+ functionName: step.functionName,
61
+ gateCount: step.gateCount,
62
+ bytecode: stepsFromFile[i].bytecode,
63
+ // TODO(AD) do we still want to take this from witness.json?
64
+ witness: witnessStack[i],
65
+ vk: stepsFromFile[i].vk,
66
+ timings: {
67
+ witgen: step.timings.witgen,
68
+ gateCount: step.timings.gateCount
69
+ }
70
+ }));
71
+ let error;
72
+ let currentLogs = [];
73
+ let provingTime;
74
+ try {
75
+ const provingTimer = new Timer();
76
+ await prover.createClientIvcProof(privateExecutionSteps);
77
+ provingTime = provingTimer.ms();
78
+ } catch (e) {
79
+ userLog.error(`Failed to generate client ivc proof for ${flow}`, e);
80
+ error = e.message;
81
+ }
82
+ // Extract logs from this run from the proxy and write them to disk unconditionally
83
+ currentLogs = proxyLogger.getLogs();
84
+ await writeFile(join(ivcFolder, flow, 'logs.json'), JSON.stringify(currentLogs, null, 2));
85
+ if (!profile.stats.timings.proving) {
86
+ profile.stats.timings.proving = provingTime;
87
+ }
88
+ const benchmark = generateBenchmark(flow, currentLogs, profile.stats, privateExecutionSteps, proverType, error);
89
+ await writeFile(join(ivcFolder, flow, 'benchmark.json'), JSON.stringify(benchmark, null, 2));
90
+ proxyLogger.flushLogs();
91
+ }
92
+ }
93
+ try {
94
+ await main();
95
+ } catch (e) {
96
+ // eslint-disable-next-line no-console
97
+ console.error(e);
98
+ process.exit(1);
99
+ }
@@ -1,5 +1,5 @@
1
- import { type AztecNode, BatchCall, type SentTx, type WaitOpts } from '@aztec/aztec.js';
2
- import { BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking';
1
+ import { type AztecNode, type SentTx, type WaitOpts } from '@aztec/aztec.js';
2
+ import { BenchmarkingContract } from '@aztec/noir-test-contracts.js/Benchmarking';
3
3
  import { type PXEService } from '@aztec/pxe/server';
4
4
  import type { MetricsType } from '@aztec/telemetry-client';
5
5
  import type { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
@@ -23,30 +23,13 @@ type MetricFilter = {
23
23
  name: string;
24
24
  unit?: string;
25
25
  };
26
- /**
27
- * Creates and returns a directory with the current job name and a random number.
28
- * @param index - Index to merge into the dir path.
29
- * @returns A path to a created dir.
30
- */
31
- export declare function makeDataDirectory(index: number): string;
32
- /**
33
- * Returns the size in disk of a folder.
34
- * @param path - Path to the folder.
35
- * @returns Size in bytes.
36
- */
37
- export declare function getFolderSize(path: string): number;
38
- /**
39
- * Returns a call to the benchmark contract. Each call has a private execution (account entrypoint),
40
- * a nested private call (create_note), a public call (increment_balance), and a nested public
41
- * call (broadcast). These include emitting one private note and one public log, two storage
42
- * reads and one write.
43
- * @param index - Index of the call within a block.
44
- * @param context - End to end context.
45
- * @param contract - Benchmarking contract.
46
- * @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
47
- * @returns A BatchCall instance.
48
- */
49
- export declare function makeCall(index: number, context: EndToEndContext, contract: BenchmarkingContract, heavyPublicCompute: boolean): Promise<BatchCall>;
26
+ export type GithubActionBenchmarkResult = {
27
+ name: string;
28
+ value: number;
29
+ range?: string;
30
+ unit: string;
31
+ extra?: string;
32
+ };
50
33
  /**
51
34
  * Assembles and sends multiple transactions simultaneously to the node in context.
52
35
  * Each tx is the result of calling makeCall.
@@ -65,6 +48,6 @@ export declare function waitTxs(txs: SentTx[], context: EndToEndContext, txWaitO
65
48
  * @param startingBlock - First l2 block to process.
66
49
  * @returns The new PXE.
67
50
  */
68
- export declare function createNewPXE(node: AztecNode, contract: BenchmarkingContract, startingBlock?: number): Promise<PXEService>;
51
+ export declare function createNewPXE(node: AztecNode, contract: BenchmarkingContract): Promise<PXEService>;
69
52
  export {};
70
53
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/bench/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAwB,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,UAAU,EAA2C,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAA4C,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAOxH,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAS,MAAM,sBAAsB,CAAC;AAEtF;;GAEG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG;IAC5B,6BAA6B,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACtE,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;GAoBF;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA0CF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,UAK9C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKlD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,oBAAoB,EAC9B,kBAAkB,EAAE,OAAO,sBAc5B;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,oBAAoB,EAC9B,kBAAkB,GAAE,OAAe,GAClC,OAAO,CAAC,MAAM,EAAE,CAAC,CAMnB;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,QAAQ,iBAI3F;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,GAAE,MAA6B,GAC3C,OAAO,CAAC,UAAU,CAAC,CAerB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/bench/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAa,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,KAAK,UAAU,EAA2C,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAA4C,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAKxH,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAS,MAAM,sBAAsB,CAAC;AAEtF;;GAEG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG;IAC5B,6BAA6B,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACtE,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;GA0BF;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA6DF;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,oBAAoB,EAC9B,kBAAkB,GAAE,OAAe,GAClC,OAAO,CAAC,MAAM,EAAE,CAAC,CAMnB;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,QAAQ,iBAI3F;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CAiBvG"}