#36707 net_processing: remove redundant `peer` check in `MaybePunishNodeForBlock`

ReviewabilityReviewsAgreementSize
#36707 fanquake net_processing: remove redundant `peer` check in `MaybePunishNodeForBlock`Ready4Strong1
  • Remove a redundant peer null check in block punishment logic
  • Cleans up dead branching and clutter in network processing code
  • Ready for review
  • Unanimous support with no objections
  • Verified safe because peer cannot be reseated between checks (l0rinc)
  • Approval without stated reasons (Crypt-iQ, jpk68, ViniciusCestarii)
  • 1 lines added or modified outside tests
  • 0 lines added or modified in tests
  • 1 lines removed in total
  • 1 files, 1 commits
P2P#71 of 71
P4 · cleanup
  • P4 because this is a minor cleanup of an already-guarded condition
  • Carries negligible risk and has no behavioral or performance impact
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Removes a duplicate null check on `peer` in `PeerManagerImpl::MaybePunishNodeForBlock`. The `Misbehaving()` call is already guarded by an outer conditional that requires `peer` to be non-null.

Problem: Redundant null checks add dead branching and clutter to network processing code.

Evidence of importance:

  • Commit 66292fa4b5: "The `Misbehaving()` call is already inside an `if (peer && ...)` block."

Risk of a mistake: low (p2p). A mistake in peer punishment could improperly penalize or fail to disconnect peers, but removing a strictly identical redundant check carries negligible risk.

Changed since the previous assessment: No changes to the patch; diff is now available.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • nothing

Agreement

Strong

substantive support, no open objection (l0rinc)

Thread notes: Initial record. Unanimous support with four ACKs; l0rinc's optional style nit to make peer const if touched again is non-blocking. / Initial record: four supporters with no objections raised. l0rinc's style nit is non-blocking.

Objections, suggestions, and questions: none recorded.

Support:

  • Crypt-iQ (member) (ACK, 2026-10-30) [read]: (no reason given) [not substantive]
  • jpk68 (contributor) (ACK, 2026-10-30): (no reason given) [not substantive]
  • ViniciusCestarii (contributor) (ACK, 2026-10-30): (no reason given) [not substantive]
  • l0rinc (member) (ACK, 2026-10-30) [read: MaybePunishNodeForBlock]: Looks safe since `peer` cannot be reseated between the checks.

Participants:

  • Crypt-iQ (member, support, 1 statements 2026-10-30 to 2026-10-30): crACK
  • ViniciusCestarii (contributor, support, 1 statements 2026-10-30 to 2026-10-30): ACK
  • jpk68 (contributor, support, 1 statements 2026-10-30 to 2026-10-30): ACK
  • l0rinc (member, support, 1 statements 2026-10-30 to 2026-10-30): ACK with analysis that peer cannot be reseated between checks

Files

0 lines under test/bench/ci.

  • src/net_processing.cpp +1/-1

Card

The short text the ranking pass compares across PRs.

Removes a redundant peer null check in PeerManagerImpl::MaybePunishNodeForBlock within net processing. The call to Misbehaving() was already guarded by an enclosing condition checking peer validity. This is a one-line internal cleanup with no change in node behavior.

Data

dossier JSON · extract JSON · model ledger, generated 2026-11-01T01:16, confidence high, input hash e3930b154038cf47
thread read through 2026-10-30 (4 statements), head 66292fa4b5
labels: none

Categories

P2P

P4 · cleanup

Removes a redundant null check where peer is already verified to be non-null by an outer conditional. This is a cosmetic code cleanup with no behavioral or performance impact.

Membership: Modifies net processing code in src/net_processing.cpp handling peer punishment logic.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0