4 minor findings · 7 suggestions
Earlier concerns neither republished nor resolved: 8 minor findings · 2 suggestions. See the Run archive for their assessments.
Findings
[minor] · Optimistic reconstruction drops prefill candidates
When optimistic reconstruction wins without candidates already cached for that block, its non-mempool transactions are omitted from outgoing prefills.
Location: src/net_processing.cpp:3870 (head).
Details and suggested fix
The CMPCTBLOCK handler can reconstruct through a local tempBlock when parallel download slots are occupied or the peer has too many blocks in transit. On READ_STATUS_OK, it sets fBlockReconstructed and calls ProcessBlock() without saving tempBlock.PrefillCandidates(). If this reconstruction first reaches an eligible NewPoWValidBlock(), the candidate hash does not match and only the coinbase-only variant is built. Useful incoming prefills and extra-pool hits therefore are not forwarded as prefills to high-bandwidth peers. Save the candidates before ProcessBlock(), as ProcessCompactBlockTxns() does. The existing hash gate and the later CheckBlock() checks before NewPoWValidBlock() also protect consumption on this path.
[minor] · Separate queue samples can miss bytes sent between them
A socket-thread send between the kernel and application queue reads can omit bytes from both samples and overstate the remaining window budget.
Location: src/net.cpp:4289 (head).
Details and suggested fix
WindowBytesTotalAndAvailable() releases m_sock_mutex after sampling the kernel queue, then acquires cs_vSend through GetSendQueueSize(). In that gap, SocketSendData() can move queued bytes into the kernel and remove them from the transport's remaining-byte count. With no intervening ACK, a 10,000-byte window and 6,000 bytes moved this way can appear to have 10,000 bytes free instead of 4,000. A 3,000-byte plain message and a 7,000-byte prefilled message then appear equally eligible, although only the plain message fits. This requires a non-empty queue and a send during the sampling gap. Acquire cs_vSend before m_sock_mutex, matching the sender's order, and read both terms while holding them. Read the application term directly rather than reacquiring cs_vSend through GetSendQueueSize().
[minor] · Cached getdata replies can overwrite current-branch header state
After a reorg, serving a stale cached compact block can overwrite pindexBestHeaderSent and make that peer's next announcement fall back to INV.
Location: src/net_processing.cpp:2380 (head).
Details and suggested fix
ProcessGetBlockData() now uses SendCompactBlock(), which unconditionally assigns pindexBestHeaderSent; the previous GETDATA reply did not change it. The fast-announcement cache can retain a stale block after a reorg, and BlockRequestAllowed() still permits serving recent valid stale blocks. If current-branch knowledge was inferred from headers we sent and pindexBestKnownBlock does not independently cover that branch, requesting the stale cached block replaces the evidence needed by PeerHasHeader(pprev). The next fast announcement can be skipped, with SendMessages() falling back to INV. This rare case affects only the requesting peer, which can recover through the normal headers/getdata flow. Keep the assignment in the announcement callers rather than applying it to GETDATA replies.
[minor] · tcp_info test ignores the Linux congestion-only fallback
On Linux without tcpi_snd_wnd, the test compares a congestion-window estimate with requested receive-buffer sizes, so valid fallback behavior can fail the test.
Location: src/test/sock_tests.cpp:221 (head).
Details and suggested fix
GetTCPWindowSize() uses tcpi_snd_wnd only when the build headers expose it and the running kernel returns a sufficiently long tcp_info. Otherwise it deliberately returns tcpi_snd_cwnd * tcpi_snd_mss. The loopback fixture still requires exact equality with 1200 and 1280 on every non-macOS platform, although the fallback has no such relationship to the peer's receive buffer. This affects supported Linux configurations with headers or kernels older than 5.4. Condition those equality assertions on the receive-window field actually being available, and test the congestion-only calculation separately with controlled TCPInfo values.
Optional improvements
[suggestion] · Proxy-facing TCP windows do not describe the peer path
For SOCKS and Tor connections, the window check measures the proxy-facing hop rather than the full path to the peer, leaving the prefill policy dependent on how the proxy is reached.
Location: src/net.cpp:4276 (head).
Details and suggested fix
ConnectThroughProxy() returns the socket connected to the SOCKS proxy, and ConnectNode() gives that socket to CNode. Inbound onion connections likewise terminate locally at the Tor forwarding connection. A successful window query therefore budgets only the proxy-facing TCP hop; a large loopback window can permit the full candidate set without reflecting constraints beyond the proxy. A unix: proxy instead makes the query fail and disables additional prefills. Do not treat the proxy-facing window as a peer-facing budget. Define an explicit policy for proxied connections, such as keeping coinbase-only announcements until measurements justify another policy. Whether the current behavior helps or hurts their end-to-end propagation remains unestablished.
[suggestion] · Expected TCP_INFO unavailability is logged as an error
Eligible compact-block sends over unix-socket proxies repeatedly log expected TCP_INFO failures even though the zero-window result already provides a normal fallback.
Location: src/util/sock.h:381 (head).
Details and suggested fix
When a non-coinbase prefilled variant is cached, eligible high-bandwidth announcements and latest-block GETDATA replies construct TCPInfo before selecting a message. Queries on -proxy=unix: sockets fail because those sockets are not TCP, and the unsupported-platform branch also warns on each construction. Both cases already fall back to coinbase-only announcements, but still produce repeated warning/error-level diagnostics without peer context. Logging is rate-limited, so this is misleading log noise rather than resource exhaustion. Skip TCP queries for non-TCP sockets and use debug-level logging for expected unavailability.
[suggestion] · Logging-only prefill work now runs under the mempool lock
Received prefills now incur serialized-size computation and, for non-mempool transactions, diagnostic-map insertion under pool->cs even when CMPCTBLOCK debug logging is disabled.
Location: src/blockencodings.cpp:105 (head).
Details and suggested fix
The previous loop computed ComputeTotalSize() and populated leftover_prefills only under debug_log, before acquiring the mempool lock. The new loop performs that work unconditionally inside LOCK(pool->cs). The map's consumer remains debug-only, and the header explicitly describes the size counters as logging-only. Candidate selection needs the GetIter() membership check and prefill_candidates.insert(), not transaction sizes or the diagnostic map. Guard the size computation, redundancy counters and map insertion with debug_log, while keeping membership checks and candidate insertion unconditional. This avoids work that grows with the number of received prefills without changing selection behavior.
[suggestion] · Non-empty prefills and candidate membership lack semantic assertions
Existing tests can miss regressions that ignore constructor candidates, encode incorrect relative indexes, or collect the wrong candidate set.
Location: src/test/blockencodings_tests.cpp:241 (head).
Details and suggested fix
The deterministic encoding tests pass empty candidate sets; SufficientPreforwardRTTest installs its non-coinbase prefills by hand. No test calls PrefillCandidates(). The compact-block fuzzer supplies nonempty sets, but its combined-count assertion still holds if candidates are ignored or relative indexes are wrong, and it does not require each generated message to reconstruct successfully. Add deterministic constructor round trips for separated, adjacent and last-position candidates, checking encoded indexes and InitData()/FillBlock() reconstruction. Also assert the exact candidate set in a mixed-source fixture: exclude a mempool-resident non-coinbase incoming prefill, and include a non-mempool prefill, an extra-pool hit and a BLOCKTXN-supplied transaction.
[suggestion] · Window-boundary selection has no deterministic test
The tests do not independently check the boundary rule that chooses between the plain and larger prefilled compact block.
Location: src/net_processing.cpp:2336 (head).
Details and suggested fix
windows_used and the comparison in SendCompactBlock() determine whether additional prefills are sent, but the current tests do not assert that choice for controlled window values. Always rejecting prefills, reversing the comparison, or introducing a boundary off-by-one could escape these assertions. Extract a small testable selection helper and cover exact fits, one byte over and equal additional-window counts. With a 1000-byte window and 400 bytes available, (plain, prefilled) sizes (300, 400) should allow prefill, (300, 401) should reject it, and (401, 1400) should allow it.
[suggestion] · Cache-update comment names a check that has not run
The comment refers to CheckBlock, but the cache update is controlled by FillBlock's merkle/witness mutation checks.
Location: src/net_processing.cpp:3865 (head).
Details and suggested fix
At this assignment, READ_STATUS_OK means FillBlock() passed IsBlockMutated(), not CheckBlock(). The latter runs later through ProcessBlock() and ProcessNewBlock(). Caching at this point is still safe for the intended use: candidates are keyed by block hash and consumed only when the matching block reaches NewPoWValidBlock() after the later checks. Reword the comment to describe that boundary rather than attributing the update to CheckBlock().
[suggestion] · Serialized-size accounting lacks direct test assertions
The new transport estimates and m_send_size drive the prefill budget without tests checking their byte counts, especially during partial sends.
Location: src/net.cpp:930 (head).
Details and suggested fix
GetMessageSize(), GetSendMessageSize() and m_send_size feed GetSendQueueSize(), but no test directly checks those estimates. The full-drain Assume(m_send_size == 0) catches unbalanced updates, not header overhead computed incorrectly on both enqueue and dequeue, or incorrect intermediate transport remainders. Extend the transport tests with independent byte-count assertions. For a v1 message with a 3-byte payload, check 27 bytes initially, 22 after sending five header bytes, 3 after the header and 0 after the payload. Also compare the v2 short- and long-message-type estimates with the bytes actually emitted.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: Diagnostic counts depend on the log level at initialization
- [minor]: Do not treat a failed send-queue query as an empty queue
- [minor]: Keep platform-specific TCP queries out of the widely included socket header
- [minor]: Include unsent kernel-buffered bytes in the window estimate
- [minor]: Allow the documented unsupported TCP-info fallback in the test
- [minor]: Preserve queued message sizes across V2 fallback
- [suggestion]: Include <set> where the header declares std::set
- [minor]: Preserve queued message sizes across V2-to-V1 fallback (earlier report)
- [suggestion]: Clarify the non-Linux congestion-window units (earlier report)
- [minor]: Compact-block nonces draw from the global RNG on worker threads (earlier report)