You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Repair and finish the BOLT10 DNS bootstrap client so it conforms 100% to the spec and interoperates with known public DNS seeders (e.g., lseed.bitcoinstats.com). Implement a DNS bootstrap service that runs when the node has fewer than N peers, and add comprehensive unit tests and integration tests (against real seeders) to ensure correctness and ongoing compatibility.
Background / Motivation
Current DnsSeedClient implementation is commented out and does not fully follow BOLT10. As a result, it fails to resolve peers from public seeders like lseed.bitcoinstats.com.
The BOLT10 DNS bootstrap process is part of initial peer discovery. We need a reliable implementation so nodes can automatically find peers if their peer list is short.
Reimplement DnsSeedClient according to BOLT10 and align with the behavior of public lseed instances.
Implement a DNS bootstrap service (background job) that integrates with existing service patterns. It should run if the node’s known peers < configurable threshold and fetch additional peers from the configured seeds.
Write tests:
Unit tests for record parsing, decoding of pubkeys, IPv4/IPv6 support, SRV resolution logic, error handling.
Integration tests against real DNS bootstrap services (e.g., lseed.bitcoinstats.com). These tests should be skipped in CI by default if DNS/network is unreliable but runnable locally and in controlled environments.
Make the service configurable via NodeOptions (seed list, thresholds, timeouts, TCP/UDP choice, IPv4/IPv6 selection, optional custom resolvers).
Non‑Goals
Implementing peer connection logic itself (beyond returning structured seed results)—that is handled by other components.
Creating a proprietary seed server. We only consume public servers per the spec.
Perform SRV lookups per BOLT10 for the appropriate service labels (and fallbacks) used by public seeders.
Resolve target hostnames to A and/or AAAA records depending on IPv4/IPv6 mode.
Correctly decode the node public key from the SRV target label per the spec/lseed conventions (bech32 payload, correct HRP, proper 5↔8‑bit conversion, validation of sizes).
Capture the advertised port from SRV records.
Shuffle and select up to the requested number of nodes.
Provide robust error handling and partial success (continue across seeds and records).
Validate that the prior assumptions (e.g., HRP "ln", single‑label bech32 decoding) match the current lseed behavior; adjust to match spec if different.
Expose a clean result model (pubkey as 33‑byte compressed key or 32‑byte x‑only public key per spec, plus IPEndPoint).
New/Updated Service
Create a DNS Bootstrap background service (or integrate into the existing service orchestration) that:
Periodically checks the known connected peer count.
If below threshold N (configurable), queries the configured seed servers and attempts to add/connect to returned nodes.
Respects NodeOptions.NetworkTimeout, DnsSeedServers, and IPv4/IPv6 preferences.
Configuration
src/NLightning.Domain/Node/Options/NodeOptions.cs
Ensure DnsSeedServers default is sensible and includes at least one well‑known public seeder for the network in use. Current default is ["nlseed.nlightn.ing"]; consider supplementing with lseed.bitcoinstats.com for mainnet.
Add settings (if not present already) for:
Bootstrap threshold (min peer count)
IPv4/IPv6 preference and whether to use TCP‑only for DNS queries
Optional custom resolvers (e.g., 8.8.8.8)
Tests
Unit tests for DnsSeedClient covering:
SRV parsing and port extraction
Target label decoding into pubkeys (valid and invalid cases)
A/AAAA record handling, IPv4/IPv6 toggling
Shuffling/selection and error resilience
Integration tests (see the attached file) in test/NLightning.Integration.Tests/BOLT10/DNSBootstrapTests.cs:
Revive and adapt tests to query real seeders like lseed.bitcoinstats.com.
Skip in CI by default when network DNS is unreliable (retain the TCP‑only option for better reliability, similar to the commented tests).
Acceptance Criteria
DnsSeedClient correctly discovers nodes from lseed.bitcoinstats.com (and similar public seeders) on both IPv4 and IPv6 where available.
Node public keys are decoded per the spec and sized/validated correctly.
DNS bootstrap service kicks in when peer count < threshold and attempts to fill to the threshold using configured seeds.
Unit tests cover core logic; integration tests succeed locally and are conditionally skipped in CI as needed.
Configuration is documented and defaults are sensible for mainnet/testnet.
Summary
Repair and finish the BOLT10 DNS bootstrap client so it conforms 100% to the spec and interoperates with known public DNS seeders (e.g.,
lseed.bitcoinstats.com). Implement a DNS bootstrap service that runs when the node has fewer than N peers, and add comprehensive unit tests and integration tests (against real seeders) to ensure correctness and ongoing compatibility.Background / Motivation
DnsSeedClientimplementation is commented out and does not fully follow BOLT10. As a result, it fails to resolve peers from public seeders likelseed.bitcoinstats.com.lseedcan found at: https://github.com/cdecker/lseed. Specification: https://github.com/lightning/bolts/blob/master/10-dns-bootstrap.mdScope
DnsSeedClientaccording to BOLT10 and align with the behavior of public lseed instances.lseed.bitcoinstats.com). These tests should be skipped in CI by default if DNS/network is unreliable but runnable locally and in controlled environments.NodeOptions(seed list, thresholds, timeouts, TCP/UDP choice, IPv4/IPv6 selection, optional custom resolvers).Non‑Goals
Proposed Changes
src/NLightning.Infrastructure/Protocol/Services/DnsSeedClient.csAand/orAAAArecords depending on IPv4/IPv6 mode."ln", single‑label bech32 decoding) match the current lseed behavior; adjust to match spec if different.IPEndPoint).New/Updated Service
NodeOptions.NetworkTimeout,DnsSeedServers, and IPv4/IPv6 preferences.Configuration
src/NLightning.Domain/Node/Options/NodeOptions.csDnsSeedServersdefault is sensible and includes at least one well‑known public seeder for the network in use. Current default is["nlseed.nlightn.ing"]; consider supplementing withlseed.bitcoinstats.comfor mainnet.8.8.8.8)Tests
DnsSeedClientcovering:test/NLightning.Integration.Tests/BOLT10/DNSBootstrapTests.cs:lseed.bitcoinstats.com.Acceptance Criteria
DnsSeedClientcorrectly discovers nodes fromlseed.bitcoinstats.com(and similar public seeders) on both IPv4 and IPv6 where available.Implementation Notes / References
src/NLightning.Infrastructure/Protocol/Services/DnsSeedClient.cs(current, commented implementation)src/NLightning.Domain/Node/Options/NodeOptions.cs(containsDnsSeedServersand related options)test/NLightning.Integration.Tests/BOLT10/DNSBootstrapTests.cs(commented integration tests)Risks / Considerations
Testing Plan
DNSBootstrapTestswith:[InlineData(true)]and[InlineData(false)]to toggle TCP‑onlylseed.bitcoinstats.comCI=trueand not TCP‑onlyDefinition of Done
lseed.bitcoinstats.comlocally (documented in test output or README).