Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request algorand#2285 from algonautshant/shant/fixTestBasi…
…cCatchpointCatchup <!-- Thanks for submitting a pull request! We appreciate the time and effort you spent to get this far. If you haven't already, please make sure that you've reviewed the CONTRIBUTING guide: https://github.com/algorand/go-algorand/blob/master/CONTRIBUTING.md#code-guidelines In particular ensure that you've run the following: * make generate * make sanity (which runs make fmt, make lint, make fix and make vet) It is also a good idea to run tests: * make test * make integration --> ## Summary peerSelector.go: various bug fixes - introduce peerSelectorPeer to wrap the network.Peer and add peerClass information, to be able to distinguish between peers of the same address but different classes. - keep track of download failures to be able to exponentially increase the cost of each failure when failing more than succeeding. This is to evict the peer faster when constantly failing to download. - initialize rankSum and rankSamples to initialRank of the class. Otherwise, the peer rank will have a very long warmup time before relfecting the correct rank. - let resetRequestPenalty bound the rank within the class bounds. Otherwise, the penalty calculation pushes the rank out of the class bounds (bug). - getNextPeer, rankPeer, and peerDownloadDurationToRank are local to the package, since they are using non-exported peerSelectorPeer - getNextPeer, PeerDownloadDurationToRank and RankPeer use peerSelectorPeer instead of network.Peer - refreshAvailablePeers distinguishes between peers with the same address but of different peer class - findPeer returns the peer given the address and the peer class (instead of just the address) catchpointCatchup_test.go: - Remove comment about giving the second node all the stake, since it is not the case here. - Use the round from the catchpoint instead of guessing the round as 36. In case the following catchpoint was obtained due to race conditions, checking for round 37 will be trivial, since it will also be obtained from the catchpoint. catchpointService.go and service.go: - Update the code to use peerSelectorPeer instead of network.Peer with peerSelector peerSelector_test.go: - Add new tests to check the peerSelector fixes in this PR - Update the tests to use peerSelectorPeer instead of network.Peer with peerSelector - Cleanup debugging printouts. <!-- Explain the goal of this change and what problem it is solving. Format this cleanly so that it may be used for a commit message, as your changes will be squash-merged. --> ## Test Plan Added tests to confirm the fixes. - TestClassUpperBound - TestClassLowerBound - TestEvictionAndUpgrade <!-- How did you test these changes? Please provide the exact scenarios you tested in as much detail as possible including commands, output and rationale. -->
- Loading branch information