-
Notifications
You must be signed in to change notification settings - Fork 6
QUIC miner #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QUIC miner #363
Conversation
illuzen
commented
Jan 26, 2026
- use QUIC instead of HTTP (no polling, just bidirectional push)
- simplify protocol to two message types
n13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment on if-else above - not a blocker though
Gemini Review:
Review of PR #363: QUIC miner
Summary
This PR replaces the HTTP-based external miner protocol with a QUIC-based protocol. This is a significant architectural improvement that enables:
- Lower Latency: Server-push for new jobs (no polling).
- Efficiency: Persistent connections and bidirectional streams.
- Simplicity: Reduced protocol complexity (only 2 main message types).
The changes involve:
- Node Side: A new
MinerServerimplementation usingquinn(QUIC). - Protocol: Definition of
MinerMessagetypes inminer-api. - Integration: Updates to
node/src/service.rsto use the new server. - Cleanup: Removal of the old
external_miner_client.rs.
Protocol Design
The move to QUIC is well-justified for a mining protocol where latency is critical. The "push" model for jobs ensures miners start working on new blocks immediately.
Message Types
The protocol is clean, but there is a slight discrepancy between EXTERNAL_MINER_PROTOCOL.md and the implementation:
- Documentation: Lists only
NewJobandJobResult. - Implementation: Includes a
Readymessage sent by the miner immediately after connection.- Reason: To establish the bidirectional stream (QUIC streams are lazily initialized).
- Recommendation: Update
EXTERNAL_MINER_PROTOCOL.mdto document theReadymessage so independent miner implementers are aware of it.
Code Review
node/src/miner_server.rs
The implementation of the QUIC server is solid.
- Concurrency: Uses
Arc<RwLock<HashMap>>for miner management, which is appropriate. - Resource Management: Miners are correctly registered and unregistered upon connection/disconnection.
- Broadcasting:
broadcast_jobiterates through all connected miners. This is efficient for the expected number of miners. - Security:
- Enforces
MAX_MESSAGE_SIZE(16MB) to prevent OOM attacks. - Uses self-signed certificates. This is acceptable for the current stage, but the documentation correctly advises using proper CAs or pinning for production.
- Enforces
node/src/service.rs
The integration logic in mining_loop is robust.
- Verification: Crucially,
worker_handle.verify_seal(&seal)is called before submitting the block. This prevents invalid work from clogging the import queue. - Stale Work: The logic handles stale results gracefully by checking
job_id. - Cancellation: The
cancellation_tokenis checked in the wait loop, ensuring the node shuts down cleanly.
miner-api/src/lib.rs
- The data structures are well-defined using
serde. MiningResultincludeselapsed_timeandhash_count, which are useful for metrics.
Suggestions
- Update Documentation: Add the
Readymessage to the protocol specification. - Metrics: Consider exposing the number of connected miners as a Prometheus metric (currently only logged).
- Configuration: The
miner_listen_portis optional. Ensure the default behavior (when not set) is clearly communicated (i.e., external mining disabled).
Conclusion
This is a high-quality PR that significantly improves the mining infrastructure. The code is clean, safe, and follows Rust idioms.
Verdict: ✅ Approve (with minor documentation update)
|
Took suggestions except for adding miner count as it requires an additional internal server. |