Skip to content
Open
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
495 changes: 414 additions & 81 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
bitcoin = { version = "0.32.5", features = ["serde", "rand"] }
tokio = { version = "1.0", features = ["full"] }
p2poolv2_lib = { git = "https://github.com/p2poolv2/p2poolv2", package = "p2poolv2_lib", tag = "v0.7.0" }
p2poolv2_cli = { git = "https://github.com/p2poolv2/p2poolv2", package = "p2poolv2_cli", tag = "v0.7.0" }
p2poolv2_api = { git = "https://github.com/p2poolv2/p2poolv2", package = "p2poolv2_api", tag = "v0.7.0" }
bitcoindrpc = { git = "https://github.com/p2poolv2/p2poolv2", package = "bitcoindrpc", tag = "v0.7.0" }
p2poolv2_lib = { git = "https://github.com/average-gary/p2pool-v2", package = "p2poolv2_lib", branch = "sv2-support", features = ["sv2"] }
p2poolv2_cli = { git = "https://github.com/average-gary/p2pool-v2", package = "p2poolv2_cli", branch = "sv2-support" }
p2poolv2_api = { git = "https://github.com/average-gary/p2pool-v2", package = "p2poolv2_api", branch = "sv2-support" }
bitcoindrpc = { git = "https://github.com/average-gary/p2pool-v2", package = "bitcoindrpc", branch = "sv2-support" }

[[bin]]
name = "hydrapool"
Expand Down
43 changes: 43 additions & 0 deletions config-testnet4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[store]
path = "./store-testnet4.db"
background_task_frequency_hours = 24
pplns_ttl_days = 1

[stratum]
hostname = "0.0.0.0"
port = 3333
start_difficulty = 1
minimum_difficulty = 1
bootstrap_address = "tb1qs5kpecpax8uv4vn5uqfyycmmmma7jhunmce0z4"
donation_address = "tb1qs5kpecpax8uv4vn5uqfyycmmmma7jhunmce0z4"
donation = 10000
ignore_difficulty = true
zmqpubhashblock = "tcp://127.0.0.1:28334"
network = "testnet4"
version_mask = "1fffe000"
difficulty_multiplier = 1.0
pool_signature = "hydrapool-sv2"

[stratum_sv2]
enabled = true
hostname = "0.0.0.0"
port = 3334
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
cert_validity_seconds = 86400
server_id = 0

[bitcoinrpc]
url = "http://127.0.0.1:48335"
username = "myusername"
password = "mypassword"

[logging]
level = "info"
stats_dir = "./logs/stats-testnet4"

[api]
hostname = "0.0.0.0"
port = 46884
auth_user = "hydrapool"
auth_token = "0d74058f74ad3b6768493cedb5e9492b$2a2599d5f4003c291e141762d0e43808cfd932f04a8260e94c375d1574599dbf"
18 changes: 18 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ difficulty_multiplier = 1.0
# to add a pool signature. Maximum length 16 bytes.
pool_signature = "hydrapool"

# Stratum V2 Mining Protocol (optional, disabled by default)
# Runs alongside the SV1 server on a separate port. Both protocols
# feed validated shares into the same PPLNS accounting pipeline.
# [stratum_sv2]
# enabled = true
# hostname = "0.0.0.0"
# port = 3334
# Noise NX keypair for encrypted connections. REQUIRED when SV2 is
# enabled — the server will refuse to start without both keys.
# Generate a keypair with:
# openssl rand -hex 32 # -> authority_secret_key
# Then derive the x-only public key from the secret key using secp256k1.
# authority_public_key = "<64 hex chars (32-byte x-only pubkey)>"
# authority_secret_key = "<64 hex chars (32-byte secret key)>"
# cert_validity_seconds = 86400
# default_extranonce_size = 16
# server_id = 0

