-
Notifications
You must be signed in to change notification settings - Fork 53
feat(sdk): source mainnet/testnet bootstrap from dash-network-seeds (backport #3533) #3570
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: dashpay/platform
Length of output: 896
🏁 Script executed:
Repository: dashpay/platform
Length of output: 1622
🏁 Script executed:
Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
rg "struct.*Seed|fn evo_seeds" packages/rs-sdk -A 5 -B 2Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
rg "seed\.address" packages/rs-sdk -B 3 -A 3Repository: dashpay/platform
Length of output: 1180
🏁 Script executed:
Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
rg "platform_http_port|address\.ip()" packages/rs-sdk -B 5 -A 3Repository: dashpay/platform
Length of output: 1644
🏁 Script executed:
rg "default_address_list_for_network|new_mainnet|new_testnet" packages/rs-sdk -B 2 -A 5Repository: dashpay/platform
Length of output: 4253
🏁 Script executed:
cat -n packages/rs-sdk/src/sdk.rs | head -120Repository: dashpay/platform
Length of output: 5481
🏁 Script executed:
rg "use.*Uri|use.*Address" packages/rs-sdk/src/sdk.rsRepository: dashpay/platform
Length of output: 145
🏁 Script executed:
rg "dash_network_seeds" packages/rs-sdk -B 2 -A 2Repository: dashpay/platform
Length of output: 691
🌐 Web query:
RFC 3986 IPv6 address URI format brackets requirement💡 Result:
Yes, RFC 3986 requires square brackets around IPv6 literal addresses in URIs. The specification defines the host component syntax such that an IPv6 address must be enclosed in square brackets to distinguish it from other host formats and resolve colon ambiguities (e.g., with ports). This is the only place in URI syntax where square brackets are permitted. Key syntax from RFC 3986: IP-literal = "[" ( IPv6address / IPvFuture ) "]" host = IP-literal / IPv4address / reg-name Without brackets, an IPv6 address like 2001:db8::1 cannot be unambiguously parsed in a URI like http://2001:db8::1:8080/, as the parser cannot distinguish the address from a port. Correct form: http://[2001:db8::1]:8080/. This requirement originates from RFC 2732 (which introduced brackets for URLs) and is formalized in RFC 3986 Section 3.2.2. Brackets are mandatory; omitting them produces invalid URI syntax per the ABNF grammar.
Citations:
🏁 Script executed:
Repository: dashpay/platform
Length of output: 185
🏁 Script executed:
Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
Repository: dashpay/platform
Length of output: 2167
🏁 Script executed:
rg "bootstrap_counts_reasonable" packages/rs-sdk -B 2 -A 10Repository: dashpay/platform
Length of output: 970
🏁 Script executed:
Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
Repository: dashpay/platform
Length of output: 688
🏁 Script executed:
Repository: dashpay/platform
Length of output: 99
🏁 Script executed:
Repository: dashpay/platform
Length of output: 102
🏁 Script executed:
Repository: dashpay/platform
Length of output: 657
🏁 Script executed:
cat packages/rs-sdk/Cargo.toml | head -50Repository: dashpay/platform
Length of output: 2120
🏁 Script executed:
Repository: dashpay/platform
Length of output: 88
🏁 Script executed:
Repository: dashpay/platform
Length of output: 378
🏁 Script executed:
Repository: dashpay/platform
Length of output: 1749
🏁 Script executed:
rg "bootstrap_counts_reasonable" packages/rs-sdk -A 20Repository: dashpay/platform
Length of output: 1382
🏁 Script executed:
Repository: dashpay/platform
Length of output: 1709
🏁 Script executed:
rg "ipv6|IPv6|v6" packages/rs-sdk -iRepository: dashpay/platform
Length of output: 42
🏁 Script executed:
Repository: dashpay/platform
Length of output: 925
🌐 Web query:
http crate Rust Uri IPv6 parsing bracket requirement💡 Result:
In the Rust http crate (used by Hyper, Reqwest, Axum), the Uri type requires IPv6 literal addresses in URIs to be enclosed in square brackets [] for parsing to succeed, per RFC 3986 and RFC 2732 standards for URI hosts. Example: "http://[::1]/".parse::http::Uri succeeds, while "http://::1/" fails with InvalidUri. Once parsed, uri.host returns the host with brackets for IPv6 literals, e.g., "[::1]" (fixed in 2019 via PR
#292). This applies to HTTP request targets and is standard across the ecosystem. For socket connections (e.g., TcpListener::bind), use "[::]:8080"; libraries like hyper-rustls strip brackets internally for TLS. Reqwest accepts url::Url inputs, which also enforce brackets in string serialization (host_str includes them), ensuring compatibility with http::Uri.Citations:
🏁 Script executed:
Repository: dashpay/platform
Length of output: 163
🏁 Script executed:
rg "IpAddr::V6|IpAddr::V4" packages/rs-sdk -B 2 -A 2Repository: dashpay/platform
Length of output: 42
🏁 Script executed:
rg "Address.*try_from" packages/rs-sdk -B 3 -A 5Repository: dashpay/platform
Length of output: 16033
Handle IPv6 addresses in bootstrap URIs.
Per RFC 3986, IPv6 literal addresses in URIs must be enclosed in square brackets. When
seed.address.ip()returnsIpAddr::V6, the current code produces invalid URIs (e.g.,https://2001:db8::1:8080) that fail to parse and are silently dropped, discarding valid IPv6 bootstrap entries.The suggested assertion on empty lists contradicts the documented design: the function explicitly states "Malformed upstream entries are silently skipped rather than panicking; the DAPI client handles retry/rotation across the remaining addresses." Fail-fast validation should be deferred to the caller if stricter semantics are desired.
🔧 Suggested fix (IPv6 only)
fn default_address_list_for_network(network: Network) -> AddressList { if !matches!(network, Network::Mainnet | Network::Testnet) { panic!("default address list is only available for mainnet and testnet"); } let mut list = AddressList::new(); for seed in dash_network_seeds::evo_seeds(network) { let Some(port) = seed.platform_http_port else { continue; }; - let url = format!("https://{}:{}", seed.address.ip(), port); + let url = match seed.address.ip() { + std::net::IpAddr::V4(ip) => format!("https://{}:{}", ip, port), + std::net::IpAddr::V6(ip) => format!("https://[{}]:{}", ip, port), + }; if let Ok(uri) = url.parse::<Uri>() { if let Ok(address) = Address::try_from(uri) { list.add(address); } } } list }📝 Committable suggestion
🤖 Prompt for AI Agents