Skip to content

Phase 0: SV2 foundation — fork deps, stratum-core, config#23

Open
average-gary wants to merge 12 commits intomainfrom
sv2-support
Open

Phase 0: SV2 foundation — fork deps, stratum-core, config#23
average-gary wants to merge 12 commits intomainfrom
sv2-support

Conversation

@average-gary
Copy link
Owner

Summary

  • Point hydrapool dependencies at average-gary/p2pool-v2 sv2-support branch (forked from p2poolv2/p2poolv2 at v0.7.0)
  • Add stratum-core v0.2.0 dependency to p2poolv2_lib with with_buffer_pool feature
  • Create stratum_sv2 module stub with smoke tests for all key SV2 types
  • Add Sv2Config struct with serde deserialization, defaults, validation, and builder methods
  • Add commented-out [stratum_sv2] config section to config.toml and docker/config-example.toml

Changes

p2pool-v2 fork (average-gary/p2pool-v2@sv2-support)

  • Cargo.toml: add stratum-core to workspace deps
  • p2poolv2_lib/Cargo.toml: add stratum-core dep
  • p2poolv2_lib/src/lib.rs: add stratum_sv2 module
  • p2poolv2_lib/src/stratum_sv2/mod.rs: smoke test importing Noise, Mining Protocol messages, binary codec
  • p2poolv2_lib/src/config.rs: add Sv2Config struct + stratum_sv2: Option<Sv2Config> field on Config + builder methods + 11 unit tests
  • config.toml: add commented SV2 section

hydrapool (this PR)

  • Cargo.toml: point 4 deps at fork branch
  • config.toml + docker/config-example.toml: add commented SV2 config section

Testing

All 388 existing p2poolv2_lib tests pass, plus 12 new tests (11 config + 1 smoke). cargo check passes on both repos.

Closes

Closes #1, #2, #3

Project

Stratum v2 Mining Protocol Support

Update Cargo.toml to use average-gary/p2pool-v2 sv2-support branch
which includes the stratum-core dependency and Sv2Config struct.

Add commented-out [stratum_sv2] section to config.toml and
docker/config-example.toml. The section is optional and disabled
by default for full backward compatibility.

Closes #1
Rebase p2pool-v2 fork onto upstream main (70 commits), then fix
hydrapool to match the new API surface:

- ChainStore -> ChainStoreHandle (renamed + new StoreWriter pipeline)
- .store() -> .chain_store_handle() on StratumServerBuilder
- start_notify() now takes ChainStoreHandle + miner_pubkey
- commands::run() is now async (hydrapool_cli needs #[tokio::main])
Enable the new 'sv2' cargo feature on p2poolv2_lib, which gates
stratum-core and all SV2 code behind a compile-time feature flag.
The stratum-core dependency now uses average-gary/stratum:feature-flag-subprotocols
with only the 'mining' subprotocol (excludes job_declaration and
template_distribution).
- Parse SV2 config, validate authority keypair
- Start SV2 connection registry + job distributor actors
- Launch Noise NX accept loop on configured port
- Clone emissions_tx so SV2 shares feed into same PPLNS pipeline
- Add SV2 graceful shutdown handling
- handshake_rx is unused pending per-connection message loop
- Import and use Sv2ConnectionContext, handle_sv2_connection, start_channel_manager
- Build Sv2ConnectionContext with connections, channels, job_distributor,
  emissions_tx, chain_store, validate_addresses, network
- Spawn handler loop that receives HandshakeResults and spawns
  handle_sv2_connection per connection
- Replace placeholder '_handshake_rx' with active handler dispatch
- Update Cargo.lock to ec704078 (handler.rs commit)
- Pass Sv2JobDistributorHandle to start_notify() so GBT templates are
  forwarded to SV2 miners via the same pipeline as SV1
- Move start_notify() spawn to after SV2 block so the handle is available
- Update Cargo.lock to p2pool-v2 478e36d (template feed + vardiff + share_commitment)
- Add EXPOSE 3333/3334 to Dockerfile, add 3334 port mapping to docker-compose
- Fix config comments: Noise NX keys are REQUIRED (not optional)
- Add SV2 endpoint to docker/README.md
- Fix docker-compose.dev.yml network name mismatch (p2pool_network -> hydrapool_network)
Add Docker-based interop test that runs the SRI mining-device (CPU SV2
miner) against Hydrapool's SV2 server on a Bitcoin regtest network.

New files:
- docker/docker-compose.interop.yml: bitcoind + hydrapool + mining-device
- docker/Dockerfile.mining-device: builds SRI mining-device from source
- docker/interop/config-regtest.toml: Hydrapool config with SV2 enabled
- docker/interop/bitcoin-regtest.conf: Bitcoin Core regtest settings
- scripts/test-interop-sv2.sh: automated test script with keypair gen
- docs/sv2-interop.md: compatibility matrix and testing documentation

Also updates Cargo.lock to latest p2pool-v2 sv2-support commit (7210da5)
which includes all 14 SV2 integration tests.
- Use signet network (p2poolv2_lib doesn't support regtest genesis)
- Shorten pool_signature to 'hydrapool-sv2' (16-char limit)
- Use verified Noise NX keypair instead of broken key derivation
- Remove auth from healthcheck (auth_user/auth_token are None)
- Update Cargo.lock to p2pool-v2 2eb5240 (SetNewPrevHash before
  NewMiningJob fix)
Pipe docker compose logs directly into grep instead of capturing 50MB+
into a bash variable. Disable pipefail locally in pool_log_has() to
prevent SIGPIPE errors when grep -q exits early. Detect mining-device
exit to avoid 120s wait timeout. All 5 SV2 lifecycle phases now pass.
Update Cargo.lock to latest p2pool-v2 sv2-support (9736403) which
includes three critical SV2 fixes:
- Send all jobs as future jobs (min_ntime=None) for SRI compatibility
- Send all job messages before any SetNewPrevHash (ordering fix)
- Skip standard channel messages for extended-only connections

Add testnet4 deployment configs:
- config-testnet4.toml: hydrapool pool config with SRI default keys
- translator-testnet4.toml: SRI translator proxy config (SV1:34255 → SV2:3334)
The SV2 spec (Section 4.7) defines the URI scheme as stratum2+tcp://,
not noise+tcp://. Noise NX encryption is implicit in the protocol.
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.

Fork p2poolv2 and update Cargo.toml dependency paths

1 participant