Add a new peer state tracking class to reduce cs_main contention. #16174
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.
CNodeState was added for validation-state-tracking, and thus,
logically, was protected by cs_main. However, as it has grown to
include non-validation state (taking state from CNode), and as
we've reduced cs_main usage for other unrelated things, CNodeState
is left with lots of cs_main locking in net_processing.
This starts the process of moving things out of cs_main (and into a new CPeerState) starting with nDoS and rejects.
This also solves the lowest-hanging fruit by wiping out 10+ (!) cs_main locks that are trivial to remove! It further removes a cs_main lock which is taken on every ProcessMessages iteration, which makes a future rebase of #12934 much more effective by being able to move onto the next peer for processing (at least sometimes) while a block is validating.