[bitcoinrpc]
# RPC credentials are loaded from env vars
url = "http://127.0.0.1:38332"
Expand Down
4 changes: 3 additions & 1 deletion docker/Dockerfile.hydrapool
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ USER hydrapool
# Set working directory
WORKDIR /var/lib/hydrapool

# Expose API port (adjust based on your config)
# Expose service ports
EXPOSE 3333
EXPOSE 3334
EXPOSE 46884

# Set environment
Expand Down
39 changes: 39 additions & 0 deletions docker/Dockerfile.mining-device
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Build the SRI mining-device (CPU SV2 miner) from source.
# Used for interoperability testing against Hydrapool's SV2 server.
#
# Build: docker build -f docker/Dockerfile.mining-device -t mining-device .
# (No local context needed; this clones from GitHub.)

FROM rust:1.85-slim-bookworm AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /build

# Clone the sv2-apps repo (pinned to main for reproducibility).
ARG SV2_APPS_REF=main
RUN git clone --depth 1 --branch ${SV2_APPS_REF} \
https://github.com/stratum-mining/sv2-apps.git .

# Build the mining-device binary.
WORKDIR /build/miner-apps/mining-device
RUN cargo build --release

# --- Runtime stage ---
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /build/miner-apps/mining-device/target/release/mining_device \
/usr/local/bin/mining_device

RUN chmod +x /usr/local/bin/mining_device

ENTRYPOINT ["/usr/local/bin/mining_device"]
7 changes: 6 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ docker compose ps

### 5. Access services

- **Stratum mining:** `stratum+tcp://localhost:3333`
- **Stratum V1 mining:** `stratum+tcp://localhost:3333`
- **Stratum V2 mining:** `stratum2+tcp://localhost:3334` (Noise NX encrypted, requires SV2-compatible miner or translator proxy; enable in config first)
- **API server:** `http://localhost:46884`
- **Grafana dashboard:** `http://localhost:3000` (if running with dashboards, login with credentials from step 2)
- **Prometheus:** `http://localhost:9090` (if running with dashboards)

> **Note:** Stratum V2 is disabled by default. Uncomment and configure the
> `[stratum_sv2]` section in `config.toml` to enable it. A Noise NX keypair
> (`authority_public_key` / `authority_secret_key`) is required.

## Updating Configuration

After editing `config.toml`, restart Hydrapool:
Expand Down
18 changes: 18 additions & 0 deletions docker/config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ difficulty_multiplier = 1.0
# Comment out for anonymous mining or replace/append your identifier.
pool_signature = "hydrapool"

# Stratum V2 Mining Protocol (optional, disabled by default)
# Runs alongside the SV1 server on a separate port. Both protocols
# feed validated shares into the same PPLNS accounting pipeline.
# [stratum_sv2]
# enabled = true
# hostname = "0.0.0.0"
# port = 3334
# Noise NX keypair for encrypted connections. REQUIRED when SV2 is
# enabled — the server will refuse to start without both keys.
# Generate a keypair with:
# openssl rand -hex 32 # -> authority_secret_key
# Then derive the x-only public key from the secret key using secp256k1.
# authority_public_key = "<64 hex chars (32-byte x-only pubkey)>"
# authority_secret_key = "<64 hex chars (32-byte secret key)>"
# cert_validity_seconds = 86400
# default_extranonce_size = 16
# server_id = 0

[bitcoinrpc]
# REQUIRED: Bitcoin RPC connection
# For Docker: use "http://host.docker.internal:38332" to connect to host
Expand Down
10 changes: 5 additions & 5 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ services:
dockerfile: docker/Dockerfile.hydrapool
image: hydrapool:dev
networks:
- p2pool_network
- hydrapool_network

hydrapool-cli:
build:
context: ..
dockerfile: docker/Dockerfile.hydrapool
image: hydrapool:dev
networks:
- p2pool_network
- hydrapool_network

prometheus:
build:
Expand All @@ -26,7 +26,7 @@ services:
ports:
- "9090:9090"
networks:
- p2pool_network
- hydrapool_network
extra_hosts:
- "host.docker.internal:host-gateway"

