Block chain - chain block bifurcation

When a node is verified will be broadcast to the other nodes, another node is verified, it will be effective if the link to the chain.

Each node maintains more than one chain of a main chain, there is a spare chain (branching out from the main chain). At any time, the backbone of the block chain are accumulated the most difficult.

In general, the backbone chain is most blocks that contain, unless other chain length and two of which demonstrated a more workload. Backbone will also have some branches, these branches on the block in the block and the main chain of each other "brother" blocks.

These blocks are effective, but not part of the backbone. The purpose is to keep these branches at some point in the future if one of them is extended and the difficulty value exceeds the backbone, then the subsequent blocks will reference them.

When the node receives a new block, it attempts to block this block into an existing chain. Node will look at this block "previousblockhash" field, which is the block reference to a parent block. Meanwhile, the new node will try to locate the parent block in an existing block chain. In most cases, the father of the block is the "top" of the main block chain, which means that the new block to extend the backbone. 

Sometimes, the extension of the new block is not a block chain backbone, in which case, a new node is added to the spare block chain, while more difficult to backup chain backbone. If the backup chain has accumulated more difficult than backbone nodes will converge to spare chain, it means that the node will select a new backup chain as its main chain, and before that the old standby has become the backbone chain. If the node is a miner, it will start to construct a new block, this update to extend longer block chain.

If a node receives a valid block, but failed to find its parent block in an existing block chain, then this block is considered a "lone block." Solitary blocks are stored in a solitary block pool until their parent node block is received. Upon receipt of a parent block and connecting it to the existing block chain, the node will block the isolated block is removed from the pool isolated, and is connected to its parent block, as the block part of the chain it. When two blocks are dug in a very short time interval, the node may have received them in reverse order, this phenomenon occurs when the block is isolated.

After selecting the block chain biggest difficulty of all nodes eventually reach a consensus in the whole network. As more workloads are added to the proof of the chain, the chain of temporary differences will eventually be resolved. Mining node to select the block chain they want extended by "voting" when they dig a new block and extends a chain, a new block itself represents their vote.

Block chain bifurcation

Because the block chain is decentralized to the data structure, it is not always consistent between different copies. Blocks may reach different nodes at different times, resulting in different nodes picture block chain.

The solution is that each node selects and always try to extend on behalf of the cumulative maximum effort to prove the chain block, which is the longest chain or maximum cumulative work (greatestcumulativeworkchain). Node workload of each block on the accumulation chains are established chain this total to be paid for work to prove. As long as all the nodes selected block chain longest cumulative work, the entire bit credits network will eventually converge to a consistent state. That is the bifurcation temporary differences that occur between different block chain, as more block is added to a bifurcation, this problem will be solved.

Since the global network transmission delays, this block chains described bifurcation occurs automatically.

Which is a simplified representation of the network bit token. For ease of description, different blocks are shown as different shapes (stars, triangles, inverted triangles, diamonds), throughout the network. Each circle represents a node in the network.

Each node has its own view of the global block chain. When each node receives the block from its neighbors, it will update its own copy of the block chain, select the maximum cumulative work chain. For ease of description, each node contains a pattern shape, it believes represents the block at the top of the main chain. So, if you see a star in the nodes inside, it means that the node is considered the star block at the top of the main chain.

There is a unified regional network chain perspective, a star block main chain "apex."

When there are two candidate blocks at the same time want to extend the longest block chain, forked event occurs. Under normal circumstances, the bifurcation occurs when two miners in a short period of time, the agenda for each workload are proof solution.

Two miners found their candidate block a solution, they immediately spread their "win" block to the network, first spread to neighboring nodes and then spread to the entire network. Each node will receive a valid block which is incorporated in and extend the block chain. If the node subsequently received another candidate block, and this block and have the same parent block, this block then the node will be connected to the candidate chain.

As a result, some nodes received a candidate block, and the other node receives another candidate block, then the two different versions of the block chain appeared. The following diagram we see two miners (NodeX and NodeY) struck almost simultaneously in two different blocks. This is the culmination of two blocks Block - sub-block star block, this block can be extended chain. For easy viewing, we generated block node X is marked as a triangle, the node labeled Y block the production of inverted triangle.

