@lightprotocol/zk-compression-cli 0.23.0 → 0.25.0

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 (78) hide show
  1. package/README.md +1 -1
  2. package/accounts/address_merkle_tree_amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2.json +1 -1
  3. package/accounts/batch_address_merkle_tree_EzKE84aVTkCUhDHLELqyJaq1Y7UVVmqxXqZjVHwHY3rK.json +1 -0
  4. package/accounts/batch_state_merkle_tree_HLKs5NJ8FXkJg8BrzJt56adFYYuwg5etzDtBbQYTsixu.json +1 -0
  5. package/accounts/batched_output_queue_6L7SzhYB3anwEQ9cphpJ1U7Scwj57bx2xueReg7R9cKU.json +1 -0
  6. package/accounts/cpi_context_2_cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK.json +1 -0
  7. package/accounts/cpi_context_cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK.json +1 -0
  8. package/accounts/group_pda_32tgQWfaASE7SfTQvMaSJDrqe728tJQ2SGzxtDDrpDwS.json +1 -0
  9. package/accounts/merkle_tree_pubkey_2_smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho.json +1 -0
  10. package/accounts/merkle_tree_pubkey_smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho.json +1 -0
  11. package/accounts/nullifier_queue_pubkey_2_nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X.json +1 -0
  12. package/accounts/nullifier_queue_pubkey_nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X.json +1 -0
  13. package/accounts/registered_program_pda_35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh.json +1 -1
  14. package/accounts/registered_registry_program_pda_DumMsyvkaGJG4QnQ1BhTgvoRMXsgGxfpKDUCr22Xqu4w.json +1 -1
  15. package/bin/account_compression.so +0 -0
  16. package/bin/light_compressed_token.so +0 -0
  17. package/bin/light_registry.so +0 -0
  18. package/bin/light_system_program_pinocchio.so +0 -0
  19. package/bin/prover-darwin-arm64 +0 -0
  20. package/bin/prover-darwin-x64 +0 -0
  21. package/bin/prover-linux-arm64 +0 -0
  22. package/bin/prover-linux-x64 +0 -0
  23. package/bin/prover-windows-arm64.exe +0 -0
  24. package/bin/prover-windows-x64.exe +0 -0
  25. package/bin/proving-keys/combined_32_40_1_1.key +0 -0
  26. package/bin/proving-keys/{combined_26_3_2.key → combined_32_40_1_2.key} +0 -0
  27. package/bin/proving-keys/{combined_26_2_2.key → combined_32_40_2_1.key} +0 -0
  28. package/bin/proving-keys/inclusion_32_1.key +0 -0
  29. package/bin/proving-keys/inclusion_32_2.key +0 -0
  30. package/bin/proving-keys/{combined_26_3_1.key → inclusion_32_3.key} +0 -0
  31. package/bin/proving-keys/{combined_26_4_1.key → inclusion_32_4.key} +0 -0
  32. package/bin/proving-keys/non-inclusion_40_1.key +0 -0
  33. package/bin/proving-keys/non-inclusion_40_2.key +0 -0
  34. package/dist/commands/balance/index.d.ts +0 -1
  35. package/dist/commands/balance/index.js +10 -17
  36. package/dist/commands/compress-spl/index.js +3 -1
  37. package/dist/commands/decompress-spl/index.js +3 -1
  38. package/dist/commands/init/index.js +21 -3
  39. package/dist/commands/start-prover/index.d.ts +2 -0
  40. package/dist/commands/start-prover/index.js +31 -6
  41. package/dist/commands/test-validator/index.d.ts +11 -1
  42. package/dist/commands/test-validator/index.js +82 -2
  43. package/dist/commands/token-balance/index.d.ts +12 -0
  44. package/dist/commands/token-balance/index.js +55 -0
  45. package/dist/utils/constants.d.ts +21 -11
  46. package/dist/utils/constants.js +25 -12
  47. package/dist/utils/initTestEnv.d.ts +9 -1
  48. package/dist/utils/initTestEnv.js +38 -28
  49. package/dist/utils/process.d.ts +4 -0
  50. package/dist/utils/process.js +41 -2
  51. package/dist/utils/processPhotonIndexer.d.ts +1 -1
  52. package/dist/utils/processPhotonIndexer.js +33 -24
  53. package/dist/utils/processProverServer.d.ts +3 -1
  54. package/dist/utils/processProverServer.js +83 -2
  55. package/oclif.manifest.json +170 -112
  56. package/package.json +30 -19
  57. package/bin/proving-keys/CHECKSUM +0 -112
  58. package/bin/proving-keys/combined_26_1_1.vkey +0 -1
  59. package/bin/proving-keys/combined_26_1_2.vkey +0 -1
  60. package/bin/proving-keys/combined_26_2_1.vkey +0 -1
  61. package/bin/proving-keys/combined_26_2_2.vkey +0 -1
  62. package/bin/proving-keys/combined_26_3_1.vkey +0 -1
  63. package/bin/proving-keys/combined_26_3_2.vkey +0 -1
  64. package/bin/proving-keys/combined_26_4_1.vkey +0 -1
  65. package/bin/proving-keys/combined_26_4_2.key +0 -0
  66. package/bin/proving-keys/combined_26_4_2.vkey +0 -1
  67. package/bin/proving-keys/inclusion_26_1.vkey +0 -1
  68. package/bin/proving-keys/inclusion_26_2.vkey +0 -1
  69. package/bin/proving-keys/inclusion_26_3.vkey +0 -1
  70. package/bin/proving-keys/inclusion_26_4.vkey +0 -1
  71. package/bin/proving-keys/inclusion_26_8.key +0 -0
  72. package/bin/proving-keys/inclusion_26_8.vkey +0 -1
  73. package/bin/proving-keys/non-inclusion_26_1.vkey +0 -1
  74. package/bin/proving-keys/non-inclusion_26_2.vkey +0 -1
  75. /package/bin/proving-keys/{inclusion_26_1.key → mainnet_inclusion_26_1.key} +0 -0
  76. /package/bin/proving-keys/{inclusion_26_2.key → mainnet_inclusion_26_2.key} +0 -0
  77. /package/bin/proving-keys/{inclusion_26_3.key → mainnet_inclusion_26_3.key} +0 -0
  78. /package/bin/proving-keys/{inclusion_26_4.key → mainnet_inclusion_26_4.key} +0 -0
