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:
@@ -285,6 +285,10 @@ extern const char* GETNSPV;
|
||||
extern const char* NSPV;
|
||||
extern const char* ALERT;
|
||||
extern const char* REJECT;
|
||||
/** Opt-in bulk block streaming (DragonX): request a contiguous range of old blocks. */
|
||||
extern const char* GETBLOCKSTREAM;
|
||||
/** Opt-in bulk block streaming (DragonX): control header preceding a streamed block range. */
|
||||
extern const char* BLOCKSTREAM;
|
||||
}; // namespace NetMsgType
|
||||
|
||||
/* Get a vector of all valid message types (see above) */
|
||||
@@ -304,6 +308,9 @@ enum ServiceFlags : uint64_t {
|
||||
NODE_NSPV = (1 << 30),
|
||||
NODE_ADDRINDEX = (1 << 29),
|
||||
NODE_SPENTINDEX = (1 << 28),
|
||||
// Opt-in bulk block streaming (DragonX). Unauthenticated advertisement; serve/request
|
||||
// handlers validate every block regardless, so robustness against false advertisement holds.
|
||||
NODE_BULKBLOCKS = (1 << 27),
|
||||
|
||||
// Bits 24-31 are reserved for temporary experiments. Just pick a bit that
|
||||
// isn't getting used, or one not being used much, and notify the
|
||||
|
||||
Reference in New Issue
Block a user