Skip to content

Commit c8e7a09

Browse files
MarcoFalkeknst
authored andcommitted
Merge bitcoin#24226: rpc: warn that nodes ignore requests for old stale blocks
f39d926 rpc: warn that nodes ignore requests for old stale blocks (Sjors Provoost) Pull request description: Adds warning to RPC help that `getblockfrompeer` is of little use for stale blocks that are more than a month old. This is an anti-fingerprinting measure. See `BlockRequestAllowed` in `net_processing`. It's been in Bitcoin Core since 2014, introduced in dashpay#2910 and later improved to not rely on checkpoints. Older and alternative clients might still serve these blocks, so not throwing an error. Allowing whitelisted nodes to fetch these blocks anyway might be nice. ACKs for top commit: fjahr: Code review ACK f39d926 Tree-SHA512: db88f9f7521289640c5e629c840dda1c2c3ab70d458e9e7136c60fbaeb02acfb36dc093502d83d4c098c331e22aab81bf8f4c4961d805e3bde0f8f3cfe68d968
1 parent fce6ecf commit c8e7a09

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/net_processing.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,8 @@ std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId peer_id, const CBl
19401940

19411941
LOCK(cs_main);
19421942
// Mark block as in-flight unless it already is (for this peer).
1943+
// If the peer does not send us a block, vBlocksInFlight remains non-empty,
1944+
// causing us to timeout and disconnect.
19431945
// If a block was already in-flight for a different peer, its BLOCKTXN
19441946
// response will be dropped.
19451947
if (!BlockRequested(peer_id, block_index)) return "Already requested from this peer";

src/rpc/blockchain.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@ static RPCHelpMan getblockfrompeer()
483483
"getblockfrompeer",
484484
"Attempt to fetch block from a given peer.\n\n"
485485
"We must have the header for this block, e.g. using submitheader.\n"
486-
"Subsequent calls for the same block and a new peer will cause the response from the previous peer to be ignored.\n\n"
486+
"Subsequent calls for the same block and a new peer will cause the response from the previous peer to be ignored.\n"
487+
"Peers generally ignore requests for a stale block that they never fully verified, or one that is more than a month old.\n"
488+
"When a peer does not respond with a block, we will disconnect.\n\n"
487489
"Returns an empty JSON object if the request was successfully scheduled.",
488490
{
489491
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash to try to fetch"},

0 commit comments

Comments
 (0)