Skip to content

feat: Stratum v2 Mining Protocol support #41

@average-gary

Description

@average-gary

Background

Following up on the discussion in #37 — I've put together a plan and started working toward adding native SV2 Mining Protocol support for downstream miners.

stratum-core vs legacy SRI crates

The concerns raised in #37 about technical debt and tight coupling in the *_sv2 crates are well-taken. Since that discussion, the stratum-mining org published stratum-core (v0.2.0), a ground-up refactor that consolidates the protocol primitives into a single crate with cleaner APIs — Responder for Noise handshake, StandardChannel/ExtendedChannel with built-in validate_share(), and all Mining Protocol message types. This plan uses stratum-core rather than the legacy individual crates.

Design

Dual-protocol: SV1 continues on port 3333, SV2 listens on port 3334. Both feed validated shares into the existing Emission pipeline — PPLNS accounting, block submission, and metrics work unchanged downstream.

Scope: Pool-side Mining Protocol only. No Job Declaration Protocol, no Template Distribution Protocol. The pool continues to build block templates via getblocktemplate + ZMQ.

Integration seam: SV2-validated shares produce the same Emission struct sent through the existing emissions_tx channel. Everything downstream is protocol-agnostic.

User identity: SetupConnection.user_identity enforces a Bitcoin address, same convention as SV1's mining.authorize.

Phases

Phase Summary
0 — Foundation Add stratum-core dependency, SV2 config section
1 — Connections Noise handshake, SetupConnection handler, connection registry
2 — Channels Standard channels, Extended channels, vardiff lifecycle
3 — Jobs GBT→SV2 template bridge, job distribution, SetNewPrevHash
4 — Shares SubmitSharesStandard/Extended, Emission bridge
5 — Wiring main.rs integration, Docker/packaging
6 — Testing Unit, integration, interop tests
7 — Metrics Prometheus counters, Grafana dashboards

Detailed issue breakdowns and task tracking: Project Board

Approach

Developing on forks of both hydrapool and p2poolv2. The SV2 code lives as a new stratum_sv2/ module in p2poolv2_lib alongside the existing stratum/ module, with minimal changes to hydrapool itself (config + wiring in main.rs). Intent is to contribute upstream as PRs.

Open to feedback on the design or phasing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions