Skip to content

Commit ae3b1a1

Browse files
joanestebanrclaude
andcommitted
feat(exit-certificate-claimer): expose build/version info
Add a --version flag (via cli.VersionPrinter) and include the aggkit build traceability (version, git rev/branch, build date, Go version, OS/arch) in the GET /health response through the new HealthResponse / VersionInfo types. Build the binary with ldflags in the Makefile so the values are populated. Docs updated in README and SPEC. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b2e79b8 commit ae3b1a1

7 files changed

Lines changed: 63 additions & 6 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ $(GOBIN)/exit_certificate:
107107

108108
.PHONY: $(GOBIN)/exit_certificate_claimer
109109
$(GOBIN)/exit_certificate_claimer:
110-
$(GOENVVARS) go build -o $(GOBIN)/exit_certificate_claimer ./tools/exit_certificate_claimer/service/cmd
110+
$(GOENVVARS) go build -ldflags "all=$(LDFLAGS)" -o $(GOBIN)/exit_certificate_claimer ./tools/exit_certificate_claimer/service/cmd
111111

112112
.PHONY: build-docker
113113
build-docker: ## Builds a docker image with the aggkit binary

tools/exit_certificate_claimer/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,17 @@ CGO_ENABLED=1 go build -o exit-certificate-claimer ./tools/exit_certificate_clai
111111

112112
# override the bind host/port from the command line (works in both modes):
113113
./exit-certificate-claimer --config config.toml --address 127.0.0.1 --port 9090
114+
115+
# print the full build/version info and exit (same fields as GET /health):
116+
./exit-certificate-claimer --version
114117
```
115118

116119
`CGO_ENABLED=1` is required (SQLite via `mattn/go-sqlite3`).
117120

121+
`--version` (alias `-v`) prints the build traceability info — version, git revision/branch, build
122+
date, Go version and OS/arch — the same data served by `GET /claimer/v1/health`. The values are
123+
injected at build time via ldflags (use the Makefile target so they are populated).
124+
118125
## Tests
119126

120127
```bash

tools/exit_certificate_claimer/SPEC.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,24 @@ Liveness/readiness probe.
114114
```json
115115
{
116116
"status": "ok",
117-
"network_id": 1
117+
"network_id": 1,
118+
"version": {
119+
"version": "v0.1.0",
120+
"git_rev": "abc1234",
121+
"git_branch": "feature/exit-certificate-tool",
122+
"build_date": "Mon, 30 Jun 2026 10:00:00 +0200",
123+
"go_version": "go1.22.0",
124+
"os": "linux",
125+
"arch": "amd64"
126+
}
118127
}
119128
```
120129

121130
| Field | Type | Description |
122131
| ----- | ---- | ----------- |
123132
| `status` | string | Always `ok`. The HTTP server only starts after the L1 Info Tree has been synced up to the certificate's settlement GER, so a reachable endpoint is always ready to serve claim requests. |
124133
| `network_id` | number | The source network ID the claimer is serving. |
134+
| `version` | object | Build/version info (same fields the exit_certificate tool prints in its startup banner): `version`, `git_rev`, `git_branch`, `build_date`, `go_version`, `os`, `arch`. Populated at build time via ldflags. |
125135

126136
### `GET /bridges`
127137

tools/exit_certificate_claimer/service/cmd/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
)
1111

1212
func main() {
13+
cli.VersionPrinter = func(*cli.Context) {
14+
aggkit.PrintVersion(os.Stdout)
15+
}
16+
1317
app := cli.NewApp()
1418
app.Name = "exit-certificate-claimer"
1519
app.Usage = "Serve claimAsset parameters for the bridge exits of a settled exit certificate"

tools/exit_certificate_claimer/service/server.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strconv"
88
"time"
99

10+
aggkit "github.com/agglayer/aggkit"
1011
"github.com/agglayer/aggkit/log"
1112
"github.com/ethereum/go-ethereum/common"
1213
"github.com/gin-gonic/gin"
@@ -80,7 +81,20 @@ func (s *Server) Start(ctx context.Context) error {
8081
}
8182

8283
func (s *Server) handleHealth(c *gin.Context) {
83-
c.JSON(http.StatusOK, gin.H{"status": "ok", "network_id": s.claimer.NetworkID()})
84+
v := aggkit.GetVersion()
85+
c.JSON(http.StatusOK, HealthResponse{
86+
Status: "ok",
87+
NetworkID: s.claimer.NetworkID(),
88+
Version: VersionInfo{
89+
Version: v.Version,
90+
GitRev: v.GitRev,
91+
GitBranch: v.GitBranch,
92+
BuildDate: v.BuildDate,
93+
GoVersion: v.GoVersion,
94+
OS: v.OS,
95+
Arch: v.Arch,
96+
},
97+
})
8498
}
8599

86100
func (s *Server) handleBridges(c *gin.Context) {

tools/exit_certificate_claimer/service/server_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ func TestServerHealth(t *testing.T) {
3939
rec := doRequest(t, srv, apiBasePath+"/health")
4040
require.Equal(t, http.StatusOK, rec.Code)
4141

42-
var body map[string]any
42+
var body HealthResponse
4343
require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &body))
44-
require.Equal(t, "ok", body["status"])
45-
require.Equal(t, float64(1), body["network_id"])
44+
require.Equal(t, "ok", body.Status)
45+
require.Equal(t, uint32(1), body.NetworkID)
46+
require.NotEmpty(t, body.Version.Version)
47+
require.NotEmpty(t, body.Version.GoVersion)
48+
require.NotEmpty(t, body.Version.OS)
49+
require.NotEmpty(t, body.Version.Arch)
4650
}
4751

4852
func TestServerBridges(t *testing.T) {

tools/exit_certificate_claimer/service/types.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ type ClaimParamsResponse struct {
6666
Claims []ClaimAssetParams `json:"claims"`
6767
}
6868

69+
// VersionInfo mirrors aggkit.FullVersion as a JSON-friendly payload.
70+
type VersionInfo struct {
71+
Version string `json:"version"`
72+
GitRev string `json:"git_rev"`
73+
GitBranch string `json:"git_branch"`
74+
BuildDate string `json:"build_date"`
75+
GoVersion string `json:"go_version"`
76+
OS string `json:"os"`
77+
Arch string `json:"arch"`
78+
}
79+
80+
// HealthResponse is the body returned by GET /health.
81+
type HealthResponse struct {
82+
Status string `json:"status"`
83+
NetworkID uint32 `json:"network_id"`
84+
Version VersionInfo `json:"version"`
85+
}
86+
6987
// errorResponse is the JSON body returned on error.
7088
type errorResponse struct {
7189
Error string `json:"error"`

0 commit comments

Comments
 (0)