Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/utils/downloadProverBinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import https from "https";
import http from "http";
import { pipeline } from "stream/promises";

const PROVER_VERSION = "1.0.4";
const PROVER_VERSION = "2.0.0";
const GITHUB_RELEASES_BASE_URL = `https://github.com/Lightprotocol/light-protocol/releases/download/light-prover-v${PROVER_VERSION}`;
const MAX_REDIRECTS = 10;

Expand Down
48 changes: 44 additions & 4 deletions cli/src/utils/processProverServer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import path from "path";
import fs from "fs";
import { execSync } from "child_process";
import {
killProcess,
killProcessByPort,
spawnBinary,
waitForServers,
} from "./process";
import { LIGHT_PROVER_PROCESS_NAME, BASE_PATH } from "./constants";
import { downloadProverBinary } from "./downloadProverBinary";
import {
downloadProverBinary,
getProverVersion as getExpectedProverVersion,
} from "./downloadProverBinary";

const KEYS_DIR = "proving-keys/";

Expand All @@ -17,17 +21,53 @@ export async function killProver() {
}

/**
* Ensures the prover binary exists, downloading it if necessary
* Gets the version of the installed prover binary
* Returns null if the binary doesn't exist or version command fails
*/
function getInstalledProverVersion(): string | null {
const binaryPath = getProverPathByArch();

if (!fs.existsSync(binaryPath)) {
return null;
}

try {
const version = execSync(`"${binaryPath}" version`, {
encoding: "utf-8",
timeout: 5000,
}).trim();
return version;
} catch (error) {
return null;
}
}

/**
* Ensures the prover binary exists with the correct version, downloading it if necessary
*/
async function ensureProverBinary(): Promise<void> {
const binaryPath = getProverPathByArch();
const binaryName = getProverNameByArch();
const expectedVersion = getExpectedProverVersion();

if (fs.existsSync(binaryPath)) {
const installedVersion = getInstalledProverVersion();

if (installedVersion === expectedVersion) {
return;
}

console.log("Prover binary not found. Downloading...");
if (installedVersion) {
console.log(
`Prover binary version mismatch. Expected: ${expectedVersion}, Found: ${installedVersion}`,
);
console.log("Downloading correct version...");
} else if (fs.existsSync(binaryPath)) {
console.log(
"Prover binary found but version could not be determined. Downloading latest version...",
);
} else {
console.log("Prover binary not found. Downloading...");
}

try {
await downloadProverBinary(binaryPath, binaryName);
Expand Down
2 changes: 1 addition & 1 deletion prover/server/Dockerfile.light
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine AS builder
FROM golang:1.25-alpine AS builder

WORKDIR /app

Expand Down
10 changes: 10 additions & 0 deletions prover/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/urfave/cli/v2"
)

const Version = "2.0.0"

func main() {
runCli()
}
Expand Down Expand Up @@ -1057,6 +1059,14 @@ func runCli() {
return nil
},
},
{
Name: "version",
Usage: "Print the prover version",
Action: func(context *cli.Context) error {
fmt.Println(Version)
return nil
},
},
},
}

Expand Down
Loading