mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
Make hanzo-node natively serve the canonical Hanzo inference engine (OpenAI / Anthropic / Responses HTTP API) in-process, alongside the existing gRPC server, behind a new default-off `engine` Cargo feature. Purely additive: with the feature off the node builds and behaves exactly as before. - Cargo.toml: optional path-deps on hanzo-server-core (default-features=false) and hanzo-engine; `engine` feature gating them; cuda/cudnn/metal/rocm/vulkan/ accelerate/mkl/nccl/flash-attn[-v3] features each forwarding to the matching engine + server-core features (mirrors hanzo-server/Cargo.toml). default = []. - .cargo/config.toml: rustflags target-cpu=native (engine's candle fork needs it). - lib.rs: add EngineConfig (enabled/cpu/engine_api_addr default 0.0.0.0:36900, + cfg-gated ModelSelected) to NodeConfig; cfg-gated hanzo_state on HanzoNode built in new() via HanzoForServerBuilder; start() runs gRPC + axum engine API concurrently (spawn + tokio::join!) when state is present, else unchanged. All engine code is #[cfg(feature = "engine")]; errors map to crate::Error, no unwrap/expect. - bin: --engine-port/HANZO_ENGINE_ADDR, --model/HANZO_ENGINE_MODEL, --engine-cpu; logs the engine URL on startup. Validation (CPU box, GPU-blocked, no weights): - cargo check -p hanzo-node (no features): pass, 0 warnings. - cargo check -p hanzo-node --features engine: pass; warnings only from upstream hanzo-engine/hanzo-server-core, none from hanzo-node. GPU feature graphs (cuda/rocm/metal/...) resolve via cargo metadata but are not compiled here (no GPU toolchains).
hanzo-node (Rust Crate)
RPC-based compute node for the Hanzo Platform, written in Rust.
Features
- P2P Networking: libp2p-based peer discovery and gossipsub messaging
- gRPC Server: Full NodeService API for compute pool operations
- Storage: Persistent sled database for deployment state
- Container Orchestration: Deployment lifecycle management
Building
cd rust
cargo build --release
Usage
# Start with defaults
./target/release/hanzo-node
# Custom configuration
./target/release/hanzo-node \
--grpc-addr 0.0.0.0:50051 \
--http-addr 0.0.0.0:8080 \
--network-id 43114
# With P2P bootstrap peers
./target/release/hanzo-node \
--p2p-addr /ip4/0.0.0.0/tcp/9000 \
--bootstrap /ip4/1.2.3.4/tcp/9000/p2p/QmPeerId
CLI Options
OPTIONS:
--node-id <ID> Node identifier (auto-generated if not provided)
--grpc-addr <ADDR> gRPC server address [default: 0.0.0.0:50051]
--http-addr <ADDR> HTTP health check address [default: 0.0.0.0:8080]
--p2p-addr <ADDR> P2P listen address [default: /ip4/0.0.0.0/tcp/9000]
--bootstrap <ADDR> Bootstrap peer address (can be specified multiple times)
--data-dir <PATH> Data directory for storage
--network-id <ID> Network ID (43114=mainnet, 43113=testnet, 1337=local)
--operator <ADDR> Operator wallet address
--mlx Enable MLX acceleration (macOS only)
--log-level <LEVEL> Log level (trace, debug, info, warn, error)
Environment Variables
HANZO_NODE_ID- Node identifierHANZO_GRPC_ADDR- gRPC server addressHANZO_HTTP_ADDR- HTTP health check addressHANZO_DATA_DIR- Data directoryHANZO_NETWORK_ID- Network IDHANZO_OPERATOR- Operator wallet addressRUST_LOG- Log level filter
gRPC API
The node implements the NodeService defined in proto/hanzo.node.v1.proto:
Health & Status
GetHealth- Node health checkGetStatus- Full node statusGetMetrics- Streaming metrics
Node Lifecycle
RegisterNode- Register with compute poolHeartbeat- Periodic heartbeatUpdateCapabilities- Update node capabilities
Deployment Management
Deploy- Deploy a compose specStop- Stop a deploymentRemove- Remove a deploymentScale- Scale deployment replicas
Monitoring
GetLogs- Stream container logsGetEvents- Stream node eventsListContainers- List all containersInspectContainer- Get container detailsExecInContainer- Execute command in container
Architecture
hanzo-node/
src/
lib.rs # Core library and HanzoNode struct
error.rs # Error types
p2p/ # P2P networking (libp2p)
rpc/ # gRPC server (tonic)
compute/ # Container orchestration
storage/ # Persistent storage (sled)
bin/
hanzo-node.rs # CLI binary
Dependencies
- tokio - Async runtime
- tonic - gRPC framework
- libp2p - P2P networking
- sled - Embedded database
- tracing - Structured logging
Testing
cargo test
License
Apache-2.0