@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.0b941701

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 (236) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +62 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +281 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +321 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +79 -0
  13. package/dest/bench/utils.d.ts +16 -41
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +41 -72
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +114 -102
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +104 -104
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +26 -27
  25. package/dest/e2e_epochs/epochs_test.d.ts +65 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +236 -49
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  31. package/dest/e2e_fees/fees_test.d.ts +38 -23
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +162 -183
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +62 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +281 -27
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +237 -175
  49. package/dest/e2e_p2p/shared.d.ts +44 -8
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +165 -27
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +96 -74
  55. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/fixtures/e2e_prover_test.js +278 -0
  58. package/dest/fixtures/fixtures.d.ts +6 -8
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +5 -5
  61. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +3 -15
  64. package/dest/fixtures/get_bb_config.d.ts +2 -2
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/index.d.ts +1 -1
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  69. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  70. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  71. package/dest/fixtures/logging.d.ts +1 -1
  72. package/dest/fixtures/setup.d.ts +218 -0
  73. package/dest/fixtures/setup.d.ts.map +1 -0
  74. package/dest/fixtures/setup.js +690 -0
  75. package/dest/fixtures/setup_p2p_test.d.ts +15 -14
  76. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  77. package/dest/fixtures/setup_p2p_test.js +82 -22
  78. package/dest/fixtures/token_utils.d.ts +10 -4
  79. package/dest/fixtures/token_utils.d.ts.map +1 -1
  80. package/dest/fixtures/token_utils.js +31 -12
  81. package/dest/fixtures/utils.d.ts +5 -153
  82. package/dest/fixtures/utils.d.ts.map +1 -1
  83. package/dest/fixtures/utils.js +4 -552
  84. package/dest/fixtures/web3signer.d.ts +5 -0
  85. package/dest/fixtures/web3signer.d.ts.map +1 -0
  86. package/dest/fixtures/web3signer.js +53 -0
  87. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  88. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  89. package/dest/fixtures/with_telemetry_utils.js +2 -2
  90. package/dest/index.d.ts +1 -1
  91. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  92. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  93. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  94. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  95. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  96. package/dest/quality_of_service/prometheus_client.js +67 -0
  97. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  98. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  99. package/dest/shared/cross_chain_test_harness.js +105 -51
  100. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  101. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  102. package/dest/shared/gas_portal_test_harness.js +51 -30
  103. package/dest/shared/index.d.ts +2 -2
  104. package/dest/shared/index.d.ts.map +1 -1
  105. package/dest/shared/jest_setup.d.ts +1 -1
  106. package/dest/shared/jest_setup.js +1 -1
  107. package/dest/shared/submit-transactions.d.ts +6 -4
  108. package/dest/shared/submit-transactions.d.ts.map +1 -1
  109. package/dest/shared/submit-transactions.js +15 -16
  110. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  111. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  112. package/dest/shared/uniswap_l1_l2.js +176 -126
  113. package/dest/simulators/index.d.ts +1 -1
  114. package/dest/simulators/lending_simulator.d.ts +7 -7
  115. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  116. package/dest/simulators/lending_simulator.js +17 -18
  117. package/dest/simulators/token_simulator.d.ts +6 -3
  118. package/dest/simulators/token_simulator.d.ts.map +1 -1
  119. package/dest/simulators/token_simulator.js +16 -13
  120. package/dest/spartan/setup_test_wallets.d.ts +27 -11
  121. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  122. package/dest/spartan/setup_test_wallets.js +233 -62
  123. package/dest/spartan/tx_metrics.d.ts +54 -0
  124. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  125. package/dest/spartan/tx_metrics.js +272 -0
  126. package/dest/spartan/utils/bot.d.ts +27 -0
  127. package/dest/spartan/utils/bot.d.ts.map +1 -0
  128. package/dest/spartan/utils/bot.js +141 -0
  129. package/dest/spartan/utils/chaos.d.ts +79 -0
  130. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  131. package/dest/spartan/utils/chaos.js +142 -0
  132. package/dest/spartan/utils/clients.d.ts +39 -0
  133. package/dest/spartan/utils/clients.d.ts.map +1 -0
  134. package/dest/spartan/utils/clients.js +90 -0
  135. package/dest/spartan/utils/config.d.ts +36 -0
  136. package/dest/spartan/utils/config.d.ts.map +1 -0
  137. package/dest/spartan/utils/config.js +20 -0
  138. package/dest/spartan/utils/health.d.ts +63 -0
  139. package/dest/spartan/utils/health.d.ts.map +1 -0
  140. package/dest/spartan/utils/health.js +202 -0
  141. package/dest/spartan/utils/helm.d.ts +15 -0
  142. package/dest/spartan/utils/helm.d.ts.map +1 -0
  143. package/dest/spartan/utils/helm.js +47 -0
  144. package/dest/spartan/utils/index.d.ts +9 -0
  145. package/dest/spartan/utils/index.d.ts.map +1 -0
  146. package/dest/spartan/utils/index.js +18 -0
  147. package/dest/spartan/utils/k8s.d.ts +98 -0
  148. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  149. package/dest/spartan/utils/k8s.js +257 -0
  150. package/dest/spartan/utils/nodes.d.ts +31 -0
  151. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  152. package/dest/spartan/utils/nodes.js +290 -0
  153. package/dest/spartan/utils/scripts.d.ts +16 -0
  154. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  155. package/dest/spartan/utils/scripts.js +66 -0
  156. package/dest/spartan/utils.d.ts +2 -415
  157. package/dest/spartan/utils.d.ts.map +1 -1
  158. package/dest/spartan/utils.js +1 -445
  159. package/package.json +66 -58
  160. package/src/bench/client_flows/benchmark.ts +363 -0
  161. package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
  162. package/src/bench/client_flows/config.ts +61 -0
  163. package/src/bench/client_flows/data_extractor.ts +89 -0
  164. package/src/bench/utils.ts +41 -85
  165. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
  166. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
  167. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  168. package/src/e2e_epochs/epochs_test.ts +315 -76
  169. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  170. package/src/e2e_fees/fees_test.ts +220 -258
  171. package/src/e2e_l1_publisher/write_json.ts +82 -0
  172. package/src/e2e_multi_validator/utils.ts +258 -0
  173. package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
  174. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  175. package/src/e2e_p2p/p2p_network.ts +341 -234
  176. package/src/e2e_p2p/shared.ts +253 -40
  177. package/src/e2e_token_contract/token_contract_test.ts +115 -126
  178. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  179. package/src/fixtures/e2e_prover_test.ts +336 -0
  180. package/src/fixtures/fixtures.ts +5 -7
  181. package/src/fixtures/get_acvm_config.ts +4 -12
  182. package/src/fixtures/get_bb_config.ts +18 -13
  183. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  184. package/src/fixtures/setup.ts +1017 -0
  185. package/src/fixtures/setup_p2p_test.ts +127 -39
  186. package/src/fixtures/token_utils.ts +33 -15
  187. package/src/fixtures/utils.ts +27 -820
  188. package/src/fixtures/web3signer.ts +63 -0
  189. package/src/fixtures/with_telemetry_utils.ts +2 -2
  190. package/src/guides/up_quick_start.sh +7 -15
  191. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  192. package/src/quality_of_service/prometheus_client.ts +113 -0
  193. package/src/shared/cross_chain_test_harness.ts +103 -91
  194. package/src/shared/gas_portal_test_harness.ts +59 -50
  195. package/src/shared/index.ts +1 -1
  196. package/src/shared/jest_setup.ts +1 -1
  197. package/src/shared/submit-transactions.ts +18 -20
  198. package/src/shared/uniswap_l1_l2.ts +197 -221
  199. package/src/simulators/lending_simulator.ts +16 -17
  200. package/src/simulators/token_simulator.ts +21 -13
  201. package/src/spartan/DEVELOP.md +128 -0
  202. package/src/spartan/setup_test_wallets.ts +308 -95
  203. package/src/spartan/tx_metrics.ts +250 -0
  204. package/src/spartan/utils/bot.ts +185 -0
  205. package/src/spartan/utils/chaos.ts +253 -0
  206. package/src/spartan/utils/clients.ts +100 -0
  207. package/src/spartan/utils/config.ts +26 -0
  208. package/src/spartan/utils/health.ts +255 -0
  209. package/src/spartan/utils/helm.ts +84 -0
  210. package/src/spartan/utils/index.ts +62 -0
  211. package/src/spartan/utils/k8s.ts +375 -0
  212. package/src/spartan/utils/nodes.ts +323 -0
  213. package/src/spartan/utils/scripts.ts +63 -0
  214. package/src/spartan/utils.ts +1 -582
  215. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  216. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  217. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  218. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  219. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  220. package/dest/fixtures/setup_l1_contracts.js +0 -17
  221. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  222. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  223. package/dest/fixtures/snapshot_manager.js +0 -479
  224. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  225. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  226. package/dest/sample-dapp/connect.js +0 -12
  227. package/dest/sample-dapp/contracts.js +0 -10
  228. package/dest/sample-dapp/deploy.js +0 -35
  229. package/dest/sample-dapp/index.js +0 -98
  230. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  231. package/src/fixtures/setup_l1_contracts.ts +0 -27
  232. package/src/fixtures/snapshot_manager.ts +0 -617
  233. package/src/sample-dapp/connect.mjs +0 -16
  234. package/src/sample-dapp/contracts.mjs +0 -14
  235. package/src/sample-dapp/deploy.mjs +0 -40
  236. package/src/sample-dapp/index.mjs +0 -128