Expand All @@ -39,10 +39,10 @@ services:
ports:
- "3000:3000"
networks:
- p2pool_network
- hydrapool_network
extra_hosts:
- "host.docker.internal:host-gateway"

networks:
p2pool_network:
hydrapool_network:
driver: bridge
88 changes: 88 additions & 0 deletions docker/docker-compose.interop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Docker Compose for SV2 interoperability testing.
#
# Services:
# bitcoind - Bitcoin Core in regtest mode (generates blocks)
# hydrapool - Hydrapool with SV2 enabled (built from local source)
# mining-device - SRI CPU miner connecting to Hydrapool via SV2
#
# Usage:
# scripts/test-interop-sv2.sh # automated test (recommended)
# docker compose -f docker/docker-compose.interop.yml up --build # manual

services:
bitcoind:
image: lncm/bitcoind:v28.0
container_name: interop-bitcoind
command:
- -conf=/bitcoin/.bitcoin/bitcoin.conf
- -regtest
volumes:
- ./interop/bitcoin-regtest.conf:/bitcoin/.bitcoin/bitcoin.conf:ro
- bitcoind_data:/bitcoin/.bitcoin
ports:
- "18443:18443"
- "28332:28332"
networks:
- interop_network
healthcheck:
test: ["CMD", "bitcoin-cli", "-regtest", "-rpcuser=hydrapool", "-rpcpassword=hydrapool", "getblockchaininfo"]
interval: 5s
timeout: 5s
retries: 30
start_period: 10s

hydrapool:
build:
context: ..
dockerfile: docker/Dockerfile.hydrapool
container_name: interop-hydrapool
depends_on:
bitcoind:
condition: service_healthy
volumes:
- ./interop/config-regtest.toml:/etc/hydrapool/config.toml:ro
- hydrapool_data:/var/lib/hydrapool
- hydrapool_logs:/var/log/hydrapool
ports:
- "3333:3333"
- "3334:3334"
- "46884:46884"
networks:
- interop_network
environment:
- RUST_LOG=debug
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:46884/health"]
interval: 5s
timeout: 5s
retries: 30
start_period: 30s

mining-device:
build:
context: ..
dockerfile: docker/Dockerfile.mining-device
container_name: interop-mining-device
depends_on:
hydrapool:
condition: service_healthy
command:
- --address-pool
- hydrapool:3334
- --id-user
- "tb1qyazxde6558qj6z3d9np5e6msmrspwpf6k0qggk.interop-rig1"
- --nominal-hashrate-multiplier
- "0.01"
networks:
- interop_network
environment:
- RUST_LOG=debug

volumes:
bitcoind_data:
hydrapool_data:
hydrapool_logs:

networks:
interop_network:
driver: bridge
3 changes: 2 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ services:
- hydrapool_logs:/var/log/hydrapool
restart: unless-stopped
ports:
- "3333:3333" # Stratum mining port
- "3333:3333" # SV1 Stratum mining port
- "3334:3334" # SV2 Stratum mining port (Noise NX encrypted)
- "46884:46884" # API server port
extra_hosts:
- "host.docker.internal:host-gateway"
Expand Down
29 changes: 29 additions & 0 deletions docker/interop/bitcoin-regtest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Bitcoin Core regtest configuration for SV2 interoperability testing.
# This runs a fully self-contained regtest node inside Docker.

regtest=1

[regtest]
# RPC credentials (must match Hydrapool's [bitcoinrpc] section)
rpcuser=hydrapool
rpcpassword=hydrapool
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcport=18443

# ZMQ notifications for new blocks
zmqpubhashblock=tcp://0.0.0.0:28332

# Minimal resource usage
prune=550
dbcache=64
maxmempool=50

# Accept non-standard transactions in regtest
acceptnonstdtxn=1

# Generate blocks quickly
fallbackfee=0.0001

# Allow connections
listen=1
Loading