@aztec/end-to-end 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05

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 (283) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +21 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +15 -16
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +125 -145
  8. package/dest/bench/client_flows/config.d.ts +2 -2
  9. package/dest/bench/client_flows/config.d.ts.map +1 -1
  10. package/dest/bench/client_flows/config.js +18 -0
  11. package/dest/bench/client_flows/data_extractor.js +3 -1
  12. package/dest/bench/utils.d.ts +9 -8
  13. package/dest/bench/utils.d.ts.map +1 -1
  14. package/dest/bench/utils.js +31 -19
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -9
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +108 -114
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +20 -14
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +92 -71
  21. package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  23. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  24. package/dest/e2e_epochs/epochs_test.d.ts +42 -15
  25. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  26. package/dest/e2e_epochs/epochs_test.js +159 -59
  27. package/dest/e2e_fees/bridging_race.notest.js +4 -6
  28. package/dest/e2e_fees/fees_test.d.ts +21 -17
  29. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  30. package/dest/e2e_fees/fees_test.js +139 -147
  31. package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
  32. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  33. package/dest/e2e_l1_publisher/write_json.js +14 -16
  34. package/dest/e2e_multi_validator/utils.js +1 -1
  35. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  36. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  37. package/dest/e2e_nested_contract/nested_contract_test.js +30 -40
  38. package/dest/e2e_p2p/inactivity_slash_test.d.ts +4 -4
  39. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  40. package/dest/e2e_p2p/inactivity_slash_test.js +9 -12
  41. package/dest/e2e_p2p/p2p_network.d.ts +25 -21
  42. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  43. package/dest/e2e_p2p/p2p_network.js +175 -130
  44. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  45. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  46. package/dest/e2e_p2p/reqresp/utils.js +193 -0
  47. package/dest/e2e_p2p/shared.d.ts +30 -12
  48. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  49. package/dest/e2e_p2p/shared.js +84 -67
  50. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  51. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  52. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  53. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  54. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  55. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  56. package/dest/e2e_token_contract/token_contract_test.d.ts +19 -10
  57. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  58. package/dest/e2e_token_contract/token_contract_test.js +100 -92
  59. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  60. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  61. package/dest/fixtures/authwit_proxy.js +34 -0
  62. package/dest/fixtures/e2e_prover_test.d.ts +16 -23
  63. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  64. package/dest/fixtures/e2e_prover_test.js +115 -139
  65. package/dest/fixtures/elu_monitor.d.ts +21 -0
  66. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  67. package/dest/fixtures/elu_monitor.js +102 -0
  68. package/dest/fixtures/fixtures.d.ts +17 -3
  69. package/dest/fixtures/fixtures.d.ts.map +1 -1
  70. package/dest/fixtures/fixtures.js +18 -3
  71. package/dest/fixtures/get_acvm_config.js +1 -1
  72. package/dest/fixtures/get_bb_config.d.ts +1 -1
  73. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  74. package/dest/fixtures/get_bb_config.js +5 -5
  75. package/dest/fixtures/ha_setup.d.ts +71 -0
  76. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  77. package/dest/fixtures/ha_setup.js +116 -0
  78. package/dest/fixtures/index.d.ts +2 -1
  79. package/dest/fixtures/index.d.ts.map +1 -1
  80. package/dest/fixtures/index.js +1 -0
  81. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  82. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  83. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  84. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  85. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  86. package/dest/fixtures/schnorr_hardcoded_account_contract.js +39 -0
  87. package/dest/fixtures/setup.d.ts +246 -0
  88. package/dest/fixtures/setup.d.ts.map +1 -0
  89. package/dest/fixtures/setup.js +625 -0
  90. package/dest/fixtures/setup_p2p_test.d.ts +18 -11
  91. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  92. package/dest/fixtures/setup_p2p_test.js +46 -35
  93. package/dest/fixtures/token_utils.d.ts +2 -2
  94. package/dest/fixtures/token_utils.d.ts.map +1 -1
  95. package/dest/fixtures/token_utils.js +7 -6
  96. package/dest/fixtures/utils.d.ts +5 -637
  97. package/dest/fixtures/utils.d.ts.map +1 -1
  98. package/dest/fixtures/utils.js +4 -647
  99. package/dest/fixtures/web3signer.js +1 -1
  100. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  101. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  102. package/dest/fixtures/with_telemetry_utils.js +2 -2
  103. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  104. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  105. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  106. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  107. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  108. package/dest/forward-compatibility/wallet_service.js +109 -0
  109. package/dest/legacy-jest-resolver.d.cts +3 -0
  110. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  111. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  112. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  113. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  114. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  115. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  116. package/dest/quality_of_service/prometheus_client.js +67 -0
  117. package/dest/shared/cross_chain_test_harness.d.ts +18 -6
  118. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  119. package/dest/shared/cross_chain_test_harness.js +27 -27
  120. package/dest/shared/gas_portal_test_harness.d.ts +12 -2
  121. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  122. package/dest/shared/gas_portal_test_harness.js +4 -4
  123. package/dest/shared/index.d.ts +3 -2
  124. package/dest/shared/index.d.ts.map +1 -1
  125. package/dest/shared/index.js +1 -0
  126. package/dest/shared/jest_setup.js +41 -1
  127. package/dest/shared/mock_state_view.d.ts +86 -0
  128. package/dest/shared/mock_state_view.d.ts.map +1 -0
  129. package/dest/shared/mock_state_view.js +186 -0
  130. package/dest/shared/submit-transactions.d.ts +4 -4
  131. package/dest/shared/submit-transactions.d.ts.map +1 -1
  132. package/dest/shared/submit-transactions.js +9 -11
  133. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  134. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  135. package/dest/shared/uniswap_l1_l2.js +58 -43
  136. package/dest/simulators/lending_simulator.d.ts +6 -2
  137. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  138. package/dest/simulators/lending_simulator.js +6 -6
  139. package/dest/simulators/token_simulator.d.ts +1 -1
  140. package/dest/simulators/token_simulator.d.ts.map +1 -1
  141. package/dest/simulators/token_simulator.js +3 -24
  142. package/dest/spartan/setup_test_wallets.d.ts +15 -5
  143. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  144. package/dest/spartan/setup_test_wallets.js +132 -43
  145. package/dest/spartan/tx_metrics.d.ts +88 -0
  146. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  147. package/dest/spartan/tx_metrics.js +438 -0
  148. package/dest/spartan/utils/bot.d.ts +28 -0
  149. package/dest/spartan/utils/bot.d.ts.map +1 -0
  150. package/dest/spartan/utils/bot.js +142 -0
  151. package/dest/spartan/utils/chaos.d.ts +79 -0
  152. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  153. package/dest/spartan/utils/chaos.js +142 -0
  154. package/dest/spartan/utils/clients.d.ts +39 -0
  155. package/dest/spartan/utils/clients.d.ts.map +1 -0
  156. package/dest/spartan/utils/clients.js +90 -0
  157. package/dest/spartan/utils/config.d.ts +45 -0
  158. package/dest/spartan/utils/config.d.ts.map +1 -0
  159. package/dest/spartan/utils/config.js +23 -0
  160. package/dest/spartan/utils/health.d.ts +63 -0
  161. package/dest/spartan/utils/health.d.ts.map +1 -0
  162. package/dest/spartan/utils/health.js +202 -0
  163. package/dest/spartan/utils/helm.d.ts +15 -0
  164. package/dest/spartan/utils/helm.d.ts.map +1 -0
  165. package/dest/spartan/utils/helm.js +47 -0
  166. package/dest/spartan/utils/index.d.ts +11 -0
  167. package/dest/spartan/utils/index.d.ts.map +1 -0
  168. package/dest/spartan/utils/index.js +22 -0
  169. package/dest/spartan/utils/k8s.d.ts +128 -0
  170. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  171. package/dest/spartan/utils/k8s.js +381 -0
  172. package/dest/spartan/utils/nodes.d.ts +40 -0
  173. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  174. package/dest/spartan/utils/nodes.js +461 -0
  175. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  176. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  177. package/dest/spartan/utils/pod_logs.js +74 -0
  178. package/dest/spartan/utils/scripts.d.ts +30 -0
  179. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  180. package/dest/spartan/utils/scripts.js +81 -0
  181. package/dest/spartan/utils.d.ts +2 -220
  182. package/dest/spartan/utils.d.ts.map +1 -1
  183. package/dest/spartan/utils.js +1 -782
  184. package/dest/test-wallet/test_wallet.d.ts +84 -0
  185. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  186. package/dest/test-wallet/test_wallet.js +255 -0
  187. package/dest/test-wallet/utils.d.ts +41 -0
  188. package/dest/test-wallet/utils.d.ts.map +1 -0
  189. package/dest/test-wallet/utils.js +71 -0
  190. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  191. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  192. package/dest/test-wallet/wallet_worker_script.js +48 -0
  193. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  194. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  195. package/dest/test-wallet/worker_wallet.js +151 -0
  196. package/dest/test-wallet/worker_wallet_schema.d.ts +279 -0
  197. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  198. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  199. package/package.json +49 -45
  200. package/src/bench/client_flows/benchmark.ts +24 -2
  201. package/src/bench/client_flows/client_flows_benchmark.ts +166 -216
  202. package/src/bench/client_flows/config.ts +9 -1
  203. package/src/bench/client_flows/data_extractor.ts +1 -1
  204. package/src/bench/utils.ts +36 -21
  205. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +123 -151
  206. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -126
  207. package/src/e2e_deploy_contract/deploy_test.ts +22 -15
  208. package/src/e2e_epochs/epochs_test.ts +222 -112
  209. package/src/e2e_fees/bridging_race.notest.ts +5 -11
  210. package/src/e2e_fees/fees_test.ts +182 -230
  211. package/src/e2e_l1_publisher/write_json.ts +16 -16
  212. package/src/e2e_multi_validator/utils.ts +1 -1
  213. package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
  214. package/src/e2e_p2p/inactivity_slash_test.ts +10 -13
  215. package/src/e2e_p2p/p2p_network.ts +245 -204
  216. package/src/e2e_p2p/reqresp/utils.ts +257 -0
  217. package/src/e2e_p2p/shared.ts +111 -81
  218. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  219. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  220. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  221. package/src/e2e_token_contract/token_contract_test.ts +121 -119
  222. package/src/fixtures/authwit_proxy.ts +54 -0
  223. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  224. package/src/fixtures/e2e_prover_test.ts +143 -189
  225. package/src/fixtures/elu_monitor.ts +126 -0
  226. package/src/fixtures/fixtures.ts +34 -5
  227. package/src/fixtures/get_acvm_config.ts +1 -1
  228. package/src/fixtures/get_bb_config.ts +7 -6
  229. package/src/fixtures/ha_setup.ts +188 -0
  230. package/src/fixtures/index.ts +1 -0
  231. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  232. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  233. package/src/fixtures/setup.ts +932 -0
  234. package/src/fixtures/setup_p2p_test.ts +51 -55
  235. package/src/fixtures/token_utils.ts +7 -6
  236. package/src/fixtures/utils.ts +27 -966
  237. package/src/fixtures/web3signer.ts +1 -1
  238. package/src/fixtures/with_telemetry_utils.ts +2 -2
  239. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  240. package/src/forward-compatibility/wallet_service.ts +104 -0
  241. package/src/guides/up_quick_start.sh +3 -5
  242. package/src/legacy-jest-resolver.cjs +135 -0
  243. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  244. package/src/quality_of_service/prometheus_client.ts +113 -0
  245. package/src/shared/cross_chain_test_harness.ts +30 -43
  246. package/src/shared/gas_portal_test_harness.ts +3 -4
  247. package/src/shared/index.ts +2 -1
  248. package/src/shared/jest_setup.ts +51 -1
  249. package/src/shared/mock_state_view.ts +188 -0
  250. package/src/shared/submit-transactions.ts +11 -16
  251. package/src/shared/uniswap_l1_l2.ts +86 -106
  252. package/src/simulators/lending_simulator.ts +11 -7
  253. package/src/simulators/token_simulator.ts +6 -30
  254. package/src/spartan/DEVELOP.md +7 -0
  255. package/src/spartan/setup_test_wallets.ts +192 -28
  256. package/src/spartan/tx_metrics.ts +388 -0
  257. package/src/spartan/utils/bot.ts +188 -0
  258. package/src/spartan/utils/chaos.ts +253 -0
  259. package/src/spartan/utils/clients.ts +100 -0
  260. package/src/spartan/utils/config.ts +29 -0
  261. package/src/spartan/utils/health.ts +255 -0
  262. package/src/spartan/utils/helm.ts +84 -0
  263. package/src/spartan/utils/index.ts +71 -0
  264. package/src/spartan/utils/k8s.ts +535 -0
  265. package/src/spartan/utils/nodes.ts +543 -0
  266. package/src/spartan/utils/pod_logs.ts +99 -0
  267. package/src/spartan/utils/scripts.ts +99 -0
  268. package/src/spartan/utils.ts +1 -982
  269. package/src/test-wallet/test_wallet.ts +357 -0
  270. package/src/test-wallet/utils.ts +112 -0
  271. package/src/test-wallet/wallet_worker_script.ts +60 -0
  272. package/src/test-wallet/worker_wallet.ts +214 -0
  273. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  274. package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
  275. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  276. package/dest/fixtures/setup_l1_contracts.js +0 -17
  277. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  278. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  279. package/dest/fixtures/snapshot_manager.js +0 -505
  280. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  281. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  282. package/src/fixtures/setup_l1_contracts.ts +0 -26
  283. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -1,21 +1,27 @@
