Skip to content

Commit

Permalink
rpc: warn that nodes ignore requests for old stale blocks
Browse files Browse the repository at this point in the history
This is an anti-fingerprinting measure. See BlockRequestAllowed in net_processing.

It has been around since 2014, but alternative clients might still serve these blocks.

See also: d8b4b49, 85da07a, a2be3b6, 3788a84
  • Loading branch information
Sjors committed Sep 6, 2022
1 parent 5291933 commit f39d926
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,8 @@ std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId peer_id, const CBl
LOCK(cs_main);

// Mark block as in-flight unless it already is (for this peer).
// If the peer does not send us a block, vBlocksInFlight remains non-empty,
// causing us to timeout and disconnect.
// If a block was already in-flight for a different peer, its BLOCKTXN
// response will be dropped.
if (!BlockRequested(peer_id, block_index)) return "Already requested from this peer";
Expand Down
4 changes: 3 additions & 1 deletion src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ static RPCHelpMan getblockfrompeer()
"getblockfrompeer",
"Attempt to fetch block from a given peer.\n\n"
"We must have the header for this block, e.g. using submitheader.\n"
"Subsequent calls for the same block and a new peer will cause the response from the previous peer to be ignored.\n\n"
"Subsequent calls for the same block and a new peer will cause the response from the previous peer to be ignored.\n"
"Peers generally ignore requests for a stale block that they never fully verified, or one that is more than a month old.\n"
"When a peer does not respond with a block, we will disconnect.\n\n"
"Returns an empty JSON object if the request was successfully scheduled.",
{
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash to try to fetch"},
Expand Down

0 comments on commit f39d926

Please sign in to comment.