-
Notifications
You must be signed in to change notification settings - Fork 204
Feat: Enhance DNS support in bootstrap discovery #1198
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
base: main
Are you sure you want to change the base?
Feat: Enhance DNS support in bootstrap discovery #1198
Conversation
- Improved error handling for DNS resolution failures in TCP and WebSocket transports, logging specific issues encountered during resolution. - Refactored multiaddr parsing in CircuitV2Transport to utilize decapsulation for better efficiency and clarity. - Updated BootstrapDiscovery to handle DNS resolution exceptions and log warnings for missing peer IDs and resolved addresses. - Utilized protocol codes for type-safe comparisons in multiaddr handling, ensuring robust address validation. - Consolidated IP extraction logic in multiaddr utilities for consistent parsing across the codebase.
- Updated the test for bootstrap address validation to include DNS protocol detection. - Introduced a new test to verify that DNS addresses are correctly identified across various DNS protocol formats. - Refactored existing tests for circuit multiaddr parsing to improve clarity and error handling for invalid cases.
- Updated bootstrap discovery to recognize multiple DNS address formats: `dns`, `dns4`, `dns6`, and `dnsaddr`, improving flexibility for IPv4/IPv6-specific entries. - Implemented exception handling for DNS resolution failures, ensuring that the process continues with the next address if a resolution fails or returns no results. - Added user-facing documentation and examples for DNS bootstrap addresses in the Getting Started guide and the bootstrap discovery API documentation.
- Added new tests to validate bootstrap integration with DNS addresses, including support for `dns4`, `dns6`, and `dnsaddr` formats. - Implemented tests to ensure that DNS resolution failures do not halt the bootstrap process, allowing for continued attempts with other addresses. - Updated existing tests to utilize validated peer IDs and improved clarity in bootstrap address handling.
|
@yashksaini-coder The current PR and issue focus on enhancing the bootstrap module to support DNS resolution. However, the proposed changes also modify the circuit relay, WebSockets, and several other modules. |
Yes Understood I will update the issue and PR regarding the new changes required |
PR: Enhance DNS support in bootstrap discovery
Issue: #1187
Discussion: #1171 (Bootstrap DNS enhancement)
Summary
This PR enhances DNS support in bootstrap discovery by:
dns,dns4, anddns6in addition todnsaddrinis_dns_addr(), enabling IPv4/IPv6-specific resolution control and alignment with the libp2p multiaddr specification.Motivation
dnsaddrwas treated as a DNS address;dns,dns4, anddns6were ignored, preventing IPv4/IPv6-specific bootstrap behaviour.Nonewas checked; there was no distinction between resolution failure and empty results, and little diagnostic information for debugging.Changes
Code
libp2p/discovery/bootstrap/bootstrap.pyis_dns_addr(addr): Now returns True for addresses whose first protocol is one ofdns,dns4,dns6, ordnsaddr(set-based check overaddr.protocols())._process_bootstrap_addr(addr_str):resolver.resolve(multiaddr)wrapped in try/except. On exception: log warning with address and exception; return. On success: ifresolved_addrsis falsy (None or empty list), log warning and return. Otherwise use resolved addresses and existing peer_id/add_addr logic.Tests
tests/core/discovery/bootstrap/test_utils.pytest_is_dns_addr_dns_protocols: Asserts thatis_dns_addr()returns True for/dns4/...,/dns6/...,/dns/...,/dnsaddr/...and False for/ip4/...,/ip6/....Behaviour
dnsaddrbootstrap entries behave as before.Requirements coverage (from issue)
is_dns_addr()recognizes dns, dns4, dns6, dnsaddrTesting
pytest tests/core/discovery/bootstrap/ -vOpen questions (from issue, out of scope for this PR)
Checklist
is_dns_addr()updated for dns, dns4, dns6, dnsaddr