Review report

core: PR #35354

3 minor findings · 3 suggestions

Findings

Link

[minor] · Snapshot sync can park filter requests until the peer times out

With a loaded snapshot and -blockfilterindex, requests above the background chain's tip can remain parked for hours, leaving that peer disconnected after a ping timeout.

Location: src/net_processing.cpp:3579 (head).

Details and suggested fix

The filter index follows the fully validated chainstate, but the racing check compares its best block with the snapshot's active-chain tip. Once the snapshot chain reaches the network tip, filter requests whose stop block is above the background chain's tip are treated as racing until background validation completes and the index restarts. While a request is parked, ProcessMessages() returns before processing further messages, so it does not process that peer's pongs; the peer is disconnected after the 20-minute ping timeout. This behavior is established, but no concrete production trigger or affected caller was identified. A disconnect-only invalidateblock can also leave the index best block on a descendant of the active tip, causing stale-branch requests to remain parked until another block connects. Compare the index best block with the validated chainstate tip using an ancestry check, and bound how far the requested stop block may be above the index best block.


Link

[minor] · Parking requests before validation reveals which stop hashes are known

While the index lags, valid and invalid requests are both parked, but unknown stop hashes are handled immediately, revealing which headers the node knows.

Location: src/net_processing.cpp:3653 (head).

Details and suggested fix

The three compact-filter request handlers check whether the index is racing before calling ServeGet*. This parks requests before PrepareBlockFilterRequest() checks the service, calls BlockRequestAllowed(), applies height limits, or looks up the requested filter. In the base revision, an unknown stop hash and a known hash rejected by BlockRequestAllowed() both caused an immediate disconnect. While the index lags now, a known hash is parked but an unknown one is disconnected, allowing a peer to probe which headers the node knows. The window is normally the validation-queue lag after a block and can persist during the long-lag states described in the previous finding. Prepare and look up the request first, then park only a transient lookup miss while the index is racing. The serve helpers should distinguish a served response, an invalid request, and a transient miss so retries cannot duplicate a partial response.


Link

[minor] · Exceptions during deferred filter responses escape the message handler

A local index read failure during a deferred retry can terminate the node instead of being caught and logged by the message handler.

Location: src/net_processing.cpp:5600 (head).

Details and suggested fix

AttemptPendingRequest() runs before the try block that catches exceptions from ProcessMessage(). It can call the filter-serving functions, which read the index; for example, ServeGetCFHeaders calls LookupFilterHeader(). A LevelDB read error throws dbwrapper_error, which is not caught by CConnman::ThreadMessageHandler; it reaches the thread entry point and terminates the process. In the base revision, serving ran inside ProcessMessage() and the exception was caught and logged. This requires a local index read failure; a remote peer cannot trigger it against a healthy index. Apply the same exception handling to deferred serving, for example through a helper shared with the ProcessMessage() path.


Optional improvements

Link

[suggestion] · A failed assertion can leave the scheduler blocked and hang the test suite

If an assertion fails before Release(), cleanup does not unblock the scheduler thread, so fixture teardown can hang instead of reporting the failure.

Location: src/test/cfilter_race_tests.cpp:110 (head).

Details and suggested fix

After WaitForEntry(), the scheduler thread waits on m_release_fut without a timeout. Release(), unregistering the blocker, restoring CaptureMessage, and destroying the block filter index happen only on the success path. If a BOOST_REQUIRE before Release() fails, fixture teardown calls m_node.scheduler->stop(), which joins the blocked thread. Dropping the local shared_ptr does not unblock it because ValidationSignals retains its own reference. A failure after Release(), such as the assertion at line 282, does not hang, but leaves the global CaptureMessage lambda capturing destroyed locals and g_filter_indexes holding an index bound to the destroyed node context. Install a scope guard after registering the blocker to release it, unregister it, restore CaptureMessage, and destroy the index on every exit.


Link

[suggestion] · The test comment and PR description do not match the implemented mechanism

The description's bounded-trigger rationale refers to a height bound and lock changes that are absent from the code, while this implementation parks requests per peer without a height bound or deadline.

Location: src/test/cfilter_race_tests.cpp:79 (head).

Details and suggested fix

The description refers to BaseIndex::WaitForRacingWrite(target, max_ahead), CF_MAX_BLOCKS_AHEAD_RACE_WAIT = 2, index lookups that drain the validation queue, changes to LookupFilterHeader() locking and try_emplace, and differently named tests. None of these are present at this head. Instead, net_processing parks requests per peer without a height bound or deadline, and LookupFilterHeader() still holds m_cs_headers_cache across the database read. The comment also refers to “the racing-check tests above,” which are absent. Update the description, including its safety rationale and reorg discussion, and this comment to describe the parking design.


Link

[suggestion] · The deferred cfheaders test does not verify the response contents

The test passes if the retry sends a CFHEADERS message with the wrong start height or stop hash.

Location: src/test/cfilter_race_tests.cpp:354 (head).

Details and suggested fix

The capture callback ignores the payload and only sets cfheaders_sent. For example, if the retry used start_height=0 instead of the stored request's start height, the request at height 101 would still fit within MAX_GETCFHEADERS_SIZE; the test would see a message and pass despite its incorrect contents. Deserialize the captured payload and assert the filter type, stop hash, previous header, and single filter hash, using expected values from the index after Release(). The getcfilters tests can similarly check the CFILTER block hash.


Coverage details