Repository navigation
Send miner auth token in Ready handshake. - #78
Conversation
Require --auth-token or --auth-token-file when connecting to a node so the miner matches the node's shared-secret QUIC auth. Co-authored-by: Cursor <[email protected]>
Require --tls-cert-sha256 or --tls-cert-sha256-file so miners reject MITM certs instead of accepting any self-signed server certificate. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
|
Ok the desired architecture for this is: The node prints an API key on the command line on start, persists it in file - so on restart, node as the same API key QUIC miners are started with the API key as a parameter to be able to authenticate with the node, it's only used in the initial handshake to set up the secure connection This protects the node from griefing attacks - example I could make thousands of fake miners, connect to nodes, and feed them bad results, meanwhile I am mining real blocks... |
A node/miner protocol mismatch now fails cleanly at the TLS handshake with "no application protocol" instead of an opaque auth error. Co-authored-by: Cursor <[email protected]>
The temporary git branch pin is no longer needed now that 0.3.0 is published. Co-authored-by: Cursor <[email protected]>
n13
left a comment
There was a problem hiding this comment.
Reviewer model: GPT Sol
Verdict: REQUEST_CHANGES — permanent auth configuration failures currently become endless reconnect loops, and the operator guidance is inconsistent with the shipped node behavior.
Findings:
-
[P1] Validate permanent auth/TLS configuration before starting long-lived services (
crates/miner-cli/src/main.rs:164-178,crates/pool-service/src/main.rs:135-146,crates/quic-transport/src/lib.rs:27-29,crates/miner-service/src/quic.rs:45-63). The CLI/pool resolvers accept any non-empty fingerprint, but parsing happens only insideconnect(), whose callers classify every error as transient. On this head,quantus-miner serve --auth-token token --tls-cert-sha256 nope --cpu-workers 1 --gpu-devices 0starts metrics and a worker, then retries the deterministic parse error forever;pool-servicealso starts and exposes its HTTP API before retrying forever. Rejected tokens have an additional issue:connect()returns immediately after writingReady, so both callers reset the delay to one second before Chain PR #662 validates the token and closes withauth failed, causing a permanently misconfigured miner to reconnect every second. Parse/validate the pin and enforce the API's serializedReadyframe limit once at startup, before spawning workers/HTTP; treat explicit auth rejection as fatal or do not reset backoff until authentication is known to have succeeded. -
[P2] Make every auth instruction and runnable example match the new required inputs (
crates/miner-cli/src/main.rs:24,242-244,crates/pool-service/src/main.rs:35,179-181,README.md:20-48,83-130). The merged node intentionally does not log the auth token, yet the CLI help, pool help, configuration table, and errors still tell operators to copy it from logs. The README's Examples and Docker commands also omit both newly required credentials, so those documentedservecommands now exit immediately. Point token guidance only atminer-auth-token, and add the file mounts/flags (or environment variables) to every affected native and container example.
Validation:
cargo fmt --all -- --check— passedtaplo fmt --check— passedcargo clippy --locked -p quic-transport -p miner-service -p miner-cli -p pool-service --all-targets -- -D warnings— passedcargo test --locked -p quic-transport -p miner-service -p miner-cli -p pool-service— passed (9 existing pool tests; the changed CLI, miner-service, and QUIC transport paths have 0 tests)- Manual malformed-pin startup checks reproduced the miner retry loop and pool HTTP-serving behavior above
- All four GitHub CI checks are green at
227da2464d02ed8497282e1f543cf4ad82d8c71b
…ing. Validate the fingerprint and Ready frame size at miner/pool startup before metrics, workers, or HTTP come up. Treat node auth rejection and pin mismatch as PermanentConnectError (no retry), and only reset reconnect backoff after the first NewJob proves auth succeeded. Co-authored-by: Cursor <[email protected]>
The node never logs the auth token; CLI/pool help and every serve/Docker example now require the chain config files (or env vars) instead of implying credentials can be copied from logs. Co-authored-by: Cursor <[email protected]>
n13
left a comment
There was a problem hiding this comment.
Reviewer model: GPT Sol
Verdict: REQUEST_CHANGES — the earlier auth/TLS startup and reconnect blockers are fixed, but the newly documented Docker commands cannot be parsed by the miner CLI.
Findings:
- [P2] Use a node address that the Docker examples can actually pass (
README.md:161,README.md:168,README.md:182,crates/miner-cli/src/main.rs:21). All three Docker examples set--node-addr/MINER_NODE_ADDRtohost.docker.internal:9833, but the option is astd::net::SocketAddr, which only accepts a numeric IP address. Running the documented value exits immediately withinvalid value 'host.docker.internal:9833' ... invalid socket address syntax, before auth or QUIC setup;localhost:9833fails identically. This leaves every Docker command added by the fix unusable. Either resolve hostnames in the CLI (for example, accept a host/port value and use async address resolution) or document a numeric address/routing setup that is actually reachable from the container, then exercise the published commands.
The previous permanent-misconfiguration findings are otherwise resolved: malformed pins and oversized Ready frames are validated before miner workers, metrics, or pool HTTP start; explicit auth failed closes are treated as permanent; reconnect backoff is not reset before the first NewJob; and the token/fingerprint guidance now matches the merged node behavior.
Validation:
cargo fmt --all -- --check— passedtaplo fmt --check— passedcargo clippy --locked -p quic-transport -p miner-service -p miner-cli -p pool-service --all-targets -- -D warnings— passedcargo test --locked -p quic-transport -p miner-service -p miner-cli -p pool-service— passed (12 tests)- Manual malformed-pin startup checks — miner and pool both exit before starting services
- Manual README address checks — reproduced immediate parse failures for
host.docker.internal:9833andlocalhost:9833 - Companion Chain PR #662 cross-check —
quantus-miner/2, DER SHA-256 pin format,Ready { token }, andauth failedclose reason match - All four GitHub CI checks are green at
361463645d82dd50183a4cb627654d9c9a1dd4fc
Container GPU access is a poor fit for this miner, and the Docker examples were unusable with SocketAddr (hostnames rejected). Run the native binary instead. Co-authored-by: Cursor <[email protected]>
n13
left a comment
There was a problem hiding this comment.
Reviewer model: GPT Sol
Verdict: REQUEST_CHANGES — the previous Docker-address blocker is resolved, but permanent upstream-auth failure still leaves pool-service running with no/live-stale work, and the checked-in protocol specification now directs clients to an incompatible insecure protocol.
Findings:
-
[P1] Propagate a permanent upstream failure to the pool process (
crates/pool-service/src/main.rs:153-178,crates/pool-service/src/upstream.rs:62-69,109-115).run_node_clientreturns when the node closes withauth failedorconnect()returnsPermanentConnectError, butmaindiscards the spawned task'sJoinHandleand awaits the HTTP server forever. At startup this leaves/api/sessionreturningno_job_availablewhile the service/container still appears alive; after a previously authenticated connection loses auth,PoolStateretains the last job and the HTTP side can keep issuing captcha challenges and tokens against that stale header after the upstream task is dead. The process also cannot pick up a corrected/rotated credential without a manual restart. Supervise the upstream task alongside HTTP and make a permanent error terminatemain(or explicitly recover while invalidating the current job and surfacing unhealthy state). -
[P2] Update or remove the obsolete top-level protocol specification (
EXTERNAL_MINER_PROTOCOL.md:53-85,118-172,199-212,233). The document still specifies onlyNewJob/JobResult, omits the initial authenticatedReady { token }, gives aservecommand without either required credential, says the miner skips certificate verification, advertises the oldquantus-minerALPN, and elsewhere claims a 16 MB frame limit instead of 1 KB. A client implemented from this repository's named protocol specification cannot negotiatequantus-miner/2or authenticate, and the TLS guidance contradicts the new mandatory pinning. Bring the document fully in line withquantus-miner-api 0.3.0, or replace it with an explicit pointer to the node's maintainedMINING.md.
The latest commit otherwise resolves the prior Docker finding by removing the unsupported container path, and the earlier startup-validation/backoff fixes remain intact.
Validation:
cargo fmt --all -- --check— passedtaplo fmt --check— passedcargo clippy --locked -p quic-transport -p miner-service -p miner-cli -p pool-service --all-targets -- -D warnings— passedcargo test --locked -p quic-transport -p miner-service -p miner-cli -p pool-service— passed (12 tests; the changed miner-service and pool upstream control paths have no direct tests)cargo build --locked -p miner-cli -p pool-service— passed- Manual startup checks — the command currently documented in
EXTERNAL_MINER_PROTOCOL.mdexits 1 for missing auth; malformed pins make both miner and pool exit before long-lived services start - Companion Chain PR #662 is merged; ALPN
quantus-miner/2, DER SHA-256 pinning,Ready { token },auth failed, and publishedquantus-miner-api 0.3.0match this head - All four GitHub CI checks are green at
aac3a141332b55ca9d328406f43f20681be11c27
…ing otherwise. Supervise run_node_client alongside HTTP so a bad token/pin ends the process instead of leaving a live API on a dead upstream. Node restarts still reconnect with backoff; the current job is cleared while disconnected so captchas are not issued against a stale header. Co-authored-by: Cursor <[email protected]>
The local copy still described the pre-auth protocol (no Ready token, no pin, old ALPN, 16 MB frames). Canonical docs live in quantus-miner-api and the node's MINING.md. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
n13
left a comment
There was a problem hiding this comment.
Reviewer model: GPT Sol
Verdict: APPROVE — the authenticated, certificate-pinned miner handshake matches the published API and merged node implementation, and no blocking findings remain.
No blocking findings.
The latest commits resolve the prior blockers: pool-service now propagates permanent upstream auth/TLS failures to the process, clears the current job across transient disconnects, and continues reconnecting only for recoverable failures. The obsolete local protocol specification is removed, while the README points operators to the node's maintained MINING.md. Startup validation, DER SHA-256 certificate pinning, quantus-miner/2 ALPN, Ready { token }, auth-rejection handling, and reconnect backoff are consistent across the miner and pool paths.
Validation at 6085dc1696f358f763cac99753f4fb56aa8d41f5:
cargo fmt --all -- --check— passedtaplo fmt --check— passedgit diff --check 2eb0341a7054c41559f51518eed5c41a0575a4f8...6085dc1696f358f763cac99753f4fb56aa8d41f5— passedcargo clippy --locked -p quic-transport -p miner-service -p miner-cli -p pool-service --all-targets -- -D warnings— passedcargo test --locked -p quic-transport -p miner-service -p miner-cli -p pool-service— passed (12 tests)cargo build --locked -p miner-cli -p pool-service— passed- Manual malformed-pin startup checks — miner and pool both exited with status 1 before starting metrics/workers or HTTP
- Published
quantus-miner-api0.3.0 and merged Chain PR #662 cross-check — message schema, 1 KiB frame cap, ALPN, certificate fingerprint format, auth close reason, and keep-alive requirements match - All four GitHub CI checks are green on the reviewed head
Summary
--auth-token/MINER_AUTH_TOKENor--auth-token-file/MINER_AUTH_TOKEN_FILE).Ready { token }in the initial handshake (matchesquantus-miner-api0.3.0).pool-servicewhen--node-addris set (POOL_AUTH_TOKEN/POOL_AUTH_TOKEN_FILE).Companion PR
Depends on the chain PR that introduces miner auth and bumps
quantus-miner-apito0.3.0.Note: this branch temporarily uses
path = "../chain2/miner-api"for local development. Before merge, switch the dependency to the published/git tag or branch once the chain change is available.Test plan
cargo check -p miner-cli -p pool-service -p quic-transport -p miner-serviceminer-auth-tokenfile.quantus-miner serve --node-addr … --auth-token <TOKEN>connects and mines.--auth-token-file <path>works against the node's token file.--node-addrrequires auth token flags.