@aztec/end-to-end 4.0.0-nightly.20260121 → 4.0.0-nightly.20260122

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 (56) hide show
  1. package/dest/shared/cross_chain_test_harness.d.ts +3 -4
  2. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  3. package/dest/shared/submit-transactions.d.ts +1 -1
  4. package/dest/shared/submit-transactions.d.ts.map +1 -1
  5. package/dest/shared/submit-transactions.js +1 -4
  6. package/dest/spartan/tx_metrics.d.ts +11 -1
  7. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  8. package/dest/spartan/tx_metrics.js +133 -4
  9. package/dest/spartan/utils/bot.d.ts +27 -0
  10. package/dest/spartan/utils/bot.d.ts.map +1 -0
  11. package/dest/spartan/utils/bot.js +141 -0
  12. package/dest/spartan/utils/chaos.d.ts +79 -0
  13. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  14. package/dest/spartan/utils/chaos.js +142 -0
  15. package/dest/spartan/utils/clients.d.ts +25 -0
  16. package/dest/spartan/utils/clients.d.ts.map +1 -0
  17. package/dest/spartan/utils/clients.js +101 -0
  18. package/dest/spartan/utils/config.d.ts +36 -0
  19. package/dest/spartan/utils/config.d.ts.map +1 -0
  20. package/dest/spartan/utils/config.js +20 -0
  21. package/dest/spartan/utils/health.d.ts +63 -0
  22. package/dest/spartan/utils/health.d.ts.map +1 -0
  23. package/dest/spartan/utils/health.js +202 -0
  24. package/dest/spartan/utils/helm.d.ts +15 -0
  25. package/dest/spartan/utils/helm.d.ts.map +1 -0
  26. package/dest/spartan/utils/helm.js +47 -0
  27. package/dest/spartan/utils/index.d.ts +9 -0
  28. package/dest/spartan/utils/index.d.ts.map +1 -0
  29. package/dest/spartan/utils/index.js +18 -0
  30. package/dest/spartan/utils/k8s.d.ts +59 -0
  31. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  32. package/dest/spartan/utils/k8s.js +185 -0
  33. package/dest/spartan/utils/nodes.d.ts +31 -0
  34. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  35. package/dest/spartan/utils/nodes.js +273 -0
  36. package/dest/spartan/utils/scripts.d.ts +16 -0
  37. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  38. package/dest/spartan/utils/scripts.js +66 -0
  39. package/dest/spartan/utils.d.ts +2 -260
  40. package/dest/spartan/utils.d.ts.map +1 -1
  41. package/dest/spartan/utils.js +1 -942
  42. package/package.json +39 -39
  43. package/src/shared/cross_chain_test_harness.ts +2 -3
  44. package/src/shared/submit-transactions.ts +1 -6
  45. package/src/spartan/tx_metrics.ts +82 -4
  46. package/src/spartan/utils/bot.ts +185 -0
  47. package/src/spartan/utils/chaos.ts +253 -0
  48. package/src/spartan/utils/clients.ts +106 -0
  49. package/src/spartan/utils/config.ts +26 -0
  50. package/src/spartan/utils/health.ts +256 -0
  51. package/src/spartan/utils/helm.ts +84 -0
  52. package/src/spartan/utils/index.ts +58 -0
  53. package/src/spartan/utils/k8s.ts +279 -0
  54. package/src/spartan/utils/nodes.ts +308 -0
  55. package/src/spartan/utils/scripts.ts +63 -0
  56. package/src/spartan/utils.ts +1 -1246