@@ -1,3 +1,10 @@
1
+ type Program = {
2
+ id: string;
3
+ name?: string;
4
+ tag?: string;
5
+ path?: string;
6
+ };
7
+ export declare const SYSTEM_PROGRAMS: Program[];
1
8
  export declare function stopTestEnv(options: {
2
9
  indexer: boolean;
3
10
  prover: boolean;
@@ -17,7 +24,7 @@ export declare function initTestEnv({ additionalPrograms, skipSystemAccounts, in
17
24
  checkPhotonVersion?: boolean;
18
25
  photonDatabaseUrl?: string;
19
26
  limitLedgerSize?: number;
20
- proverRunMode?: "inclusion" | "non-inclusion" | "forester" | "forester-test" | "rpc" | "full" | "full-test";
27
+ proverRunMode?: "local-rpc" | "inclusion" | "non-inclusion" | "forester" | "forester-test" | "rpc" | "full" | "full-test";
21
28
  circuits?: string[];
22
29
  validatorArgs?: string;
23
30
  geyserConfig?: string;
@@ -59,3 +66,4 @@ export declare function startTestValidator({ additionalPrograms, skipSystemAccou
59
66
  geyserConfig?: string;
60
67
  }): Promise<void>;
61
68
  export declare function killTestValidator(): Promise<void>;
69
+ export {};
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SYSTEM_PROGRAMS = void 0;
3
4
  exports.stopTestEnv = stopTestEnv;
4
5
  exports.initTestEnv = initTestEnv;
5
6
  exports.initTestEnvIfNeeded = initTestEnvIfNeeded;
@@ -16,6 +17,33 @@ const psp_utils_1 = require("../psp-utils");
16
17
  const process_1 = require("./process");
17
18
  const processProverServer_1 = require("./processProverServer");
18
19
  const processPhotonIndexer_1 = require("./processPhotonIndexer");
20
+ exports.SYSTEM_PROGRAMS = [
21
+ {
22
+ id: "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",
23
+ name: "spl_noop.so",
24
+ tag: constants_1.SPL_NOOP_PROGRAM_TAG,
25
+ },
26
+ {
27
+ id: "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7",
28
+ name: "light_system_program_pinocchio.so",
29
+ tag: constants_1.LIGHT_SYSTEM_PROGRAM_TAG,
30
+ },
31
+ {
32
+ id: "cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m",
33
+ name: "light_compressed_token.so",
34
+ tag: constants_1.LIGHT_COMPRESSED_TOKEN_TAG,
35
+ },
36
+ {
37
+ id: "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq",
38
+ name: "account_compression.so",
39
+ tag: constants_1.LIGHT_ACCOUNT_COMPRESSION_TAG,
40
+ },
41
+ {
42
+ id: "Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX",
43
+ name: "light_registry.so",
44
+ tag: constants_1.LIGHT_REGISTRY_TAG,
45
+ },
46
+ ];
19
47
  async function stopTestEnv(options) {
20
48
  const processesToKill = [
21
49
  { name: "photon", condition: options.indexer, killFunction: processPhotonIndexer_1.killIndexer },
@@ -65,7 +93,15 @@ async function initTestEnv({ additionalPrograms, skipSystemAccounts, indexer = t
65
93
  const config = (0, utils_1.getConfig)();
66
94
  config.proverUrl = `http://127.0.0.1:${proverPort}`;
67
95
  (0, utils_1.setConfig)(config);
68
- await (0, processProverServer_1.startProver)(proverPort, proverRunMode, circuits);
96
+ try {
97
+ // TODO: check if using redisUrl is better here.
98
+ await (0, processProverServer_1.startProver)(proverPort, proverRunMode, circuits);
99
+ }
100
+ catch (error) {
101
+ console.error("Failed to start prover:", error);
102
+ // Prover logs will be automatically displayed by spawnBinary in process.ts
103
+ throw error;
104
+ }
69
105
  }
70
106
  }
71
107
  async function initTestEnvIfNeeded({ additionalPrograms, skipSystemAccounts, indexer = false, prover = false, geyserConfig, validatorArgs, } = {}) {
@@ -120,33 +156,7 @@ function programFilePath(programName) {
120
156
  }
121
157
  async function getSolanaArgs({ additionalPrograms, skipSystemAccounts, limitLedgerSize, rpcPort, gossipHost, downloadBinaries = true, }) {
122
158
  // TODO: adjust program tags
123
- const programs = [
124
- {
125
- id: "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",
126
- name: "spl_noop.so",
127
- tag: constants_1.SPL_NOOP_PROGRAM_TAG,
128
- },
129
- {
130
- id: "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7",
131
- name: "light_system_program.so",
132
- tag: constants_1.LIGHT_SYSTEM_PROGRAM_TAG,
133
- },
134
- {
135
- id: "cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m",
136
- name: "light_compressed_token.so",
137
- tag: constants_1.LIGHT_COMPRESSED_TOKEN_TAG,
138
- },
139
- {
140
- id: "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq",
141
- name: "account_compression.so",
142
- tag: constants_1.LIGHT_ACCOUNT_COMPRESSION_TAG,
143
- },
144
- {
145
- id: "Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX",
146
- name: "light_registry.so",
147
- tag: constants_1.LIGHT_REGISTRY_TAG,
148
- },
149
- ];
159
+ const programs = [...exports.SYSTEM_PROGRAMS];
150
160
  if (additionalPrograms)
151
161
  additionalPrograms.forEach((program) => {
152
162
  programs.push({ id: program.address, path: program.path });
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Logs the contents of prover log files in test-ledger dir.
3
+ */
4
+ export declare function logProverFileContents(): Promise<void>;
1
5
  export declare function killProcess(processName: string): Promise<void>;
2
6
  export declare function killProcessByPort(port: number): Promise<void>;
3
7
  /**
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logProverFileContents = logProverFileContents;
3
4
  exports.killProcess = killProcess;
4
5
  exports.killProcessByPort = killProcessByPort;
5
6
  exports.executeCommand = executeCommand;
@@ -16,6 +17,41 @@ const node_child_process_1 = require("node:child_process");
16
17
  const util_1 = require("util");
17
18
  const axios_1 = tslib_1.__importDefault(require("axios"));
18
19
  const waitOn = require("wait-on");
20
+ const readdir = (0, util_1.promisify)(fs_1.default.readdir);
21
+ const readFile = (0, util_1.promisify)(fs_1.default.readFile);
22
+ /**
23
+ * Logs the contents of prover log files in test-ledger dir.
24
+ */
25
+ async function logProverFileContents() {
26
+ const testLedgerDir = path_1.default.join(__dirname, "../..", "test-ledger");
27
+ try {
28
+ if (!fs_1.default.existsSync(testLedgerDir)) {
29
+ console.log("test-ledger directory does not exist");
30
+ return;
31
+ }
32
+ const files = await readdir(testLedgerDir);
33
+ const proverFiles = files.filter((file) => file.includes("prover"));
34
+ if (proverFiles.length === 0) {
35
+ console.log("No prover log files found in test-ledger directory");
36
+ return;
37
+ }
38
+ for (const file of proverFiles) {
39
+ const filePath = path_1.default.join(testLedgerDir, file);
40
+ console.log(`\n========== Contents of ${file} ==========`);
41
+ try {
42
+ const contents = await readFile(filePath, "utf8");
43
+ console.log(contents);
44
+ console.log(`========== End of ${file} ==========\n`);
45
+ }
46
+ catch (error) {
47
+ console.error(`Error reading ${file}:`, error);
48
+ }
49
+ }
50
+ }
51
+ catch (error) {
52
+ console.error("Error accessing test-ledger directory:", error);
53
+ }
54
+ }
19
55
  async function killProcess(processName) {
20
56
  const processList = await (0, find_process_1.default)("name", processName);
21
57
  const targetProcesses = processList.filter((proc) => proc.name.includes(processName) || proc.cmd.includes(processName));
@@ -27,7 +63,6 @@ async function killProcess(processName) {
27
63
  console.error(`Failed to kill process ${proc.pid}: ${error}`);
28
64
  }
29
65
  }
30
- // Double-check if processes are still running
31
66
  const remainingProcesses = await (0, find_process_1.default)("name", processName);
32
67
  if (remainingProcesses.length > 0) {
33
68
  console.warn(`Warning: ${remainingProcesses.length} processes still running after kill attempt`);
@@ -145,8 +180,12 @@ function spawnBinary(command, args = []) {
145
180
  shell: false,
146
181
  detached: true,
147
182
  });
148
- spawnedProcess.on("close", (code) => {
183
+ spawnedProcess.on("close", async (code) => {
149
184
  console.log(`${binaryName} process exited with code ${code}`);
185
+ if (code !== 0 && binaryName.includes("prover")) {
186
+ console.error(`Prover process failed with exit code ${code}`);
187
+ await logProverFileContents();
188
+ }
150
189
  });
151
190
  return spawnedProcess;
152
191
  }
@@ -1,2 +1,2 @@
1
- export declare function startIndexer(rpcUrl: string, indexerPort: number, checkPhotonVersion?: boolean, photonDatabaseUrl?: string): Promise<void>;
1
+ export declare function startIndexer(rpcUrl: string, indexerPort: number, checkPhotonVersion?: boolean, photonDatabaseUrl?: string): Promise<undefined>;
2
2
  export declare function killIndexer(): Promise<void>;
@@ -8,27 +8,48 @@ const process_1 = require("./process");
8
8
  const constants_1 = require("./constants");
9
9
  const node_child_process_1 = require("node:child_process");
10
10
  const util = tslib_1.__importStar(require("node:util"));
11
+ const node_process_1 = require("node:process");
12
+ const execAsync = util.promisify(node_child_process_1.exec);
13
+ async function isExpectedPhotonVersion(requiredVersion) {
14
+ try {
15
+ const { stdout } = await execAsync("photon --version");
16
+ const version = stdout.trim();
17
+ return version.includes(requiredVersion);
18
+ }
19
+ catch (error) {
20
+ console.error("Error checking Photon version:", error);
21
+ return false;
22
+ }
23
+ }
24
+ function getPhotonInstallMessage() {
25
+ if (constants_1.USE_PHOTON_FROM_GIT && constants_1.PHOTON_GIT_COMMIT) {
26
+ return `\nLatest Photon indexer not found. Please install it by running: "cargo install --git ${constants_1.PHOTON_GIT_REPO} --rev ${constants_1.PHOTON_GIT_COMMIT} --locked"`;
27
+ }
28
+ else if (constants_1.USE_PHOTON_FROM_GIT) {
29
+ return `\nLatest Photon indexer not found. Please install it by running: "cargo install --git ${constants_1.PHOTON_GIT_REPO} --locked"`;
30
+ }
31
+ else {
32
+ return `\nLatest Photon indexer not found. Please install it by running: "cargo install photon-indexer --version ${constants_1.PHOTON_VERSION} --locked"`;
33
+ }
34
+ }
11
35
  async function startIndexer(rpcUrl, indexerPort, checkPhotonVersion = true, photonDatabaseUrl) {
12
36
  await killIndexer();
13
37
  const resolvedOrNull = which_1.default.sync("photon", { nothrow: true });
14
38
  if (resolvedOrNull === null ||
15
39
  (checkPhotonVersion && !(await isExpectedPhotonVersion(constants_1.PHOTON_VERSION)))) {
16
- const message = `Photon indexer not found. Please install it by running "cargo install photon-indexer --version ${constants_1.PHOTON_VERSION} --locked"`;
17
- console.log(message);
18
- throw new Error(message);
40
+ console.log(getPhotonInstallMessage());
41
+ return (0, node_process_1.exit)(1);
19
42
  }
20
43
  else {
21
44
  console.log("Starting indexer...");
22
- let args = [];
45
+ const args = [
46
+ "--port",
47
+ indexerPort.toString(),
48
+ "--rpc-url",
49
+ rpcUrl,
50
+ ];
23
51
  if (photonDatabaseUrl) {
24
- args = [
25
- "--db-url",
26
- photonDatabaseUrl,
27
- "--port",
28
- indexerPort.toString(),
29
- "--rpc-url",
30
- rpcUrl,
31
- ];
52
+ args.push("--db-url", photonDatabaseUrl);
32
53
  }
33
54
  (0, process_1.spawnBinary)(constants_1.INDEXER_PROCESS_NAME, args);
34
55
  await (0, process_1.waitForServers)([{ port: indexerPort, path: "/getIndexerHealth" }]);
@@ -38,15 +59,3 @@ async function startIndexer(rpcUrl, indexerPort, checkPhotonVersion = true, phot
38
59
  async function killIndexer() {
39
60
  await (0, process_1.killProcess)(constants_1.INDEXER_PROCESS_NAME);
40
61
  }
41
- const execAsync = util.promisify(node_child_process_1.exec);
42
- async function isExpectedPhotonVersion(requiredVersion) {
43
- try {
44
- const { stdout } = await execAsync("photon --version");
45
- const version = stdout.trim();
46
- return version.includes(requiredVersion);
47
- }
48
- catch (error) {
49
- console.error("Error checking Photon version:", error);
50
- return false;
51
- }
52
- }
@@ -1,4 +1,6 @@
1
1
  export declare function killProver(): Promise<void>;
2
- export declare function startProver(proverPort: number, runMode: string | undefined, circuits?: string[] | undefined): Promise<void>;
2
+ export declare function isProverRunningWithFlags(runMode?: string, circuits?: string[], proverPort?: number, redisUrl?: string): Promise<boolean>;
3
+ export declare function startProver(proverPort: number, runMode: string | undefined, circuits?: string[] | undefined, force?: boolean, redisUrl?: string): Promise<void>;
3
4
  export declare function getProverNameByArch(): string;
4
5
  export declare function getProverPathByArch(): string;
6
+ export declare function healthCheck(port: number, retries?: number, timeout?: number): Promise<boolean>;
@@ -1,19 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.killProver = killProver;
4
+ exports.isProverRunningWithFlags = isProverRunningWithFlags;
4
5
  exports.startProver = startProver;
5
6
  exports.getProverNameByArch = getProverNameByArch;
6
7
  exports.getProverPathByArch = getProverPathByArch;
8
+ exports.healthCheck = healthCheck;
7
9
  const tslib_1 = require("tslib");
8
10
  const path_1 = tslib_1.__importDefault(require("path"));
9
11
  const process_1 = require("./process");
10
12
  const constants_1 = require("./constants");
13
+ const find_process_1 = tslib_1.__importDefault(require("find-process"));
11
14
  const KEYS_DIR = "proving-keys/";
12
15
  async function killProver() {
13
16
  await (0, process_1.killProcess)(getProverNameByArch());
14
17
  await (0, process_1.killProcess)(constants_1.LIGHT_PROVER_PROCESS_NAME);
15
18
  }
16
- async function startProver(proverPort, runMode, circuits = []) {
19
+ async function isProverRunningWithFlags(runMode, circuits, proverPort, redisUrl) {
20
+ // Use find-process to get prover processes by name pattern
21
+ const proverProcesses = await (0, find_process_1.default)("name", "prover-");
22
+ const expectedArgs = [];
23
+ if (runMode) {
24
+ expectedArgs.push("--run-mode", runMode);
25
+ }
26
+ if (Array.isArray(circuits)) {
27
+ for (const c of circuits) {
28
+ expectedArgs.push("--circuit", c);
29
+ }
30
+ }
31
+ if (proverPort) {
32
+ expectedArgs.push("--prover-address", `0.0.0.0:${proverPort}`);
33
+ }
34
+ if (redisUrl) {
35
+ expectedArgs.push("--redis-url", redisUrl);
36
+ }
37
+ let found = false;
38
+ for (const proc of proverProcesses) {
39
+ if (proc.cmd &&
40
+ (proc.cmd.includes("prover-") || proc.name.startsWith("prover-"))) {
41
+ console.log("\n[Prover Process Detected]");
42
+ console.log(` PID: ${proc.pid}`);
43
+ console.log(` Command: ${proc.cmd}`);
44
+ let matches = true;
45
+ for (const arg of expectedArgs) {
46
+ if (!proc.cmd.includes(arg)) {
47
+ matches = false;
48
+ break;
49
+ }
50
+ }
51
+ if (matches) {
52
+ found = true;
53
+ console.log("\x1b[32m✔ Prover is already running with the same configuration.\x1b[0m");
54
+ console.log(" To restart the prover, stop the process above or use the --force flag.\n");
55
+ break;
56
+ }
57
+ else {
58
+ const missing = proc.cmd
59
+ ? expectedArgs.filter((arg) => !proc.cmd.includes(arg))
60
+ : [];
61
+ if (missing.length > 0) {
62
+ console.log(` (Not a match for current request. Missing args: ${missing.join(", ")})`);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ if (!found) {
68
+ console.log("\x1b[33mNo running prover found with the requested configuration.\x1b[0m");
69
+ }
70
+ return found;
71
+ }
72
+ async function startProver(proverPort, runMode, circuits = [], force = false, redisUrl) {
73
+ if (!force &&
74
+ (await isProverRunningWithFlags(runMode, circuits, proverPort))) {
75
+ return;
76
+ }
17
77
  console.log("Kill existing prover process...");
18
78
  await killProver();
19
79
  await (0, process_1.killProcessByPort)(proverPort);
@@ -34,10 +94,13 @@ async function startProver(proverPort, runMode, circuits = []) {
34
94
  console.log(`Starting prover with circuits: ${circuits.join(", ")}...`);
35
95
  }
36
96
  if ((!circuits || circuits.length === 0) && runMode == null) {
37
- runMode = "rpc";
97
+ runMode = "local-rpc";
38
98
  args.push("--run-mode", runMode);
39
99
  console.log(`Starting prover with fallback ${runMode} mode...`);
40
100
  }
101
+ if (redisUrl) {
102
+ args.push("--redis-url", redisUrl);
103
+ }
41
104
  (0, process_1.spawnBinary)(getProverPathByArch(), args);
42
105
  await (0, process_1.waitForServers)([{ port: proverPort, path: "/" }]);
43
106
  console.log(`Prover started successfully!`);
@@ -61,3 +124,21 @@ function getProverPathByArch() {
61
124
  binaryName = path_1.default.join(binDir, binaryName);
62
125
  return binaryName;
63
126
  }
127
+ async function healthCheck(port, retries = 3, timeout = 3000) {
128
+ const fetch = (await Promise.resolve().then(() => tslib_1.__importStar(require("node-fetch")))).default;
129
+ for (let i = 0; i < retries; i++) {
130
+ try {
131
+ const res = await fetch(`http://localhost:${port}/health`);
132
+ if (res.ok) {
133
+ console.log("Health check passed!");
134
+ return true;
135
+ }
136
+ }
137
+ catch (e) {
138
+ console.error("Health check error:", e);
139
+ }
140
+ await new Promise((r) => setTimeout(r, timeout));
141
+ }
142
+ console.log("Health check failed after all attempts.");
143
+ return false;
144
+ }