Skip to content

Native Stratum mining server with tiered routing and GPU miner tool#101

Open
Boblepointu wants to merge 40 commits intodoged-io:masterfrom
FrenchBTC:dogeeed
Open

Native Stratum mining server with tiered routing and GPU miner tool#101
Boblepointu wants to merge 40 commits intodoged-io:masterfrom
FrenchBTC:dogeeed

Conversation

@Boblepointu
Copy link
Copy Markdown

Summary

Adds a built-in Stratum v1 mining server to doged, eliminating the need for external pool software. The server plugs directly into the node's block assembly and validation pipeline, using Scrypt PoW throughout — no SHA-256 mining path.

Stratum server (src/stratum/)

  • Full Stratum v1 protocol: mining.subscribe, mining.authorize, mining.notify, mining.submit
  • Job manager that builds work from CreateNewBlock, splits the coinbase for extranonce injection, and computes merkle branches
  • Share validation against Scrypt PoW hash with configurable difficulty and optional variable difficulty (vardiff)
  • Merge-mining support via createauxblock / submitauxblock RPCs, respecting Dogecoin's AuxPoW chain ID (0x62) and fabe6d6d prefix
  • Libevent-based TCP server with thread-safe bufferevent handling for cross-thread broadcast
  • Worker session management with idle timeout and per-worker stats
  • JSON stats endpoint at /stratum/status

Tiered routing (stratumrouter + stratumproxy)

  • Prioritized work sourcing: local node (when synced) → upstream pool proxy → failover between healthy pools → warning on solo fallback
  • Upstream pool connector with health monitoring, automatic reconnection, and extranonce relay
  • Fully transparent to downstream miners — tier switches trigger clean job broadcasts
  • Configurable via -stratumproxy=host:port:user[:pass[:priority]], -stratumpreferlocal, -stratumwarnsolo

Miner tool (tools/miner/)

  • Standalone Scrypt(1024,1,1) Stratum miner with OpenCL GPU and CPU fallback
  • OpenCL kernel implementing PBKDF2-SHA256 → Salsa20/8 ROMix → target check
  • Zero external dependencies (self-contained JSON parser, Scrypt implementation)
  • Auto-detects GPU devices and adjusts work size to fit VRAM
  • doged-miner -o stratum+tcp://host:port -u worker -p x [--gpu 0] [--cpu 4]

Integration

  • Stratum server lifecycle wired into init.cpp (start after chainstate load, interrupt/stop on shutdown)
  • BCLog::STRATUM logging category for dedicated debug output
  • createauxblock and submitauxblock RPCs added to rpc/mining.cpp
  • CMake wiring for all new modules and test suites

Testing

  • 10 Boost unit test suites covering protocol parsing, config validation, worker state, job creation, share validation, auxpow, stats, proxy, and router logic
  • 5 Python functional tests for subscribe/authorize flow, share submission, auxpow, vardiff retarget, and tier routing
  • Verified end-to-end on regtest: miner connects, receives jobs, finds Scrypt shares, blocks accepted on-chain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant