Make static dials subject to the maxActiveDials limit. #1202
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.
Description
In #1192, we pulled in the the new dial scheduler from upstream, but modified it to exempt static dials from the limits it put on them (which were set as
maxDialPeers
andmaxActiveDials
), because we rely on static dials for the connections between validators/proxies and their validator/proxy peers. This PR modifies that to make them respect themaxActiveDials
limit. So, while static dialed connections will still be exempt frommaxDialPeers
(and therefore frommaxPeers)
, the establishing of those connections will not be allowed to push the number of active dials being attempted past its limit (whose default value was set to 50 upstream).Note that, prior to the new dial scheduler (i.e. in celo-blockchain 1.1.0 and earlier and in the corresponding code upstream), the equivalent to
maxActiveDial
(calledmaxActiveDialTasks
) was 16, and static dials were subject to it (though not tomaxDialPeers
), so even after this PR we will still have a considerably larger limit than before it. See the value atcelo-blockchain/p2p/server.go
Line 54 in 990a7a2
Tested
Updated the unit tests involved, as well as re-added a test from upstream (though modified to account for the fact that we exempt static dials from
maxDialPeers
), which checks thatmaxActiveDials
is respected and that the peers to dial are selected at random fromd.staticPool
.Backwards compatibility
Doesn't affect the protocol, so there are no backwards compatibility concerns.