#35502 refactor: extract per-message helpers from ProcessMessage (move-only)
| Reviewability | Reviews | Agreement | Size | ||||
|---|---|---|---|---|---|---|---|
| #35502 refactor: extract per-message helpers from ProcessMessage (move-only) | Waiting on author | 1 (+3) | Strong | 1,078 | |||
|
|
|
|
| |||
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
Extracts logic for nine P2P message types out of the monolithic `PeerManagerImpl::ProcessMessage()` into dedicated member functions in `src/net_processing.cpp`. Each message handler is extracted in its own move-only commit, followed by a final commit normalizing formatting and control flow.
Problem: `PeerManagerImpl::ProcessMessage()` is an oversized (~1,000-line) function that handles every P2P message type inline, making navigation, scoping, and review in `net_processing` difficult.
Evidence of importance:
- Author notes the extraction continues the pattern of merged PR commits fa5ab0220e02377c3c855042ecdf1f5f950d0965 (ProcessPong) and fa55723b8fbd4fd056dddac5b35daf2e86021422 (ProcessAddrs), suggested in #34588.
Scope: The PR consists of nine move-only extraction commits designed to be reviewed with `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`, followed by one commit containing minor formatting cleanups and control flow adjustments.
Risk of a mistake: medium (p2p). A mistake in control flow or lock annotations while moving message-processing logic could disconnect peers, drop P2P messages, or crash nodes.
Changed since the previous assessment: Rebased with minor co-author metadata additions and updated commit hashes while preserving the same structure and message extractions.
Reviewability
Paused · Waiting on author
Open objection from pablomartin4btc with no author reply for 13 days; review would repeat what has been asked.
Waiting on (from the thread read):
- author: response to pablomartin4btc's suggestion to remove __func__ prefix from debug logs 2026-10-20
Agreement
Strong
substantive support, no open objection (stickies-v, theStack, pseudoramdom, thomasbuilds, pablomartin4btc, maflcko, l0rinc, l0rinc, pablomartin4btc, pablomartin4btc)
Thread notes: Added an open suggestion from pablomartin4btc to strip the __func__ prefix from debug logs via a prepare commit.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| pablomartin4btc (member) | suggestion, scope | extract ProcessCompactBlock and ProcessVersion as well | fixed · fix pushed · extractions added in later push and confirmed in follow-up review | answered | no | 2026-06-12: 'CMPCTBLOCK (248 lines) and VERSION (235 lines) remain the two dominant inline blocks — extracting those two alone would drop it another ~480 lines, bringing it under 550. The same move-only pattern ap' Status from: 2026-09-24: pablomartin4btc: 'Thanks for taking my suggestion to also extract `ProcessCompactBlock()` and `ProcessVersion()`.' |
| davidgumberg (member) | objection, maintenance | extracting handlers into separate helpers introduces questions about callers, setup, and caller assumptions that don't exist with a flat switch statement, adding friction to reading and modifying code | accepted · accepted by reviewer conceding to stylistic preference of other contributors | answered | yes | 2026-06-19: 'These questions have to be answered when reading / modifying code and for all of the logic that lives in the ProcessMessage() ~switch statement these ambiguities don't exist.' Status from: 2026-06-25: davidgumberg: 'That being said, it sounds like other contributors prefer the style of this PR to the style of master, and given that th' |
| l0rinc (member) | suggestion, approach | simplify the send_getaddr conditional check in ProcessVersion | fixed · fix pushed · author simplified the check in the cleanup commit and reviewer confirmed in follow-up ACK | answered | yes | 2026-09-23: 'Seems to me this is basically just: if (!pfrom.IsInboundConn() && SetupAddressRelay(pfrom, peer)) {' Status from: 2026-09-24: l0rinc: 'minimal reformatting and the equivalent `break`→`return` and `send_getaddr` cleanups as suggested.' |
| pablomartin4btc (member) | suggestion, style | add a prepare commit removing the __func__ prefix from debug logs used in ProcessMessage | open | answered | no | 2026-10-20: 'Perhaps you can add a prepare commit that removes the prefix from the debug logs used in `ProcessMessage()`.' |
Support:
- stickies-v (member) (Concept ACK, 2026-06-10) [read]: makes it easier to navigate net_processing and better encapsulates logic
- theStack (member) (Concept ACK, 2026-06-10) [read]: supports extracting helpers, noting past attempt #9608 failed mostly due to lack of review
- pablomartin4btc (member) (Concept ACK, 2026-06-10): in favour of these refactoring [not substantive]
- pseudoramdom (member) (ACK, 2026-06-11) [read]: verified the change is a move-only refactor with git show --color-moved
- thomasbuilds (contributor) (ACK, 2026-06-11) [read]: verified pure code move, return semantics preserved, and clang -Wthread-safety thread-safety annotations match
- pablomartin4btc (member) (ACK, 2026-06-12) [read]: supports refactor and notes control flow is not obscured; suggested future extractions of CMPCTBLOCK and VERSION
- maflcko (member) (Concept ACK, 2026-06-19) [read]: improves review with git diff --function-context and aligns with consistency of existing helpers
- l0rinc (member) (Tested ACK, 2026-09-23) [both]: rebased and reimplemented extractions, tested behavior with coverage locally, and reviewed each commit with git color-moved
- l0rinc (member) (Tested ACK, 2026-09-24) [both]: remains a straightforward refactor; minimal reformatting and cleanups addressed
- pablomartin4btc (member) (ACK, 2026-09-24) [read]: ProcessCompactBlock() and ProcessVersion() extracted as suggested, feedback addressed, and cleanup commit added
- pablomartin4btc (member) (ACK, 2026-10-09) [read]: confirmed pure rebase with git range-diff, showing 8 byte-identical commits and only incidental upstream context differences in the other 2
Participants:
- pablomartin4btc (member, support, 5 statements 2026-06-10 to 2026-10-20): re-ACKed after range-diff verification of rebase; suggested removing __func__ from debug logs
- stickies-v (member, support, 1 statements 2026-06-10 to 2026-06-10): Concept ACK; easier navigation and better encapsulates logic
- theStack (member, support, 1 statements 2026-06-10 to 2026-06-10): Concept ACK; noted previous attempt #9608
- pseudoramdom (member, support, 1 statements 2026-06-11 to 2026-06-11): code review ACK; verified move-only refactor
- thomasbuilds (contributor, support, 1 statements 2026-06-11 to 2026-06-11): code review ACK; verified pure code move and clang thread-safety annotations
- davidgumberg (member, objection, 2 statements 2026-06-19 to 2026-06-25): Concept -0; argued separate helpers add friction and ambiguity, but conceded to others' preference
- maflcko (member, support, 1 statements 2026-06-19 to 2026-06-19): Concept ACK; helps with git diff --function-context and consistency
- l0rinc (member, support, 8 statements 2026-09-23 to 2026-09-24): tested ACK; verified move-only refactor and suggested cleanup and conditional simplification
Files
0 lines under test/bench/ci.
- src/net_processing.cpp +1078/-1029
Card
The short text the ranking pass compares across PRs.
Extracts handling logic for nine P2P message types out of `PeerManagerImpl::ProcessMessage()` in `src/net_processing.cpp` into dedicated helper functions across nine move-only commits and one cleanup commit. The function is an oversized monolith handling many message types inline, making navigation and code maintenance in `net_processing` cumbersome. The author notes this continues previously merged cleanup work splitting up the ~1,000-line function. It makes no intentional functional changes aside from a function name in one debug log.
Data
thread read through 2026-10-20 (29 statements), head 87ca532651
labels: Refactoring, Needs rebase
Categories
P2P
P4 · cleanup (assessed alone as P3; Demoted to P4 to match #35522, the identical move-only split of the sibling net_processing function.)
Breaks up the monolithic `PeerManagerImpl::ProcessMessage()` function by extracting nine message handlers into dedicated member functions. Reviewers note this encapsulation improves navigation and diff readability in `net_processing.cpp`, but it is an internal refactor that does not retire a known protocol hazard or alter network behavior.
Membership: Modifies P2P message handling logic in `src/net_processing.cpp`.
Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1