Allow discovery of the peers when slots for functional connections are consumed #2743
+912
−241
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.
Closes #2741
Rework of #2644 PR
The
max_discovery_peers_connected__nodes_will_discover_new_peers_if_first_peer_is_full
test was flaky and was failing in our CI(plus sometimes locally for me).This PR reimplement the discovery feature from #2644 in a more stable way. Plus, this change also takes into account reserved nodes(which was missed in the previous PR).
The approach is simple, when number of functional connections is full, we return
Dummy
handler for connections, which doesn't support any protocols and do nothing. It is done for all behaviours except discovery, connection limitation and blacklisting.It allows us to continue processing peers, which are connected via the discovery protocol. Also, because we don't return an error now, we will not close the connection, allowing bootstrap nodes to accumulate more nodes/IPs that can later be shared with connected nodes.
Because full nodes don't support any protocol, a request to them will fail automatically on the sender side.
Also, this change adds support for the limited number of outbound connections to solve over-connection of the network.