-
Notifications
You must be signed in to change notification settings - Fork 291
Improve Trusted Nodes Handling; Auto-populate from DNS Node #4962
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
Conversation
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
mur-me
reviewed
Oct 30, 2025
52d9bfe to
ab03adc
Compare
ab03adc to
b931b99
Compare
Collaborator
|
Hey @GheisMohammadi, please take a look on tests 🙏 |
Collaborator
Author
Fixed |
mur-me
approved these changes
Nov 6, 2025
mur-me
requested changes
Nov 6, 2025
…er functions in stream manager
mur-me
approved these changes
Nov 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR refines how trusted peers are sourced and maintained by the P2P host. If the configuration does not provide enough concrete trusted nodes, the host now expands DNS-based sources (dnsaddr) and randomly selects only as many peers as needed to meet the staged stream sync minimum. This avoids over-connecting while ensuring the stream manager has sufficient stable peers to begin and sustain syncing.
Trusted node initialization is centralized to ensure correctness and observability. Concrete multiaddrs are parsed and connected directly, while dnsaddr sources are resolved into peer candidates and sampled to fill the gap up to the configured minimum. The host marks these peers as trusted, seeds the peerstore, and attempts connections so that the stream manager can proactively establish and preserve streams with them.
The update also fixes issues where trusted nodes were added without being marked trusted or without connection attempts, and it introduces detailed logs covering the full lifecycle—from identifying trusted sources and fallback decisions, through DNS resolution, selection, and connection results. This should make diagnosing trusted-node bootstrap problems straightforward in testing and production.
Configuration Changes
TrustedNodeshas been moved fromNetworksettings toSyncsettings for better organizationDNSStaticNodesconfiguration option has been added underSyncsettings to support dnsaddr-based trusted peer sources (e.g., ["/dnsaddr/_dnsaddr.trusted.s0.ps.hmny.io"])New Metrics
The PR introduces Prometheus metrics to observe trusted-node behavior over time:
P2P Host Level Metrics (
hmy_p2p_*)hmy_p2p_trusted_peers(Gauge) - Current number of trusted peers configured at the P2P host level (libp2p peer connections)hmy_p2p_trusted_peers_added_total(Counter) - Total number of trusted peers successfully added and connected at the P2P host levelhmy_p2p_trusted_dns_resolved_total(Counter) - Total number of trusted peer candidates resolved from DNS-based multiaddr sources (dnsaddr)hmy_p2p_trusted_peer_connect_failures_total(Counter) - Total number of failed attempts to establish P2P host-level connections with trusted peersStream Manager Level Metrics (
hmy_stream_*)hmy_stream_num_trusted_peer_streams(GaugeVec, label:topic) - Current number of active trusted peer streams (streams established with trusted peers and added to main list)hmy_stream_num_reserved_trusted_peer_streams(GaugeVec, label:topic) - Current number of reserved trusted peer streams (streams established with trusted peers and added to reserved list)hmy_stream_trusted_peer_streams_added_total(CounterVec, label:topic) - Total number of trusted peer streams successfully added to the stream managerhmy_stream_trusted_peer_streams_setup_attempts_total(CounterVec, label:topic) - Total number of attempts to setup streams with trusted peers (includes both successful and failed attempts)hmy_stream_trusted_peer_streams_connect_failures_total(CounterVec, label:topic) - Total number of failed attempts to establish streams with trusted peers