1
1
  import { generateSchnorrAccounts } from '@aztec/accounts/testing';
2
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
3
  import { AztecAddress } from '@aztec/aztec.js/addresses';
4
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
5
  import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
4
6
  import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
5
7
  import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
6
8
  import { Fr } from '@aztec/aztec.js/fields';
7
- import { type AztecNode, createAztecNodeClient } from '@aztec/aztec.js/node';
9
+ import { type AztecNode, createAztecNodeClient, waitForTx } from '@aztec/aztec.js/node';
8
10
  import type { Wallet } from '@aztec/aztec.js/wallet';
9
- import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
11
+ import { createEthereumChain } from '@aztec/ethereum/chain';
12
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
10
13
  import type { Logger } from '@aztec/foundation/log';
11
- import { retryUntil } from '@aztec/foundation/retry';
14
+ import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
12
15
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
13
16
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
14
- import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
17
+ import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
15
18
 
16
19
  import { getACVMConfig } from '../fixtures/get_acvm_config.js';
17
20
  import { getBBConfig } from '../fixtures/get_bb_config.js';
18
21
  import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
22
+ import { TestWallet } from '../test-wallet/test_wallet.js';
23
+ import { proveInteraction } from '../test-wallet/utils.js';
24
+ import { WorkerWallet } from '../test-wallet/worker_wallet.js';
19
25
 
