#35321 p2p: Misbehave on invalid compact block in optimistic reconstruction
https://github.com/bitcoin/bitcoin/pull/35321 · · +41/-1 in 2 files, 2 commits · labels: P2P
Goal
- Penalize peers that send malformed compact blocks during optimistic reconstruction
- Ensures consistent DoS protection across all compact block processing paths
This PR updates the optimistic compact block reconstruction path in net_processing to call Misbehaving when a peer provides malformed compact block data. Previously, an invalid compact block during optimistic reconstruction was silently ignored under a TODO comment.
Problem: When the maximum number of in-flight compact block reconstructions for a block is reached, subsequent peers sending compact blocks trigger optimistic reconstruction. If a peer sends a malformed compact block in this path, the node silently discarded the failure instead of penalizing the peer, creating an inconsistency with standard compact block handling.
Category: P2P (#21 of 65)
P3 · DoS protection
- P3 because it enforces an omitted peer penalty to complete intended DoS protection
- Operational impact is modest because it only triggers when several compact blocks are already in flight
P3 because it resolves an omitted peer penalty on malformed P2P messages, completing a TODO left in net_processing. While it improves consistency in DoS protection against peers sending invalid compact blocks, the scenario only triggers when three compact blocks for the same block are already in-flight, making real-world operational impact modest.
Membership: Modifies net_processing.cpp peer misbehavior handling for compact block reception and adds a functional test in p2p_compactblocks.py.
Factors: security/stability 1, bug 1, performance 0, user value 0, leverage 0
Reviewability: Stale: Author silent
- Code is mergeable and passes CI, but the author has been silent for over three months
The author has been silent for 111 days, exceeding the 60-day threshold, though the PR is mergeable and passes CI.
Author status: silent since 2026-05-29
Resolved concerns:
- Reviewers requested clearer comments distinguishing reconstruction failures from malformed blocks and renaming test variables, both addressed by the author.
Agreement: Strong
- Strong consensus to penalize invalid compact blocks consistently across all paths
- Support for consistency with standard validation and peer penalties (davidgumberg)
- Approved after minor test and comment nits were resolved (w0xlt)
Strong: davidgumberg and w0xlt supported the change for consistency with happy-path compact block validation; nits were resolved.
Reviewers agreed that malformed compact blocks should be penalized consistently across all paths, and all raised nits were addressed.
- davidgumberg noted: 'This is consistent with how the happy path invalid compact blocks are treated, and consistent with how Misbehaving() is used in general'
- w0xlt commented: 'Good catch ! ACK f24db575d33cdd6ebaac8cd02233bf9d266b7d42 with some non-blocking nits'
Review verdicts (DrahtBot): 0 (+2)
- Stale ACK: davidgumberg, w0xlt
- Concept ACK: sedited
Files
39 lines under test/bench/ci.
- test/functional/p2p_compactblocks.py +39/-0
- src/net_processing.cpp +2/-1
Card
This pull request ensures that peers sending malformed compact blocks during optimistic reconstruction are marked as misbehaving and disconnected, resolving a longstanding TODO. Previously, invalid compact blocks encountered on this fallback path were silently ignored, unlike in the primary compact block processing path. Reviewers strongly supported the change for consistency with existing P2P protocol enforcement, and previous review comments were addressed. The PR is mechanically clean but has been idle with the author inactive for over 100 days. It has no open blockers or external dependencies.