Skip to content
glyphqPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Glyph Pool

A Qubic mining pool for bpp9000 ant-colony work. The repository contains the Provider-backed coordinator, the miner gateway, an independent verifier, the public read API and wallet console, settlement and payout tooling, the miner download service, and a native Rust miner.

Status. The workspace builds and its test suites run against Postgres and Redis. The native miner builds with and without the OpenTUI feature. CUDA and HIP kernels are behind feature flags and are not exercised on real GPU hardware in this repository. See Implementation status.

What runs

flowchart LR
  Miner[Native miner<br/>TUI or headless] -->|WSS /ws/miner| Caddy
  Qatum[Qatum v3 miner] -->|TCP 7777| Gateway
  Browser[Browser] --> Caddy
  Caddy --> Web[Next.js static export]
  Caddy --> API[api]
  Caddy --> Gateway[gateway]
  Gateway --> Redis[(Redis)]
  Gateway --> PG[(Postgres)]
  Verifier[verifier] --> Redis
  Verifier --> PG
  Coordinator[coordinator] --> Redis
  Coordinator --> PG
  Coordinator --> Provider[Provider API]
  API --> PG
  API --> Provider
  Payout[payout<br/>opt-in job] --> PG
  Payout --> GlyphAPI[Glyph transaction API]
  Download[download] -->|release files| Miner
Loading
Service Listener Role
caddy 80, 443 TLS termination, web, API proxy, WebSocket proxy, download proxy.
web static Next.js static export served by Caddy from WEB_DIST_PATH.
api 8080 internal Wallet auth, sessions, API keys, worker/account reads, public pool/epoch reads, webhooks, device approval.
gateway 8080 internal, 7777 published Authenticated WSS miner sessions and optional Qatum v3 TCP. Holds leases and enqueues shares.
coordinator 8081 internal Provider polling, anchor and parent selection, scheduler, Redis snapshot publication, verified-share publication.
verifier 8082 internal Consumes the raw-share stream, recomputes the bpp9000 score, persists shares and publishes verdicts.
download 8083 internal Derives latest.json, checksums, installers and immutable release assets from a mounted directory.
payout none (one-shot) settle, pay, confirm, reconcile commands.
postgres 5432 internal System of record. Schema is embedded in the binaries and applied at connect time.
redis 6379 internal Job/allocation/epoch snapshots, raw and verified share streams, verdict pub/sub, hashrate counters, worker telemetry.

Only Caddy ports 80/443 and the Qatum host port 7777 are published by Compose. QATUM_HOST_IP and QATUM_PORT select the published interface and port. QATUM_ENABLED=0 disables the listener.

Repository layout

crates/
  crypto/       KangarooTwelve, Qubic base-26 identities, FourQ/SchnorrQ
  mining/       bpp9000 ANN, epoch pool, mutation walk, scorer, canonical nonces
  proto/        WSS wire types and validation
  provider/     Provider partner API client
  store/        SQLx pool, embedded migrations, ledger posting
  queue/        Redis keys, snapshots and stream payloads
  verifier/     raw-share consumer and bit-exact rescore
  payout/       settlement, ledger, QU transfers, reconciliation, webhooks
  gateway/      WSS sessions, Qatum v3, lease selection, share admission
  api/          HTTP API and OpenAPI document
  coordinator/  Provider polling, scheduler, parent/job selection, publication
  miner/        CLI, headless runner, OpenTUI dashboard
  download/     static miner release service
migrations/     ordered SQL migrations
openapi/        OpenAPI 3.1 contract
deploy/         Caddy configs, host bootstrap, firewall
web/            Next.js App Router static site

Configuration

Copy .env.example to .env. Compose passes blank optional values through, so leave an optional secret commented out instead of setting it to an empty string.

Required to start the full stack:

Variable Used by Notes
POSTGRES_PASSWORD Postgres, services Compose builds DATABASE_URL from it in deploy.
DATABASE_URL all services postgres://... reachable from the Compose network.
REDIS_URL gateway, coordinator, verifier, api redis://redis:6379 in Compose.
PROVIDER_TOKEN coordinator Bearer token. Compose refuses to start the coordinator without it.
PROVIDER_BASE_URL coordinator, api Defaults to https://provider.invalid/v1.
PROVIDER_COLLECTION_ID coordinator Optional. Settlement destination, never logged.

