Skip to content

feat: Add GetVersion gRPC endpoint to aggkit-prover and fix build-time version injection #344

@joanestebanr

Description

@joanestebanr

Summary

Two related problems need to be addressed together: aggkit-prover does not expose its version over gRPC, and the binary always reports 0.1.0 at runtime because the version is not injected at build time.

Problem 1 — no version endpoint in the gRPC API

Clients such as aggkit have no way to programmatically check which version of aggkit-prover they are talking to. This makes it impossible to:

  • Enforce a minimum compatible version and surface a warning (or hard error) when the requirement is not met.
  • Log the prover version alongside client diagnostics for easier debugging.

Problem 2 — version is always 0.1.0 at runtime

The compiled binary has no awareness of the actual release version because the version string is never injected during the build. Even if a GetVersion endpoint existed today, it would always return 0.1.0, making it useless. Both problems must be fixed together.

Proposed solution

Part A · gRPC endpoint

Add a GetVersion RPC to the prover's protobuf service definition:

rpc GetVersion(GetVersionRequest) returns (GetVersionResponse);

message GetVersionRequest {}

message GetVersionResponse {
  string version = 1; // semver, e.g. "0.3.1"
}

Part B · build-time version injection

Add a build.rs at the crate root that reads the version using the vergen-git2 crate — the same approach used in the main agglayer binary.

Add the build dependency to Cargo.toml:

[build-dependencies]
vergen-git2 = { version = "9.1.0", features = ["build"] }

Add build.rs at the crate root:

use eyre::eyre;
use vergen_git2::{Emitter, Git2Builder};

fn main() -> eyre::Result<()> {
    color_eyre::install()?;
    Emitter::new()
        .add_instructions(
            &Git2Builder::default()
                .describe(true, true, None)
                .commit_timestamp(true)
                .build()?,
        )
        .map_err(|e| eyre!(e))?
        .emit()
        .map_err(|e| eyre!(e))?;
    Ok(())
}

The GetVersion handler should read the injected variables at compile time:

const VERSION: &str = env!("VERGEN_GIT_DESCRIBE");
const COMMIT_TIMESTAMP: &str = env!("VERGEN_GIT_COMMIT_TIMESTAMP");

VERGEN_GIT_DESCRIBE produces a string equivalent to git describe --tags --always --dirty,
e.g. v0.3.1 on a clean tag or v0.3.1-4-gabcdef1-dirty on a dev build — richer than a
plain tag string and safe to parse as semver (strip the leading v and any suffix).

Part C · client-side check (aggkit)

On startup, aggkit (and any other client) should call GetVersion, parse the semver response, and compare it against the minimum required version. Suggested behaviour:

  • Version < minimum required → log a warning (or configurable hard error).
  • Version satisfies constraint → proceed normally.
  • Endpoint unavailable (older prover) → log a warning that version could not be verified.

Acceptance criteria

  • aggkit-prover exposes a GetVersion gRPC method that returns the real semver string.
  • Builds produced by CI inject the correct version via -ldflags; running aggkit-prover --version (or equivalent) confirms this.
  • Version is printed to stdout/log at service startup.
  • aggkit calls GetVersion on startup and emits a warning when the version is below the declared minimum.
  • Unit / integration tests cover the version comparison logic.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions