[Xu Xiaodi] Detailed explanation of EOS's new consensus mechanism BFT-DPoS

In the latest white paper of EOS, the consensus mechanism has been upgraded from DPoS to BFT-DPoS (Byzantine Fault Tolerance - Deligated Proof of Stake, with Byzantine Fault Tolerance Delegated Proof of Stake). This article will explain the principle of the new consensus mechanism in detail.

Traditional DPoS

When the EOS project was just released, the consensus mechanism was DPoS (Deligated Proof of Stake), which is similar to Bitshares and Steem. This consensus mechanism uses a random witness block generation sequence, the block generation speed is 3 seconds, and the transaction is irreversible. It takes 45 seconds. Why does it take 45 seconds? Because under DPoS, the witness produces a new block, which means that he has confirmed the entire previous blockchain, indicating that the witness recognizes the current entire chain. For a transaction to reach an irreversible state, more than 2/3 of the witnesses are required to confirm it, which is 14 witnesses in EOS. Let's assume that a transaction is included in block 1000 and requires 13 other witnesses to take turns streaming out to block 1013 in order to "collect" 14 witnesses to confirm the transaction (including the one that produced block 1000). witness). Transactions confirmed by more than 2/3 witnesses are irreversible transactions, which is the origin of the 45-second confirmation time.

Byzantine Fault Tolerance (BFT)

In order to improve the traditional DPoS algorithm, we can learn from the mechanism of PBFT (Practical Byzantine Fault Tolerance, Byzantine Fault Tolerance). In the traditional DPoS consensus mechanism, we let each witness broadcast the block to the whole network when the block is produced, but even if other witnesses receive the current new block, they cannot confirm the new block and need to wait for their turn When a block is produced, the previous block can only be confirmed by producing the block.

Under the new mechanism, each witness still broadcasts the whole network when they generate a block. After other witnesses receive the new block, they will immediately verify the block and return the block whose signature has been verified to the block witness immediately. There is no need to wait for other witnesses to confirm when they produce their own blocks. From the perspective of the current block-producing witness, he produced a block, broadcast it to the whole network, and then successively received confirmations of this block from other witnesses. At the moment of receiving confirmation from 2/3 of the witnesses, the block (including transactions in it) are irreversible. The transaction confirmation time is greatly shortened, from 45 seconds to about 3 seconds (mainly the time to wait for the production block). This mechanism can be called the primary version of the BFT-DPoS consensus mechanism.

BFT-DPoS

In order to explore the performance of the EOS system, Daniel Larimer made modifications on the basis of the above. First, he shortened the block generation speed from 3 seconds to 0.5 seconds. In theory, this can greatly improve system performance, but it brings about network delay problems: the confirmation time of 0.5 seconds will cause the next block producer to not receive the previous block. The block of a block producer should produce the next block, then the next block producer will ignore the previous block, causing the blockchain to fork (there are two blocks with the same block height). For example: Chinese Witnesses may be followed by American Witnesses. The network delay between China and the United States is sometimes as high as 300ms. It is very likely that when American Witnesses have not received the blocks of Chinese Witnesses, it is time to produce blocks. Blocks will be skipped.

In order to solve this problem, Daniel Larimer changed the original random block generation order to the block generation order determined by the witnesses after negotiation, so that the witnesses with low network connection delay can produce adjacent blocks. For example, the Japanese Witnesses are followed by the Chinese Witnesses, then the Russian Witnesses, then the British Witnesses, and then the American Witnesses. This can greatly reduce network latency between witnesses. This makes the block generation speed of 0.5 seconds theoretically possible.

In order to be foolproof and not allow any witness to be skipped due to unexpected network delays, Daniel Larimer asked each witness to continuously produce 6 blocks, that is, each witness is still responsible for 3 seconds of block production, but From the initial production of only 1 to the production of 6. In the worst case, the last one or two of the 6 blocks may be skipped by the next witness due to network delays or other accidents, but the first few of the 6 blocks will have enough time to pass to the next witness.

Let’s discuss the transaction confirmation time of BFT-DPoS: each block is broadcasted to the entire network immediately after the production. The block producer waits for 0.5 seconds to produce the next block, and at the same time receives other witnesses’ confirmation of the previous block. result. The production of new blocks and the receipt of confirmations of old blocks occur simultaneously. In most cases, the transaction will be confirmed within 1 second (irreversible). This includes 0.5 seconds of block production, and the time it takes for other witnesses to confirm.

The EOS system stipulates that once the block reaches an irreversible state (confirmed by 2/3 witnesses), it cannot be forked before this, ensuring the permanent credibility of the transaction. In addition, even if most witnesses want to fork the blockchain, they can only compete with the main chain at the same speed (0.5 seconds). Even if there is only one witness left in the main chain, the forked chain will never catch up with the main chain. , to ensure the stability of the system.

Daniel Larimer said that the new BFT-DPoS consensus mechanism of EOS is still under development and will be completed before the system goes live, so let's wait and see.


Yuanfangyuan Blockchain brings together a large number of famous blockchain teachers and adopts a tutor duty system to solve technical difficulties for students in real time. Please pay attention to Yuanfangyuan Blockchain Knowledge Planet and Mentors. (For training inquiries, please contact the captain on 13826054890 with the same WeChat mobile number)

 

The author, Xiaodi, focuses on EOS technology research and blockchain smart contract development. He is the mentor of Yuanfangyuan Blockchain. For more articles and videos of Mr. Xiaodi, please pay attention to the official account of Yuanfangyuan Chain Circle.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325563518&siteId=291194637