@aztec/end-to-end 0.0.1-commit.24de95ac → 0.0.1-commit.2ed92850

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 (209) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +21 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +21 -15
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +129 -119
  7. package/dest/bench/client_flows/config.d.ts +1 -1
  8. package/dest/bench/client_flows/data_extractor.d.ts +1 -1
  9. package/dest/bench/client_flows/data_extractor.js +7 -27
  10. package/dest/bench/utils.d.ts +8 -7
  11. package/dest/bench/utils.d.ts.map +1 -1
  12. package/dest/bench/utils.js +27 -18
  13. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +96 -112
  16. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -13
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +91 -70
  19. package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  21. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  22. package/dest/e2e_epochs/epochs_test.d.ts +11 -9
  23. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  24. package/dest/e2e_epochs/epochs_test.js +22 -16
  25. package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
  26. package/dest/e2e_fees/bridging_race.notest.js +5 -7
  27. package/dest/e2e_fees/fees_test.d.ts +20 -16
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +127 -139
  30. package/dest/e2e_l1_publisher/write_json.d.ts +2 -2
  31. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  32. package/dest/e2e_l1_publisher/write_json.js +23 -18
  33. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  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 +31 -38
  38. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  39. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  40. package/dest/e2e_p2p/inactivity_slash_test.js +7 -6
  41. package/dest/e2e_p2p/p2p_network.d.ts +225 -18
  42. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  43. package/dest/e2e_p2p/p2p_network.js +121 -110
  44. package/dest/e2e_p2p/shared.d.ts +11 -11
  45. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  46. package/dest/e2e_p2p/shared.js +13 -19
  47. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  48. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  49. package/dest/e2e_token_contract/token_contract_test.js +89 -91
  50. package/dest/fixtures/e2e_prover_test.d.ts +12 -18
  51. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  52. package/dest/fixtures/e2e_prover_test.js +100 -108
  53. package/dest/fixtures/fixtures.d.ts +2 -3
  54. package/dest/fixtures/fixtures.d.ts.map +1 -1
  55. package/dest/fixtures/fixtures.js +2 -3
  56. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  57. package/dest/fixtures/get_acvm_config.js +1 -1
  58. package/dest/fixtures/get_bb_config.d.ts +1 -1
  59. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  60. package/dest/fixtures/index.d.ts +1 -1
  61. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  62. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  63. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  64. package/dest/fixtures/logging.d.ts +1 -1
  65. package/dest/fixtures/setup.d.ts +218 -0
  66. package/dest/fixtures/setup.d.ts.map +1 -0
  67. package/dest/fixtures/setup.js +690 -0
  68. package/dest/fixtures/setup_p2p_test.d.ts +4 -4
  69. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  70. package/dest/fixtures/setup_p2p_test.js +18 -10
  71. package/dest/fixtures/token_utils.d.ts +5 -2
  72. package/dest/fixtures/token_utils.d.ts.map +1 -1
  73. package/dest/fixtures/token_utils.js +13 -7
  74. package/dest/fixtures/utils.d.ts +5 -192
  75. package/dest/fixtures/utils.d.ts.map +1 -1
  76. package/dest/fixtures/utils.js +4 -648
  77. package/dest/fixtures/web3signer.d.ts +1 -1
  78. package/dest/fixtures/web3signer.js +1 -1
  79. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  80. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  81. package/dest/fixtures/with_telemetry_utils.js +2 -2
  82. package/dest/index.d.ts +1 -1
  83. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  84. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  85. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  86. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  87. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  88. package/dest/quality_of_service/prometheus_client.js +67 -0
  89. package/dest/shared/cross_chain_test_harness.d.ts +7 -6
  90. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  91. package/dest/shared/cross_chain_test_harness.js +14 -14
  92. package/dest/shared/gas_portal_test_harness.d.ts +2 -2
  93. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  94. package/dest/shared/gas_portal_test_harness.js +2 -2
  95. package/dest/shared/index.d.ts +2 -2
  96. package/dest/shared/index.d.ts.map +1 -1
  97. package/dest/shared/jest_setup.d.ts +1 -1
  98. package/dest/shared/submit-transactions.d.ts +3 -3
  99. package/dest/shared/submit-transactions.d.ts.map +1 -1
  100. package/dest/shared/submit-transactions.js +9 -11
  101. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  102. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  103. package/dest/shared/uniswap_l1_l2.js +55 -35
  104. package/dest/simulators/index.d.ts +1 -1
  105. package/dest/simulators/lending_simulator.d.ts +2 -2
  106. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  107. package/dest/simulators/lending_simulator.js +6 -4
  108. package/dest/simulators/token_simulator.d.ts +1 -1
  109. package/dest/simulators/token_simulator.d.ts.map +1 -1
  110. package/dest/spartan/setup_test_wallets.d.ts +8 -5
  111. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  112. package/dest/spartan/setup_test_wallets.js +85 -23
  113. package/dest/spartan/tx_metrics.d.ts +54 -0
  114. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  115. package/dest/spartan/tx_metrics.js +272 -0
  116. package/dest/spartan/utils/bot.d.ts +27 -0
  117. package/dest/spartan/utils/bot.d.ts.map +1 -0
  118. package/dest/spartan/utils/bot.js +141 -0
  119. package/dest/spartan/utils/chaos.d.ts +79 -0
  120. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  121. package/dest/spartan/utils/chaos.js +142 -0
  122. package/dest/spartan/utils/clients.d.ts +39 -0
  123. package/dest/spartan/utils/clients.d.ts.map +1 -0
  124. package/dest/spartan/utils/clients.js +90 -0
  125. package/dest/spartan/utils/config.d.ts +36 -0
  126. package/dest/spartan/utils/config.d.ts.map +1 -0
  127. package/dest/spartan/utils/config.js +20 -0
  128. package/dest/spartan/utils/health.d.ts +63 -0
  129. package/dest/spartan/utils/health.d.ts.map +1 -0
  130. package/dest/spartan/utils/health.js +202 -0
  131. package/dest/spartan/utils/helm.d.ts +15 -0
  132. package/dest/spartan/utils/helm.d.ts.map +1 -0
  133. package/dest/spartan/utils/helm.js +47 -0
  134. package/dest/spartan/utils/index.d.ts +9 -0
  135. package/dest/spartan/utils/index.d.ts.map +1 -0
  136. package/dest/spartan/utils/index.js +18 -0
  137. package/dest/spartan/utils/k8s.d.ts +98 -0
  138. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  139. package/dest/spartan/utils/k8s.js +257 -0
  140. package/dest/spartan/utils/nodes.d.ts +31 -0
  141. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  142. package/dest/spartan/utils/nodes.js +290 -0
  143. package/dest/spartan/utils/scripts.d.ts +16 -0
  144. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  145. package/dest/spartan/utils/scripts.js +66 -0
  146. package/dest/spartan/utils.d.ts +2 -218
  147. package/dest/spartan/utils.d.ts.map +1 -1
  148. package/dest/spartan/utils.js +1 -749
  149. package/package.json +43 -40
  150. package/src/bench/client_flows/benchmark.ts +24 -2
  151. package/src/bench/client_flows/client_flows_benchmark.ts +152 -170
  152. package/src/bench/client_flows/data_extractor.ts +6 -28
  153. package/src/bench/utils.ts +30 -20
  154. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -142
  155. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -124
  156. package/src/e2e_deploy_contract/deploy_test.ts +22 -15
  157. package/src/e2e_epochs/epochs_test.ts +67 -48
  158. package/src/e2e_fees/bridging_race.notest.ts +5 -11
  159. package/src/e2e_fees/fees_test.ts +180 -219
  160. package/src/e2e_l1_publisher/write_json.ts +25 -19
  161. package/src/e2e_multi_validator/utils.ts +1 -1
  162. package/src/e2e_nested_contract/nested_contract_test.ts +33 -55
  163. package/src/e2e_p2p/inactivity_slash_test.ts +10 -9
  164. package/src/e2e_p2p/p2p_network.ts +181 -180
  165. package/src/e2e_p2p/shared.ts +25 -27
  166. package/src/e2e_token_contract/token_contract_test.ts +103 -118
  167. package/src/fixtures/e2e_prover_test.ts +111 -149
  168. package/src/fixtures/fixtures.ts +2 -5
  169. package/src/fixtures/get_acvm_config.ts +1 -1
  170. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  171. package/src/fixtures/setup.ts +1017 -0
  172. package/src/fixtures/setup_p2p_test.ts +23 -9
  173. package/src/fixtures/token_utils.ts +8 -7
  174. package/src/fixtures/utils.ts +27 -947
  175. package/src/fixtures/web3signer.ts +1 -1
  176. package/src/fixtures/with_telemetry_utils.ts +2 -2
  177. package/src/guides/up_quick_start.sh +1 -1
  178. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  179. package/src/quality_of_service/prometheus_client.ts +113 -0
  180. package/src/shared/cross_chain_test_harness.ts +19 -36
  181. package/src/shared/gas_portal_test_harness.ts +3 -3
  182. package/src/shared/index.ts +1 -1
  183. package/src/shared/submit-transactions.ts +9 -15
  184. package/src/shared/uniswap_l1_l2.ts +65 -86
  185. package/src/simulators/lending_simulator.ts +7 -5
  186. package/src/spartan/DEVELOP.md +7 -0
  187. package/src/spartan/setup_test_wallets.ts +119 -28
  188. package/src/spartan/tx_metrics.ts +250 -0
  189. package/src/spartan/utils/bot.ts +185 -0
  190. package/src/spartan/utils/chaos.ts +253 -0
  191. package/src/spartan/utils/clients.ts +100 -0
  192. package/src/spartan/utils/config.ts +26 -0
  193. package/src/spartan/utils/health.ts +255 -0
  194. package/src/spartan/utils/helm.ts +84 -0
  195. package/src/spartan/utils/index.ts +62 -0
  196. package/src/spartan/utils/k8s.ts +375 -0
  197. package/src/spartan/utils/nodes.ts +323 -0
  198. package/src/spartan/utils/scripts.ts +63 -0
  199. package/src/spartan/utils.ts +1 -942
  200. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  201. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  202. package/dest/fixtures/setup_l1_contracts.js +0 -17
  203. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  204. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  205. package/dest/fixtures/snapshot_manager.js +0 -505
  206. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  207. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  208. package/src/fixtures/setup_l1_contracts.ts +0 -26
  209. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -0,0 +1,100 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
