Skip to content

Support hostname targets in config - #24

Merged
lucasbalieiro merged 6 commits into
stratum-mining:mainfrom
lucasbalieiro:fix-14-parse-hostnames
Nov 13, 2026
Merged

lucasbalieiro merged 6 commits into
stratum-mining:mainfrom
lucasbalieiro:fix-14-parse-hostnames

Conversation

@lucasbalieiro

@lucasbalieiro lucasbalieiro commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

closes #14

Target addresses now accept hostnames as well as IP literals. Hostnames are resolved concurrently before the run starts, and IPv4 is preferred when both address families are returned. Malformed addresses still fail during TOML parsing; unresolvable ones are reported per target without stopping the remaining sites, though the CLI exits non-zero at the end.

TargetAddress keeps IP literals and hostnames distinct, so SocketAddr owns IP parsing and formatting. Resolution errors are summarized in the default output, with the OS resolver detail available under --verbose.

── Bad DNS: MiningServer at does-not-exist.invalid:3333 ──
  ✗ target unresolved: DNS lookup failed
✗ no targets resolved (1 unresolved)

The block shows the default output. With --verbose, the platform-specific resolver line is added under target unresolved

@lucasbalieiro
lucasbalieiro marked this pull request as ready for review November 6, 2026 16:42
@plebhash
plebhash self-requested a review November 10, 2026 16:29

@bit-aloo bit-aloo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direction makes sense. Some suggestions.

Comment thread src/config.rs Resolved
Comment thread src/bin/sv2-compliance.rs Resolved
Comment thread src/config.rs Resolved
Comment thread src/config.rs Resolved
@plebhash

Copy link
Copy Markdown
Member

I'm not strongly opinionated on this, but while looking at the diff I wondered whether std or tokio didn't deliver solutions that are being implemented by hand here

@lucasbalieiro was this something you took into consideration or deliberately avoid?

@bit-aloo

Copy link
Copy Markdown
Member

Are you talking about vectored lookup? like here we iterate on list and then do lookup calls here, so maybe having a vectored lookup might be helpful?

@plebhash

Copy link
Copy Markdown
Member

Are you talking about vectored lookup? like here we iterate on list and then do lookup calls here, so maybe having a vectored lookup might be helpful?

assuming this question is directed to my earlier comment:

no, I was just referring to the logic around HostPort.

I don't have opinions on whether we should have concurrency to resolve hostnames.

@lucasbalieiro

Copy link
Copy Markdown
Collaborator Author

I'm not strongly opinionated on this, but while looking at the diff I wondered whether std or tokio didn't deliver solutions that are being implemented by hand here

@lucasbalieiro was this something you took into consideration or deliberately avoid?

well, this was considered. The code already uses tokio::net::lookup_host and IP literals go through SocketAddr.

The hand-rolled part is only at the TOML boundary. To my knowledge, std doesn't provide a deserializable type for a "hostname-or-IP + port" value.

I could, of course, remove this parsing logic from the TOML layer and simply feed the value to lookup_host or SocketAddr, surfacing their errors directly.

However, there's a trade-off: errors would move from config-load time to runtime. A typo in the address could become indistinguishable from a DNS resolution failure, resulting in less specific and more generic errors.

The errors would also tend to be OS-specific, e.g. failed to lookup address information: nodename nor servname provided, rather than something actionable like expected host:port, not a URL.

The try_from approach also lets TOML report the exact field and line where deserialization failed, which makes configuration errors much easier to diagnose.

For example, with HostPort validation:

TOML parse error at line 3, column 24
invalid address "sri.pool.org": expected host:port (for example stratum.ckpool.org:3336)

Versus simply passing the string to the Tokio function:

── Site: MiningServer at sri.pool.org ──
✗ target unresolved: failed to lookup address information: nodename nor servname provided

Both fail, but only the first tells the user what's actually wrong: they forgot to specify the port.

That said, HostPort isn't strictly necessary for the functionality itself. I'd consider it a small usability improvement rather than a hard requirement. I'm not particularly opinionated about keeping it or removing it; the implementation is already there, but I'm happy to simplify it if we feel these extra guardrails aren't worth it.

Comment thread src/config.rs Resolved
@lucasbalieiro
lucasbalieiro merged commit 7ef8202 into stratum-mining:main Nov 13, 2026
3 checks passed
@lucasbalieiro
lucasbalieiro deleted the fix-14-parse-hostnames branch November 13, 2026 20:17
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.

make the config parser understand hostnames

3 participants