[WIP] Ensure Trusted Node Creation and Prevent Duplicate Streams #4934
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.
Todo
Summary
In
streammanager.go
,discoverAndSetupStream
establishes application-level protocols with peers from the peer store, including setting up underlying protocol connections. Meanwhile,AddTrustedNodes
inhost.go
handles protocol handshakes and adds trusted nodes to the peer store. Currently,Start()
is invoked beforeAddTrustedNodes
, so trusted nodes may be missing from the peer store whendiscoverAndSetupStream
runs, causing them to be skipped. To fix this, trusted nodes should be added to the peer storage during host creation, ensuring they are available during stream setup. With this change,AddTrustedNodes
becomes unnecessary and can be removed.EOF Issue
We suspect that
failed to negotiate security protocol: EOF
is triggered by resource exhaustion from an excessive number of connected peers. At present, thousands of nodes are subscribing to topics unrelated to the Harmony network, causing each Harmony node to maintain between 2,000 and 6,000 active connections. This load can overwhelm file descriptors, goroutines, and CPU/memory resources, leading the connection manager to prune aggressively or reject new dials.Changes
host.go
:AddTrustedNodes()
, which adds the peer to peer storage and sets up the connection, from the main loop.streammanager.go
: