This cleans up an old main-carryover - it made sense that main could decide what DoS scores to assign things because the DoS scores were handled in a different part of main, but now validation is telling net_processing what DoS scores to assign to different things, which is utter nonsense. Instead, we replace CValidationState’s nDoS and CorruptionPossible with a general ValidationInvalidReason, which net_processing can handle as it sees fit. I keep the behavior changes here to a minimum, but in the future we can utilize these changes for other smarter behavior, such as disconnecting/preferring to rotate outbound peers based on them providing things which are invalid due to SOFT_FORK because we shouldn’t ban for such cases.
This is somewhat complementary with, though obviously conflicts heavily with #11523, which added enums in place of DoS scores, as well as a few other cleanups (which are still relevant).
Compared with previous bans, the following changes are made:
- Txn with empty vin/vout or null prevouts move from 10 DoS points to 100.
- Loose transactions with a dependency loop now result in a ban instead of 10 DoS points.
- BIP68-violation no longer results in a ban as it is SOFT_FORK.
- Non-SegWit SigOp violation no longer results in a ban as it considers P2SH sigops and is thus SOFT_FORK.
- Any script violation in a block no longer results in a ban as it may be the result of a SOFT_FORK. This should likely be fixed in the future by differentiating between them.
- Proof of work failure moves from 50 DoS points to a ban.
- Blocks with timestamps under MTP now result in a ban, blocks too far in the future continue to not result in a ban.
- Inclusion of non-final transactions in a block now results in a ban instead of 10 DoS points.