For example, we assume that the node X miners found despread workload proof block chain, i.e. triangular block, constructed on top of the parent star block. At the same time, the same star-block extension node Y also found despread workload proof block chain, i.e., inverted triangle blocks as candidate blocks.

There are two possible blocks, triangular blocks, and the node Y to the node X inverted triangular block, the two blocks are effective, both workload proof solution comprising an effective and prolonged block of the same parent. The two blocks may contain almost the same deal, but in slightly different sort of transaction.

When two blocks began to spread in the network, some nodes triangular first received block, a number of additional node first receives inverted triangle blocks. As shown below, the nodes on the network to the apex block of bits credits chains were divided with one block is a triangular apex, the inverted triangle blocks faction vertex.

 In the figure, assume that node X receives the first triangular block and extend it with a star chain. Select node X triangular block main chain. After that, the node X also received inverted triangle blocks. Because it is the second time received, it is determined that the block is inverted triangle competitive product failed, considered invalid blocks.

However, inverted triangle blocks are not discarded. It is linked to the parent star block chain, and the formation of alternate chains. Although the node X thinks he has the right to select the winning chain, but it will also save the "lost" chain, the "lost" if the chain could eventually "win", it also has the information needed repackaged.

在网络的另一端,节点Y根据自己的视角构建一个区块链。首先获得倒三角形区块,并选择这条链作为“赢家”。当它稍后收到三角形区块时, 它也将三角形区块连接到星形链的父区块作为备用链。

双方都是“正确的”或“不正确的”。两者都是自己关于区块链的有效立场。只有事后,才能理解这两个竞争链如何通过额外的工作得到延伸。

节点X阵营的其他节点将立即开始挖掘候选区块,以“三角形”作为扩展区块链的顶端。通过将三角形作为候选区块的父区块,它们用自己的哈希算力进行投票。 它们的投票标明支持自己选择的链为主链。

同样,节点Y阵营的其他节点,将开始构建一个以倒三角形作为其父节点的候选节点,扩展它们认为是主链的链。比赛再次开始。分叉问题几乎总是在一个区块内就被解决了。

网络中的一部分算力专注于“三角形”区块为父区块,在其之上建立新的区块;另一部分算力则专注在“倒三角形”区块上。即便算力在这两个阵营中平均分配,也总有一个阵营抢在另一个阵营前发现工作量证明解并将其传播出去。

在这个例子中我们可以打个比方,假如工作在“三角形”区块上的矿工找到 了一个“菱形”区块延长了区块链(星形-三角形-菱形),他们会立刻传播这个新区块,整个网络会都会认为这个区块是有效的,如下图所示。

 选择“三角形”作为上一轮中胜出者的所有节点将简单地将区块链扩展一个块。 然而,选择“倒三角”的节点现在将看到两个链:星形-三角形-菱形和星型-到三角形。星形-三角形-菱形这条链现在比其他链条更长(更多累积的工作)。

因此,这些节点将星形-三角形-菱形设置为主链,并将星型-倒三角形链变为备用链,如图所示。

这是一个链的重新共识,因为这些节点被迫修改他们对块链的立场,把自己纳入更长的链。任何从事延伸星形-倒三角形的矿工现在都 将停止这项工作,因为他们的候选人是“孤儿”,因为他们的父母“倒三角形”不再是最长的连锁。

“倒三角形”内的交易重新插入到内存池中用来包含在下一个块中,因为它们所在的块不再位于主链中。整个网络重新回到单一链状态,星形三角形-菱形,“菱形”成为链中的最后一个块。所有矿工立即开始研究以“菱形”为父区块的候选块,以扩展这条星形-三角形-菱形链。

从理论上来说,两个区块的分叉是有可能的,这种情况发生在因先前分叉而相互对立起来的矿工,又几乎同时发现了两个不同区块的解。然而,这种情况发生的几率是很低的。单区块分叉每周都会发生,而双块分叉则非常罕见。

比特币将区块间隔设计为10分钟,是在更快速的交易确认和更低的分叉概率间作出的妥协。 更短的区块产生间隔会让交 易清算更快地完成,也会导致更加频繁地区块链分叉。与之相对地,更长的间隔会减少分叉数量,却会导致更长的清算时间。

Guess you like

Origin blog.csdn.net/qq_40452317/article/details/90550290