Skip to content

Translate block inventory announcements from sendheaders peers. - #1265

Closed
echennells wants to merge 1 commit into
libbitcoin:masterfrom
echennells:fix/inv-after-sendheaders
Closed

echennells wants to merge 1 commit into
libbitcoin:masterfrom
echennells:fix/inv-after-sendheaders

Conversation

@echennells

Copy link
Copy Markdown
Contributor

A peer that was sent sendheaders is never subscribed to inventory. protocol_header_in_70012::complete sets subscribed and then calls the 31800 complete, which subscribes to inventory only while subscribed is clear. From 70012 up the one flag stands for both, so handle_receive_inventory is not attached.

bitcoind announces by inv to such a peer when more than eight blocks are new or its headers would not connect, and keeps doing so. bs then learns of no block from that peer until it reconnects.

This gives the inv translation its own flag. It stays conditional on a current chain, so a node that is not current ignores inv as before.

The tests announce an unknown block by inv to a bip130 peer. Regtest, one bitcoind 31.0 peer, compact blocks off, bs at the tip, bitcoind mines 100, 30 or 12 blocks in one call: without the change bs stays at the old tip with the connection up in 12 of 24 runs over two heads; with it 24 of 24 sync.

@echennells
echennells requested a review from evoskuil November 17, 2026 21:56
@evoskuil

evoskuil commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

This describes bad bitcoind behavior that we do not want to emulate. It's not a protocol requirement. It is a single threaded network message pump operating on send cycles across peers. In the case of a catch-up sync it may be processing hundreds or thousands of blocks. And it accumulates the outgoing INV in a buffer for each peer. The 8 element cap etc. is protection against it overflowing its own buffers. We don't do that, we send one announcement per block, per peer, as they occur. If the peer is too slow, they get dropped at high water. If we send 1000 headers, that's fine. Sending a single tip INV isn't better, as the peer must still request the headers, adding a round trip.

The actual gap could be that when we fall behind we don't let the peer know until we catch up, since we stop announcements altogether when not current. We consider that good behavior. And peers get announcements once we are caught up, not while we are trying to do so (just like IBD).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants