Note: TLS is supported. You can use stratum+ssl:// in [pool.url], or set pool.tls=true when no scheme is specified. For testing only, pool.tls_insecure=true disables certificate verification. These map to configuration keys under [pool]: tls and tls_insecure. CI: A GitHub Actions workflow is provided at .github/workflows/ci.yml to run fmt, clippy, tests, and build the CLI with the dummy backend.
Nitrate is a modular, Rust-based GPU miner scaffold focused on Bitcoin (Stratum v1) with a pluggable GPU backend abstraction. The core engine is algorithm-agnostic; Bitcoin-specific logic lives in a separate crate, and GPU details are behind a trait so multiple backends (CUDA/HIP/OpenCL) can be swapped in. A dummy GPU backend is provided so you can run the full stack while wiring up network/protocol and core scheduling.
Key goals:
For an in-depth tour of the workspace and responsibilities, see Agents & Workspace Guide (agents.md). For milestones, see the Roadmap (roadmap.md).
nitrate-gpu-api) with a dummy backend for development.Download the latest release from GitHub Releases:
# Download the latest release
wget https://github.com/grenade/nitrate/releases/latest/download/nitrate-cli-linux-x86_64-cuda
# Make executable
chmod +x nitrate-cli-linux-x86_64-cuda
# Run the miner
./nitrate-cli-linux-x86_64-cuda --config miner.toml
Requirements for pre-built binaries:
# Clone the repository
git clone https://github.com/grenade/nitrate.git
cd nitrate
# Build with CUDA support (requires CUDA toolkit)
cargo build --release -p nitrate-cli --features gpu-cuda
# Or build with dummy backend (no GPU required)
cargo build --release -p nitrate-cli --features gpu-dummy
# Run from build directory
./target/release/nitrate-cli --config miner.toml
Environment variables for controlling the build:
NVCC: Override path to NVCC compiler (default: searches CUDA_HOME/bin, CUDA_PATH/bin, or PATH)CUDA_ARCH: Target CUDA architecture (default: sm_52)NITRATE_CUDA_SKIP=1: Skip CUDA compilation entirely (useful for CI/checks without CUDA toolkit)Example:
# Build for specific CUDA architecture
CUDA_ARCH=sm_86 cargo build --release -p nitrate-cli --features gpu-cuda
# Run clippy checks without CUDA toolkit
NITRATE_CUDA_SKIP=1 cargo clippy --features nitrate-core/gpu-cuda
Top-level files:
Cargo.toml — Workspace configuration, shared profiles/lints.rust-toolchain.toml — Toolchain pin.miner.toml — Example runtime configuration.agents.md — Architecture and wiring guide.roadmap.md — Milestones, definitions of done, and acceptance tests.Crates (under crates/):
nitrate-core — Mining engine (job handling, scheduling, verification, share submission).nitrate-proto — Stratum v1 types and serde helpers.nitrate-pool — Pool client (Tokio, JSON-RPC framing, reconnect, job channel).nitrate-btc — Bitcoin header/target math, midstate, CPU verification.nitrate-gpu-api — Cross-backend GPU abstraction traits and types.nitrate-gpu-dummy — No-op backend used for development/testing.nitrate-metrics — Prometheus exporter (counters, gauges).nitrate-config — Loading and validating TOML + ENV into strongly typed config.nitrate-utils — Utilities (double_sha256, hex, endian helpers).nitrate-bench — Criterion microbenchmarks and perf scaffolding.Binaries (under bins/):
nitrate-cli — Main CLI to run the miner and list devices.nitrate-devtool — Dev tooling for job replay and kernel param sweeps (future).Install Rust (matching the pinned toolchain in rust-toolchain.toml).
Prepare configuration:
miner.toml at the repository root (see Configuration below).Run the miner (dummy backend):
Verify metrics:
List devices (no-op with dummy backend, useful once real backends are added):
Configuration is loaded from TOML (with environment variable overrides) into a strongly-typed AppCfg. The default example file is at the repository root: miner.toml.
Sections:
tracing (e.g., "info", "debug")Minimal example:
[pool]
url = "stratum+tcp://solo.ckpool.org:3333"
user = "bc1q...worker1"
pass = "x"
[gpu]
backend = "dummy"
devices = [0]
intensity = "auto"
[runtime]
reconnect_backoff = "1s..30s"
stale_drop_ms = 500
telemetry_addr = "127.0.0.1:9100"
log = "info"
The miner includes GPU-specific optimizations that automatically detect and configure optimal settings for different GPU models:
To use multiple GPUs, configure the device indices in your config:
[gpu]
backend = "cuda"
devices = [0, 1] # Use both GPU 0 and GPU 1
For manual tuning, you can override the auto-detected settings:
[[gpu.device_overrides]]
device_index = 0
grid_size = 2720 # Number of blocks
block_size = 512 # Threads per block
nonces_per_thread = 4 # Nonces processed per thread
ring_capacity = 32768 # Result buffer size
Monitor your hashrate and GPU utilization:
# View hashrate from metrics endpoint
curl http://localhost:9100/metrics | grep hashrate
# Monitor GPU utilization
nvidia-smi dmon -s u
# Check for thermal throttling
nvidia-smi -q -d PERFORMANCE
The miner implements several key optimizations:
__funnelshift_r)Protocol layer (nitrate-proto, nitrate-pool):
Bitcoin layer (nitrate-btc):
Core engine (nitrate-core):
clean_jobs/new notify.GPU abstraction (nitrate-gpu-api):
GpuBackend trait for enumerate/launch/poll lifecycles.Dummy backend (nitrate-gpu-dummy):
Metrics (nitrate-metrics):
Format, lint, and test:
Targeted testing:
Benchmarks:
Observability:
Feature flags (future):
Cancellations and stales:
clean_jobs or when a new job arrives.Stability and reconnects:
Security:
clippy clean; prefer anyhow at app edges and thiserror for library errors.tracing spans for job and device context in logs.The workspace uses a single version defined in the root Cargo.toml:
[workspace.package]
version = "0.1.0"
All crates inherit this version using version.workspace = true. To manage versions:
# Get current version
./scripts/version.sh get
# Set new version
./scripts/version.sh set 1.2.3
# Show all crate versions
./scripts/version.sh show
# Bump version
./scripts/version.sh bump patch # or minor/major
The CI pipeline runs on standard GitHub runners without CUDA. For CUDA-related checks:
NITRATE_CUDA_SKIP=1 to generate stub PTX modulesghcr.io/quantus-network/cuda-builder:13.0.0 Docker image with CUDA 13.0Releases are created through GitHub Actions:
Binary releases include:
nitrate-cli-linux-x86_64-cuda: Standalone executable with CUDA supportnitrate-X.Y.Z-linux-x86_64-cuda.tar.gz: Archive with binary and example configurationHappy hacking!
33 activities