Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Dev Docs: Document Blocks-First IBD & Orphan Blocks #685
Conversation
harding
added
the
Dev Docs
label
Dec 18, 2014
|
Rebased to fix merge conflicts. |
saivann
commented on an outdated diff
Jan 31, 2015
| +instance of the object. For blocks, the unique identifier is a hash of | ||
| +the block's header. | ||
| + | ||
| +The block inventories appear in the `inv` message in the same order they | ||
| +appear in the block chain, so this first `inv` message contains | ||
| +inventories for blocks 1 through 501. (For example, the hash of block 1 | ||
| +is 4860...0000 as seen in the illustration above.) | ||
| + | ||
| +The IBD node uses the received inventories to request 128 blocks from | ||
| +the sync node in the `getdata` message illustrated below. | ||
| + | ||
| + | ||
| + | ||
| +It's important to headers-first nodes that the blocks be requested and | ||
| +sent in order because each block header references the header hash of | ||
| +the preceeding block. That means the IBD node can't fully validate a |
|
|
saivann
commented on an outdated diff
Jan 31, 2015
| + | ||
| + | ||
| +Upon receipt of the second `getblocks` message, the sync node takes the | ||
| +first listed header hash and searches its local best block chain for a | ||
| +block with that header hash. If it finds a block with that hash, it | ||
| +replies with 500 block inventories starting with the following block. | ||
| +But if it doesn't find a block with that hash, it takes the next header | ||
| +hash from the `getblocks` message and searches its block chain for that | ||
| +hash. If that hash matches, it will reply with 500 block inventories | ||
| +starting with the following hash from that point. But, again, if it | ||
| +doesn't find that hash, it will proceed to check the next hash in the | ||
| +message (and so on until it runs out of hashes in the message). If the | ||
| +last hash in the message (besides the stopping hash) doesn't match, it | ||
| +assumes the only block the two nodes have in common is block 0 and so it | ||
| +sends an `inv` starting with block 1 (the same `inv` message seen | ||
| +several illustrations above). |
saivann
Contributor
|
|
@harding Thanks!! LGTM |
harding commentedDec 18, 2014
Dev Docs: Document Blocks-First IBD & Orphan Blocks
Preview IBD section: http://dg0.dtrt.org/en/developer-guide#initial-block-download
Preview Orphan Blocks section: http://dg0.dtrt.org/en/developer-guide#orphan-blocks
This pull adds a new section about the Initial Block Download (IBD) method used in Bitcoin Core 0.9, which I've retroactively named blocks-first. It also adds a short section explaining the difference between orphan blocks and stale blocks. See the commit message for minor details.
This is a partial resubmission of closed pull #660 focusing only on the current IBD method. This keeps the text shorter and, hopefully, easier to review. I also think this version is much, much better---it includes nearly 100% rewritten text plus five new illustrations that didn't appear in the original pull. After we get this merged, I'll rewrite and resubmit the headers-first part of pull #660.