@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
@@ -0,0 +1,438 @@
1
+ import { createHistogram } from 'perf_hooks';
2
+ /** Metrics class for proving-related benchmarks. */ export class ProvingMetrics {
3
+ prefix;
4
+ successfulTxs;
5
+ proofDuration;
6
+ activeAgents;
7
+ avgQueueTime;
8
+ jobRetries;
9
+ jobDuration;
10
+ timedOutJobs;
11
+ resolvedJobs;
12
+ rejectedJobs;
13
+ epochProvingDuration;
14
+ provenTransactions;
15
+ provenBlocks;
16
+ constructor(prefix){
17
+ this.prefix = prefix;
18
+ }
19
+ recordSuccessfulTxs(count) {
20
+ this.successfulTxs = count;
21
+ }
22
+ recordProofDuration(seconds) {
23
+ this.proofDuration = seconds;
24
+ }
25
+ recordActiveAgents(count) {
26
+ this.activeAgents = count;
27
+ }
28
+ recordAvgQueueTime(ms) {
29
+ this.avgQueueTime = ms;
30
+ }
31
+ recordJobRetries(count) {
32
+ this.jobRetries = count;
33
+ }
34
+ recordJobDuration(ms) {
35
+ this.jobDuration = ms;
36
+ }
37
+ recordTimedOutJobs(count) {
38
+ this.timedOutJobs = count;
39
+ }
40
+ recordResolvedJobs(count) {
41
+ this.resolvedJobs = count;
42
+ }
43
+ recordRejectedJobs(count) {
44
+ this.rejectedJobs = count;
45
+ }
46
+ recordEpochProvingDuration(seconds) {
47
+ this.epochProvingDuration = seconds;
48
+ }
49
+ recordProvenTransactions(count) {
50
+ this.provenTransactions = count;
51
+ }
52
+ recordProvenBlocks(count) {
53
+ this.provenBlocks = count;
54
+ }
55
+ toGithubActionBenchmarkJSON() {
56
+ const data = [];
57
+ if (this.successfulTxs !== undefined) {
58
+ data.push({
59
+ name: `${this.prefix}/successful_txs`,
60
+ unit: 'count',
61
+ value: this.successfulTxs
62
+ });
63
+ }
64
+ if (this.proofDuration !== undefined) {
65
+ data.push({
66
+ name: `${this.prefix}/proof_duration`,
67
+ unit: 's',
68
+ value: this.proofDuration
69
+ });
70
+ }
71
+ if (this.activeAgents !== undefined) {
72
+ data.push({
73
+ name: `${this.prefix}/active_agents`,
74
+ unit: 'count',
75
+ value: this.activeAgents
76
+ });
77
+ }
78
+ if (this.avgQueueTime !== undefined) {
79
+ data.push({
80
+ name: `${this.prefix}/avg_queue_time`,
81
+ unit: 'ms',
82
+ value: this.avgQueueTime
83
+ });
84
+ }
85
+ if (this.jobRetries !== undefined) {
86
+ data.push({
87
+ name: `${this.prefix}/job_retries`,
88
+ unit: 'count',
89
+ value: this.jobRetries
90
+ });
91
+ }
92
+ if (this.jobDuration !== undefined) {
93
+ data.push({
94
+ name: `${this.prefix}/job_duration`,
95
+ unit: 'ms',
96
+ value: this.jobDuration
97
+ });
98
+ }
99
+ if (this.timedOutJobs !== undefined) {
100
+ data.push({
101
+ name: `${this.prefix}/timed_out_jobs`,
102
+ unit: 'count',
103
+ value: this.timedOutJobs
104
+ });
105
+ }
106
+ if (this.resolvedJobs !== undefined) {
107
+ data.push({
108
+ name: `${this.prefix}/resolved_jobs`,
109
+ unit: 'count',
110
+ value: this.resolvedJobs
111
+ });
112
+ }
113
+ if (this.rejectedJobs !== undefined) {
114
+ data.push({
115
+ name: `${this.prefix}/rejected_jobs`,
116
+ unit: 'count',
117
+ value: this.rejectedJobs
118
+ });
119
+ }
120
+ if (this.epochProvingDuration !== undefined) {
121
+ data.push({
122
+ name: `${this.prefix}/epoch_proving_duration`,
123
+ unit: 's',
124
+ value: this.epochProvingDuration
125
+ });
126
+ }
127
+ if (this.provenTransactions !== undefined) {
128
+ data.push({
129
+ name: `${this.prefix}/proven_transactions`,
130
+ unit: 'count',
131
+ value: this.provenTransactions
132
+ });
133
+ }
134
+ if (this.provenBlocks !== undefined) {
135
+ data.push({
136
+ name: `${this.prefix}/proven_blocks`,
137
+ unit: 'count',
138
+ value: this.provenBlocks
139
+ });
140
+ }
141
+ const scenario = process.env.BENCH_SCENARIO?.trim();
142
+ if (!scenario) {
143
+ return data;
144
+ }
145
+ const scenarioPrefix = `scenario/${scenario}/`;
146
+ return data.map((entry)=>({
147
+ ...entry,
148
+ name: `${scenarioPrefix}${entry.name}`
149
+ }));
150
+ }
151
+ }
152
+ export class TxInclusionMetrics {
153
+ aztecNode;
154
+ logger;
155
+ data;
156
+ groups;
157
+ blocks;
158
+ p2pGossipLatencyByTopic;
159
+ attestationLatency;
160
+ attestationCounts;
161
+ reqRespStats;
162
+ peerStats;
163
+ mempoolMinedDelay;
164
+ constructor(aztecNode, logger){
165
+ this.aztecNode = aztecNode;
166
+ this.logger = logger;
167
+ this.data = new Map();
168
+ this.groups = new Set();
169
+ this.blocks = new Map();
170
+ this.p2pGossipLatencyByTopic = {};
171
+ }
172
+ recordSentTx(tx, group) {
173
+ const txHash = tx.getTxHash().toString();
174
+ const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
175
+ if (this.data.has(txHash)) {
176
+ this.logger?.debug(`Overwriting tx inclusion data for ${txHash}`, {
177
+ txHash,
178
+ group
179
+ });
180
+ }
181
+ this.data.set(txHash, {
182
+ txHash,
183
+ sentAt: Math.trunc(Date.now() / 1000),
184
+ minedAt: -1,
185
+ attestedAt: -1,
186
+ blocknumber: -1,
187
+ priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
188
+ totalFee: -1,
189
+ positionInBlock: -1,
190
+ group
191
+ });
192
+ this.groups.add(group);
193
+ }
194
+ async recordMinedTx(txReceipt) {
195
+ const { txHash, blockNumber } = txReceipt;
196
+ if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
197
+ this.logger?.debug('Skipping mined tx record due to receipt status', {
198
+ txHash: txHash.toString(),
199
+ status: txReceipt.status,
200
+ blockNumber
201
+ });
202
+ return;
203
+ }
204
+ if (!this.blocks.has(blockNumber)) {
205
+ this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber, {
206
+ includeTransactions: true
207
+ }));
208
+ }
209
+ const block = await this.blocks.get(blockNumber);
210
+ if (!block) {
211
+ this.logger?.warn('Failed to load block for mined tx receipt', {
212
+ txHash: txHash.toString(),
213
+ blockNumber
214
+ });
215
+ return;
216
+ }
217
+ const data = this.data.get(txHash.toString());
218
+ if (!data) {
219
+ const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
220
+ this.logger?.warn(message, {
221
+ txHash: txHash.toString(),
222
+ blockNumber
223
+ });
224
+ throw new Error(message);
225
+ }
226
+ data.blocknumber = blockNumber;
227
+ data.minedAt = Number(block.header.globalVariables.timestamp);
228
+ data.attestedAt = -1;
229
+ data.totalFee = Number(txReceipt.transactionFee ?? 0n);
230
+ data.positionInBlock = block.body.txEffects.findIndex((txEffect)=>txEffect.txHash.equals(txHash));
231
+ }
232
+ inclusionTimeInSeconds(group) {
233
+ const histogram = createHistogram({});
234
+ let nonPositive = 0;
235
+ for (const tx of this.data.values()){
236
+ if (!tx.blocknumber || tx.group !== group || tx.minedAt === -1) {
237
+ continue;
238
+ }
239
+ // `minedAt` is the block's L2 slot timestamp (seconds) while `sentAt` is the wall-clock
240
+ // send time. Because the slot timestamp can precede or equal the send time, the delta
241
+ // can be <= 0, which perf_hooks.createHistogram rejects. Skip those instead of crashing.
242
+ const delta = tx.minedAt - tx.sentAt;
243
+ if (delta <= 0) {
244
+ nonPositive++;
245
+ continue;
246
+ }
247
+ histogram.record(delta);
248
+ }
249
+ if (nonPositive > 0) {
250
+ this.logger?.debug(`Dropped ${nonPositive} tx inclusion samples with non-positive delta`, {
251
+ group
252
+ });
253
+ }
254
+ if (histogram.count === 0) {
255
+ return {
256
+ group,
257
+ count: 0,
258
+ mean: 0,
259
+ max: 0,
260
+ median: 0,
261
+ min: 0,
262
+ p99: 0
263
+ };
264
+ }
265
+ return {
266
+ group,
267
+ count: histogram.count,
268
+ mean: histogram.mean,
269
+ max: histogram.max,
270
+ median: histogram.percentile(50),
271
+ min: histogram.min,
272
+ p99: histogram.percentile(99)
273
+ };
274
+ }
275
+ recordP2PGossipLatency(topicName, p50, p95) {
276
+ this.p2pGossipLatencyByTopic[topicName] = {
277
+ p50,
278
+ p95
279
+ };
280
+ }
281
+ recordAttestationLatency(p50, p95) {
282
+ this.attestationLatency = {
283
+ p50,
284
+ p95
285
+ };
286
+ }
287
+ recordAttestationCounts(success, failedBad, failedNode) {
288
+ this.attestationCounts = {
289
+ success,
290
+ failedBad,
291
+ failedNode
292
+ };
293
+ }
294
+ recordReqRespStats(fraction, delayP50, delayP95) {
295
+ this.reqRespStats = {
296
+ fraction,
297
+ delayP50,
298
+ delayP95
299
+ };
300
+ }
301
+ recordPeerStats(avgCount, connectionDurationP50, connectionDurationP95) {
302
+ this.peerStats = {
303
+ avgCount,
304
+ connectionDurationP50,
305
+ connectionDurationP95
306
+ };
307
+ }
308
+ recordMempoolMinedDelay(txP50, txP95, attestationP50, attestationP95) {
309
+ this.mempoolMinedDelay = {
310
+ txP50,
311
+ txP95,
312
+ attestationP50,
313
+ attestationP95
314
+ };
315
+ }
316
+ toGithubActionBenchmarkJSON() {
317
+ const data = [];
318
+ for (const group of this.groups){
319
+ const stats = this.inclusionTimeInSeconds(group);
320
+ data.push({
321
+ name: `${group}/avg_inclusion`,
322
+ unit: 's',
323
+ value: stats.mean
324
+ }, {
325
+ name: `${group}/p50_inclusion`,
326
+ unit: 's',
327
+ value: stats.median
328
+ }, {
329
+ name: `${group}/p99_inclusion`,
330
+ unit: 's',
331
+ value: stats.p99
332
+ });
333
+ }
334
+ for (const [topic, { p50, p95 }] of Object.entries(this.p2pGossipLatencyByTopic)){
335
+ data.push({
336
+ name: `p2p_gossip_latency/${topic}/p50`,
337
+ unit: 'ms',
338
+ value: p50
339
+ });
340
+ data.push({
341
+ name: `p2p_gossip_latency/${topic}/p95`,
342
+ unit: 'ms',
343
+ value: p95
344
+ });
345
+ }
346
+ if (this.attestationLatency) {
347
+ data.push({
348
+ name: 'attestation_latency/p50',
349
+ unit: 'ms',
350
+ value: this.attestationLatency.p50
351
+ }, {
352
+ name: 'attestation_latency/p95',
353
+ unit: 'ms',
354
+ value: this.attestationLatency.p95
355
+ });
356
+ }
357
+ if (this.attestationCounts) {
358
+ const { success, failedBad, failedNode } = this.attestationCounts;
359
+ const total = success + failedBad + failedNode;
360
+ const ratio = total > 0 ? success / total : 0;
361
+ data.push({
362
+ name: 'attestation/success_count',
363
+ unit: 'count',
364
+ value: success
365
+ }, {
366
+ name: 'attestation/failed_bad_proposal_count',
367
+ unit: 'count',
368
+ value: failedBad
369
+ }, {
370
+ name: 'attestation/failed_node_issue_count',
371
+ unit: 'count',
372
+ value: failedNode
373
+ }, {
374
+ name: 'attestation/success_ratio',
375
+ unit: 'ratio',
376
+ value: ratio
377
+ });
378
+ }
379
+ if (this.reqRespStats) {
380
+ data.push({
381
+ name: 'req_resp/txs_requested_fraction',
382
+ unit: 'ratio',
383
+ value: this.reqRespStats.fraction
384
+ }, {
385
+ name: 'req_resp/delay_p50',
386
+ unit: 'ms',
387
+ value: this.reqRespStats.delayP50
388
+ }, {
389
+ name: 'req_resp/delay_p95',
390
+ unit: 'ms',
391
+ value: this.reqRespStats.delayP95
392
+ });
393
+ }
394
+ if (this.peerStats) {
395
+ data.push({
396
+ name: 'peers/avg_count',
397
+ unit: 'peers',
398
+ value: this.peerStats.avgCount
399
+ }, {
400
+ name: 'peers/connection_duration_p50',
401
+ unit: 'ms',
402
+ value: this.peerStats.connectionDurationP50
403
+ }, {
404
+ name: 'peers/connection_duration_p95',
405
+ unit: 'ms',
406
+ value: this.peerStats.connectionDurationP95
407
+ });
408
+ }
409
+ if (this.mempoolMinedDelay) {
410
+ data.push({
411
+ name: 'mempool/tx_mined_delay_p50',
412
+ unit: 'ms',
413
+ value: this.mempoolMinedDelay.txP50
414
+ }, {
415
+ name: 'mempool/tx_mined_delay_p95',
416
+ unit: 'ms',
417
+ value: this.mempoolMinedDelay.txP95
418
+ }, {
419
+ name: 'mempool/attestation_mined_delay_p50',
420
+ unit: 'ms',
421
+ value: this.mempoolMinedDelay.attestationP50
422
+ }, {
423
+ name: 'mempool/attestation_mined_delay_p95',
424
+ unit: 'ms',
425
+ value: this.mempoolMinedDelay.attestationP95
426
+ });
427
+ }
428
+ const scenario = process.env.BENCH_SCENARIO?.trim();
429
+ if (!scenario) {
430
+ return data;
431
+ }
432
+ const scenarioPrefix = `scenario/${scenario}/`;
433
+ return data.map((entry)=>({
434
+ ...entry,
435
+ name: `${scenarioPrefix}${entry.name}`
436
+ }));
437
+ }
438
+ }
@@ -0,0 +1,28 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ export declare function restartBot(namespace: string, log: Logger): Promise<void>;
3
+ /**
4
+ * Installs or upgrades the transfer bot Helm release for the given namespace.
5
+ * Intended for test setup to enable L2 traffic generation only when needed.
6
+ */
7
+ export declare function installTransferBot({ namespace, spartanDir, logger: log, replicas, txIntervalSeconds, followChain, pxeSyncChainTip, mnemonic, mnemonicStartIndex, botPrivateKey, nodeUrl, timeout, reuseValues, aztecSlotDuration }: {
8
+ namespace: string;
9
+ spartanDir: string;
10
+ logger: Logger;
11
+ replicas?: number;
12
+ txIntervalSeconds?: number;
13
+ followChain?: string;
14
+ pxeSyncChainTip?: string;
15
+ mnemonic?: string;
16
+ mnemonicStartIndex?: number | string;
17
+ botPrivateKey?: string;
18
+ nodeUrl?: string;
19
+ timeout?: string;
20
+ reuseValues?: boolean;
21
+ aztecSlotDuration?: number;
22
+ }): Promise<void>;
23
+ /**
24
+ * Uninstalls the transfer bot Helm release from the given namespace.
25
+ * Intended for test teardown to clean up bot resources.
26
+ */
27
+ export declare function uninstallTransferBot(namespace: string, log: Logger): Promise<void>;
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3BhcnRhbi91dGlscy9ib3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFXcEQsd0JBQXNCLFVBQVUsQ0FBQyxTQUFTLEVBQUUsTUFBTSxFQUFFLEdBQUcsRUFBRSxNQUFNLGlCQWE5RDtBQUVEOzs7R0FHRztBQUNILHdCQUFzQixrQkFBa0IsQ0FBQyxFQUN2QyxTQUFTLEVBQ1QsVUFBVSxFQUNWLE1BQU0sRUFBRSxHQUFHLEVBQ1gsUUFBWSxFQUNaLGlCQUFzQixFQUN0QixXQUE0QixFQUM1QixlQUE0QixFQUM1QixRQUEyRyxFQUMzRyxrQkFBa0IsRUFDbEIsYUFBc0UsRUFDdEUsT0FBTyxFQUNQLE9BQWUsRUFDZixXQUFrQixFQUNsQixpQkFBaUUsRUFDbEUsRUFBRTtJQUNELFNBQVMsRUFBRSxNQUFNLENBQUM7SUFDbEIsVUFBVSxFQUFFLE1BQU0sQ0FBQztJQUNuQixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBQ2YsUUFBUSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2xCLGlCQUFpQixDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQzNCLFdBQVcsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNyQixlQUFlLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDekIsUUFBUSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2xCLGtCQUFrQixDQUFDLEVBQUUsTUFBTSxHQUFHLE1BQU0sQ0FBQztJQUNyQyxhQUFhLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDdkIsT0FBTyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2pCLE9BQU8sQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNqQixXQUFXLENBQUMsRUFBRSxPQUFPLENBQUM7SUFDdEIsaUJBQWlCLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDNUIsaUJBaUhBO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQXNCLG9CQUFvQixDQUFDLFNBQVMsRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLE1BQU0saUJBUXhFIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/bot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAWpD,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAa9D;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,UAAU,EACV,MAAM,EAAE,GAAG,EACX,QAAY,EACZ,iBAAsB,EACtB,WAA4B,EAC5B,eAA4B,EAC5B,QAA2G,EAC3G,kBAAkB,EAClB,aAAsE,EACtE,OAAO,EACP,OAAe,EACf,WAAkB,EAClB,iBAAiE,EAClE,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,iBAiHA;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAQxE"}
@@ -0,0 +1,142 @@
1
+ import { sleep } from '@aztec/foundation/sleep';
2
+ import { exec } from 'child_process';
3
+ import { promisify } from 'util';
4
+ import { execHelmCommand, forceDeleteHelmReleaseRecord, getHelmReleaseStatus, hasDeployedHelmRelease } from './helm.js';
5
+ import { deleteResourceByLabel, getChartDir, waitForResourceByLabel } from './k8s.js';
6
+ const execAsync = promisify(exec);
7
+ export async function restartBot(namespace, log) {
8
+ log.info(`Restarting bot`);
9
+ await deleteResourceByLabel({
10
+ resource: 'pods',
11
+ namespace,
12
+ label: 'app.kubernetes.io/name=bot'
13
+ });
14
+ await sleep(10 * 1000);
15
+ // Some bot images may take time to report Ready due to heavy boot-time proving.
16
+ // Waiting for PodReadyToStartContainers ensures the pod is scheduled and starting without blocking on full readiness.
17
+ await waitForResourceByLabel({
18
+ resource: 'pods',
19
+ namespace,
20
+ label: 'app.kubernetes.io/name=bot',
21
+ condition: 'PodReadyToStartContainers'
22
+ });
23
+ log.info(`Bot restarted`);
24
+ }
25
+ /**
26
+ * Installs or upgrades the transfer bot Helm release for the given namespace.
27
+ * Intended for test setup to enable L2 traffic generation only when needed.
28
+ */ export async function installTransferBot({ namespace, spartanDir, logger: log, replicas = 1, txIntervalSeconds = 10, followChain = 'CHECKPOINTED', pxeSyncChainTip = 'proposed', mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk', mnemonicStartIndex, botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01', nodeUrl, timeout = '15m', reuseValues = true, aztecSlotDuration = Number(process.env.AZTEC_SLOT_DURATION ?? 12) }) {
29
+ const instanceName = `${namespace}-bot-transfers`;
30
+ const helmChartDir = getChartDir(spartanDir, 'aztec-bot');
31
+ const resolvedNodeUrl = nodeUrl ?? `http://${namespace}-rpc-aztec-node.${namespace}.svc.cluster.local:8080`;
32
+ log.info(`Installing/upgrading transfer bot: replicas=${replicas}, followChain=${followChain}`);
33
+ const values = {
34
+ 'bot.replicaCount': replicas,
35
+ 'bot.txIntervalSeconds': txIntervalSeconds,
36
+ 'bot.followChain': followChain,
37
+ 'bot.pxeSyncChainTip': pxeSyncChainTip,
38
+ 'bot.botPrivateKey': botPrivateKey,
39
+ 'bot.nodeUrl': resolvedNodeUrl,
40
+ 'bot.mnemonic': mnemonic,
41
+ 'bot.feePaymentMethod': 'fee_juice',
42
+ 'aztec.slotDuration': aztecSlotDuration,
43
+ // Ensure bot can reach its own PXE started in-process (default rpc.port is 8080)
44
+ // Note: since aztec-bot depends on aztec-node with alias `bot`, env vars go under `bot.node.env`.
45
+ 'bot.node.env.BOT_PXE_URL': 'http://127.0.0.1:8080',
46
+ // Provide L1 execution RPC for bridging fee juice
47
+ 'bot.node.env.ETHEREUM_HOSTS': `http://${namespace}-eth-execution.${namespace}.svc.cluster.local:8545`,
48
+ // Provide L1 mnemonic for bridging (falls back to labs mnemonic)
49
+ 'bot.node.env.BOT_L1_MNEMONIC': mnemonic,
50
+ // The bot does not need Kubernetes API access. Disable RBAC + ServiceAccount creation so the chart
51
+ // can be installed by users without cluster-scoped RBAC permissions.
52
+ 'bot.rbac.create': false,
53
+ 'bot.serviceAccount.create': false,
54
+ 'bot.serviceAccount.name': 'default'
55
+ };
56
+ // Ensure we derive a funded L1 key (index 0 is funded on anvil default mnemonic)
57
+ if (mnemonicStartIndex === undefined) {
58
+ values['bot.mnemonicStartIndex'] = 0;
59
+ }
60
+ // Also pass a funded private key directly if available
61
+ if (process.env.FUNDING_PRIVATE_KEY) {
62
+ values['bot.node.env.BOT_L1_PRIVATE_KEY'] = process.env.FUNDING_PRIVATE_KEY;
63
+ }
64
+ // Align bot image with the running network image: prefer env var, else detect from a validator pod
65
+ let repositoryFromEnv;
66
+ let tagFromEnv;
67
+ const aztecDockerImage = process.env.AZTEC_DOCKER_IMAGE;
68
+ if (aztecDockerImage && aztecDockerImage.includes(':')) {
69
+ const lastColon = aztecDockerImage.lastIndexOf(':');
70
+ repositoryFromEnv = aztecDockerImage.slice(0, lastColon);
71
+ tagFromEnv = aztecDockerImage.slice(lastColon + 1);
72
+ }
73
+ let repository = repositoryFromEnv;
74
+ let tag = tagFromEnv;
75
+ if (!repository || !tag) {
76
+ try {
77
+ const { stdout } = await execAsync(`kubectl get pods -l app.kubernetes.io/name=validator -n ${namespace} -o jsonpath='{.items[0].spec.containers[?(@.name=="aztec")].image}' | cat`);
78
+ const image = stdout.trim().replace(/^'|'$/g, '');
79
+ if (image && image.includes(':')) {
80
+ const lastColon = image.lastIndexOf(':');
81
+ repository = image.slice(0, lastColon);
82
+ tag = image.slice(lastColon + 1);
83
+ }
84
+ } catch (err) {
85
+ log.warn(`Could not detect aztec image from validator pod: ${String(err)}`);
86
+ }
87
+ }
88
+ if (repository && tag) {
89
+ values['global.aztecImage.repository'] = repository;
90
+ values['global.aztecImage.tag'] = tag;
91
+ }
92
+ if (mnemonicStartIndex !== undefined) {
93
+ values['bot.mnemonicStartIndex'] = typeof mnemonicStartIndex === 'string' ? mnemonicStartIndex : Number(mnemonicStartIndex);
94
+ }
95
+ // If a previous install attempt left the release in a non-deployed state (e.g. FAILED),
96
+ // `helm upgrade --install` can error with "has no deployed releases".
97
+ // In that case, clear the release record and do a clean install.
98
+ const existingStatus = await getHelmReleaseStatus(instanceName, namespace);
99
+ if (existingStatus && existingStatus.toLowerCase() !== 'deployed') {
100
+ log.warn(`Transfer bot release ${instanceName} is in status '${existingStatus}'. Reinstalling cleanly.`);
101
+ await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`).catch(()=>undefined);
102
+ // If helm left the release in `uninstalling`, force-delete the record so we can reinstall.
103
+ const afterUninstallStatus = await getHelmReleaseStatus(instanceName, namespace);
104
+ if (afterUninstallStatus?.toLowerCase() === 'uninstalling') {
105
+ await forceDeleteHelmReleaseRecord(instanceName, namespace, log);
106
+ }
107
+ }
108
+ // `--reuse-values` fails if the release has never successfully deployed (e.g. first install, or a previous failed install).
109
+ // Only reuse values when we have a deployed release to reuse from.
110
+ const effectiveReuseValues = reuseValues && await hasDeployedHelmRelease(instanceName, namespace);
111
+ await execHelmCommand({
112
+ instanceName,
113
+ helmChartDir,
114
+ namespace,
115
+ valuesFile: undefined,
116
+ timeout,
117
+ values: values,
118
+ reuseValues: effectiveReuseValues
119
+ });
120
+ if (replicas > 0) {
121
+ await waitForResourceByLabel({
122
+ resource: 'pods',
123
+ namespace,
124
+ label: 'app.kubernetes.io/name=bot',
125
+ condition: 'PodReadyToStartContainers'
126
+ });
127
+ }
128
+ }
129
+ /**
130
+ * Uninstalls the transfer bot Helm release from the given namespace.
131
+ * Intended for test teardown to clean up bot resources.
132
+ */ export async function uninstallTransferBot(namespace, log) {
133
+ const instanceName = `${namespace}-bot-transfers`;
134
+ log.info(`Uninstalling transfer bot release ${instanceName}`);
135
+ await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`);
136
+ // Ensure any leftover pods are removed
137
+ await deleteResourceByLabel({
138
+ resource: 'pods',
139
+ namespace,
140
+ label: 'app.kubernetes.io/name=bot'
141
+ }).catch(()=>undefined);
142
+ }