From 64e13308f2ef1bd48e4d8d1ab3827e7457953d35 Mon Sep 17 00:00:00 2001 From: Josh Green Date: Thu, 2 Jan 2020 14:17:44 -0500 Subject: [PATCH] Blockchain Reorg Content --- home.md | 10 +++++----- protocol/blockchain.md | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/home.md b/home.md index 8f41d38..a59b37b 100644 --- a/home.md +++ b/home.md @@ -61,11 +61,11 @@ - [Bip-158](/protocol/forks/bip-0158) - [Bip-159](/protocol/forks/bip-0159) - BCH UAHF (BUIP-55) - - HF20171113 - - HF20180515 - - HF20181115 - - HF20190515 - - HF20191115 + - [HF-20171113](/protocol/forks/hf-20171113) + - HF-20180515 + - HF-20181115 + - HF-20190515 + - HF-20191115 - Peer-to-Peer Network - [Messages](/protocol/network/messages) - *Announcements* diff --git a/protocol/blockchain.md b/protocol/blockchain.md index 0be171c..fa2bac5 100644 --- a/protocol/blockchain.md +++ b/protocol/blockchain.md @@ -17,7 +17,7 @@ With this property, changing old blocks becomes nearly impossible as long as the Blocks are applied sequentially, and therefore for a given chain, a block can be identified by its distance from the Genesis Block. This distance is commonly referred to as `Block Height`. There may be multiple blocks at the same `Block Height` if two blocks are built that share a previous Block's Hash. -Multiple Blocks with the same `Block Height` are often referred to as "sibling" Blocks. +Multiple Blocks with the same `Block Height` are often referred to as "sibling" Blocks, or "contentious" blocks. Sibling Blocks can happen if a Block is created with sufficient Work before the mining Node has been made aware of the new (Sibling) Block. Sibling Blocks are incompatible with one another, and eventually one will become orphaned. The [Genesis Block](/protocol/blockchain#genesis-block) is the first Block in a chain, and has a `Block Height` of `0` (as its distance to the Genesis Block is zero). @@ -27,10 +27,41 @@ As of [BIP-0034](/blockchain/forks/bip-34), the `Block Height` is included withi ## Work The longest valid chain with the most [Proof of Work](/protocol/blockchain/proof-of-work) is generally considered to be the main chain. -Work can be quickly verified by evaluating the Block's [Difficulty](/protocol/blockchain/proof-of-work/difficulty). -The [Chain Work](/protocol/blockchain/proof-of-work#chain-work) is the summation of all work done up to a point on the Blockchain. +Work can be quickly verified by evaluating the Block's [Difficulty](/protocol/blockchain/proof-of-work/difficulty) and validated by checking the Block's hash. +[Chain Work](/protocol/blockchain/proof-of-work#chain-work) is the summation of all work done on each block up to a point on the Blockchain. +As of [HF-20171113](/protocol/forks/hf-20171113), Chain Work is used to calculate new Block's [difficulty adjustment](/protocol/blockchain/proof-of-work/difficulty-adjustment-algorithm) as of Block Height. ## Blockchain Reorganization +When two valid blocks share the same block height, they are considered contentious blocks. +Contentious blocks can happen organically due to the random nature of mining—the likeliness being proportional to the block propagation speed and the time between blocks. +Slow-propagating blocks require a longer block interval in order to prevent contentious blocks. + +When two blocks become contentious, the first-seen block is usually considered the valid block on the main chain; however, different nodes across the network may have seen different blocks first. +Consensus is formed when a second block is mined on a contentious block. +This second block may also be contentious, although a rare circumstance. +In this case, the process repeats and the race continues until consensus is reached. + + +```diagramLabel + +1. Blocks 2a and 2b are mined before the either have fully propogated throughout the network. + +2. Some Nodes follow Block 2a, others follow Block 2b, depending on which Block they received first. + +3. Block 3 is mined on top of Block 2b. Nodes originally following Block 2a abandon Block 2A, and begin following Block 2b/3. + +``` + +```mermaid +graph LR + +0 --> 1 +1 --> 2a +1 --> 2b +2b --> 3 + +style 2a stroke: #AAAAAA, stroke-dasharray: 5, 5 +``` ## Genesis Block \ No newline at end of file