20
26
  export interface TestAccounts {
21
27
  aztecNode: AztecNode;
@@ -83,11 +89,19 @@ export async function deploySponsoredTestAccountsWithTokens(
83
89
 
84
90
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
85
91
  const recipientDeployMethod = await recipientAccount.getDeployMethod();
86
- await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
92
+ await recipientDeployMethod.send({
93
+ from: NO_FROM,
94
+ fee: { paymentMethod },
95
+ wait: { timeout: 2400 },
96
+ });
87
97
  await Promise.all(
88
98
  fundedAccounts.map(async a => {
89
99
  const deployMethod = await a.getDeployMethod();
90
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
100
+ await deployMethod.send({
101
+ from: NO_FROM,
102
+ fee: { paymentMethod },
103
+ wait: { timeout: 2400 },
104
+ }); // increase timeout on purpose in order to account for two empty epochs
91
105
  logger.info(`Account deployed at ${a.address}`);
92
106
  }),
93
107
  );
@@ -115,11 +129,103 @@ export async function deploySponsoredTestAccountsWithTokens(
115
129
  };
116
130
  }
117
131
 
132
+ async function deployAccountWithDiagnostics(
133
+ account: { getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>; address: any },
134
+ paymentMethod: SponsoredFeePaymentMethod,
135
+ aztecNode: AztecNode,
136
+ logger: Logger,
137
+ accountLabel: string,
138
+ estimateGas?: boolean,
139
+ ): Promise<void> {
140
+ const deployMethod = await account.getDeployMethod();
141
+ let gasSettings: any;
142
+ if (estimateGas) {
143
+ const sim = await deployMethod.simulate({ from: NO_FROM, fee: { paymentMethod } });
144
+ gasSettings = sim.estimatedGas;
145
+ logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
146
+ }
147
+
148
+ // Track the tx hash across retries so we don't re-send when the previous tx is still pending.
149
+ let sentTxHash: { txHash: any } | undefined;
150
+
151
+ await retry(
152
+ async () => {
153
+ // Check if already deployed (handles case where previous attempt succeeded but waitForTx timed out)
154
+ const existing = await aztecNode.getContract(account.address);
155
+ if (existing) {
156
+ logger.info(`${accountLabel} already deployed at ${account.address}, skipping`);
157
+ return;
158
+ }
159
+
160
+ // If we already sent a tx, check if it was dropped before deciding to re-send.
161
+ if (sentTxHash) {
162
+ const prevReceipt = await aztecNode.getTxReceipt(sentTxHash.txHash);
163
+ if (prevReceipt.isDropped()) {
164
+ logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} was dropped, re-sending`);
165
+ sentTxHash = undefined;
166
+ } else {
167
+ logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} still pending, waiting again...`);
168
+ }
169
+ }
170
+
171
+ if (!sentTxHash) {
172
+ const deployResult = await deployMethod.send({
173
+ from: NO_FROM,
174
+ fee: { paymentMethod, gasSettings },
175
+ wait: NO_WAIT,
176
+ });
177
+ sentTxHash = { txHash: deployResult.txHash };
178
+ logger.info(`${accountLabel} tx sent`, { txHash: sentTxHash.txHash.toString() });
179
+ }
180
+
181
+ const receipt = await waitForTx(aztecNode, sentTxHash.txHash, { timeout: 600 });
182
+ if (receipt.isDropped()) {
183
+ sentTxHash = undefined;
184
+ throw new Error(`${accountLabel} tx was dropped, retrying...`);
185
+ }
186
+ logger.info(`${accountLabel} deployed at ${account.address}`);
187
+ },
188
+ `deploy ${accountLabel}`,
189
+ makeBackoff([1, 2, 4, 8, 16]),
190
+ logger,
191
+ );
192
+ }
193
+
194
+ async function deployAccountsInBatches(
195
+ accounts: {
196
+ getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>;
197
+ address: any;
198
+ }[],
199
+ paymentMethod: SponsoredFeePaymentMethod,
200
+ aztecNode: AztecNode,
201
+ logger: Logger,
202
+ labelPrefix: string,
203
+ batchSize = 2,
204
+ estimateGas?: boolean,
205
+ ): Promise<void> {
206
+ for (let i = 0; i < accounts.length; i += batchSize) {
207
+ const batch = accounts.slice(i, i + batchSize);
208
+ await Promise.all(
209
+ batch.map((account, idx) =>
210
+ deployAccountWithDiagnostics(
211
+ account,
212
+ paymentMethod,
213
+ aztecNode,
214
+ logger,
215
+ `${labelPrefix}${i + idx + 1}`,
216
+ estimateGas,
217
+ ),
218
+ ),
219
+ );
220
+ }
221
+ }
222
+
118
223
  export async function deploySponsoredTestAccounts(
119
224
  wallet: TestWallet,
120
225
  aztecNode: AztecNode,
121
226
  logger: Logger,
122
227
  numberOfFundedWallets = 1,
228
+ opts?: { estimateGas?: boolean },
123
229
  ): Promise<TestAccountsWithoutTokens> {
124
230
  const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
125
231
  const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
@@ -128,14 +234,23 @@ export async function deploySponsoredTestAccounts(
128
234
  await registerSponsoredFPC(wallet);
129
235
 
130
236
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
131
- const recipientDeployMethod = await recipientAccount.getDeployMethod();
132
- await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
133
- await Promise.all(
134
- fundedAccounts.map(async a => {
135
- const deployMethod = await a.getDeployMethod();
136
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
137
- logger.info(`Account deployed at ${a.address}`);
138
- }),
237
+
238
+ await deployAccountWithDiagnostics(
239
+ recipientAccount,
240
+ paymentMethod,
241
+ aztecNode,
242
+ logger,
243
+ 'Recipient account',
244
+ opts?.estimateGas,
245
+ );
246
+ await deployAccountsInBatches(
247
+ fundedAccounts,
248
+ paymentMethod,
249
+ aztecNode,
250
+ logger,
251
+ 'Funded account ',
252
+ 2,
253
+ opts?.estimateGas,
139
254
  );
140
255
 
141
256
  return {
@@ -174,7 +289,7 @@ export async function deployTestAccountsWithTokens(
174
289
  fundedAccounts.map(async (a, i) => {
175
290
  const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
176
291
  const deployMethod = await a.getDeployMethod();
177
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait();
292
+ await deployMethod.send({ from: NO_FROM, fee: { paymentMethod } });
178
293
  logger.info(`Account deployed at ${a.address}`);
179
294
  }),
180
295
  );
@@ -218,7 +333,7 @@ async function bridgeL1FeeJuice(
218
333
  const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
219
334
 
220
335
  const isSynced = async () =>
221
- (await aztecNode.getL1ToL2MessageBlock(Fr.fromHexString(claim.messageHash))) !== undefined;
336
+ (await aztecNode.getL1ToL2MessageCheckpoint(Fr.fromHexString(claim.messageHash))) !== undefined;
222
337
  await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
223
338
 
224
339
  log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
@@ -250,14 +365,19 @@ async function deployTokenAndMint(
250
365
  logger: Logger,
251
366
  ) {
252
367
  logger.verbose(`Deploying TokenContract...`);
253
- const tokenContract = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS)
254
- .send({
255
- from: admin,
256
- fee: {
257
- paymentMethod,
258
- },
259
- })
260
- .deployed({ timeout: 600 });
368
+ const { contract: tokenContract } = await TokenContract.deploy(
369
+ wallet,
370
+ admin,
371
+ TOKEN_NAME,
372
+ TOKEN_SYMBOL,
373
+ TOKEN_DECIMALS,
374
+ ).send({
375
+ from: admin,
376
+ fee: {
377
+ paymentMethod,
378
+ },
379
+ wait: { timeout: 600 },
380
+ });
261
381
 
262
382
  const tokenAddress = tokenContract.address;
263
383
 
@@ -267,8 +387,7 @@ async function deployTokenAndMint(
267
387
  accounts.map(acc =>
268
388
  TokenContract.at(tokenAddress, wallet)
269
389
  .methods.mint_to_public(acc, mintAmount)
270
- .send({ from: admin, fee: { paymentMethod } })
271
- .wait({ timeout: 600 }),
390
+ .send({ from: admin, fee: { paymentMethod }, wait: { timeout: 600 } }),
272
391
  ),
273
392
  );
274
393
 
@@ -308,17 +427,23 @@ export async function performTransfers({
308
427
 
309
428
  const provenTxs = await Promise.all(txs);
310
429
 
311
- await Promise.all(provenTxs.map(t => t.send().wait({ timeout: 600 })));
430
+ await Promise.all(provenTxs.map(t => t.send({ wait: { timeout: 600 } })));
312
431
 
313
432
  logger.info(`Completed round ${i + 1} / ${rounds}`);
314
433
  }
315
434
  }
316
435
 
436
+ export type WalletWrapper = {
437
+ wallet: TestWallet;
438
+ aztecNode: AztecNode;
439
+ cleanup: () => Promise<void>;
440
+ };
441
+
317
442
  export async function createWalletAndAztecNodeClient(
318
443
  nodeUrl: string,
319
444
  proverEnabled: boolean,
320
445
  logger: Logger,
321
- ): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise<void> }> {
446
+ ): Promise<WalletWrapper> {
322
447
  const aztecNode = createAztecNodeClient(nodeUrl);
323
448
  const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
324
449
  const pxeConfig = {
@@ -340,3 +465,42 @@ export async function createWalletAndAztecNodeClient(
340
465
  },
341
466
  };
342
467
  }
468
+
469
+ export type WorkerWalletWrapper = {
470
+ wallet: WorkerWallet;
471
+ aztecNode: AztecNode;
472
+ cleanup: () => Promise<void>;
473
+ };
474
+
475
+ export async function createWorkerWalletClient(
476
+ nodeUrl: string,
477
+ proverEnabled: boolean,
478
+ logger: Logger,
479
+ ): Promise<WorkerWalletWrapper> {
480
+ const aztecNode = createAztecNodeClient(nodeUrl);
481
+ const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
482
+
483
+ // Strip cleanup functions — they can't be structured-cloned for worker transfer
484
+ const { cleanup: bbCleanup, ...bbPaths } = bbConfig ?? {};
485
+ const { cleanup: acvmCleanup, ...acvmPaths } = acvmConfig ?? {};
486
+
487
+ const pxeConfig = {
488
+ dataDirectory: undefined,
489
+ dataStoreMapSizeKb: 1024 * 1024,
490
+ ...bbPaths,
491
+ ...acvmPaths,
492
+ proverEnabled,
493
+ };
494
+
495
+ const wallet = await WorkerWallet.create(nodeUrl, pxeConfig);
496
+
497
+ return {
498
+ wallet,
499
+ aztecNode,
500
+ async cleanup() {
501
+ await wallet.stop();
502
+ await bbCleanup?.();
503
+ await acvmCleanup?.();
504
+ },
505
+ };
506
+ }
@@ -0,0 +1,388 @@
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import type { Logger } from '@aztec/foundation/log';
3
+ import type { BlockResponse } from '@aztec/stdlib/interfaces/client';
4
+ import type { TopicType } from '@aztec/stdlib/p2p';
5
+ import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
6
+
7
+ import { createHistogram } from 'perf_hooks';
8
+
9
+ /** Metrics class for proving-related benchmarks. */
10
+ export class ProvingMetrics {
11
+ private successfulTxs: number | undefined;
12
+ private proofDuration: number | undefined;
13
+ private activeAgents: number | undefined;
14
+ private avgQueueTime: number | undefined;
15
+ private jobRetries: number | undefined;
16
+ private jobDuration: number | undefined;
17
+ private timedOutJobs: number | undefined;
18
+ private resolvedJobs: number | undefined;
19
+ private rejectedJobs: number | undefined;
20
+ private epochProvingDuration: number | undefined;
21
+ private provenTransactions: number | undefined;
22
+ private provenBlocks: number | undefined;
23
+
24
+ constructor(private prefix: string) {}
25
+
26
+ recordSuccessfulTxs(count: number): void {
27
+ this.successfulTxs = count;
28
+ }
29
+
30
+ recordProofDuration(seconds: number): void {
31
+ this.proofDuration = seconds;
32
+ }
33
+
34
+ recordActiveAgents(count: number): void {
35
+ this.activeAgents = count;
36
+ }
37
+
38
+ recordAvgQueueTime(ms: number): void {
39
+ this.avgQueueTime = ms;
40
+ }
41
+
42
+ recordJobRetries(count: number): void {
43
+ this.jobRetries = count;
44
+ }
45
+
46
+ recordJobDuration(ms: number): void {
47
+ this.jobDuration = ms;
48
+ }
49
+
50
+ recordTimedOutJobs(count: number): void {
51
+ this.timedOutJobs = count;
52
+ }
53
+
54
+ recordResolvedJobs(count: number): void {
55
+ this.resolvedJobs = count;
56
+ }
57
+
58
+ recordRejectedJobs(count: number): void {
59
+ this.rejectedJobs = count;
60
+ }
61
+
62
+ recordEpochProvingDuration(seconds: number): void {
63
+ this.epochProvingDuration = seconds;
64
+ }
65
+
66
+ recordProvenTransactions(count: number): void {
67
+ this.provenTransactions = count;
68
+ }
69
+
70
+ recordProvenBlocks(count: number): void {
71
+ this.provenBlocks = count;
72
+ }
73
+
74
+ toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number }> {
75
+ const data: Array<{ name: string; unit: string; value: number }> = [];
76
+
77
+ if (this.successfulTxs !== undefined) {
78
+ data.push({ name: `${this.prefix}/successful_txs`, unit: 'count', value: this.successfulTxs });
79
+ }
80
+
81
+ if (this.proofDuration !== undefined) {
82
+ data.push({ name: `${this.prefix}/proof_duration`, unit: 's', value: this.proofDuration });
83
+ }
84
+
85
+ if (this.activeAgents !== undefined) {
86
+ data.push({ name: `${this.prefix}/active_agents`, unit: 'count', value: this.activeAgents });
87
+ }
88
+
89
+ if (this.avgQueueTime !== undefined) {
90
+ data.push({ name: `${this.prefix}/avg_queue_time`, unit: 'ms', value: this.avgQueueTime });
91
+ }
92
+
93
+ if (this.jobRetries !== undefined) {
94
+ data.push({ name: `${this.prefix}/job_retries`, unit: 'count', value: this.jobRetries });
95
+ }
96
+
97
+ if (this.jobDuration !== undefined) {
98
+ data.push({ name: `${this.prefix}/job_duration`, unit: 'ms', value: this.jobDuration });
99
+ }
100
+
101
+ if (this.timedOutJobs !== undefined) {
102
+ data.push({ name: `${this.prefix}/timed_out_jobs`, unit: 'count', value: this.timedOutJobs });
103
+ }
104
+
105
+ if (this.resolvedJobs !== undefined) {
106
+ data.push({ name: `${this.prefix}/resolved_jobs`, unit: 'count', value: this.resolvedJobs });
107
+ }
108
+
109
+ if (this.rejectedJobs !== undefined) {
110
+ data.push({ name: `${this.prefix}/rejected_jobs`, unit: 'count', value: this.rejectedJobs });
111
+ }
112
+
113
+ if (this.epochProvingDuration !== undefined) {
114
+ data.push({ name: `${this.prefix}/epoch_proving_duration`, unit: 's', value: this.epochProvingDuration });
115
+ }
116
+
117
+ if (this.provenTransactions !== undefined) {
118
+ data.push({ name: `${this.prefix}/proven_transactions`, unit: 'count', value: this.provenTransactions });
119
+ }
120
+
121
+ if (this.provenBlocks !== undefined) {
122
+ data.push({ name: `${this.prefix}/proven_blocks`, unit: 'count', value: this.provenBlocks });
123
+ }
124
+
125
+ const scenario = process.env.BENCH_SCENARIO?.trim();
126
+ if (!scenario) {
127
+ return data;
128
+ }
129
+
130
+ const scenarioPrefix = `scenario/${scenario}/`;
131
+ return data.map(entry => ({ ...entry, name: `${scenarioPrefix}${entry.name}` }));
132
+ }
133
+ }
134
+
135
+ export type TxInclusionData = {
136
+ txHash: string;
137
+ sentAt: number;
138
+ minedAt: number;
139
+ attestedAt: number;
140
+ blocknumber: number;
141
+ priorityFee: number;
142
+ totalFee: number;
143
+ positionInBlock: number;
144
+ group: string;
145
+ };
146
+
147
+ export class TxInclusionMetrics {
148
+ private data = new Map<string, TxInclusionData>();
149
+ private groups = new Set<string>();
150
+ private blocks = new Map<number, Promise<BlockResponse<{ includeTransactions: true }> | undefined>>();
151
+
152
+ private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
153
+
154
+ private attestationLatency: { p50: number; p95: number } | undefined;
155
+ private attestationCounts: { success: number; failedBad: number; failedNode: number } | undefined;
156
+ private reqRespStats: { fraction: number; delayP50: number; delayP95: number } | undefined;
157
+ private peerStats: { avgCount: number; connectionDurationP50: number; connectionDurationP95: number } | undefined;
158
+ private mempoolMinedDelay:
159
+ | { txP50: number; txP95: number; attestationP50: number; attestationP95: number }
160
+ | undefined;
161
+
162
+ constructor(
163
+ private aztecNode: AztecNode,
164
+ private logger?: Logger,
165
+ ) {}
166
+
167
+ recordSentTx(tx: Tx, group: string): void {
168
+ const txHash = tx.getTxHash().toString();
169
+ const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
170
+
171
+ if (this.data.has(txHash)) {
172
+ this.logger?.debug(`Overwriting tx inclusion data for ${txHash}`, { txHash, group });
173
+ }
174
+
175
+ this.data.set(txHash, {
176
+ txHash,
177
+ sentAt: Math.trunc(Date.now() / 1000),
178
+ minedAt: -1,
179
+ attestedAt: -1,
180
+ blocknumber: -1,
181
+ priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
182
+ totalFee: -1,
183
+ positionInBlock: -1,
184
+ group,
185
+ });
186
+ this.groups.add(group);
187
+ }
188
+
189
+ async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
190
+ const { txHash, blockNumber } = txReceipt;
191
+ if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
192
+ this.logger?.debug('Skipping mined tx record due to receipt status', {
193
+ txHash: txHash.toString(),
194
+ status: txReceipt.status,
195
+ blockNumber,
196
+ });
197
+ return;
198
+ }
199
+
200
+ if (!this.blocks.has(blockNumber)) {
201
+ this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber, { includeTransactions: true }));
202
+ }
203
+
204
+ const block = await this.blocks.get(blockNumber)!;
205
+ if (!block) {
206
+ this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
207
+ return;
208
+ }
209
+ const data = this.data.get(txHash.toString());
210
+ if (!data) {
211
+ const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
212
+ this.logger?.warn(message, { txHash: txHash.toString(), blockNumber });
213
+ throw new Error(message);
214
+ }
215
+ data.blocknumber = blockNumber;
216
+ data.minedAt = Number(block.header.globalVariables.timestamp);
217
+ data.attestedAt = -1;
218
+ data.totalFee = Number(txReceipt.transactionFee ?? 0n);
219
+ data.positionInBlock = block.body.txEffects.findIndex(txEffect => txEffect.txHash.equals(txHash));
220
+ }
221
+
222
+ public inclusionTimeInSeconds(group: string): {
223
+ count: number;
224
+ group: string;
225
+ min: number;
226
+ mean: number;
227
+ max: number;
228
+ median: number;
229
+ p99: number;
230
+ } {
231
+ const histogram = createHistogram({});
232
+ let nonPositive = 0;
233
+ for (const tx of this.data.values()) {
234
+ if (!tx.blocknumber || tx.group !== group || tx.minedAt === -1) {
235
+ continue;
236
+ }
237
+
238
+ // `minedAt` is the block's L2 slot timestamp (seconds) while `sentAt` is the wall-clock
239
+ // send time. Because the slot timestamp can precede or equal the send time, the delta
240
+ // can be <= 0, which perf_hooks.createHistogram rejects. Skip those instead of crashing.
241
+ const delta = tx.minedAt - tx.sentAt;
242
+ if (delta <= 0) {
243
+ nonPositive++;
244
+ continue;
245
+ }
246
+ histogram.record(delta);
247
+ }
248
+ if (nonPositive > 0) {
249
+ this.logger?.debug(`Dropped ${nonPositive} tx inclusion samples with non-positive delta`, { group });
250
+ }
251
+
252
+ if (histogram.count === 0) {
253
+ return {
254
+ group,
255
+ count: 0,
256
+ mean: 0,
257
+ max: 0,
258
+ median: 0,
259
+ min: 0,
260
+ p99: 0,
261
+ };
262
+ }
263
+
264
+ return {
265
+ group,
266
+ count: histogram.count,
267
+ mean: histogram.mean,
268
+ max: histogram.max,
269
+ median: histogram.percentile(50),
270
+ min: histogram.min,
271
+ p99: histogram.percentile(99),
272
+ };
273
+ }
274
+
275
+ public recordP2PGossipLatency(topicName: TopicType, p50: number, p95: number): void {
276
+ this.p2pGossipLatencyByTopic[topicName] = { p50, p95 };
277
+ }
278
+
279
+ public recordAttestationLatency(p50: number, p95: number): void {
280
+ this.attestationLatency = { p50, p95 };
281
+ }
282
+
283
+ public recordAttestationCounts(success: number, failedBad: number, failedNode: number): void {
284
+ this.attestationCounts = { success, failedBad, failedNode };
285
+ }
286
+
287
+ public recordReqRespStats(fraction: number, delayP50: number, delayP95: number): void {
288
+ this.reqRespStats = { fraction, delayP50, delayP95 };
289
+ }
290
+
291
+ public recordPeerStats(avgCount: number, connectionDurationP50: number, connectionDurationP95: number): void {
292
+ this.peerStats = { avgCount, connectionDurationP50, connectionDurationP95 };
293
+ }
294
+
295
+ public recordMempoolMinedDelay(txP50: number, txP95: number, attestationP50: number, attestationP95: number): void {
296
+ this.mempoolMinedDelay = { txP50, txP95, attestationP50, attestationP95 };
297
+ }
298
+
299
+ toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> {
300
+ const data: Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> = [];
301
+ for (const group of this.groups) {
302
+ const stats = this.inclusionTimeInSeconds(group);
303
+
304
+ data.push(
305
+ {
306
+ name: `${group}/avg_inclusion`,
307
+ unit: 's',
308
+ value: stats.mean,
309
+ },
310
+ {
311
+ name: `${group}/p50_inclusion`,
312
+ unit: 's',
313
+ value: stats.median,
314
+ },
315
+ {
316
+ name: `${group}/p99_inclusion`,
317
+ unit: 's',
318
+ value: stats.p99,
319
+ },
320
+ );
321
+ }
322
+
323
+ for (const [topic, { p50, p95 }] of Object.entries(this.p2pGossipLatencyByTopic)) {
324
+ data.push({
325
+ name: `p2p_gossip_latency/${topic}/p50`,
326
+ unit: 'ms',
327
+ value: p50,
328
+ });
329
+ data.push({
330
+ name: `p2p_gossip_latency/${topic}/p95`,
331
+ unit: 'ms',
332
+ value: p95,
333
+ });
334
+ }
335
+
336
+ if (this.attestationLatency) {
337
+ data.push(
338
+ { name: 'attestation_latency/p50', unit: 'ms', value: this.attestationLatency.p50 },
339
+ { name: 'attestation_latency/p95', unit: 'ms', value: this.attestationLatency.p95 },
340
+ );
341
+ }
342
+
343
+ if (this.attestationCounts) {
344
+ const { success, failedBad, failedNode } = this.attestationCounts;
345
+ const total = success + failedBad + failedNode;
346
+ const ratio = total > 0 ? success / total : 0;
347
+ data.push(
348
+ { name: 'attestation/success_count', unit: 'count', value: success },
349
+ { name: 'attestation/failed_bad_proposal_count', unit: 'count', value: failedBad },
350
+ { name: 'attestation/failed_node_issue_count', unit: 'count', value: failedNode },
351
+ { name: 'attestation/success_ratio', unit: 'ratio', value: ratio },
352
+ );
353
+ }
354
+
355
+ if (this.reqRespStats) {
356
+ data.push(
357
+ { name: 'req_resp/txs_requested_fraction', unit: 'ratio', value: this.reqRespStats.fraction },
358
+ { name: 'req_resp/delay_p50', unit: 'ms', value: this.reqRespStats.delayP50 },
359
+ { name: 'req_resp/delay_p95', unit: 'ms', value: this.reqRespStats.delayP95 },
360
+ );
361
+ }
362
+
363
+ if (this.peerStats) {
364
+ data.push(
365
+ { name: 'peers/avg_count', unit: 'peers', value: this.peerStats.avgCount },
366
+ { name: 'peers/connection_duration_p50', unit: 'ms', value: this.peerStats.connectionDurationP50 },
367
+ { name: 'peers/connection_duration_p95', unit: 'ms', value: this.peerStats.connectionDurationP95 },
368
+ );
369
+ }
370
+
371
+ if (this.mempoolMinedDelay) {
372
+ data.push(
373
+ { name: 'mempool/tx_mined_delay_p50', unit: 'ms', value: this.mempoolMinedDelay.txP50 },
374
+ { name: 'mempool/tx_mined_delay_p95', unit: 'ms', value: this.mempoolMinedDelay.txP95 },
375
+ { name: 'mempool/attestation_mined_delay_p50', unit: 'ms', value: this.mempoolMinedDelay.attestationP50 },
376
+ { name: 'mempool/attestation_mined_delay_p95', unit: 'ms', value: this.mempoolMinedDelay.attestationP95 },
377
+ );
378
+ }
379
+
380
+ const scenario = process.env.BENCH_SCENARIO?.trim();
381
+ if (!scenario) {
382
+ return data;
383
+ }
384
+
385
+ const scenarioPrefix = `scenario/${scenario}/`;
386
+ return data.map(entry => ({ ...entry, name: `${scenarioPrefix}${entry.name}` }));
387
+ }
388
+ }