@aztec/end-to-end 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (271) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +17 -2
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +38 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +14 -15
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +132 -150
  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 +33 -19
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
  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 +120 -117
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +30 -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 +122 -70
  21. package/dest/e2e_deploy_contract/deploy_test.d.ts +6 -5
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  23. package/dest/e2e_deploy_contract/deploy_test.js +20 -14
  24. package/dest/e2e_epochs/epochs_test.d.ts +39 -8
  25. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  26. package/dest/e2e_epochs/epochs_test.js +172 -51
  27. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  28. package/dest/e2e_fees/fees_test.d.ts +18 -15
  29. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  30. package/dest/e2e_fees/fees_test.js +158 -143
  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_nested_contract/nested_contract_test.d.ts +7 -10
  35. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  36. package/dest/e2e_nested_contract/nested_contract_test.js +32 -41
  37. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  38. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  39. package/dest/e2e_p2p/inactivity_slash_test.js +8 -6
  40. package/dest/e2e_p2p/p2p_network.d.ts +20 -17
  41. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  42. package/dest/e2e_p2p/p2p_network.js +167 -124
  43. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  44. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  45. package/dest/e2e_p2p/reqresp/utils.js +206 -0
  46. package/dest/e2e_p2p/shared.d.ts +30 -12
  47. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  48. package/dest/e2e_p2p/shared.js +88 -68
  49. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  50. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  51. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  52. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  53. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  54. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  55. package/dest/e2e_token_contract/token_contract_test.d.ts +20 -11
  56. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  57. package/dest/e2e_token_contract/token_contract_test.js +103 -93
  58. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  59. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  60. package/dest/fixtures/authwit_proxy.js +34 -0
  61. package/dest/fixtures/e2e_prover_test.d.ts +15 -20
  62. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  63. package/dest/fixtures/e2e_prover_test.js +115 -135
  64. package/dest/fixtures/elu_monitor.d.ts +21 -0
  65. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  66. package/dest/fixtures/elu_monitor.js +102 -0
  67. package/dest/fixtures/fixtures.d.ts +78 -2
  68. package/dest/fixtures/fixtures.d.ts.map +1 -1
  69. package/dest/fixtures/fixtures.js +75 -1
  70. package/dest/fixtures/get_bb_config.d.ts +1 -1
  71. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  72. package/dest/fixtures/get_bb_config.js +5 -5
  73. package/dest/fixtures/ha_setup.d.ts +71 -0
  74. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  75. package/dest/fixtures/ha_setup.js +116 -0
  76. package/dest/fixtures/index.d.ts +2 -1
  77. package/dest/fixtures/index.d.ts.map +1 -1
  78. package/dest/fixtures/index.js +1 -0
  79. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  80. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  81. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  82. package/dest/fixtures/setup.d.ts +266 -0
  83. package/dest/fixtures/setup.d.ts.map +1 -0
  84. package/dest/fixtures/setup.js +714 -0
  85. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  86. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  87. package/dest/fixtures/setup_p2p_test.js +43 -32
  88. package/dest/fixtures/token_utils.d.ts +2 -2
  89. package/dest/fixtures/token_utils.d.ts.map +1 -1
  90. package/dest/fixtures/token_utils.js +7 -6
  91. package/dest/fixtures/utils.d.ts +5 -194
  92. package/dest/fixtures/utils.d.ts.map +1 -1
  93. package/dest/fixtures/utils.js +4 -619
  94. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  95. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  96. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  97. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  98. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  99. package/dest/forward-compatibility/wallet_service.js +109 -0
  100. package/dest/install_legacy_contracts.d.cts +10 -0
  101. package/dest/install_legacy_contracts.d.cts.map +1 -0
  102. package/dest/legacy-jest-resolver.d.cts +3 -0
  103. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  104. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  105. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  106. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  107. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  108. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  109. package/dest/quality_of_service/prometheus_client.js +67 -0
  110. package/dest/shared/cross_chain_test_harness.d.ts +18 -6
  111. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  112. package/dest/shared/cross_chain_test_harness.js +33 -29
  113. package/dest/shared/gas_portal_test_harness.d.ts +18 -5
  114. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  115. package/dest/shared/gas_portal_test_harness.js +20 -11
  116. package/dest/shared/index.d.ts +3 -2
  117. package/dest/shared/index.d.ts.map +1 -1
  118. package/dest/shared/index.js +1 -0
  119. package/dest/shared/jest_setup.js +41 -1
  120. package/dest/shared/mock_state_view.d.ts +86 -0
  121. package/dest/shared/mock_state_view.d.ts.map +1 -0
  122. package/dest/shared/mock_state_view.js +186 -0
  123. package/dest/shared/submit-transactions.d.ts +4 -4
  124. package/dest/shared/submit-transactions.d.ts.map +1 -1
  125. package/dest/shared/submit-transactions.js +9 -11
  126. package/dest/shared/uniswap_l1_l2.d.ts +3 -28
  127. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  128. package/dest/shared/uniswap_l1_l2.js +88 -47
  129. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  130. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  131. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  132. package/dest/simulators/lending_simulator.d.ts +14 -3
  133. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  134. package/dest/simulators/lending_simulator.js +28 -16
  135. package/dest/simulators/token_simulator.d.ts +1 -1
  136. package/dest/simulators/token_simulator.d.ts.map +1 -1
  137. package/dest/simulators/token_simulator.js +3 -24
  138. package/dest/spartan/setup_test_wallets.d.ts +15 -5
  139. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  140. package/dest/spartan/setup_test_wallets.js +133 -43
  141. package/dest/spartan/tx_metrics.d.ts +68 -5
  142. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  143. package/dest/spartan/tx_metrics.js +399 -19
  144. package/dest/spartan/utils/bot.d.ts +28 -0
  145. package/dest/spartan/utils/bot.d.ts.map +1 -0
  146. package/dest/spartan/utils/bot.js +142 -0
  147. package/dest/spartan/utils/chaos.d.ts +79 -0
  148. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  149. package/dest/spartan/utils/chaos.js +142 -0
  150. package/dest/spartan/utils/clients.d.ts +39 -0
  151. package/dest/spartan/utils/clients.d.ts.map +1 -0
  152. package/dest/spartan/utils/clients.js +90 -0
  153. package/dest/spartan/utils/config.d.ts +19 -0
  154. package/dest/spartan/utils/config.d.ts.map +1 -0
  155. package/dest/spartan/utils/config.js +23 -0
  156. package/dest/spartan/utils/health.d.ts +63 -0
  157. package/dest/spartan/utils/health.d.ts.map +1 -0
  158. package/dest/spartan/utils/health.js +202 -0
  159. package/dest/spartan/utils/helm.d.ts +15 -0
  160. package/dest/spartan/utils/helm.d.ts.map +1 -0
  161. package/dest/spartan/utils/helm.js +47 -0
  162. package/dest/spartan/utils/index.d.ts +11 -0
  163. package/dest/spartan/utils/index.d.ts.map +1 -0
  164. package/dest/spartan/utils/index.js +22 -0
  165. package/dest/spartan/utils/k8s.d.ts +128 -0
  166. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  167. package/dest/spartan/utils/k8s.js +381 -0
  168. package/dest/spartan/utils/nodes.d.ts +40 -0
  169. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  170. package/dest/spartan/utils/nodes.js +461 -0
  171. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  172. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  173. package/dest/spartan/utils/pod_logs.js +74 -0
  174. package/dest/spartan/utils/scripts.d.ts +30 -0
  175. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  176. package/dest/spartan/utils/scripts.js +81 -0
  177. package/dest/spartan/utils.d.ts +2 -231
  178. package/dest/spartan/utils.d.ts.map +1 -1
  179. package/dest/spartan/utils.js +1 -853
  180. package/dest/test-wallet/test_wallet.d.ts +85 -0
  181. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  182. package/dest/test-wallet/test_wallet.js +273 -0
  183. package/dest/test-wallet/utils.d.ts +41 -0
  184. package/dest/test-wallet/utils.d.ts.map +1 -0
  185. package/dest/test-wallet/utils.js +66 -0
  186. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  187. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  188. package/dest/test-wallet/wallet_worker_script.js +48 -0
  189. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  190. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  191. package/dest/test-wallet/worker_wallet.js +155 -0
  192. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  193. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  194. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  195. package/package.json +53 -45
  196. package/src/bench/client_flows/benchmark.ts +43 -2
  197. package/src/bench/client_flows/client_flows_benchmark.ts +189 -240
  198. package/src/bench/client_flows/config.ts +9 -1
  199. package/src/bench/client_flows/data_extractor.ts +1 -1
  200. package/src/bench/utils.ts +38 -22
  201. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
  202. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +166 -118
  203. package/src/e2e_deploy_contract/deploy_test.ts +24 -16
  204. package/src/e2e_epochs/epochs_test.ts +218 -94
  205. package/src/e2e_fees/bridging_race.notest.ts +4 -10
  206. package/src/e2e_fees/fees_test.ts +207 -230
  207. package/src/e2e_l1_publisher/write_json.ts +16 -16
  208. package/src/e2e_nested_contract/nested_contract_test.ts +38 -57
  209. package/src/e2e_p2p/inactivity_slash_test.ts +8 -6
  210. package/src/e2e_p2p/p2p_network.ts +239 -191
  211. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  212. package/src/e2e_p2p/shared.ts +115 -86
  213. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  214. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  215. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  216. package/src/e2e_token_contract/token_contract_test.ts +129 -117
  217. package/src/fixtures/authwit_proxy.ts +54 -0
  218. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  219. package/src/fixtures/e2e_prover_test.ts +143 -185
  220. package/src/fixtures/elu_monitor.ts +126 -0
  221. package/src/fixtures/fixtures.ts +97 -1
  222. package/src/fixtures/get_bb_config.ts +7 -6
  223. package/src/fixtures/ha_setup.ts +188 -0
  224. package/src/fixtures/index.ts +1 -0
  225. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  226. package/src/fixtures/setup.ts +1037 -0
  227. package/src/fixtures/setup_p2p_test.ts +52 -52
  228. package/src/fixtures/token_utils.ts +7 -6
  229. package/src/fixtures/utils.ts +29 -907
  230. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  231. package/src/forward-compatibility/wallet_service.ts +104 -0
  232. package/src/guides/up_quick_start.sh +3 -5
  233. package/src/install_legacy_contracts.cjs +75 -0
  234. package/src/legacy-jest-resolver.cjs +112 -0
  235. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  236. package/src/quality_of_service/prometheus_client.ts +113 -0
  237. package/src/shared/cross_chain_test_harness.ts +34 -40
  238. package/src/shared/gas_portal_test_harness.ts +22 -12
  239. package/src/shared/index.ts +2 -1
  240. package/src/shared/jest_setup.ts +51 -1
  241. package/src/shared/mock_state_view.ts +188 -0
  242. package/src/shared/submit-transactions.ts +11 -16
  243. package/src/shared/uniswap_l1_l2.ts +114 -108
  244. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  245. package/src/simulators/lending_simulator.ts +34 -16
  246. package/src/simulators/token_simulator.ts +6 -30
  247. package/src/spartan/setup_test_wallets.ts +191 -29
  248. package/src/spartan/tx_metrics.ts +329 -25
  249. package/src/spartan/utils/bot.ts +188 -0
  250. package/src/spartan/utils/chaos.ts +253 -0
  251. package/src/spartan/utils/clients.ts +100 -0
  252. package/src/spartan/utils/config.ts +29 -0
  253. package/src/spartan/utils/health.ts +255 -0
  254. package/src/spartan/utils/helm.ts +84 -0
  255. package/src/spartan/utils/index.ts +71 -0
  256. package/src/spartan/utils/k8s.ts +535 -0
  257. package/src/spartan/utils/nodes.ts +543 -0
  258. package/src/spartan/utils/pod_logs.ts +99 -0
  259. package/src/spartan/utils/scripts.ts +99 -0
  260. package/src/spartan/utils.ts +1 -1077
  261. package/src/test-wallet/test_wallet.ts +376 -0
  262. package/src/test-wallet/utils.ts +108 -0
  263. package/src/test-wallet/wallet_worker_script.ts +60 -0
  264. package/src/test-wallet/worker_wallet.ts +218 -0
  265. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  266. package/dest/fixtures/snapshot_manager.d.ts +0 -93
  267. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  268. package/dest/fixtures/snapshot_manager.js +0 -493
  269. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  270. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  271. package/src/fixtures/snapshot_manager.ts +0 -651
@@ -1,24 +1,188 @@
1
- import { TxStatus } from '@aztec/stdlib/tx';
2
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
+ }
3
152
  export class TxInclusionMetrics {
4
153
  aztecNode;
154
+ logger;
5
155
  data;
6
156
  groups;
7
157
  blocks;
8
- constructor(aztecNode){
158
+ p2pGossipLatencyByTopic;
159
+ attestationLatency;
160
+ attestationCounts;
161
+ reqRespStats;
162
+ peerStats;
163
+ mempoolMinedDelay;
164
+ constructor(aztecNode, logger){
9
165
  this.aztecNode = aztecNode;
166
+ this.logger = logger;
10
167
  this.data = new Map();
11
168
  this.groups = new Set();
12
169
  this.blocks = new Map();
170
+ this.p2pGossipLatencyByTopic = {};
13
171
  }
14
172
  recordSentTx(tx, group) {
15
173
  const txHash = tx.getTxHash().toString();
16
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
+ }
17
181
  this.data.set(txHash, {
18
182
  txHash,
19
- sentAt: Math.trunc(Date.now() / 1000),
20
- minedAt: -1,
21
- attestedAt: -1,
183
+ sentAtMs: Date.now(),
184
+ minedAtMs: -1,
185
+ attestedAtMs: -1,
22
186
  blocknumber: -1,
23
187
  priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
24
188
  totalFee: -1,
@@ -27,29 +191,102 @@ export class TxInclusionMetrics {
27
191
  });
28
192
  this.groups.add(group);
29
193
  }
194
+ /**
195
+ * Stamp mined-at metadata for any tracked tx contained in this block, using
196
+ * `observedAtMs` (caller-supplied wall-clock at the moment they first saw the
197
+ * block). Idempotent: existing minedAtMs is preserved so the first observer
198
+ * wins (typically the block-watcher; recordMinedTx is a fallback).
199
+ */ observeBlockForMinedTxs(blockNumber, txHashes, observedAtMs) {
200
+ txHashes.forEach((txHash, position)=>{
201
+ const data = this.data.get(txHash.toString());
202
+ if (!data || data.minedAtMs !== -1) {
203
+ return;
204
+ }
205
+ data.blocknumber = blockNumber;
206
+ data.minedAtMs = observedAtMs;
207
+ data.positionInBlock = position;
208
+ });
209
+ }
30
210
  async recordMinedTx(txReceipt) {
31
- const { status, txHash, blockNumber } = txReceipt;
32
- if (status !== TxStatus.SUCCESS || !blockNumber) {
211
+ const { txHash, blockNumber } = txReceipt;
212
+ if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
213
+ this.logger?.debug('Skipping mined tx record due to receipt status', {
214
+ txHash: txHash.toString(),
215
+ status: txReceipt.status,
216
+ blockNumber
217
+ });
33
218
  return;
34
219
  }
35
- if (!this.blocks.has(blockNumber)) {
36
- this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber));
37
- }
38
- const block = await this.blocks.get(blockNumber);
39
220
  const data = this.data.get(txHash.toString());
40
- data.blocknumber = blockNumber;
41
- data.minedAt = Number(block.header.globalVariables.timestamp);
42
- data.attestedAt = -1;
221
+ if (!data) {
222
+ const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
223
+ this.logger?.warn(message, {
224
+ txHash: txHash.toString(),
225
+ blockNumber
226
+ });
227
+ throw new Error(message);
228
+ }
43
229
  data.totalFee = Number(txReceipt.transactionFee ?? 0n);
44
- data.positionInBlock = block.body.txEffects.findIndex((txEffect)=>txEffect.txHash.equals(txHash));
230
+ // Fallback path for txs the block-watcher missed (e.g. observed only after
231
+ // the watcher stopped). Stamp with the block's L2 slot timestamp; this is
232
+ // earlier than the true client-observed time by attestation+propagation
233
+ // lag, but it's the only deterministic timestamp available post-hoc.
234
+ if (data.minedAtMs === -1) {
235
+ if (!this.blocks.has(blockNumber)) {
236
+ this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber, {
237
+ includeTransactions: true
238
+ }));
239
+ }
240
+ const block = await this.blocks.get(blockNumber);
241
+ if (!block) {
242
+ this.logger?.warn('Failed to load block for mined tx receipt', {
243
+ txHash: txHash.toString(),
244
+ blockNumber
245
+ });
246
+ return;
247
+ }
248
+ data.blocknumber = blockNumber;
249
+ data.minedAtMs = Number(block.header.globalVariables.timestamp) * 1000;
250
+ data.positionInBlock = block.body.txEffects.findIndex((txEffect)=>txEffect.txHash.equals(txHash));
251
+ }
252
+ }
253
+ /** Per-tx inclusion records for a group. Used to serialise out for downstream tooling. */ getInclusionRecords(group) {
254
+ const out = [];
255
+ for (const tx of this.data.values()){
256
+ if (group !== undefined && tx.group !== group) {
257
+ continue;
258
+ }
259
+ out.push({
260
+ ...tx
261
+ });
262
+ }
263
+ return out;
45
264
  }
46
265
  inclusionTimeInSeconds(group) {
47
266
  const histogram = createHistogram({});
267
+ let nonPositive = 0;
48
268
  for (const tx of this.data.values()){
49
- if (!tx.blocknumber || tx.group !== group) {
269
+ if (!tx.blocknumber || tx.group !== group || tx.minedAtMs === -1) {
270
+ continue;
271
+ }
272
+ // Both timestamps are client wall-clock (ms). A negative delta should be
273
+ // impossible since the watcher stamps minedAtMs strictly after sentAtMs,
274
+ // but the fallback path (recordMinedTx via L2 slot timestamp) can stamp
275
+ // earlier than sentAtMs. perf_hooks.createHistogram rejects <=0; skip
276
+ // those instead of crashing.
277
+ const deltaMs = tx.minedAtMs - tx.sentAtMs;
278
+ if (deltaMs <= 0) {
279
+ nonPositive++;
50
280
  continue;
51
281
  }
52
- histogram.record(tx.minedAt - tx.sentAt);
282
+ // Histogram is recorded in seconds (rounded) to match the existing
283
+ // toGithubActionBenchmarkJSON output unit; per-tx records carry the raw ms.
284
+ histogram.record(Math.max(1, Math.round(deltaMs / 1000)));
285
+ }
286
+ if (nonPositive > 0) {
287
+ this.logger?.debug(`Dropped ${nonPositive} tx inclusion samples with non-positive delta`, {
288
+ group
289
+ });
53
290
  }
54
291
  if (histogram.count === 0) {
55
292
  return {
@@ -72,6 +309,47 @@ export class TxInclusionMetrics {
72
309
  p99: histogram.percentile(99)
73
310
  };
74
311
  }
312
+ recordP2PGossipLatency(topicName, p50, p95) {
313
+ this.p2pGossipLatencyByTopic[topicName] = {
314
+ p50,
315
+ p95
316
+ };
317
+ }
318
+ recordAttestationLatency(p50, p95) {
319
+ this.attestationLatency = {
320
+ p50,
321
+ p95
322
+ };
323
+ }
324
+ recordAttestationCounts(success, failedBad, failedNode) {
325
+ this.attestationCounts = {
326
+ success,
327
+ failedBad,
328
+ failedNode
329
+ };
330
+ }
331
+ recordReqRespStats(fraction, delayP50, delayP95) {
332
+ this.reqRespStats = {
333
+ fraction,
334
+ delayP50,
335
+ delayP95
336
+ };
337
+ }
338
+ recordPeerStats(avgCount, connectionDurationP50, connectionDurationP95) {
339
+ this.peerStats = {
340
+ avgCount,
341
+ connectionDurationP50,
342
+ connectionDurationP95
343
+ };
344
+ }
345
+ recordMempoolMinedDelay(txP50, txP95, attestationP50, attestationP95) {
346
+ this.mempoolMinedDelay = {
347
+ txP50,
348
+ txP95,
349
+ attestationP50,
350
+ attestationP95
351
+ };
352
+ }
75
353
  toGithubActionBenchmarkJSON() {
76
354
  const data = [];
77
355
  for (const group of this.groups){
@@ -81,7 +359,7 @@ export class TxInclusionMetrics {
81
359
  unit: 's',
82
360
  value: stats.mean
83
361
  }, {
84
- name: `${group}/median_inclusion`,
362
+ name: `${group}/p50_inclusion`,
85
363
  unit: 's',
86
364
  value: stats.median
87
365
  }, {
@@ -90,6 +368,108 @@ export class TxInclusionMetrics {
90
368
  value: stats.p99
91
369
  });
92
370
  }
93
- return data;
371
+ for (const [topic, { p50, p95 }] of Object.entries(this.p2pGossipLatencyByTopic)){
372
+ data.push({
373
+ name: `p2p_gossip_latency/${topic}/p50`,
374
+ unit: 'ms',
375
+ value: p50
376
+ });
377
+ data.push({
378
+ name: `p2p_gossip_latency/${topic}/p95`,
379
+ unit: 'ms',
380
+ value: p95
381
+ });
382
+ }
383
+ if (this.attestationLatency) {
384
+ data.push({
385
+ name: 'attestation_latency/p50',
386
+ unit: 'ms',
387
+ value: this.attestationLatency.p50
388
+ }, {
389
+ name: 'attestation_latency/p95',
390
+ unit: 'ms',
391
+ value: this.attestationLatency.p95
392
+ });
393
+ }
394
+ if (this.attestationCounts) {
395
+ const { success, failedBad, failedNode } = this.attestationCounts;
396
+ const total = success + failedBad + failedNode;
397
+ const ratio = total > 0 ? success / total : 0;
398
+ data.push({
399
+ name: 'attestation/success_count',
400
+ unit: 'count',
401
+ value: success
402
+ }, {
403
+ name: 'attestation/failed_bad_proposal_count',
404
+ unit: 'count',
405
+ value: failedBad
406
+ }, {
407
+ name: 'attestation/failed_node_issue_count',
408
+ unit: 'count',
409
+ value: failedNode
410
+ }, {
411
+ name: 'attestation/success_ratio',
412
+ unit: 'ratio',
413
+ value: ratio
414
+ });
415
+ }
416
+ if (this.reqRespStats) {
417
+ data.push({
418
+ name: 'req_resp/txs_requested_fraction',
419
+ unit: 'ratio',
420
+ value: this.reqRespStats.fraction
421
+ }, {
422
+ name: 'req_resp/delay_p50',
423
+ unit: 'ms',
424
+ value: this.reqRespStats.delayP50
425
+ }, {
426
+ name: 'req_resp/delay_p95',
427
+ unit: 'ms',
428
+ value: this.reqRespStats.delayP95
429
+ });
430
+ }
431
+ if (this.peerStats) {
432
+ data.push({
433
+ name: 'peers/avg_count',
434
+ unit: 'peers',
435
+ value: this.peerStats.avgCount
436
+ }, {
437
+ name: 'peers/connection_duration_p50',
438
+ unit: 'ms',
439
+ value: this.peerStats.connectionDurationP50
440
+ }, {
441
+ name: 'peers/connection_duration_p95',
442
+ unit: 'ms',
443
+ value: this.peerStats.connectionDurationP95
444
+ });
445
+ }
446
+ if (this.mempoolMinedDelay) {
447
+ data.push({
448
+ name: 'mempool/tx_mined_delay_p50',
449
+ unit: 'ms',
450
+ value: this.mempoolMinedDelay.txP50
451
+ }, {
452
+ name: 'mempool/tx_mined_delay_p95',
453
+ unit: 'ms',
454
+ value: this.mempoolMinedDelay.txP95
455
+ }, {
456
+ name: 'mempool/attestation_mined_delay_p50',
457
+ unit: 'ms',
458
+ value: this.mempoolMinedDelay.attestationP50
459
+ }, {
460
+ name: 'mempool/attestation_mined_delay_p95',
461
+ unit: 'ms',
462
+ value: this.mempoolMinedDelay.attestationP95
463
+ });
464
+ }
465
+ const scenario = process.env.BENCH_SCENARIO?.trim();
466
+ if (!scenario) {
467
+ return data;
468
+ }
469
+ const scenarioPrefix = `scenario/${scenario}/`;
470
+ return data.map((entry)=>({
471
+ ...entry,
472
+ name: `${scenarioPrefix}${entry.name}`
473
+ }));
94
474
  }
95
475
  }
@@ -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
+ }