Review report

bitcoin/bitcoin: PR #35354

3 minor findings · 2 suggestions

Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Persistent index lag is mistaken for an in-flight filter append

With -peerblockfilters, a synced index following an assumeutxo historical chain can make recent filter requests pause the requesting peer until timeout without supplying the missing filters.

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

Details and suggested fix

summary.synced means the index caught up with its own chainstate, not necessarily ActiveChain(). The index binds to ValidatedChainstate() and ignores unvalidated snapshot events, whereas IBD can end based on the snapshot chain's recency. Once the index has latched synced against the historical chain, a known stop above its best block passes this predicate. If background validation does not reach that stop within five seconds, getcfilters or getcfheaders still receives no answer, as before, but later messages from that peer now wait until timeout. loadtxoutset leaves the compact-filter service bit advertised. The same non-ancestry test unnecessarily parks stale-branch requests whose filters are already indexed while the best hash differs from the active tip; catch-up can release those before timeout. Restrict deferral to a short active-chain append gap, exclude historical-chainstate indexing, and use an ancestor-based caught-up check against the chainstate the index follows. The timing of m_synced during mainnet background validation was not measured, so production frequency is unconfirmed.


Link

[minor] · Deferred filter responses bypass the message exception handler

A local filter-index database read error during deferred serving can terminate the node instead of being caught and logged as it was before this change.

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

Details and suggested fix

ProcessMessages() calls AttemptPendingRequest() before entering its handler exception boundary. A deferred getcfheaders with a nonzero start height calls LookupFilterHeader() for the preceding block. When that lookup reaches the database, LookUpOne() calls CDBWrapper::Read(), which throws dbwrapper_error on an internal database error. Neither the retry path nor ThreadMessageHandler() catches it, and TraceThread() logs and rethrows, so the exception escapes the thread entry point and terminates the process. This requires a local index read failure, such as an I/O error or corruption. Run deferred serving under the same exception handling as immediate serving, while retaining the removal of the pending request before serving.


Link

[minor] · A backward clock step can extend the parked-peer timeout

A backward wall-clock step while a request is parked bypasses both readiness checks and the five-second timeout until the clock catches up, delaying that peer's later messages.

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

Details and suggested fix

park_time and last_retry_time use NodeClock, which reads the system clock. After a backward step, now - last_retry_time remains below the retry interval, so this early return prevents both the filter-ready check and MAX_CF_PARK_INTERVAL from running. A step of Δ can therefore keep the peer paused for roughly Δ even after its filter becomes available. This requires a local clock adjustment during the normally short parking window, so it should be rare in practice. Use MockableSteadyClock for both timestamps and drive the elapsed-time tests with FakeSteadyClock so wall-clock changes cannot extend the pause.


Optional improvements

Link

[suggestion] · Requests that should be rejected are parked before validation

A BASIC request for a known uncovered stop can pause its peer before service, range, or block-access checks reject it, delaying disconnection until catch-up or the parking timeout.

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

Details and suggested fix

The three compact-filter handlers call ShouldDeferCFilterRequest() before PrepareBlockFilterRequest(). Outside IBD, a synced but lagging local BASIC index is enough to park a request without checking NODE_COMPACT_FILTERS, BlockRequestAllowed(), or the applicable start/stop limits. For example, a node running -blockfilterindex without -peerblockfilters can park a BASIC request that it will later reject. Oversized or inverted ranges have the same ordering issue. These requests now retain pending state and hold later peer messages for at least the retry interval, potentially until the roughly five-second timeout, instead of disconnecting immediately after parsing. Split validation from serving and run it before the deferral decision so only valid requests wait for filter construction.


Link

[suggestion] · Fatal assertions can hang race-test teardown and leave the capture hook dangling

A fatal assertion before cleanup can leave the scheduler blocked and the global CaptureMessage hook referencing destroyed test locals.

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

Details and suggested fix

In the timeout test, BOOST_REQUIRE_EQUAL(sent_types.size(), 1U) runs while the scheduler is deliberately blocked and before blocker->Release(). A regression that prevents timeout recovery leaves the response count at zero, so the requirement exits without releasing the callback. Validation registration retains the blocker, and fixture teardown then joins the blocked scheduler instead of completing the failed test. Early exits after replacing CaptureMessage also skip restoration of its reference-capturing lambda. Use scope-bound cleanup to release, drain, and unregister the blocker on every exit, and restore the capture hook before its captured locals are destroyed. Keep the explicit normal-path release at its current point to preserve deterministic race control.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.