Part of #36833.
Based on #36919; review from p2p: add staletip message type and payload.
This adds the BIP 332 staletip message, negotiated through the BIP 434 BIP332 feature. With -staletips=headers, the node announces the stale tips it tracks and tracks the ones its peers announce. Only headers are relayed.
Key changes
New
staletipmessage type and payload.Add a
StaleTipRelayManager, which holds the relay policy.With
-staletips=headers, the node advertisesBIP332(withprefers_blocks=false) and relays only with peers that advertise it too.Stale tips learned from peers are tracked, and listed by
getchaintipswithstaletips_only:<details> <summary>Sample output</summary>
A node that learned of a stale tip only from a peer's
staletipmessage:$ bitcoin-cli -named getchaintips staletips_only=true [ { "height": 111, "hash": "6377f9037ff98cb738f676bee62d1931adf41c2cdb00e0148b8d5fbf6161807d", "branchlen": 1, "fork_point": "24bed510a58473fb7ac8cd0f48bb25d75cf9848f00a62be08721b64cea6acd20", "status": "headers-only" } ]</details>
getnetworkinfogets alocalfeaturesfield, listing the BIP 434 features the node advertises.<details> <summary>Sample output</summary>
$ bitcoin-cli getnetworkinfo { ... "localfeatures": { "BIP332": { "prefers_blocks": false } }, ... }</details>
getpeerinfogets afeaturesfield, listing the BIP 434 features each peer advertises.<details> <summary>Sample output</summary>
$ bitcoin-cli getpeerinfo [ { "id": 1, ... "features": { "BIP332": { "prefers_blocks": false } }, ... } ]</details>