Skip to content

Fix get_client_filters livelock in protocol_filter_out_70015#1071

Open
echennells wants to merge 1 commit into
libbitcoin:masterfrom
echennells:fix-filter-out-70015-getdata-livelock
Open

Fix get_client_filters livelock in protocol_filter_out_70015#1071
echennells wants to merge 1 commit into
libbitcoin:masterfrom
echennells:fix-filter-out-70015-getdata-livelock

Conversation

@echennells

@echennells echennells commented Jul 3, 2026

Copy link
Copy Markdown

Bug

handle_receive_get_filters returns false (drop), and send_filter, on an empty ancestry, resubscribes via SUBSCRIBE_CHANNEL inside the notify cycle, re-entering the handler for the same in-flight message. This is the bip157 compact-filter sibling of the protocol_transaction_out_106 get_data livelock (#1070) -- the identical resubscribe-during-notify pattern.

Reachability

Config-gated: protocol_filter_out_70015 attaches only when the node advertises node_client_filters and the peer negotiates bip157, and a default node advertises neither (protocol_maximum caps at bip130, filters off). It becomes reachable only when the node is configured as a compact-filter server ([peer] protocol_maximum = 70015 plus the node_client_filters service bit and filter_bk_buckets > 0).

Now reproduced live under that config (previously latent / inspection-only): on a filter-indexed testnet3 store, a single-block getcfilters (start_height == stop height) yields count 0 -> empty ancestry -> the loop. Unpatched spins CPU hot; patched holds ~0% and still serves filters. (The count-0-for-a-single-block result is a separate off-by-one, handled independently -- this PR is only the livelock.)

Fix (revised per review)

Same as #1070: keep return false (the drop is backpressure) and the resubscribe; wrap the send in POST(send_filter, ...) so it runs outside notify. The other two handlers in this protocol (get_filter_checkpoint, get_filter_headers) already return true and are unaffected.

@evoskuil

evoskuil commented Jul 3, 2026

Copy link
Copy Markdown
Member

The fix doesn’t seem to address why the subscription is being dropped while a notification is being handled. The channel must not accept another request on the protocol type while one is being handled. This opens the node up to DoS by way of memory exhaustion.

@echennells echennells force-pushed the fix-filter-out-70015-getdata-livelock branch from 294b347 to e09c28d Compare July 6, 2026 21:18
@echennells

Copy link
Copy Markdown
Author

Revised, same fix as #1070 -- keeps the drop (backpressure), POSTs the send outside notify. Also updated reachability: now reproduced live under a compact-filter-server config (was inspection-only); details in the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants