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
8 changes: 5 additions & 3 deletions antd-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("OK: %v, Network: %s\n", health.OK, health.Network)
fmt.Printf("OK: %v, Network: %s, Version: %s, EVM: %s\n",
health.OK, health.Network, health.Version, health.EvmNetwork)

// Store data
result, err := client.DataPutPublic(ctx, []byte("Hello, Autonomi!"))
Expand Down Expand Up @@ -88,7 +89,7 @@ All methods take a `context.Context` as the first parameter for cancellation and
### Health
| Method | Description |
|--------|-------------|
| `Health(ctx)` | Check daemon status |
| `Health(ctx)` | Check daemon status — returns `*HealthStatus` with daemon version, EVM network, uptime, build commit, and payment contract addresses |

### Data (Immutable)
| Method | Description |
Expand Down Expand Up @@ -167,7 +168,8 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("OK: %v, Network: %s\n", health.OK, health.Network)
fmt.Printf("OK: %v, Network: %s, Version: %s, EVM: %s\n",
health.OK, health.Network, health.Version, health.EvmNetwork)

result, err := client.DataPutPublic(ctx, []byte("Hello via gRPC!"))
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions antd-go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ func (c *Client) Health(ctx context.Context) (*HealthStatus, error) {
return nil, err
}
return &HealthStatus{
OK: str(j, "status") == "ok",
Network: str(j, "network"),
OK: str(j, "status") == "ok",
Network: str(j, "network"),
Version: str(j, "version"),
EvmNetwork: str(j, "evm_network"),
UptimeSeconds: unum64(j, "uptime_seconds"),
BuildCommit: str(j, "build_commit"),
PaymentTokenAddress: str(j, "payment_token_address"),
PaymentVaultAddress: str(j, "payment_vault_address"),
}, nil
}

Expand Down
17 changes: 16 additions & 1 deletion antd-go/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ func mockDaemon(t *testing.T) *httptest.Server {
switch {
// Health
case r.Method == "GET" && r.URL.Path == "/health":
json.NewEncoder(w).Encode(map[string]any{"status": "ok", "network": "local"})
json.NewEncoder(w).Encode(map[string]any{
"status": "ok",
"network": "local",
"version": "0.4.0",
"evm_network": "local",
"uptime_seconds": 42,
"build_commit": "abcdef123456",
"payment_token_address": "0xtoken",
"payment_vault_address": "0xvault",
})

// Data put public
case r.Method == "POST" && r.URL.Path == "/v1/data/public":
Expand Down Expand Up @@ -142,6 +151,12 @@ func TestHealth(t *testing.T) {
if !h.OK || h.Network != "local" {
t.Fatalf("unexpected health: %+v", h)
}
if h.Version != "0.4.0" || h.EvmNetwork != "local" || h.UptimeSeconds != 42 {
t.Fatalf("unexpected diagnostic fields: %+v", h)
}
if h.BuildCommit != "abcdef123456" || h.PaymentTokenAddress != "0xtoken" || h.PaymentVaultAddress != "0xvault" {
t.Fatalf("unexpected build/payment fields: %+v", h)
}
}

func TestDataPublic(t *testing.T) {
Expand Down
10 changes: 8 additions & 2 deletions antd-go/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ func (c *GrpcClient) Health(ctx context.Context) (*HealthStatus, error) {
return nil, errorFromGrpc(err)
}
return &HealthStatus{
OK: resp.GetStatus() == "ok",
Network: resp.GetNetwork(),
OK: resp.GetStatus() == "ok",
Network: resp.GetNetwork(),
Version: resp.GetVersion(),
EvmNetwork: resp.GetEvmNetwork(),
UptimeSeconds: resp.GetUptimeSeconds(),
BuildCommit: resp.GetBuildCommit(),
PaymentTokenAddress: resp.GetPaymentTokenAddress(),
PaymentVaultAddress: resp.GetPaymentVaultAddress(),
}, nil
}

Expand Down
16 changes: 14 additions & 2 deletions antd-go/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ type mockHealthService struct {

func (m *mockHealthService) Check(_ context.Context, _ *pb.HealthCheckRequest) (*pb.HealthCheckResponse, error) {
return &pb.HealthCheckResponse{
Status: "ok",
Network: "local",
Status: "ok",
Network: "local",
Version: "0.4.0",
EvmNetwork: "local",
UptimeSeconds: 42,
BuildCommit: "abcdef123456",
PaymentTokenAddress: "0xtoken",
PaymentVaultAddress: "0xvault",
}, nil
}

Expand Down Expand Up @@ -222,6 +228,12 @@ func TestGrpcHealth(t *testing.T) {
if !h.OK || h.Network != "local" {
t.Fatalf("unexpected health: %+v", h)
}
if h.Version != "0.4.0" || h.EvmNetwork != "local" || h.UptimeSeconds != 42 {
t.Fatalf("unexpected diagnostic fields: %+v", h)
}
if h.BuildCommit != "abcdef123456" || h.PaymentTokenAddress != "0xtoken" || h.PaymentVaultAddress != "0xvault" {
t.Fatalf("unexpected build/payment fields: %+v", h)
}
}

func TestGrpcDataPutPublic(t *testing.T) {
Expand Down
10 changes: 8 additions & 2 deletions antd-go/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ package antd

// HealthStatus is the result of a health check.
type HealthStatus struct {
OK bool `json:"ok"`
Network string `json:"network"`
OK bool `json:"ok"`
Network string `json:"network"`
Version string `json:"version"` // antd crate version
EvmNetwork string `json:"evm_network"` // arbitrum-one, arbitrum-sepolia, local, custom
UptimeSeconds uint64 `json:"uptime_seconds"` // seconds since daemon start
BuildCommit string `json:"build_commit"` // short git SHA, "" if unknown
PaymentTokenAddress string `json:"payment_token_address"`
PaymentVaultAddress string `json:"payment_vault_address"`
}

// PutResult is the result of a put/create operation.
Expand Down
3 changes: 1 addition & 2 deletions antd-go/proto/antd/v1/chunks.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions antd-go/proto/antd/v1/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions antd-go/proto/antd/v1/data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions antd-go/proto/antd/v1/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions antd-go/proto/antd/v1/files.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 63 additions & 9 deletions antd-go/proto/antd/v1/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions antd-rust/src/grpc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ impl v1::health_service_server::HealthService for MockHealthService {
Ok(Response::new(v1::HealthCheckResponse {
status: "ok".to_string(),
network: "local".to_string(),
// Diagnostic fields added in 0.4.0 — left as defaults here
// because antd-rust's HealthStatus model has not yet been
// extended (tracked in issue #37). The mock just needs to
// satisfy the wire type.
..Default::default()
}))
}
}
Expand Down
2 changes: 1 addition & 1 deletion antd/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion antd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "antd"
version = "0.3.0"
version = "0.4.0"
edition = "2021"

[dependencies]
Expand Down
16 changes: 16 additions & 0 deletions antd/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
use std::process::Command;

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Capture short git SHA for /health diagnostics. Falls back to "" when
// built outside a git checkout (e.g. crates.io source distribution) — the
// /health endpoint reports the empty string in that case.
let commit = Command::new("git")
.args(["rev-parse", "--short=12", "HEAD"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_default();
println!("cargo:rustc-env=ANTD_BUILD_COMMIT={commit}");
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/heads");

tonic_build::configure()
.build_client(false)
.build_server(true)
Expand Down
Loading
Loading