diff --git a/cli/src/utils/downloadProverBinary.ts b/cli/src/utils/downloadProverBinary.ts index cf690ba01b..d8ed0c380c 100644 --- a/cli/src/utils/downloadProverBinary.ts +++ b/cli/src/utils/downloadProverBinary.ts @@ -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; diff --git a/cli/src/utils/processProverServer.ts b/cli/src/utils/processProverServer.ts index fdb57b5ebb..3e91b30256 100644 --- a/cli/src/utils/processProverServer.ts +++ b/cli/src/utils/processProverServer.ts @@ -1,5 +1,6 @@ import path from "path"; import fs from "fs"; +import { execSync } from "child_process"; import { killProcess, killProcessByPort, @@ -7,7 +8,10 @@ import { 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/"; @@ -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 { 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); diff --git a/prover/server/Dockerfile.light b/prover/server/Dockerfile.light index 40460407a0..d2d3560393 100644 --- a/prover/server/Dockerfile.light +++ b/prover/server/Dockerfile.light @@ -1,4 +1,4 @@ -FROM golang:1.23-alpine AS builder +FROM golang:1.25-alpine AS builder WORKDIR /app diff --git a/prover/server/main.go b/prover/server/main.go index 77dd29fd26..b0eac6e726 100644 --- a/prover/server/main.go +++ b/prover/server/main.go @@ -21,6 +21,8 @@ import ( "github.com/urfave/cli/v2" ) +const Version = "2.0.0" + func main() { runCli() } @@ -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 + }, + }, }, }