Add opt-in bulk block streaming (-bulkblocksync)
A single getblockstrm request makes a peer stream a contiguous range of old blocks back-to-back as ordinary BLOCK messages, amortizing the per-block round-trip over the whole range instead of the MAX_BLOCKS_IN_TRANSIT_PER_PEER window. This targets the bandwidth-delay-product ceiling that dominates IBD from few/high-latency peers below the checkpoint. Design (off by default; negotiated via a NODE_BULKBLOCKS service bit; the default getdata IBD path is untouched when disabled): - protocol: NODE_BULKBLOCKS service bit + getblockstrm/blockstream messages. - requester: in SendMessages, after FindNextBlocksToDownload, when the first needed block is >= BULK_TIP_MARGIN (5000) below the network tip and the peer advertises the bit and we are in IBD, request a contiguous range (<=128 blocks) instead of per-block getdata; mark the range in-flight. - server: stream the range (caps 128 blocks / 8 MiB; reads outside cs_main; per-peer flood throttle), then a trailing blockstream header with the actual count sent. Self-suppresses while the server itself is in IBD. - received blocks ride the existing BLOCK -> ProcessNewBlock path (fully validated; checkpoints below 2.84M still apply); the trailing header reconciles partial deliveries and the range is freed on a 90s timeout, so a partial/withheld/refused batch falls back to the normal path (no leak, no permanent gap, no disconnect). In-flight tracking is by literal hash, so a reorg cannot orphan range entries. Hardened against the issues found in two adversarial review passes (drain vs timeout, partial reconciliation, ownership-guarded frees, one-shot header, reorg-proof helpers, cs_main hold). Validated end-to-end between two local v1.0.3 nodes (128/128 and partial serves; height advanced; no errors). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,8 @@ const char *GETNSPV="getnSPV"; //used
|
||||
const char *NSPV="nSPV"; //used
|
||||
const char *ALERT="alert"; //used
|
||||
const char *REJECT="reject"; //used
|
||||
const char *GETBLOCKSTREAM="getblockstrm"; // 12 chars (COMMAND_SIZE max); "getblockstream" would truncate
|
||||
const char *BLOCKSTREAM="blockstream";
|
||||
} // namespace NetMsgType
|
||||
|
||||
/** All known message types. Keep this in the same order as the list of
|
||||
@@ -119,6 +121,8 @@ const static std::string allNetMessageTypes[] = {
|
||||
NetMsgType::NSPV,
|
||||
NetMsgType::ALERT,
|
||||
NetMsgType::REJECT,
|
||||
NetMsgType::GETBLOCKSTREAM,
|
||||
NetMsgType::BLOCKSTREAM,
|
||||
};
|
||||
|
||||
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn)
|
||||
|
||||
Reference in New Issue
Block a user