@@ -0,0 +1,290 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
3
+ import { sleep } from '@aztec/foundation/sleep';
4
+ import { createAztecNodeAdminClient } from '@aztec/stdlib/interfaces/client';
5
+ import { exec } from 'child_process';
6
+ import { promisify } from 'util';
7
+ import { execHelmCommand } from './helm.js';
8
+ import { deleteResourceByLabel, getChartDir, startPortForward, waitForResourceByLabel } from './k8s.js';
9
+ const execAsync = promisify(exec);
10
+ const logger = createLogger('e2e:k8s-utils');
11
+ export async function awaitCheckpointNumber(rollupCheatCodes, checkpointNumber, timeoutSeconds, log) {
12
+ log.info(`Waiting for checkpoint ${checkpointNumber}`);
13
+ let tips = await rollupCheatCodes.getTips();
14
+ const endTime = Date.now() + timeoutSeconds * 1000;
15
+ while(tips.pending < checkpointNumber && Date.now() < endTime){
16
+ log.info(`At checkpoint ${tips.pending}`);
17
+ await sleep(1000);
18
+ tips = await rollupCheatCodes.getTips();
19
+ }
20
+ if (tips.pending < checkpointNumber) {
21
+ throw new Error(`Timeout waiting for checkpoint ${checkpointNumber}, only reached ${tips.pending}`);
22
+ } else {
23
+ log.info(`Reached checkpoint ${tips.pending}`);
24
+ }
25
+ }
26
+ export async function getSequencers(namespace) {
27
+ const selectors = [
28
+ 'app.kubernetes.io/name=validator',
29
+ 'app.kubernetes.io/component=validator',
30
+ 'app.kubernetes.io/component=sequencer-node',
31
+ 'app=validator'
32
+ ];
33
+ for (const selector of selectors){
34
+ try {
35
+ const command = `kubectl get pods -l ${selector} -n ${namespace} -o jsonpath='{.items[*].metadata.name}'`;
36
+ const { stdout } = await execAsync(command);
37
+ const sequencers = stdout.split(' ').map((s)=>s.trim()).filter(Boolean);
38
+ if (sequencers.length > 0) {
39
+ logger.verbose(`Found sequencer pods ${sequencers.join(', ')} (selector=${selector})`);
40
+ return sequencers;
41
+ }
42
+ } catch {
43
+ // try next selector
44
+ }
45
+ }
46
+ // Fail fast instead of returning [''] which leads to attempts to port-forward `pod/`.
47
+ throw new Error(`No sequencer/validator pods found in namespace ${namespace}. Tried selectors: ${selectors.join(', ')}`);
48
+ }
49
+ export function updateSequencersConfig(env, config) {
50
+ return withSequencersAdmin(env, async (client)=>{
51
+ await client.setConfig(config);
52
+ return client.getConfig();
53
+ });
54
+ }
55
+ export function getSequencersConfig(env) {
56
+ return withSequencersAdmin(env, (client)=>client.getConfig());
57
+ }
58
+ export async function withSequencersAdmin(env, fn) {
59
+ const adminContainerPort = 8880;
60
+ const namespace = env.NAMESPACE;
61
+ const sequencers = await getSequencers(namespace);
62
+ const results = [];
63
+ for (const sequencer of sequencers){
64
+ // Wrap port-forward + fetch in a retry to handle flaky port-forwards
65
+ const result = await retry(async ()=>{
66
+ const { process, port } = await startPortForward({
67
+ resource: `pod/${sequencer}`,
68
+ namespace,
69
+ containerPort: adminContainerPort
70
+ });
71
+ try {
72
+ const url = `http://localhost:${port}`;
73
+ // Quick health check before using the connection
74
+ const statusRes = await fetch(`${url}/status`);
75
+ if (statusRes.status !== 200) {
76
+ throw new Error(`Admin endpoint returned status ${statusRes.status}`);
77
+ }
78
+ const client = createAztecNodeAdminClient(url);
79
+ return {
80
+ result: await fn(client),
81
+ process
82
+ };
83
+ } catch (err) {
84
+ // Kill the port-forward before retrying
85
+ process.kill();
86
+ throw err;
87
+ }
88
+ }, 'connect to node admin', makeBackoff([
89
+ 1,
90
+ 2,
91
+ 4,
92
+ 8
93
+ ]), logger, true);
94
+ results.push(result.result);
95
+ result.process.kill();
96
+ }
97
+ return results;
98
+ }
99
+ /**
100
+ * Enables or disables probabilistic transaction dropping on validators and waits for rollout.
101
+ * Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
102
+ */ export async function setValidatorTxDrop({ namespace, enabled, probability, logger: log }) {
103
+ const drop = enabled ? 'true' : 'false';
104
+ const prob = String(probability);
105
+ const selectors = [
106
+ 'app.kubernetes.io/name=validator',
107
+ 'app.kubernetes.io/component=validator',
108
+ 'app=validator'
109
+ ];
110
+ let updated = false;
111
+ for (const selector of selectors){
112
+ try {
113
+ const list = await execAsync(`kubectl get statefulset -l ${selector} -n ${namespace} --no-headers -o name | cat`);
114
+ const names = list.stdout.split('\n').map((s)=>s.trim()).filter(Boolean);
115
+ if (names.length === 0) {
116
+ continue;
117
+ }
118
+ const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
119
+ log.info(`command: ${cmd}`);
120
+ await execAsync(cmd);
121
+ updated = true;
122
+ } catch (e) {
123
+ log.warn(`Failed to update validators with selector ${selector}: ${String(e)}`);
124
+ }
125
+ }
126
+ if (!updated) {
127
+ log.warn(`No validator StatefulSets found in ${namespace}. Skipping tx drop toggle.`);
128
+ return;
129
+ }
130
+ // Restart validator pods to ensure env vars take effect and wait for readiness
131
+ await restartValidators(namespace, log);
132
+ }
133
+ export async function restartValidators(namespace, log) {
134
+ const selectors = [
135
+ 'app.kubernetes.io/name=validator',
136
+ 'app.kubernetes.io/component=validator',
137
+ 'app=validator'
138
+ ];
139
+ let any = false;
140
+ for (const selector of selectors){
141
+ try {
142
+ const { stdout } = await execAsync(`kubectl get pods -l ${selector} -n ${namespace} --no-headers -o name | cat`);
143
+ if (!stdout || stdout.trim().length === 0) {
144
+ continue;
145
+ }
146
+ any = true;
147
+ await deleteResourceByLabel({
148
+ resource: 'pods',
149
+ namespace,
150
+ label: selector
151
+ });
152
+ } catch (e) {
153
+ log.warn(`Error restarting validator pods with selector ${selector}: ${String(e)}`);
154
+ }
155
+ }
156
+ if (!any) {
157
+ log.warn(`No validator pods found to restart in ${namespace}.`);
158
+ return;
159
+ }
160
+ // Wait for either label to be Ready
161
+ for (const selector of selectors){
162
+ try {
163
+ await waitForResourceByLabel({
164
+ resource: 'pods',
165
+ namespace,
166
+ label: selector
167
+ });
168
+ return;
169
+ } catch {
170
+ // try next
171
+ }
172
+ }
173
+ log.warn(`Validator pods did not report Ready; continuing.`);
174
+ }
175
+ export async function enableValidatorDynamicBootNode(instanceName, namespace, spartanDir, log) {
176
+ log.info(`Enabling validator dynamic boot node`);
177
+ await execHelmCommand({
178
+ instanceName,
179
+ namespace,
180
+ helmChartDir: getChartDir(spartanDir, 'aztec-network'),
181
+ values: {
182
+ 'validator.dynamicBootNode': 'true'
183
+ },
184
+ valuesFile: undefined,
185
+ timeout: '15m',
186
+ reuseValues: true
187
+ });
188
+ log.info(`Validator dynamic boot node enabled`);
189
+ }
190
+ /**
191
+ * Rolls the Aztec pods in the given namespace.
192
+ * @param namespace - The namespace to roll the Aztec pods in.
193
+ * @param clearState - If true, also deletes the underlying PVCs to clear persistent storage.
194
+ * This is required for rollup upgrades where the old state is incompatible with the new rollup.
195
+ * Defaults to false, which preserves the existing storage.
196
+ */ export async function rollAztecPods(namespace, clearState = false) {
197
+ // Pod components use 'validator', but StatefulSets and PVCs use 'sequencer-node' for validators
198
+ const podComponents = [
199
+ 'p2p-bootstrap',
200
+ 'prover-node',
201
+ 'prover-broker',
202
+ 'prover-agent',
203
+ 'sequencer-node',
204
+ 'rpc'
205
+ ];
206
+ const pvcComponents = [
207
+ 'p2p-bootstrap',
208
+ 'prover-node',
209
+ 'prover-broker',
210
+ 'sequencer-node',
211
+ 'rpc'
212
+ ];
213
+ // StatefulSet components that need to be scaled down before PVC deletion
214
+ // Note: validators use 'sequencer-node' as component label, not 'validator'
215
+ const statefulSetComponents = [
216
+ 'p2p-bootstrap',
217
+ 'prover-node',
218
+ 'prover-broker',
219
+ 'sequencer-node',
220
+ 'rpc'
221
+ ];
222
+ if (clearState) {
223
+ // To delete PVCs, we must first scale down StatefulSets so pods release the volumes
224
+ // Otherwise PVC deletion will hang waiting for pods to terminate
225
+ // First, save original replica counts
226
+ const originalReplicas = new Map();
227
+ for (const component of statefulSetComponents){
228
+ try {
229
+ const getCmd = `kubectl get statefulset -l app.kubernetes.io/component=${component} -n ${namespace} -o jsonpath='{.items[0].spec.replicas}'`;
230
+ const { stdout } = await execAsync(getCmd);
231
+ const replicas = parseInt(stdout.replace(/'/g, '').trim(), 10);
232
+ if (!isNaN(replicas) && replicas > 0) {
233
+ originalReplicas.set(component, replicas);
234
+ }
235
+ } catch {
236
+ // Component might not exist, continue
237
+ }
238
+ }
239
+ // Scale down to 0
240
+ for (const component of statefulSetComponents){
241
+ try {
242
+ const scaleCmd = `kubectl scale statefulset -l app.kubernetes.io/component=${component} -n ${namespace} --replicas=0 --timeout=2m`;
243
+ logger.info(`command: ${scaleCmd}`);
244
+ await execAsync(scaleCmd);
245
+ } catch (e) {
246
+ // Component might not exist or might be a Deployment, continue
247
+ logger.verbose(`Scale down ${component} skipped: ${e}`);
248
+ }
249
+ }
250
+ // Wait for pods to terminate
251
+ await sleep(15 * 1000);
252
+ // Now delete PVCs (they should no longer be in use)
253
+ for (const component of pvcComponents){
254
+ await deleteResourceByLabel({
255
+ resource: 'persistentvolumeclaims',
256
+ namespace: namespace,
257
+ label: `app.kubernetes.io/component=${component}`
258
+ });
259
+ }
260
+ // Scale StatefulSets back up to original replica counts
261
+ for (const component of statefulSetComponents){
262
+ const replicas = originalReplicas.get(component) ?? 1;
263
+ try {
264
+ const scaleCmd = `kubectl scale statefulset -l app.kubernetes.io/component=${component} -n ${namespace} --replicas=${replicas} --timeout=2m`;
265
+ logger.info(`command: ${scaleCmd}`);
266
+ await execAsync(scaleCmd);
267
+ } catch (e) {
268
+ logger.verbose(`Scale up ${component} skipped: ${e}`);
269
+ }
270
+ }
271
+ } else {
272
+ // Just delete pods (no state clearing)
273
+ for (const component of podComponents){
274
+ await deleteResourceByLabel({
275
+ resource: 'pods',
276
+ namespace: namespace,
277
+ label: `app.kubernetes.io/component=${component}`
278
+ });
279
+ }
280
+ }
281
+ await sleep(10 * 1000);
282
+ // Wait for pods to come back
283
+ for (const component of podComponents){
284
+ await waitForResourceByLabel({
285
+ resource: 'pods',
286
+ namespace: namespace,
287
+ label: `app.kubernetes.io/component=${component}`
288
+ });
289
+ }
290
+ }
@@ -0,0 +1,16 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ /**
3
+ * Returns the absolute path to the git repository root
4
+ */
5
+ export declare function getGitProjectRoot(): string;
6
+ export declare function getAztecBin(): string;
7
+ /**
8
+ * Runs the Aztec binary
9
+ * @param args - The arguments to pass to the Aztec binary
10
+ * @param logger - The logger to use
11
+ * @param env - Optional environment variables to set for the process
12
+ * @returns The exit code of the Aztec binary
13
+ */
14
+ export declare function runAztecBin(args: string[], logger: Logger, env?: Record<string, string>): Promise<number>;
15
+ export declare function runProjectScript(script: string, args: string[], logger: Logger, env?: Record<string, string>): Promise<number>;
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyaXB0cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NwYXJ0YW4vdXRpbHMvc2NyaXB0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQTRCcEQ7O0dBRUc7QUFDSCx3QkFBZ0IsaUJBQWlCLElBQUksTUFBTSxDQVcxQztBQUVELHdCQUFnQixXQUFXLFdBRTFCO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsd0JBQWdCLFdBQVcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxtQkFFdkY7QUFFRCx3QkFBZ0IsZ0JBQWdCLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxtQkFHNUcifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AA4BpD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C;AAED,wBAAgB,WAAW,WAE1B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBAEvF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBAG5G"}
@@ -0,0 +1,66 @@
1
+ import { execSync, spawn } from 'child_process';
2
+ import path from 'path';
3
+ /**
4
+ * @param scriptPath - The path to the script, relative to the project root
5
+ * @param args - The arguments to pass to the script
6
+ * @param logger - The logger to use
7
+ * @returns The exit code of the script
8
+ */ function runScript(scriptPath, args, logger, env) {
9
+ const childProcess = spawn(scriptPath, args, {
10
+ stdio: [
11
+ 'ignore',
12
+ 'pipe',
13
+ 'pipe'
14
+ ],
15
+ env: env ? {
16
+ ...process.env,
17
+ ...env
18
+ } : process.env
19
+ });
20
+ return new Promise((resolve, reject)=>{
21
+ childProcess.on('close', (code)=>resolve(code ?? 0));
22
+ childProcess.on('error', reject);
23
+ childProcess.stdout?.on('data', (data)=>{
24
+ logger.info(data.toString());
25
+ });
26
+ childProcess.stderr?.on('data', (data)=>{
27
+ logger.error(data.toString());
28
+ });
29
+ });
30
+ }
31
+ /**
32
+ * Returns the absolute path to the git repository root
33
+ */ export function getGitProjectRoot() {
34
+ try {
35
+ const rootDir = execSync('git rev-parse --show-toplevel', {
36
+ encoding: 'utf-8',
37
+ stdio: [
38
+ 'ignore',
39
+ 'pipe',
40
+ 'ignore'
41
+ ]
42
+ }).trim();
43
+ return rootDir;
44
+ } catch (error) {
45
+ throw new Error(`Failed to determine git project root: ${error}`);
46
+ }
47
+ }
48
+ export function getAztecBin() {
49
+ return path.join(getGitProjectRoot(), 'yarn-project/aztec/dest/bin/index.js');
50
+ }
51
+ /**
52
+ * Runs the Aztec binary
53
+ * @param args - The arguments to pass to the Aztec binary
54
+ * @param logger - The logger to use
55
+ * @param env - Optional environment variables to set for the process
56
+ * @returns The exit code of the Aztec binary
57
+ */ export function runAztecBin(args, logger, env) {
58
+ return runScript('node', [
59
+ getAztecBin(),
60
+ ...args
61
+ ], logger, env);
62
+ }
63
+ export function runProjectScript(script, args, logger, env) {
64
+ const scriptPath = script.startsWith('/') ? script : path.join(getGitProjectRoot(), script);
65
+ return runScript(scriptPath, args, logger, env);
66
+ }