2 minor findings · 1 suggestion
Findings
[minor] · Thread-launch failure interrupts block acceptance before storage
Under local thread-resource exhaustion, the forced async launch can interrupt acceptance of a new tip-extending block before storage, although a retry can recover.
Location: src/net_processing.cpp:2253 (head).
Details and suggested fix
Unlike base's deferred launch, std::async(std::launch::async, ...) can throw std::system_error when the runtime cannot create a thread. Outside IBD, a tip-extending block at a new maximum fast-announcement height reaches this launch once SegWit is active. ValidationSignals::NewPoWValidBlock invokes the callback synchronously from AcceptBlock, before the disk-write try block, so the exception interrupts processing before the block is stored. The P2P boundary only logs it and requires the block to be received again; submitblock returns an RPC error. This is not permanent rejection: m_highest_fast_announce has already advanced, so another attempt at that height skips the launch and can store the block. No production occurrence was identified. Preserve async execution on success, but catch the launch's std::system_error and fall back to a deferred future using the same value-capturing lambda. That avoids making this relay optimization a prerequisite for storing the block while retaining the normal overlap with transaction-map construction.
[minor] · Cached getdata replies overwrite header-announcement state
A cached compact-block request can replace the peer's new-branch header state with a stale-branch block, causing an extra inv/getdata round trip when its recorded best-known block does not cover the new branch.
Location: src/net_processing.cpp:2312 (head).
Details and suggested fix
ProcessGetBlockData now updates pindexBestHeaderSent through SendCompactBlock only on a cache hit; base and the cache-miss fallback merely send the reply. After a reorg onto blocks that were not fast-announced, the cache can still contain a recent, script-validated old-branch block. If a peer requests that block within the compact-block serving limits after we sent it new-branch headers, the unconditional assignment replaces that recorded header state. When pindexBestKnownBlock does not establish the new branch's ancestry, PeerHasHeader can then fail for the next announcement's parent and force an inv instead of a header or compact-block announcement. No current production occurrence of this backward move was identified. Keep SendCompactBlock send-only and update the pointer in NewPoWValidBlock and SendMessages, preserving the previous announcement behavior. The commit description should also identify this getdata side effect: its stated SendMessages fallback change already existed at base.
Optional improvements
[suggestion] · The fallback comment describes an impossible cache-update window
The new SendMessages comment attributes a cache miss to a block connection after vHeaders assembly, but cs_main prevents the cache from changing during that interval.
Location: src/net_processing.cpp:6269 (head).
Details and suggested fix
SendMessages holds cs_main continuously while assembling vHeaders and calling SendCompactBlock, and NewPoWValidBlock takes that same lock before updating the cache. The fallback can instead occur because the announced block was never fast-announced, for example after a reorg or out-of-order arrival, or because a newer block was fast-announced after the older block was queued for announcement through UpdatedBlockTip. Replace the comment with wording such as: "pBestIndex is not the cached fast-announced block, for example after a reorg or out-of-order arrival, or when a newer block was fast-announced after this one was queued for announcement."