HomePhabricator

[validation] Fix peer punishment for bad blocks

Description

[validation] Fix peer punishment for bad blocks

Summary:

Because the call to MaybePunishNode() in
PeerLogicValidation::BlockChecked() only previously happened if the
REJECT code was > 0 and < REJECT_INTERNAL, then there are cases were
MaybePunishNode() can get called where it wasn't previously:

  • when AcceptBlockHeader() fails with CACHED_INVALID.
  • when AcceptBlockHeader() fails with BLOCK_MISSING_PREV.

Note that BlockChecked() cannot fail with an 'internal' reject code. The
only internal reject code was REJECT_HIGHFEE, which was only set in
ATMP.

This change restores the behaviour pre-commit
https://github.com/bitcoin/bitcoin/commit/5d08c9c579ba8cc7b684105c6a08263992b08d52
which did punish nodes that
sent us CACHED_INVALID and BLOCK_MISSING_PREV blocks.

This is a backport of Core PR17004 [1/5]
Commit https://github.com/bitcoin/bitcoin/pull/17004/commits/a1a07cfe99fc8cee30ba5976dc36b47b1f6532ab

Test Plan: ninja all check-all

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D8181

Details

Provenance
John Newbery <john@johnnewbery.com>Authored on Oct 29 2020, 21:33
PiRKCommitted on Oct 29 2020, 21:33
abc-botPushed on Oct 29 2020, 21:39
Reviewer
Restricted Owners Package
Differential Revision
D8181: [validation] Fix peer punishment for bad blocks
Parents
rABCccf0cf3c662e: [SECP256K1] Make autotools check for all the used openssl functions
Branches
Unknown
Tags
Unknown