3
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
4
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
5
+ import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
6
+
7
+ import type { ChildProcess } from 'child_process';
8
+ import { createPublicClient, fallback, http } from 'viem';
9
+
10
+ import type { TestConfig } from './config.js';
11
+ import { type ServiceEndpoint, getEthereumEndpoint, getRPCEndpoint } from './k8s.js';
12
+
13
+ const logger = createLogger('e2e:k8s-utils');
14
+
15
+ /**
16
+ * Returns a public viem client to the eth execution node.
17
+ * Tries external IP first, falls back to port-forward.
18
+ * If CREATE_ETH_DEVNET is false, uses the external RPC url from L1_RPC_URLS_JSON.
19
+ *
20
+ * @param env - Test environment config
21
+ * @param forcePortForward - If true, skip external IP and use port-forward directly
22
+ * @returns URL, client, and optional process (if port-forward was used). Caller must kill process when done.
23
+ */
24
+ export async function getPublicViemClient(
25
+ env: TestConfig,
26
+ forcePortForward?: boolean,
27
+ ): Promise<{
28
+ url: string;
29
+ client: ViemPublicClient;
30
+ process?: ChildProcess;
31
+ }> {
32
+ const { NAMESPACE, CREATE_ETH_DEVNET, L1_RPC_URLS_JSON } = env;
33
+ if (CREATE_ETH_DEVNET) {
34
+ logger.info(`Connecting to eth execution node in namespace ${NAMESPACE}`);
35
+ const endpoint = await getEthereumEndpoint(NAMESPACE, forcePortForward);
36
+ const client: ViemPublicClient = createPublicClient({
37
+ transport: fallback([http(endpoint.url, { batch: false })]),
38
+ });
39
+ return { url: endpoint.url, client, process: endpoint.process };
40
+ } else {
41
+ logger.info(`Connecting to the eth execution node at ${L1_RPC_URLS_JSON}`);
42
+ if (!L1_RPC_URLS_JSON) {
43
+ throw new Error(`L1_RPC_URLS_JSON is not defined`);
44
+ }
45
+ const client: ViemPublicClient = createPublicClient({
46
+ transport: fallback([http(L1_RPC_URLS_JSON, { batch: false })]),
47
+ });
48
+ return { url: L1_RPC_URLS_JSON, client };
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Queries an Aztec node for the L1 deployment addresses.
54
+ *
55
+ * @param env - Test environment config
56
+ * @param forcePortForward - If true, skip external IP and use port-forward directly
57
+ */
58
+ export async function getL1DeploymentAddresses(
59
+ env: TestConfig,
60
+ forcePortForward?: boolean,
61
+ ): Promise<L1ContractAddresses> {
62
+ let endpoint: ServiceEndpoint | undefined;
63
+ try {
64
+ endpoint = await getRPCEndpoint(env.NAMESPACE, forcePortForward);
65
+ const node = createAztecNodeClient(endpoint.url);
66
+ return await retry(
67
+ () => node.getNodeInfo().then(i => i.l1ContractAddresses),
68
+ 'get node info',
69
+ makeBackoff([1, 3, 6]),
70
+ logger,
71
+ );
72
+ } finally {
73
+ endpoint?.process?.kill();
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Returns a client to the RPC node.
79
+ * Tries external IP first, falls back to port-forward.
80
+ *
81
+ * @param env - Test environment config
82
+ * @param forcePortForward - If true, skip external IP and use port-forward directly
83
+ */
84
+ export async function getNodeClient(
85
+ env: TestConfig,
86
+ forcePortForward?: boolean,
87
+ ): Promise<{ node: ReturnType<typeof createAztecNodeClient>; url: string; process?: ChildProcess }> {
88
+ const namespace = env.NAMESPACE;
89
+
90
+ const endpoint = await getRPCEndpoint(namespace, forcePortForward);
91
+ await retry(
92
+ () => fetch(`${endpoint.url}/status`).then(res => res.status === 200),
93
+ 'check RPC endpoint',
94
+ makeBackoff([1, 1, 2, 6]),
95
+ logger,
96
+ true,
97
+ );
98
+ const client = createAztecNodeClient(endpoint.url);
99
+ return { node: client, url: endpoint.url, process: endpoint.process };
100
+ }
@@ -0,0 +1,26 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
+ import { schemas } from '@aztec/foundation/schemas';
3
+
4
+ import { z } from 'zod';
5
+
6
+ const logger = createLogger('e2e:k8s-utils');
7
+
8
+ const testConfigSchema = z.object({
9
+ NAMESPACE: z.string().default('scenario'),
10
+ REAL_VERIFIER: schemas.Boolean.optional().default(true),
11
+ CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
12
+ L1_RPC_URLS_JSON: z.string().optional(),
13
+ L1_ACCOUNT_MNEMONIC: z.string().optional(),
14
+ AZTEC_SLOT_DURATION: z.coerce.number().optional().default(24),
15
+ AZTEC_EPOCH_DURATION: z.coerce.number().optional().default(32),
16
+ AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
17
+ AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
18
+ });
19
+
20
+ export type TestConfig = z.infer<typeof testConfigSchema>;
21
+
22
+ export function setupEnvironment(env: unknown): TestConfig {
23
+ const config = testConfigSchema.parse(env);
24
+ logger.warn(`Loaded env config`, config);
25
+ return config;
26
+ }
@@ -0,0 +1,255 @@
1
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
2
+ import { createEthereumChain } from '@aztec/ethereum/chain';
3
+ import { RollupContract } from '@aztec/ethereum/contracts';
4
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
5
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
6
+ import type { Logger } from '@aztec/foundation/log';
7
+
8
+ import { createPublicClient, fallback, http } from 'viem';
9
+
10
+ import { type ServiceEndpoint, getEthereumEndpoint, getRPCEndpoint } from './k8s.js';
11
+
12
+ /**
13
+ * Snapshot of chain state captured during setup for comparison in teardown.
14
+ */
15
+ export interface ChainHealthSnapshot {
16
+ blockNumber: number;
17
+ checkpointNumber: CheckpointNumber;
18
+ timestamp: number;
19
+ }
20
+
21
+ /**
22
+ * Pre-flight and post-flight health checks for the Aztec network.
23
+ *
24
+ * Use in beforeAll/afterAll to validate the chain is healthy before tests run
25
+ * and verify it continued progressing during the test.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const health = new ChainHealth(config.NAMESPACE, logger);
30
+ *
31
+ * beforeAll(async () => {
32
+ * await health.setup();
33
+ * });
34
+ *
35
+ * afterAll(async () => {
36
+ * await health.teardown();
37
+ * });
38
+ * ```
39
+ */
40
+ export class ChainHealth {
41
+ private namespace: string;
42
+ private logger: Logger;
43
+ private snapshot?: ChainHealthSnapshot;
44
+
45
+ constructor(namespace: string, logger: Logger) {
46
+ this.namespace = namespace;
47
+ this.logger = logger;
48
+ }
49
+
50
+ /**
51
+ * Pre-flight health check. Validates chain is in a testable state and captures
52
+ * initial state for comparison in teardown.
53
+ *
54
+ * Checks performed:
55
+ * - Node is reachable and returns valid info
56
+ * - ENR exists
57
+ * - L1 is accessible
58
+ * - At least 1 L2 block has been mined
59
+ * - Committee exists
60
+ * - At least 1 checkpoint has been reached
61
+ *
62
+ * @throws Error if any health check fails
63
+ */
64
+ async setup(): Promise<void> {
65
+ const endpoints: ServiceEndpoint[] = [];
66
+
67
+ try {
68
+ // Establish connections (LB or port-forward)
69
+ const rpcEndpoint = await getRPCEndpoint(this.namespace);
70
+ endpoints.push(rpcEndpoint);
71
+
72
+ const ethEndpoint = await getEthereumEndpoint(this.namespace);
73
+ endpoints.push(ethEndpoint);
74
+
75
+ const nodeUrl = rpcEndpoint.url;
76
+ const ethereumUrl = ethEndpoint.url;
77
+
78
+ // Create clients
79
+ const node = createAztecNodeClient(nodeUrl);
80
+
81
+ // Check 1: Node is reachable
82
+ let nodeInfo;
83
+ try {
84
+ nodeInfo = await node.getNodeInfo();
85
+ } catch (err) {
86
+ throw new Error(`Health check failed: Node is not reachable at ${nodeUrl}. Error: ${err}`);
87
+ }
88
+
89
+ if (!nodeInfo) {
90
+ throw new Error('Health check failed: Node returned empty info');
91
+ }
92
+
93
+ // Check 2: ENR exists (P2P identity)
94
+ if (!nodeInfo.enr || !nodeInfo.enr.startsWith('enr:-')) {
95
+ throw new Error(`Health check failed: Invalid or missing ENR. Got: ${nodeInfo.enr}`);
96
+ }
97
+
98
+ // Check 3: L1 is accessible
99
+ const chain = createEthereumChain([ethereumUrl], nodeInfo.l1ChainId);
100
+ const ethereumClient: ViemPublicClient = createPublicClient({
101
+ chain: chain.chainInfo,
102
+ transport: fallback([http(ethereumUrl, { batch: false })]),
103
+ });
104
+
105
+ try {
106
+ await ethereumClient.getBlockNumber();
107
+ } catch (err) {
108
+ throw new Error(`Health check failed: L1 is not accessible at ${ethereumUrl}. Error: ${err}`);
109
+ }
110
+
111
+ // Check 4: At least 1 L2 block mined
112
+ let l2BlockNumber;
113
+ try {
114
+ l2BlockNumber = await node.getBlockNumber();
115
+ } catch (err) {
116
+ throw new Error(`Health check failed: Could not get L2 block number. Error: ${err}`);
117
+ }
118
+
119
+ if (l2BlockNumber < 1) {
120
+ throw new Error(`Health check failed: No L2 blocks mined yet. Block number: ${l2BlockNumber}`);
121
+ }
122
+
123
+ // Check 5: Committee exists
124
+ const rollup = new RollupContract(ethereumClient, nodeInfo.l1ContractAddresses.rollupAddress);
125
+
126
+ let committee;
127
+ try {
128
+ committee = await rollup.getCurrentEpochCommittee();
129
+ } catch (err) {
130
+ throw new Error(`Health check failed: Could not get committee. Error: ${err}`);
131
+ }
132
+
133
+ if (!committee || committee.length === 0) {
134
+ throw new Error('Health check failed: No committee exists. Validators may not be registered yet.');
135
+ }
136
+
137
+ // Check 6: At least 1 checkpoint reached
138
+ let checkpointNumber;
139
+ try {
140
+ checkpointNumber = await rollup.getCheckpointNumber();
141
+ } catch (err) {
142
+ throw new Error(`Health check failed: Could not get checkpoint number. Error: ${err}`);
143
+ }
144
+
145
+ if (checkpointNumber < CheckpointNumber(1)) {
146
+ throw new Error(
147
+ `Health check failed: No checkpoint reached yet. Checkpoint number: ${checkpointNumber}. ` +
148
+ 'The proving pipeline may not have completed a proof yet.',
149
+ );
150
+ }
151
+
152
+ // Capture snapshot for teardown comparison
153
+ this.snapshot = {
154
+ blockNumber: l2BlockNumber,
155
+ checkpointNumber,
156
+ timestamp: Date.now(),
157
+ };
158
+
159
+ this.logger.info('Pre-flight health check passed');
160
+ } finally {
161
+ endpoints.forEach(e => e.process?.kill());
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Post-flight health check. Verifies the chain continued progressing during the test.
167
+ *
168
+ * For tests that ran longer than the threshold, checks:
169
+ * - Block number increased since setup
170
+ * - Checkpoint number increased since setup
171
+ *
172
+ * For shorter tests, skips the check.
173
+ *
174
+ * @throws Error if chain did not progress
175
+ */
176
+ async teardown(): Promise<void> {
177
+ if (!this.snapshot) {
178
+ this.logger.warn('Teardown called without setup - skipping chain progress check');
179
+ return;
180
+ }
181
+
182
+ const endpoints: ServiceEndpoint[] = [];
183
+ // Minimum test duration to check chain progression
184
+ const PROGRESS_CHECK_THRESHOLD_SECONDS = 120;
185
+
186
+ try {
187
+ const elapsedSeconds = Math.round((Date.now() - this.snapshot.timestamp) / 1000);
188
+
189
+ // Skip progress check for short tests
190
+ if (elapsedSeconds <= PROGRESS_CHECK_THRESHOLD_SECONDS) {
191
+ this.logger.info('Post-flight health check passed (skipped progress check - test too short)');
192
+ return;
193
+ }
194
+
195
+ const rpcEndpoint = await getRPCEndpoint(this.namespace);
196
+ endpoints.push(rpcEndpoint);
197
+
198
+ const ethEndpoint = await getEthereumEndpoint(this.namespace);
199
+ endpoints.push(ethEndpoint);
200
+
201
+ const nodeUrl = rpcEndpoint.url;
202
+ const ethereumUrl = ethEndpoint.url;
203
+ const node = createAztecNodeClient(nodeUrl);
204
+
205
+ // Check that block number increased
206
+ let currentBlockNumber;
207
+ try {
208
+ currentBlockNumber = await node.getBlockNumber();
209
+ } catch (err) {
210
+ throw new Error(`Teardown health check failed: Could not get block number. Error: ${err}`);
211
+ }
212
+
213
+ if (currentBlockNumber <= this.snapshot.blockNumber) {
214
+ throw new Error(
215
+ `Chain did not progress during test. ` +
216
+ `Block number at setup: ${this.snapshot.blockNumber}, ` +
217
+ `Block number at teardown: ${currentBlockNumber}, ` +
218
+ `Elapsed time: ${elapsedSeconds}s. ` +
219
+ `The chain may have stalled during the test.`,
220
+ );
221
+ }
222
+
223
+ // Check that checkpoint number increased
224
+ const nodeInfo = await node.getNodeInfo();
225
+ const chain = createEthereumChain([ethereumUrl], nodeInfo.l1ChainId);
226
+ const ethereumClient: ViemPublicClient = createPublicClient({
227
+ chain: chain.chainInfo,
228
+ transport: fallback([http(ethereumUrl, { batch: false })]),
229
+ });
230
+
231
+ const rollup = new RollupContract(ethereumClient, nodeInfo.l1ContractAddresses.rollupAddress);
232
+ let currentCheckpoint;
233
+ try {
234
+ currentCheckpoint = await rollup.getCheckpointNumber();
235
+ } catch (err) {
236
+ throw new Error(`Teardown health check failed: Could not get checkpoint number. Error: ${err}`);
237
+ }
238
+
239
+ if (currentCheckpoint <= this.snapshot.checkpointNumber) {
240
+ throw new Error(
241
+ `Proving pipeline did not progress during test. ` +
242
+ `Checkpoint at setup: ${this.snapshot.checkpointNumber}, ` +
243
+ `Checkpoint at teardown: ${currentCheckpoint}, ` +
244
+ `Elapsed time: ${elapsedSeconds}s. ` +
245
+ `The proving pipeline may have stalled during the test.`,
246
+ );
247
+ }
248
+
249
+ this.logger.info('Post-flight health check passed');
250
+ } finally {
251
+ endpoints.forEach(e => e.process?.kill());
252
+ this.snapshot = undefined;
253
+ }
254
+ }
255
+ }
@@ -0,0 +1,84 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
+ import type { Logger } from '@aztec/foundation/log';
3
+
4
+ import { exec } from 'child_process';
5
+ import { promisify } from 'util';
6
+
7
+ const execAsync = promisify(exec);
8
+
9
+ const logger = createLogger('e2e:k8s-utils');
10
+
11
+ function shellQuote(value: string) {
12
+ // Single-quote safe shell escaping: ' -> '\''
13
+ return `'${value.replace(/'/g, "'\\''")}'`;
14
+ }
15
+
16
+ function valuesToArgs(values: Record<string, string | number | boolean>) {
17
+ return Object.entries(values)
18
+ .map(([key, value]) =>
19
+ typeof value === 'number' || typeof value === 'boolean'
20
+ ? `--set ${key}=${value}`
21
+ : `--set-string ${key}=${shellQuote(String(value))}`,
22
+ )
23
+ .join(' ');
24
+ }
25
+
26
+ export function createHelmCommand({
27
+ instanceName,
28
+ helmChartDir,
29
+ namespace,
30
+ valuesFile,
31
+ timeout,
32
+ values,
33
+ reuseValues = false,
34
+ }: {
35
+ instanceName: string;
36
+ helmChartDir: string;
37
+ namespace: string;
38
+ valuesFile: string | undefined;
39
+ timeout: string;
40
+ values: Record<string, string | number | boolean>;
41
+ reuseValues?: boolean;
42
+ }) {
43
+ const valuesFileArgs = valuesFile ? `--values ${helmChartDir}/values/${valuesFile}` : '';
44
+ const reuseValuesArgs = reuseValues ? '--reuse-values' : '';
45
+ return `helm upgrade --install ${instanceName} ${helmChartDir} --namespace ${namespace} ${valuesFileArgs} ${reuseValuesArgs} --wait --timeout=${timeout} ${valuesToArgs(
46
+ values,
47
+ )}`;
48
+ }
49
+
50
+ export async function execHelmCommand(args: Parameters<typeof createHelmCommand>[0]) {
51
+ const helmCommand = createHelmCommand(args);
52
+ logger.info(`helm command: ${helmCommand}`);
53
+ const { stdout } = await execAsync(helmCommand);
54
+ return stdout;
55
+ }
56
+
57
+ export async function getHelmReleaseStatus(instanceName: string, namespace: string): Promise<string | undefined> {
58
+ try {
59
+ const { stdout } = await execAsync(
60
+ `helm list --namespace ${namespace} --all --filter '^${instanceName}$' --output json | cat`,
61
+ );
62
+ const parsed = JSON.parse(stdout) as Array<{ name?: string; status?: string }>;
63
+ const row = parsed.find(r => r.name === instanceName);
64
+ return row?.status;
65
+ } catch {
66
+ return undefined;
67
+ }
68
+ }
69
+
70
+ export async function forceDeleteHelmReleaseRecord(instanceName: string, namespace: string, log?: Logger) {
71
+ const labelSelector = `owner=helm,name=${instanceName}`;
72
+ const cmd = `kubectl delete secret -n ${namespace} -l ${labelSelector} --ignore-not-found=true`;
73
+ (log ?? logger).warn(`Force deleting Helm release record: ${cmd}`);
74
+ await execAsync(cmd).catch(() => undefined);
75
+ }
76
+
77
+ export async function hasDeployedHelmRelease(instanceName: string, namespace: string): Promise<boolean> {
78
+ try {
79
+ const status = await getHelmReleaseStatus(instanceName, namespace);
80
+ return status?.toLowerCase() === 'deployed';
81
+ } catch {
82
+ return false;
83
+ }
84
+ }
@@ -0,0 +1,62 @@
1
+ // Re-export all utilities from individual modules
2
+ // Note: Internal helpers (helm commands, etc.) are not re-exported to maintain the original public API
3
+
4
+ // Config
5
+ export { type TestConfig, setupEnvironment } from './config.js';
6
+
7
+ // Scripts
8
+ export { getGitProjectRoot, getAztecBin, runAztecBin, runProjectScript } from './scripts.js';
9
+
10
+ // K8s operations
11
+ export {
12
+ startPortForward,
13
+ getExternalIP,
14
+ startPortForwardForPrometeheus,
15
+ startPortForwardForRPC,
16
+ startPortForwardForEthereum,
17
+ deleteResourceByName,
18
+ deleteResourceByLabel,
19
+ waitForResourceByLabel,
20
+ waitForResourceByName,
21
+ waitForResourcesByName,
22
+ getChartDir,
23
+ type ServiceEndpoint,
24
+ getServiceEndpoint,
25
+ getRPCEndpoint,
26
+ getEthereumEndpoint,
27
+ } from './k8s.js';
28
+
29
+ // Chaos Mesh
30
+ export {
31
+ uninstallChaosMesh,
32
+ installChaosMeshChart,
33
+ applyProverFailure,
34
+ applyValidatorFailure,
35
+ applyProverKill,
36
+ applyProverBrokerKill,
37
+ applyBootNodeFailure,
38
+ applyValidatorKill,
39
+ applyNetworkShaping,
40
+ } from './chaos.js';
41
+
42
+ // Bot management
43
+ export { restartBot, installTransferBot, uninstallTransferBot } from './bot.js';
44
+
45
+ // Node operations (sequencers, validators, pods)
46
+ export {
47
+ awaitCheckpointNumber,
48
+ getSequencers,
49
+ updateSequencersConfig,
50
+ getSequencersConfig,
51
+ withSequencersAdmin,
52
+ setValidatorTxDrop,
53
+ restartValidators,
54
+ enableValidatorDynamicBootNode,
55
+ rollAztecPods,
56
+ } from './nodes.js';
57
+
58
+ // Client utilities
59
+ export { getPublicViemClient, getL1DeploymentAddresses, getNodeClient } from './clients.js';
60
+
61
+ // Health checks
62
+ export { ChainHealth, type ChainHealthSnapshot } from './health.js';