@@ -0,0 +1,142 @@
1
+ import { exec } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { execHelmCommand } from './helm.js';
4
+ import { deleteResourceByLabel, getChartDir } from './k8s.js';
5
+ const execAsync = promisify(exec);
6
+ export async function uninstallChaosMesh(instanceName, namespace, log) {
7
+ // uninstall the helm chart if it exists
8
+ log.info(`Uninstalling helm chart ${instanceName}`);
9
+ await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`);
10
+ // and delete the chaos-mesh resources created by this release
11
+ const deleteByLabel = async (resource)=>{
12
+ const args = {
13
+ resource,
14
+ namespace: namespace,
15
+ label: `app.kubernetes.io/instance=${instanceName}`
16
+ };
17
+ log.info(`Deleting ${resource} resources for release ${instanceName}`);
18
+ await deleteResourceByLabel(args).catch((e)=>{
19
+ log.error(`Error deleting ${resource}: ${e}`);
20
+ log.info(`Force deleting ${resource}`);
21
+ return deleteResourceByLabel({
22
+ ...args,
23
+ force: true
24
+ });
25
+ });
26
+ };
27
+ await deleteByLabel('podchaos');
28
+ await deleteByLabel('networkchaos');
29
+ await deleteByLabel('podnetworkchaos');
30
+ await deleteByLabel('workflows');
31
+ await deleteByLabel('workflownodes');
32
+ }
33
+ /**
34
+ * Installs a Helm chart with the given parameters.
35
+ * @param instanceName - The name of the Helm chart instance.
36
+ * @param targetNamespace - The namespace with the resources to be affected by the Helm chart.
37
+ * @param valuesFile - The values file to use for the Helm chart.
38
+ * @param chaosMeshNamespace - The namespace to install the Helm chart in.
39
+ * @param timeout - The timeout for the Helm command.
40
+ * @param clean - Whether to clean up the Helm chart before installing it.
41
+ * @returns The stdout of the Helm command.
42
+ * @throws If the Helm command fails.
43
+ *
44
+ * Example usage:
45
+ * ```typescript
46
+ * const stdout = await installChaosMeshChart({ instanceName: 'force-reorg', targetNamespace: 'smoke', valuesFile: 'prover-failure.yaml'});
47
+ * console.log(stdout);
48
+ * ```
49
+ */ export async function installChaosMeshChart({ instanceName, targetNamespace, valuesFile, helmChartDir, timeout = '10m', clean = true, values = {}, logger: log }) {
50
+ if (clean) {
51
+ await uninstallChaosMesh(instanceName, targetNamespace, log);
52
+ }
53
+ return execHelmCommand({
54
+ instanceName,
55
+ helmChartDir,
56
+ namespace: targetNamespace,
57
+ valuesFile,
58
+ timeout,
59
+ values: {
60
+ ...values,
61
+ 'global.targetNamespace': targetNamespace
62
+ }
63
+ });
64
+ }
65
+ export function applyProverFailure({ namespace, spartanDir, durationSeconds, logger: log }) {
66
+ return installChaosMeshChart({
67
+ instanceName: 'prover-failure',
68
+ targetNamespace: namespace,
69
+ valuesFile: 'prover-failure.yaml',
70
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
71
+ values: {
72
+ 'proverFailure.duration': `${durationSeconds}s`
73
+ },
74
+ logger: log
75
+ });
76
+ }
77
+ export function applyValidatorFailure({ namespace, spartanDir, logger: log, values, instanceName }) {
78
+ return installChaosMeshChart({
79
+ instanceName: instanceName ?? 'validator-failure',
80
+ targetNamespace: namespace,
81
+ valuesFile: 'validator-failure.yaml',
82
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
83
+ values,
84
+ logger: log
85
+ });
86
+ }
87
+ export function applyProverKill({ namespace, spartanDir, logger: log, values }) {
88
+ return installChaosMeshChart({
89
+ instanceName: 'prover-kill',
90
+ targetNamespace: namespace,
91
+ valuesFile: 'prover-kill.yaml',
92
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
93
+ chaosMeshNamespace: namespace,
94
+ clean: true,
95
+ logger: log,
96
+ values
97
+ });
98
+ }
99
+ export function applyProverBrokerKill({ namespace, spartanDir, logger: log, values }) {
100
+ return installChaosMeshChart({
101
+ instanceName: 'prover-broker-kill',
102
+ targetNamespace: namespace,
103
+ valuesFile: 'prover-broker-kill.yaml',
104
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
105
+ clean: true,
106
+ logger: log,
107
+ values
108
+ });
109
+ }
110
+ export function applyBootNodeFailure({ instanceName = 'boot-node-failure', namespace, spartanDir, durationSeconds, logger: log, values }) {
111
+ return installChaosMeshChart({
112
+ instanceName,
113
+ targetNamespace: namespace,
114
+ valuesFile: 'boot-node-failure.yaml',
115
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
116
+ values: {
117
+ 'bootNodeFailure.duration': `${durationSeconds}s`,
118
+ ...values ?? {}
119
+ },
120
+ logger: log
121
+ });
122
+ }
123
+ export function applyValidatorKill({ instanceName = 'validator-kill', namespace, spartanDir, logger: log, values, clean = true }) {
124
+ return installChaosMeshChart({
125
+ instanceName: instanceName ?? 'validator-kill',
126
+ targetNamespace: namespace,
127
+ valuesFile: 'validator-kill.yaml',
128
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
129
+ clean,
130
+ logger: log,
131
+ values
132
+ });
133
+ }
134
+ export function applyNetworkShaping({ instanceName = 'network-shaping', valuesFile, namespace, spartanDir, logger: log }) {
135
+ return installChaosMeshChart({
136
+ instanceName,
137
+ targetNamespace: namespace,
138
+ valuesFile,
139
+ helmChartDir: getChartDir(spartanDir, 'aztec-chaos-scenarios'),
140
+ logger: log
141
+ });
142
+ }
@@ -0,0 +1,25 @@
1
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
3
+ import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
4
+ import type { ChildProcess } from 'child_process';
5
+ import type { TestConfig } from './config.js';
6
+ /**
7
+ * Returns a public viem client to the eth execution node. If it was part of a local eth devnet,
8
+ * it first port-forwards the service and points to it. Otherwise, just uses the external RPC url.
9
+ */
10
+ export declare function getPublicViemClient(env: TestConfig,
11
+ /** If set, will push the new process into it */
12
+ processes?: ChildProcess[]): Promise<{
13
+ url: string;
14
+ client: ViemPublicClient;
15
+ process?: ChildProcess;
16
+ }>;
17
+ /** Queries an Aztec node for the L1 deployment addresses */
18
+ export declare function getL1DeploymentAddresses(env: TestConfig): Promise<L1ContractAddresses>;
19
+ /** Returns a client to the RPC of the given sequencer (defaults to first) */
20
+ export declare function getNodeClient(env: TestConfig, index?: number): Promise<{
21
+ node: ReturnType<typeof createAztecNodeClient>;
22
+ port: number;
23
+ process: ChildProcess;
24
+ }>;
25
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NwYXJ0YW4vdXRpbHMvY2xpZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2pGLE9BQU8sS0FBS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AK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,UAAU;AACf,gDAAgD;AAChD,SAAS,CAAC,EAAE,YAAY,EAAE,GACzB,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAC;IAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC,CAyB5E;AAED,4DAA4D;AAC5D,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsB5F;AAED,6EAA6E;AAC7E,wBAAsB,aAAa,CACjC,GAAG,EAAE,UAAU,EACf,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC,CA0BlG"}
@@ -0,0 +1,101 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
3
+ import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
4
+ import { createPublicClient, fallback, http } from 'viem';
5
+ import { startPortForward } from './k8s.js';
6
+ import { getSequencers } from './nodes.js';
7
+ const logger = createLogger('e2e:k8s-utils');
8
+ /**
9
+ * Returns a public viem client to the eth execution node. If it was part of a local eth devnet,
10
+ * it first port-forwards the service and points to it. Otherwise, just uses the external RPC url.
11
+ */ export async function getPublicViemClient(env, /** If set, will push the new process into it */ processes) {
12
+ const { NAMESPACE, CREATE_ETH_DEVNET, L1_RPC_URLS_JSON } = env;
13
+ if (CREATE_ETH_DEVNET) {
14
+ logger.info(`Creating port forward to eth execution node`);
15
+ const { process, port } = await startPortForward({
16
+ resource: `svc/${NAMESPACE}-eth-execution`,
17
+ namespace: NAMESPACE,
18
+ containerPort: 8545
19
+ });
20
+ const url = `http://127.0.0.1:${port}`;
21
+ const client = createPublicClient({
22
+ transport: fallback([
23
+ http(url, {
24
+ batch: false
25
+ })
26
+ ])
27
+ });
28
+ if (processes) {
29
+ processes.push(process);
30
+ }
31
+ return {
32
+ url,
33
+ client,
34
+ process
35
+ };
36
+ } else {
37
+ logger.info(`Connecting to the eth execution node at ${L1_RPC_URLS_JSON}`);
38
+ if (!L1_RPC_URLS_JSON) {
39
+ throw new Error(`L1_RPC_URLS_JSON is not defined`);
40
+ }
41
+ const client = createPublicClient({
42
+ transport: fallback([
43
+ http(L1_RPC_URLS_JSON, {
44
+ batch: false
45
+ })
46
+ ])
47
+ });
48
+ return {
49
+ url: L1_RPC_URLS_JSON,
50
+ client
51
+ };
52
+ }
53
+ }
54
+ /** Queries an Aztec node for the L1 deployment addresses */ export async function getL1DeploymentAddresses(env) {
55
+ let forwardProcess;
56
+ try {
57
+ const [sequencer] = await getSequencers(env.NAMESPACE);
58
+ const { process, port } = await startPortForward({
59
+ resource: `pod/${sequencer}`,
60
+ namespace: env.NAMESPACE,
61
+ containerPort: 8080
62
+ });
63
+ forwardProcess = process;
64
+ const url = `http://127.0.0.1:${port}`;
65
+ const node = createAztecNodeClient(url);
66
+ return await retry(()=>node.getNodeInfo().then((i)=>i.l1ContractAddresses), 'get node info', makeBackoff([
67
+ 1,
68
+ 3,
69
+ 6
70
+ ]), logger);
71
+ } finally{
72
+ forwardProcess?.kill();
73
+ }
74
+ }
75
+ /** Returns a client to the RPC of the given sequencer (defaults to first) */ export async function getNodeClient(env, index = 0) {
76
+ const namespace = env.NAMESPACE;
77
+ const containerPort = 8080;
78
+ const sequencers = await getSequencers(namespace);
79
+ const sequencer = sequencers[index];
80
+ if (!sequencer) {
81
+ throw new Error(`No sequencer found at index ${index} in namespace ${namespace}`);
82
+ }
83
+ const { process, port } = await startPortForward({
84
+ resource: `pod/${sequencer}`,
85
+ namespace,
86
+ containerPort
87
+ });
88
+ const url = `http://localhost:${port}`;
89
+ await retry(()=>fetch(`${url}/status`).then((res)=>res.status === 200), 'forward port', makeBackoff([
90
+ 1,
91
+ 1,
92
+ 2,
93
+ 6
94
+ ]), logger, true);
95
+ const client = createAztecNodeClient(url);
96
+ return {
97
+ node: client,
98
+ port,
99
+ process
100
+ };
101
+ }
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ declare const testConfigSchema: z.ZodObject<{
3
+ NAMESPACE: z.ZodDefault<z.ZodString>;
4
+ REAL_VERIFIER: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodEffects<z.ZodNumber, 0 | 1, number>, boolean, number>, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, boolean, string>]>>>;
5
+ CREATE_ETH_DEVNET: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodEffects<z.ZodNumber, 0 | 1, number>, boolean, number>, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, boolean, string>]>>>;
6
+ L1_RPC_URLS_JSON: z.ZodOptional<z.ZodString>;
7
+ L1_ACCOUNT_MNEMONIC: z.ZodOptional<z.ZodString>;
8
+ AZTEC_SLOT_DURATION: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
9
+ AZTEC_EPOCH_DURATION: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
10
+ AZTEC_PROOF_SUBMISSION_WINDOW: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
+ AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ NAMESPACE: string;
14
+ REAL_VERIFIER: boolean;
15
+ CREATE_ETH_DEVNET: boolean;
16
+ L1_RPC_URLS_JSON?: string | undefined;
17
+ L1_ACCOUNT_MNEMONIC?: string | undefined;
18
+ AZTEC_SLOT_DURATION: number;
19
+ AZTEC_EPOCH_DURATION: number;
20
+ AZTEC_PROOF_SUBMISSION_WINDOW: number;
21
+ AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: number;
22
+ }, {
23
+ NAMESPACE?: string | undefined;
24
+ REAL_VERIFIER?: string | number | boolean | undefined;
25
+ CREATE_ETH_DEVNET?: string | number | boolean | undefined;
26
+ L1_RPC_URLS_JSON?: string | undefined;
27
+ L1_ACCOUNT_MNEMONIC?: string | undefined;
28
+ AZTEC_SLOT_DURATION?: number | undefined;
29
+ AZTEC_EPOCH_DURATION?: number | undefined;
30
+ AZTEC_PROOF_SUBMISSION_WINDOW?: number | undefined;
31
+ AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET?: number | undefined;
32
+ }>;
33
+ export type TestConfig = z.infer<typeof testConfigSchema>;
34
+ export declare function setupEnvironment(env: unknown): TestConfig;
35
+ export {};
36
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3BhcnRhbi91dGlscy9jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUl4QixRQUFBLE1BQU0sZ0JBQWdCOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7RUFVcEIsQ0FBQztBQUVILE1BQU0sTUFBTSxVQUFVLEdBQUcsQ0FBQyxDQUFDLEtBQUssQ0FBQyxPQUFPLGdCQUFnQixDQUFDLENBQUM7QUFFMUQsd0JBQWdCLGdCQUFnQixDQUFDLEdBQUcsRUFBRSxPQUFPLEdBQUcsVUFBVSxDQUl6RCJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUpB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAIzD"}
@@ -0,0 +1,20 @@
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
+ import { schemas } from '@aztec/foundation/schemas';
3
+ import { z } from 'zod';
4
+ const logger = createLogger('e2e:k8s-utils');
5
+ const testConfigSchema = z.object({
6
+ NAMESPACE: z.string().default('scenario'),
7
+ REAL_VERIFIER: schemas.Boolean.optional().default(true),
8
+ CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
9
+ L1_RPC_URLS_JSON: z.string().optional(),
10
+ L1_ACCOUNT_MNEMONIC: z.string().optional(),
11
+ AZTEC_SLOT_DURATION: z.coerce.number().optional().default(24),
12
+ AZTEC_EPOCH_DURATION: z.coerce.number().optional().default(32),
13
+ AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
14
+ AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2)
15
+ });
16
+ export function setupEnvironment(env) {
17
+ const config = testConfigSchema.parse(env);
18
+ logger.warn(`Loaded env config`, config);
19
+ return config;
20
+ }
@@ -0,0 +1,63 @@
1
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
2
+ import type { Logger } from '@aztec/foundation/log';
3
+ /**
4
+ * Snapshot of chain state captured during setup for comparison in teardown.
5
+ */
6
+ export interface ChainHealthSnapshot {
7
+ blockNumber: number;
8
+ checkpointNumber: CheckpointNumber;
9
+ timestamp: number;
10
+ }
11
+ /**
12
+ * Pre-flight and post-flight health checks for the Aztec network.
13
+ *
14
+ * Use in beforeAll/afterAll to validate the chain is healthy before tests run
15
+ * and verify it continued progressing during the test.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const health = new ChainHealth(config.NAMESPACE, logger);
20
+ *
21
+ * beforeAll(async () => {
22
+ * await health.setup();
23
+ * });
24
+ *
25
+ * afterAll(async () => {
26
+ * await health.teardown();
27
+ * });
28
+ * ```
29
+ */
30
+ export declare class ChainHealth {
31
+ private namespace;
32
+ private logger;
33
+ private snapshot?;
34
+ constructor(namespace: string, logger: Logger);
35
+ /**
36
+ * Pre-flight health check. Validates chain is in a testable state and captures
37
+ * initial state for comparison in teardown.
38
+ *
39
+ * Checks performed:
40
+ * - Node is reachable and returns valid info
41
+ * - ENR exists
42
+ * - L1 is accessible
43
+ * - At least 1 L2 block has been mined
44
+ * - Committee exists
45
+ * - At least 1 checkpoint has been reached
46
+ *
47
+ * @throws Error if any health check fails
48
+ */
49
+ setup(): Promise<void>;
50
+ /**
51
+ * Post-flight health check. Verifies the chain continued progressing during the test.
52
+ *
53
+ * For tests that ran longer than the threshold, checks:
54
+ * - Block number increased since setup
55
+ * - Checkpoint number increased since setup
56
+ *
57
+ * For shorter tests, skips the check.
58
+ *
59
+ * @throws Error if chain did not progress
60
+ */
61
+ teardown(): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVhbHRoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3BhcnRhbi91dGlscy9oZWFsdGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDbkUsT0FBTyxLQUFLLEVBQUUsTU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AsB;IAEvC,YAAY,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAG5C;IAED;;;;;;;;;;;;;OAaG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAmG3B;IAED;;;;;;;;;;OAUG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CA8E9B;CACF"}
@@ -0,0 +1,202 @@
1
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
2
+ import { createEthereumChain } from '@aztec/ethereum/chain';
3
+ import { RollupContract } from '@aztec/ethereum/contracts';
4
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
5
+ import { createPublicClient, fallback, http } from 'viem';
6
+ import { startPortForwardForEthereum, startPortForwardForRPC } from './k8s.js';
7
+ /**
8
+ * Pre-flight and post-flight health checks for the Aztec network.
9
+ *
10
+ * Use in beforeAll/afterAll to validate the chain is healthy before tests run
11
+ * and verify it continued progressing during the test.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const health = new ChainHealth(config.NAMESPACE, logger);
16
+ *
17
+ * beforeAll(async () => {
18
+ * await health.setup();
19
+ * });
20
+ *
21
+ * afterAll(async () => {
22
+ * await health.teardown();
23
+ * });
24
+ * ```
25
+ */ export class ChainHealth {
26
+ namespace;
27
+ logger;
28
+ snapshot;
29
+ constructor(namespace, logger){
30
+ this.namespace = namespace;
31
+ this.logger = logger;
32
+ }
33
+ /**
34
+ * Pre-flight health check. Validates chain is in a testable state and captures
35
+ * initial state for comparison in teardown.
36
+ *
37
+ * Checks performed:
38
+ * - Node is reachable and returns valid info
39
+ * - ENR exists
40
+ * - L1 is accessible
41
+ * - At least 1 L2 block has been mined
42
+ * - Committee exists
43
+ * - At least 1 checkpoint has been reached
44
+ *
45
+ * @throws Error if any health check fails
46
+ */ async setup() {
47
+ const processes = [];
48
+ try {
49
+ // Establish temporary connections
50
+ const { process: rpcProcess, port: rpcPort } = await startPortForwardForRPC(this.namespace);
51
+ processes.push(rpcProcess);
52
+ const { process: ethProcess, port: ethPort } = await startPortForwardForEthereum(this.namespace);
53
+ processes.push(ethProcess);
54
+ const nodeUrl = `http://127.0.0.1:${rpcPort}`;
55
+ const ethereumUrl = `http://127.0.0.1:${ethPort}`;
56
+ // Create clients
57
+ const node = createAztecNodeClient(nodeUrl);
58
+ // Check 1: Node is reachable
59
+ let nodeInfo;
60
+ try {
61
+ nodeInfo = await node.getNodeInfo();
62
+ } catch (err) {
63
+ throw new Error(`Health check failed: Node is not reachable at ${nodeUrl}. Error: ${err}`);
64
+ }
65
+ if (!nodeInfo) {
66
+ throw new Error('Health check failed: Node returned empty info');
67
+ }
68
+ // Check 2: ENR exists (P2P identity)
69
+ if (!nodeInfo.enr || !nodeInfo.enr.startsWith('enr:-')) {
70
+ throw new Error(`Health check failed: Invalid or missing ENR. Got: ${nodeInfo.enr}`);
71
+ }
72
+ // Check 3: L1 is accessible
73
+ const chain = createEthereumChain([
74
+ ethereumUrl
75
+ ], nodeInfo.l1ChainId);
76
+ const ethereumClient = createPublicClient({
77
+ chain: chain.chainInfo,
78
+ transport: fallback([
79
+ http(ethereumUrl, {
80
+ batch: false
81
+ })
82
+ ])
83
+ });
84
+ try {
85
+ await ethereumClient.getBlockNumber();
86
+ } catch (err) {
87
+ throw new Error(`Health check failed: L1 is not accessible at ${ethereumUrl}. Error: ${err}`);
88
+ }
89
+ // Check 4: At least 1 L2 block mined
90
+ let l2BlockNumber;
91
+ try {
92
+ l2BlockNumber = await node.getBlockNumber();
93
+ } catch (err) {
94
+ throw new Error(`Health check failed: Could not get L2 block number. Error: ${err}`);
95
+ }
96
+ if (l2BlockNumber < 1) {
97
+ throw new Error(`Health check failed: No L2 blocks mined yet. Block number: ${l2BlockNumber}`);
98
+ }
99
+ // Check 5: Committee exists
100
+ const rollup = new RollupContract(ethereumClient, nodeInfo.l1ContractAddresses.rollupAddress);
101
+ let committee;
102
+ try {
103
+ committee = await rollup.getCurrentEpochCommittee();
104
+ } catch (err) {
105
+ throw new Error(`Health check failed: Could not get committee. Error: ${err}`);
106
+ }
107
+ if (!committee || committee.length === 0) {
108
+ throw new Error('Health check failed: No committee exists. Validators may not be registered yet.');
109
+ }
110
+ // Check 6: At least 1 checkpoint reached
111
+ let checkpointNumber;
112
+ try {
113
+ checkpointNumber = await rollup.getCheckpointNumber();
114
+ } catch (err) {
115
+ throw new Error(`Health check failed: Could not get checkpoint number. Error: ${err}`);
116
+ }
117
+ if (checkpointNumber < CheckpointNumber(1)) {
118
+ throw new Error(`Health check failed: No checkpoint reached yet. Checkpoint number: ${checkpointNumber}. ` + 'The proving pipeline may not have completed a proof yet.');
119
+ }
120
+ // Capture snapshot for teardown comparison
121
+ this.snapshot = {
122
+ blockNumber: l2BlockNumber,
123
+ checkpointNumber,
124
+ timestamp: Date.now()
125
+ };
126
+ this.logger.info('Pre-flight health check passed');
127
+ } finally{
128
+ processes.forEach((p)=>p.kill());
129
+ }
130
+ }
131
+ /**
132
+ * Post-flight health check. Verifies the chain continued progressing during the test.
133
+ *
134
+ * For tests that ran longer than the threshold, checks:
135
+ * - Block number increased since setup
136
+ * - Checkpoint number increased since setup
137
+ *
138
+ * For shorter tests, skips the check.
139
+ *
140
+ * @throws Error if chain did not progress
141
+ */ async teardown() {
142
+ if (!this.snapshot) {
143
+ this.logger.warn('Teardown called without setup - skipping chain progress check');
144
+ return;
145
+ }
146
+ const processes = [];
147
+ // Minimum test duration to check chain progression
148
+ const PROGRESS_CHECK_THRESHOLD_SECONDS = 120;
149
+ try {
150
+ const elapsedSeconds = Math.round((Date.now() - this.snapshot.timestamp) / 1000);
151
+ // Skip progress check for short tests
152
+ if (elapsedSeconds <= PROGRESS_CHECK_THRESHOLD_SECONDS) {
153
+ this.logger.info('Post-flight health check passed (skipped progress check - test too short)');
154
+ return;
155
+ }
156
+ const { process: rpcProcess, port: rpcPort } = await startPortForwardForRPC(this.namespace);
157
+ processes.push(rpcProcess);
158
+ const { process: ethProcess, port: ethPort } = await startPortForwardForEthereum(this.namespace);
159
+ processes.push(ethProcess);
160
+ const nodeUrl = `http://127.0.0.1:${rpcPort}`;
161
+ const ethereumUrl = `http://127.0.0.1:${ethPort}`;
162
+ const node = createAztecNodeClient(nodeUrl);
163
+ // Check that block number increased
164
+ let currentBlockNumber;
165
+ try {
166
+ currentBlockNumber = await node.getBlockNumber();
167
+ } catch (err) {
168
+ throw new Error(`Teardown health check failed: Could not get block number. Error: ${err}`);
169
+ }
170
+ if (currentBlockNumber <= this.snapshot.blockNumber) {
171
+ throw new Error(`Chain did not progress during test. ` + `Block number at setup: ${this.snapshot.blockNumber}, ` + `Block number at teardown: ${currentBlockNumber}, ` + `Elapsed time: ${elapsedSeconds}s. ` + `The chain may have stalled during the test.`);
172
+ }
173
+ // Check that checkpoint number increased
174
+ const nodeInfo = await node.getNodeInfo();
175
+ const chain = createEthereumChain([
176
+ ethereumUrl
177
+ ], nodeInfo.l1ChainId);
178
+ const ethereumClient = createPublicClient({
179
+ chain: chain.chainInfo,
180
+ transport: fallback([
181
+ http(ethereumUrl, {
182
+ batch: false
183
+ })
184
+ ])
185
+ });
186
+ const rollup = new RollupContract(ethereumClient, nodeInfo.l1ContractAddresses.rollupAddress);
187
+ let currentCheckpoint;
188
+ try {
189
+ currentCheckpoint = await rollup.getCheckpointNumber();
190
+ } catch (err) {
191
+ throw new Error(`Teardown health check failed: Could not get checkpoint number. Error: ${err}`);
192
+ }
193
+ if (currentCheckpoint <= this.snapshot.checkpointNumber) {
194
+ throw new Error(`Proving pipeline did not progress during test. ` + `Checkpoint at setup: ${this.snapshot.checkpointNumber}, ` + `Checkpoint at teardown: ${currentCheckpoint}, ` + `Elapsed time: ${elapsedSeconds}s. ` + `The proving pipeline may have stalled during the test.`);
195
+ }
196
+ this.logger.info('Post-flight health check passed');
197
+ } finally{
198
+ processes.forEach((p)=>p.kill());
199
+ this.snapshot = undefined;
200
+ }
201
+ }
202
+ }
@@ -0,0 +1,15 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ export declare function createHelmCommand({ instanceName, helmChartDir, namespace, valuesFile, timeout, values, reuseValues }: {
3
+ instanceName: string;
4
+ helmChartDir: string;
5
+ namespace: string;
6
+ valuesFile: string | undefined;
7
+ timeout: string;
8
+ values: Record<string, string | number | boolean>;
9
+ reuseValues?: boolean;
10
+ }): string;
11
+ export declare function execHelmCommand(args: Parameters<typeof createHelmCommand>[0]): Promise<string>;
12
+ export declare function getHelmReleaseStatus(instanceName: string, namespace: string): Promise<string | undefined>;
13
+ export declare function forceDeleteHelmReleaseRecord(instanceName: string, namespace: string, log?: Logger): Promise<void>;
14
+ export declare function hasDeployedHelmRelease(instanceName: string, namespace: string): Promise<boolean>;
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVsbS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NwYXJ0YW4vdXRpbHMvaGVsbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQXdCcEQsd0JBQWdCLGlCQUFpQixDQUFDLEVBQ2hDLFlBQVksRUFDWixZQUFZLEVBQ1osU0FBUyxFQUNULFVBQVUsRUFDVixPQUFPLEVBQ1AsTUFBTSxFQUNOLFdBQW1CLEVBQ3BCLEVBQUU7SUFDRCxZQUFZLEVBQUUsTUFBTSxDQUFDO0lBQ3JCLFlBQVksRUFBRSxNQUFNLENBQUM7SUFDckIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixVQUFVLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztJQUMvQixPQUFPLEVBQUUsTUFBTSxDQUFDO0lBQ2hCLE1BQU0sRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sR0FBRyxNQUFNLEdBQUcsT0FBTyxDQUFDLENBQUM7SUFDbEQsV0FBVyxDQUFDLEVBQUUsT0FBT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