Saturday, July 6, 2024

p2p – At what level does a node begin downloading blocks in IBD?

What I am fascinated with is at what level does node begin requesting for
blocks? Is it throughout IBD or does it first obtain headers from all
friends, create an entire header tree and solely then begin downloading
blocks for the chain with probably the most cumulative energy and transfer the
energetic chain tip?

There are two completely different processes.

The primary is IBD. It’s divided in two phases (attributable to header pre-sync). In first we choose one peer because the sync peer and ship him one after the other getheaders requests. Because the timestamp of obtained headers begins to strategy the present timestamp, we begin sending getheaders messages to different friends as nicely. Peer responses with corresponding headers, we validate them and retailer their tiny identifiers (nothing is saved in block header tree at this second).

Solely after the friends ship us all of the headers they’ve (all header messages with lower than 2000 objects) we transfer to the second section.

Within the second section, we ship getheaders messages just for headers which are a part of the chain that has sufficient cumulative work. There are two circumstances: that cumulative work should be inside sooner or later of the present energetic chain tip and better than a sure predefined worth. For the reason that first situation on the very first second is a genesis block (and a few low issue blocks), will probably be simply bypassed by malicious peer, nevertheless, the second situation won’t. At this section, it doesn’t matter which peer you’re requesting (whether or not it’s sync peer or another), it’s only essential that we ask some peer for which we all know it has given header.

Extra to examine header pre-synchronization you will discover in this put up.

The second course of works, one thing like, on occasions. Every time a brand new header is added to the tree (occasion) this course of is triggered. If numerous obligatory circumstances are met, a request for the block can be despatched to one of many friends that’s thought of to have it.

When a node is simply began, since in preliminary synchronization we solely “speak” to at least one peer, then as sync peer sends us headers, we validate them and put within the tree, getdata requests for these blocks can be despatched to that sync peer instantly.

Subsequently, no! We don’t retailer all headers first, create full tree after which obtain blocks. Every little thing is completed concurrently. Nevertheless, we do obtain all headers within the tree for pre-sync first, earlier than doing the rest.

For this and far more different info examine this put up.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles