Consensus (Consensus), that is, the consensus reached. Since the emergence of human collaboration, consensus has been born. A functioning consensus mechanism can help an organization to collaborate and distribute efficiently.
Is there a consensus in the following two situations?
No cooperative relationship, such as fighting alone
There is a central environment
In the first case, since there is no collaborative relationship, there is no need to reach a consensus. In the second case, the consensus of the system is determined by the center, and each participant only needs to obey the center. Just like in the real world, the design of various third parties and central institutions is unified by the third party for clearing and decision-making. It is a scheme usually adopted in the initial stage to improve efficiency or establish a monopoly.
The soul of blockchain
In the blockchain, the consensus mechanism is regarded as the soul of the blockchain. The reason why it is the soul is because under the network design of the blockchain distributed ledger, each node has the same rights. Therefore, how to get the participating nodes to reach a consensus has become a difficult point. And it is also necessary to assume that when malicious nodes exist in the network, the communication consistency of the entire network is the problem.
Comparison and pros and cons of several mainstream consensus mechanisms
In the history of computer applications, there have been many attempts at consistency issues in a distributed environment. Among them, the Byzantine generals problem is one of the most classic cases.
▲ Byzantine generals problem
Byzantine fault tolerance mechanism
The Byzantine Generals Problem describes such a distributed communication environment: Byzantine generals besiege a castle, the army is divided into many branches, and each army is independently commanded by a general. The generals maintain communication through the messengers in order to reach a consensus action (offensive or retreat). But some generals are hidden traitors, and they will use false information to disrupt the plans of the loyal generals. Everyone does not know who the traitor is. So, can the loyal generals have a way to reach a consensus without being disturbed by false information?
In history, there has been no Byzantine army besieging the castle. This example was actually created by Leslie Lamport in 1982 (Leslie Lamport), a patriarch who studied the issue of Distributed Consensus.
According to this problem, Miguel Castro (Castro) and Barbara Liskov (Liskov) proposed PBFT (Practical Byzantine Fault Tolerance) in 1999.
The operating steps of the PBFT algorithm are:
(1) Take one copy (a general) as the master node, and other copies (other generals) as backups;
(2) The client sends a request to use the service operation to the master node;
(3) The master node sends the request to other replicas by broadcasting;
(4) All copies execute the request and send the result back to the client;
(5) The client needs to wait for F+1 (F is the tolerable number of Byzantine nodes) different replica nodes to send back the same result as the final result of the entire operation.
▲ Three stages in the practical Byzantine algorithm:
Pre-prepare, prepare and commit
In the figure, C is the user terminal, 0 is the master node, and 1, 2, 3 are copies
Therefore, the Byzantine fault-tolerant calculation is mainly based on the decision of the quorum. One node represents one vote, and the Byzantine fault-tolerant calculation is implemented in a way that the minority obeys the majority. Assuming that the total number of nodes is N and the number of traitor generals is F, when N >= 3F+1, the problem can be solved and consensus can be reached. Therefore, in the Byzantine fault-tolerant mechanism, the system can only operate normally when the malicious node <= ⅓ of the total node.
Problems with Byzantine Fault Tolerant Mechanism
The computational efficiency depends on the number of nodes participating in the protocol, which is not suitable for blockchain systems with too large number of nodes, and has poor scalability.
The fault tolerance rate of ⅓ is low.
Since the system nodes are fixed, it cannot cope with the open environment where public chain nodes join and withdraw at any time. It is only suitable for alliance chains or private chain environments.
Due to the limitations of PBFT, a consensus mechanism suitable for a more open public chain environment emerged. In the current blockchain projects and applications, there are the following mainstream consensus mechanisms:
PoW workload proof mechanism
Regarding PoW (Proof of Work), a relatively simple way of understanding is result-oriented. If the task party confesses a certain task, there is no need to see the execution process, but only need to see the results of the task completed by the executor at the end of the time to verify that it has paid the corresponding workload. The typical project that applies the PoW consensus mechanism is Bitcoin.
The implementation process of the workload proof mechanism:
▲Illustration of PoW workload proof process
Hash (block_header) <Target
The target is the calculated target number, usually a variable, to control the block generation period with an average of ten minutes.
In such a design, the greater the proportion of the computing power owned by the node in the entire network, the more likely it is to calculate this arithmetic problem in the competition as quickly as possible, obtain the right to this round of accounting and obtain block rewards.
PoW advantages and disadvantages
The advantages of the proof-of-work mechanism (PoW) are obvious. Each node can participate in the competition on an equal basis, and a positive circular economic system is constructed through incentives, thereby gradually accumulating huge computing power to protect the security of the system.
- Waste of computing resources
A common criticism of the proof-of-work mechanism is “wasting” energy, because nodes consume electricity when competing in computing power.
- Concentration of rights and interests to the top
In addition, driven by mining interests, many investors around the world have created mining pool alliances, and mining pool giants represented by Nvidia and Bitmain have become super nodes that actually maintain the Bitcoin network. The Bitcoin Core development team and super miners have become two main camps and interest groups, and ordinary nodes are also outside the consensus system of the blockchain.
3.51% hashrate attack
In addition, some people are worried about the hidden dangers of network security that the PoW consensus mechanism will bring. On the premise that computing power is the only measurement factor, it means that once someone controls more than half of the computing power of the entire network, he will directly control the blockchain network.
PoS Stake Proof Mechanism
In order to solve the problem of waste of computing power caused by POW, many other consensus mechanisms have been created. Among them, POS (Proof of Stake) is one of the mechanisms for competitive block-making based on equity.
The process of POS function operation:
hash(block_header) =<target * coinage
Among them, coinage (coin age/also known as coin days) = number of equity held * number of days held
It can be seen that, compared with the POW consensus mechanism, the process of finding this target will be directly related to coinage. The coinage variable will cause the target value seen by each miner to be different. This also reflects the meaning of the POS consensus mechanism: if your currency days are larger, the core consumes more currency days, which means the easier it is for you to get answers. The situation of the coinage owned by the node is just like the shareholder in the company's shareholding system, according to the different proportions of the equity held, and the corresponding profits and dividends are obtained.
Here, we will explain the calculation of Bintian and the whereabouts of Bintian during the block generation process:
For example, you have 200 equity and held it for 10 days, so the total amount of currency days you own is 200*10=2000.
In the process of block generation, an additional 0.05 equity will be generated every 365 coin days. At the same time, the original equity holding time will be cleared.
In this process, assuming this new block is generated by you, then the amount of your newly added equity is 2000/365=5.479
Therefore, the number of equity you hold is updated to 205.479, but the number of days held at the same time is cleared, so the currency day is 205.479*0=0
POS Advantages and Disadvantages****
PoS introduces coinage variables, and the POS mechanism avoids the problem of wasting computing resources.
With the increase of time, the POS equity proof mechanism cannot enhance the security of the blockchain network. Because this means that the blockchain will eventually fall into the hands of the few nodes with the highest equity.
DPOS agent equity proof mechanism
Regardless of the proof-of-work PoW or the proof-of-stake PoS consensus, the final calculation result needs to be witnessed by the entire network. Therefore, both are facing the challenge of improving the efficiency of the consensus. The design of DPoS (Delegated Proof of Stake) has solved this problem well.
The DPOS consensus mechanism is a consensus algorithm based on voting and election, which is a bit like a democratic conference. The currency holders select several representative nodes to operate the network, and professionally run network servers are used to ensure the security and performance of the blockchain network.
▲ Schematic diagram of DPOS mechanism
Specifically, the DPOS mechanism does not require computing power to solve mathematical problems. Instead, nodes voted by nodes generate blocks. Each coin-holding node grants its voting rights to a representative, and the top 100 representatives with the most votes will generate blocks in turn according to a set schedule. All representatives will receive 1% of the transaction fee equivalent to an average block. If the producer is incompetent, it is possible to be voted out at any time. This design greatly improves the consensus efficiency.
From a certain point of view, DPoS is community governance plus a consensus algorithm, and is no longer a pure technical consensus. This is the biggest difference from PoW and PoS algorithms.
Advantages and disadvantages of DPOS
- Compared with POW and POS, one of the biggest advantages of the DPOS mechanism is that the cycle of consensus is much shorter.
The POW-based Bitcoin processes 7 transactions per second; the POW and POS-based Ethereum processes 15 transactions per second; EOS will use a parallel chain method, which is expected to reach a maximum confirmation speed of millions per second.
- DPOS will also distribute part of the rewards to network maintenance nodes and voters as a reward for community maintenance, which is conducive to promoting the active operation of the community.
However, this design is not perfect. There is also the characteristic of "centralization" that has been criticized: an 11-person council is equivalent to 11 super nodes, with greater witness rights.
BFChain's original DPOP consensus mechanism
In order to consider the longer-term ecology of BFChain, BFChain data has higher reliability, and effectively avoids problems in the development of existing consensus mechanisms. Inspired by DPOS, we redesigned the DPOP (Delegated Participation Proof of Rights Mechanism) consensus mechanism based on participation, which not only effectively inherits the business attributes of POS, the efficient attributes of DPOS, and the full participation attributes of PBFT In addition, it can also effectively avoid the problem of low cost for nodes without equity and high equity collectives to commit evil.
Specifically, DPOP has the following 3 unprecedented innovations:
1. Incorporating participation into the consensus mechanism for the first time
BFChain's DPOP consensus mechanism incorporates participation into the consensus mechanism for the first time, as an important part of it. In the network design of BFChain NAAS (Node as a Service), different node types obtain corresponding participation proofs from different participation dimensions. Among them, The R-Node (real-time node) obtains participation by providing highly reliable network performance, and The S-Node (service node) obtains participation by providing terminal services. The activities of each participating node on the network will increase its participation to a certain extent. The increase in participation is based on obtaining the service signature of the served node, and "self-participation" is based on the submitted valid transaction vouchers. This can ensure that participants of different dimensions truly participate in the network consensus of the blockchain.
2. Multi-dimensional consensus vs single-dimensional consensus
In the past consensus design, only unilateral rights or computing power were used as factors for evaluating nodes to participate in the consensus. In the DPOP consensus mechanism, this multi-dimensional comprehensive evaluation is passed. Nodes participating in voting must not only provide proof of equity, but also proof of participation. So as to effectively avoid the problems of concentration of rights and collective evil that are easily caused by a single consensus mechanism.
3. Promote ecological prosperity and symbiosis
The design of the DPOP consensus mechanism makes the different node types in the distributed environment not only the participants in the network, but also the producers. The rights and interests obtained by the nodes participating in the consensus will reversely promote the enthusiasm of the nodes, thus creating a virtuous ecological cycle mechanism. .
In addition, under this design, the intention of returning rights and interests to individuals through blockchain technology is truly realized. It is conceivable that through BFChain with the DPOP consensus mechanism as the soul, the prototype of the fair and just credit era will be presented more vividly.