The ’not_found’ message, introduced in protocol version 70001 (Bitcoin Core 0.8.0 - Feb 2013), serves as a response to a ‘getdata’ message when the receiving node does not have the requested data available for relay. Thus far, this has only been applied to transactions. This PR proposes extending its use to blocks as well.
Currently, when the remote peer does not have the requested block data, it ignores the ‘getdata’ inventory block request. This lack of response causes the requesting node to wait (and stall if the request was for an IBD block) for 10 minutes until the request timeout is triggered. As a result, the local node abruptly disconnects the peer due to perceived unresponsiveness in order to download the block from another source, even though the peer handled the message accordantly and may still be relaying other headers, blocks, and transactions properly.
This behavior is suboptimal for well-behaving nodes. Therefore, this PR proposes sending ’not_found’ messages for blocks the remote peer does not know about or no longer stores, allowing the local node to promptly request them from another peer. Doing so will help prevent network synchronization stalling scenarios, allow us to shorten idle wait times (by reducing the block request timeout for peers supporting this feature), and ensure well-behaving peers remain connected.
Pending tasks:
- Write detailed commits description.
- Expand PR description
- Describe feature negotiation message. Annotate all considered options.
- Describe ’not_found’ handler behavior for blocks closer to the tip vs historical ones.
- Create BIP for the new feature negotiation message.
- Think about increasing the peer’s block download priority when it signals support for the feature.
- Think about disconnecting the peer when a known feature negotiation message is received prior to the version message.
- Complete TODOs in the code.