server: Simplify and correct ban score logging. #3592
Merged
+17
−19
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.
This is rebased on #3591.
Currently, the logic that accumulates the persistent and transient ban scores incorrectly logs debug messages alleging whitelisted peers are misbehaving due to perfectly normal accumulation of the decaying transient ban score.
Also, it currently logs the overall ban score whenever it is over the warning threshold even when the score is not increasing. There isn't anything incorrect about that behavior, and the comments even correctly call out that is what it is intended to do, but it also not very useful.
This modifies the logic to address the aforementioned and takes the opportunity to simplify the code a bit.
In particular, it now treats whitelisted peers the same as all other peers in terms of tracking the ban score and warning for misbehavior whenever the score exceeds the warning threshold. However, when the ban score exceeds the ban threshold, whitelisted peers are exempted.
The misbehavior warning messages that are shown once the ban score exceeds the warning threshold will now include the additional detail that the peer is whitelisted when that is the case.
Finally, there is no longer any logging when the ban score is not increasing.