Scheduler defaults that differ between the binary and Compose are documented in Mining scheduler. The Compose values are the production tuning.

Build

Rust 1.100 is pinned in rust-toolchain.toml.

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --all-targets --locked

Tests that touch Postgres or Redis read DATABASE_URL and REDIS_URL and skip when the services are absent. Store::connect applies the embedded migrations.

The OpenTUI dashboard is optional:

eval "$(scripts/fetch-opentui.sh)"
cargo build -p miner --features tui

CUDA and HIP builds are opt-in and require the corresponding toolkit:

cargo build -p miner --release --features cuda
cargo build -p miner --release --features hip

GPU releases set CUDAARCHS in CI. A local CUDA build without GLYPH_CUDA_ARCH or CUDAARCHS emits no -arch flag, so nvcc uses its toolkit default and the driver JITs from PTX. See GPU tuning.

Run the stack

cp .env.example .env
# Fill POSTGRES_PASSWORD, DATABASE_URL, REDIS_URL, PROVIDER_TOKEN and
# optionally PROVIDER_COLLECTION_ID, PAYOUT_SEED and WEBHOOK_SIGNING_KEY.
mkdir -p dist/miner dist/web

docker compose up -d --build
docker compose ps
docker compose exec -T api curl -fsS http://127.0.0.1:8080/healthz

The default stack is Postgres, Redis, API, gateway, coordinator, verifier, download and Caddy. Payout is an opt-in profile:

docker compose --profile jobs run --rm payout settle --epoch 250 --mode solo --dry-run
docker compose --profile jobs run --rm payout pay --epoch 250 --dry-run
docker compose --profile jobs run --rm payout confirm --epoch 250
docker compose --profile jobs run --rm payout reconcile --epoch 250

For local development without Docker, start Postgres and Redis and then run cargo run -p api, -p gateway, -p coordinator, -p verifier and -p download with the same variables.

Host firewall

deploy/firewall.sh is idempotent and applies both UFW and a DOCKER-USER chain, because Docker-published ports bypass UFW. It allows SSH (DEPLOY_SSH_PORT, default 22), 80/tcp and 443/tcp, and allows QATUM_PORT only from QATUM_ALLOW_FROM (comma-separated CIDRs). With QATUM_ENABLED=0 the Qatum rule is dropped and the port is denied. A systemd unit glyph-docker-firewall.service reapplies the chain after Docker starts.

Miner

# Download and install on Linux
curl -fsSL https://dl-miner.glyphq.org/miner/install.sh | bash

# Wallet approval, then TUI when stdout is a terminal
glyph-miner mine --connect

# Headless worker
GLYPH_POOL_KEY=gpk_... glyph-miner mine --worker worker-01 --no-tui --json

# Update
glyph-miner update --channel stable --check
glyph-miner update --channel stable

The miner stores worker profiles in a JSON config file, keeps the API key in a mode-0600 file, and refuses to run a second instance from the same config. See Miner and TUI.

Web and API

web/ is a Next.js App Router static export. The routes in the app are /, /api, /app, /app/workers, /app/shares, /app/epochs, /app/epochs/[number], /app/epochs/view, /app/tree, /app/settings, /app/miner and /app/miner/connect.

The OpenAPI 3.1 contract is openapi/pool.openapi.json and generates the typed client used by the web app:

cd web
bun install
bun run generate:api
bun run check
bun run build

Caddy serves WEB_DIST_PATH, proxies /v1/*, /healthz, /openapi.json, /docs, /docs/* and /scalar.js to the API, and proxies /ws/miner to the gateway. GET /docs is the Scalar reference.

Deployment

  • .github/workflows/ci.yml runs fmt, clippy, workspace tests with Postgres and Redis services, the web build, and the OpenTUI clippy check.
  • .github/workflows/deploy.yml runs for service runtime inputs and deploys the Compose stack over SSH. Images are tagged with the commit SHA. Health is checked against the pool and download origins.
  • .github/workflows/deploy-miner.yml builds Linux and Windows miner assets, optional CUDA assets, publishes a GitHub release and rsyncs the versioned directory into dist/miner.
  • .github/workflows/deploy-web.yml builds and checks web/ and rsyncs web/out into WEB_DIST_PATH.
  • .github/workflows/miner-release.yml builds tagged releases.
  • .github/workflows/bench.yml runs the CPU benchmark matrix.

Documentation

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages