@@ -22,12 +22,80 @@ infrastructure projects.
2222meeting, highlighting some of the important questions and answers. Click on a
2323question below to see a summary of the answer from the meeting.*
2424
25- FIXME: LarryRuane
25+ [ Reduce bandwidth during initial headers sync when a block is found] [ review club 25720 ]
26+ is a PR by Suhas Daftuar that reduces a node's network bandwidth
27+ requirements while synchronizing the blockchain with peers, including
28+ during Initial Block Download (IBD). An important part of the Bitcoin
29+ ethos is minimizing resource demands of running a fully-validating node,
30+ including networking resources, to encourage more users
31+ to run full nodes. Speeding up the sync time furthers this
32+ goal as well.
33+
34+ Blockchain synchronization occurs in two phases: First, the node
35+ receives block headers from peers; these headers are sufficient
36+ to determine the (likely) best chain (the one with the most work).
37+ Second, the node uses this best chain of headers to request and download the
38+ corresponding full blocks.
39+ This PR affects only the first phase (headers download).
2640
2741{% include functions/details-list.md
28- q0=""
29- a0=""
30- a0link="https://bitcoincore.reviews/25527#l-FIXME "
42+ q0="Why do nodes (mostly) receive ` inv ` block announcements while
43+ they are doing initial headers sync, even though they indicated
44+ preference for headers announcements ([ BIP 130] [ ] )?"
45+ a0="A node will not announce a new block to a peer using a headers
46+ message if the peer has not previously sent a header to which the
47+ new header connects to, and syncing nodes do not send headers."
48+ a0link="https://bitcoincore.reviews/25720#l-30 "
49+
50+ q1="Why is bandwidth wasted (during initial headers sync) by adding all
51+ peers that announce a block to us via an ` inv ` as headers sync peers?"
52+ a1="Each of these peers will then begin sending us the same stream
53+ of headers: the ` inv ` triggers a ` getheaders ` to the same peer,
54+ and its ` headers ` reply triggers another ` getheaders ` for the
55+ immediately following range of block headers. Receiving duplicate
56+ headers is harmless except for the additional bandwidth."
57+ a1link="https://bitcoincore.reviews/25720#l-62 "
58+
59+ q2="What would be your estimate (lower/upper bound) of how much
60+ bandwidth is wasted?"
61+ a2="Upper bound (in bytes): ` (number_peers - 1) * number_blocks * 81 ` ;
62+ lower bound: zero (if no new blocks arrive during headers sync;
63+ if the syncing peer and the network are fast, downloading all
64+ 700k+ headers takes only a few minutes)"
65+ a2link="https://bitcoincore.reviews/25720#l-79 "
66+
67+ q3="What’s the purpose of CNodeState’s members ` fSyncStarted ` and
68+ ` m_headers_sync_timeout ` , and ` PeerManagerImpl::nSyncStarted ` ?
69+ If we start syncing headers with peers that announce a block to
70+ us via an ` inv ` , why do we not increase ` nSyncStarted ` and set
71+ ` fSyncStarted = true ` and update ` m_headers_sync_timeout ` ?"
72+ a3="` nSyncStarted ` counts the number of peers whose ` fSyncStarted `
73+ is true, and this number can't be greater than 1 until the
74+ node has headers close to (within one day of) the current time.
75+ This (arbitrary) peer will be our initial headers-sync peer. If this
76+ peer is slow, the node times it out (` m_headers_sync_timeout ` ) and
77+ finds another 'initial' headers syncing peer.
78+ But if, during headers sync, a node sends an ` inv ` message
79+ that announces blocks, then without this PR, the node will
80+ start requesting headers from this peer as well, _ without_ setting
81+ its ` fSyncStarted ` flag. This is the source of the redundant
82+ headers messages, and was probably not intended, but has the
83+ benefit of allowing headers sync to proceed even if the
84+ initial headers-sync peer is malicious, broken, or very slow.
85+ With this PR, the node requests headers from only _ one_ additional
86+ peer (rather than from all peers who announced the new block)."
87+ a3link="https://bitcoincore.reviews/25720#l-102 "
88+
89+ q4="An alternative to the approach taken in the PR would be to add
90+ an additional headers sync peer after a timeout (fixed or random).
91+ What is the benefit of the approach taken in the PR over this
92+ alternative?"
93+ a4="One benefit is that peers that announce an ` inv ` to us have a
94+ higher probability of being responsive. Another is that a peer that
95+ manages to send us the block ` inv ` first is often also a very fast peer.
96+ So we'd not pick another slow peer if for some reason our initial
97+ peer is slow."
98+ q4link="https://bitcoincore.reviews/25720#l-135 "
3199%}
32100
33101## Releases and release candidates
@@ -104,3 +172,5 @@ Proposals (BIPs)][bips repo], and [Lightning BOLTs][bolts repo].*
104172[ news193 cln5058 ] : /en/newsletters/2022/03/30/#c-lightning-5058
105173[ news211 rb994 ] : /en/newsletters/2022/08/03/#rust-bitcoin-994
106174[ ldk 0.0.111 ] : https://github.com/lightningdevkit/rust-lightning/releases/tag/v0.0.111
175+ [ review club 25720 ] : https://bitcoincore.reviews/25720
176+ [ BIP 130 ] : https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki
0 commit comments