fix(net): Reduce maximum number of connections per IP to 1 #6993
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.
Motivation
After running PR #6980 over the weekend, I started getting these logs:
This means that 15% of the peer set (7/46) is redundant connections, which seems like a peer set takeover risk.
I'm running 3 nodes locally on 2 IPs, so it's possible that 4 of those connections are from my local setup. But that would still be 11% redundant connections (5/46) from external nodes.
I suggest we aim for 5-10% redundant connections at most.
In my setup:
I don't mind whether we choose 1 or 2, but 3 peers per IP seems to allow too many redundant connections.
Specifications
zcashd
's limit is one connection per IP address:https://github.com/zcash/zcash/blob/fa3827656df8f97fb4700b22022cc581fbda61fa/src/net.cpp#L1663
Solution
Limit Zebra to 1 connection per IP address.
Related fixes:
Review
This should go in before the next release.
@arya2 wrote the original PR #6980.
Reviewer Checklist