Discussion on the consensus mechanism of block chain __ block chain

Source: Internet
Author: User
Tags pow prepare
Preface

This article has done some introduction and own opinion to the common consensus mechanism in the block chain, welcome the advice.

The block chain solves the problem of transmitting the trusted information and value transfer on the untrusted channel, and the consensus mechanism solves the problem of how the block chain can reach the uniformity under the distributed scene. So I think the great of the block chain is that its consensus mechanism in the central to the mind to solve the problem of mutual trust between the nodes. The block chain can achieve a more balanced state in many nodes because of the consensus mechanism. Although cryptography occupies half of the block chain, consensus mechanism is the key to ensure the continuous operation of block chain system.

In fact, when the distributed ideas are presented, people begin to design consensus algorithms based on the FLP theorem and cap theorem. The specification says that the ideal distributed system consistency should meet the following three points: 1. Termination (termination): The results of consistency can be completed within a limited time. 2. Consensus (Consensus): The results of the final decision of the different nodes should be the same. 3. Legality (validity): The outcome of a decision must be a proposal made by other processes. However, in the actual cluster of computers, the following problems may exist: 1. Nodes have different ability to handle transactions, the throughput of network node data is different 2. Communication between nodes may not be secure 3. There may be evil nodes appearing 4. When the asynchronous processing capability is high, the scalability of the system becomes worse (the addition of the new node is not available).

Scientists believe that it is impossible to give full uniformity to distributed scenarios. But engineers can sacrifice a portion of the cost in return for the consistency of distributed scenarios, these two major theorems are also this idea, so the various formula mechanism based on block chain design can be regarded as sacrificing that part of the price in exchange for more suitable consistency, my idea is that in this kind of thinking can be a flexible transformation, That is, in the appropriate time space at the expense of a part of the cost to adapt to the scene at the time of consistency, you can achieve a flexible block chain system, plug-and-pull block chain system. Today I would like to introduce my views and analysis of the consensus mechanism, there are no evil nodes in the distributed system are divided into Byzantine fault-tolerant and non-Byzantine fault-tolerant mechanism. The following is an introduction to Byzantine fault-tolerant consensus algorithms: POW: Bitcoin, such as currency (public chain) (proof of work) , in bitcoin and other currency block chains, let each node agree on the consensus mechanism for work proof, also we said the mining.

The amount of work proved to be a hash of a first 23-bit 0, which became the nonce gold number, while the miners processed the transaction data (and hashed the data). When one of the miners hashes out of the nonce, he publishes the chunks he packs, and the other nodes will agree that the block is connected to the block chain and continue to pack and hash the next chunk. In this process, in the middle of the great God is through the calculation of power to sacrifice a part of the final consistency (because there will be a fork) and need to wait for multiple confirmation, but this simple method of violence to ensure the entire block chain system legitimacy, and the block chain system to maximize the robustness, Even if the whole network is left with only one node to run, the block chain system will continue to run. Finally POW also fully improve the security of the block chain system, rely on 51% attack theory to destroy the block chain system is only the government or the madman will take the method.

Advantages: Completely to the center of the node free access, easy to achieve. The cost of destroying the system is huge.

Disadvantage: The performance of the node network environment Requirements High cannot achieve final consistency of the most critical, waste of energy. Pos:bitshares and QUTM contract block chains (proof of stake) If you simply treat POW as a force, POS is much more than endurance.

POS is a unit (currency) based on the amount of money in the wallet and the number of days that the currency exists in the wallet. It is based on the currency of the relationship of the computer hash calculation to reduce the difficulty, reduce the threshold of the computer, but there is a certain requirement on the computer, it will be the wallet and block chain system consistency binding. The greater the number of coins in the wallet, the greater the probability of having the right to account. But the idea of solving problems like the POW mechanism also leads to the same flaws as POW, which sacrifices part of the consensus (the same bifurcation) and waits for multiple confirmations. Advantages: Low performance requirements for the node, short consensus time (the network environment is good to achieve millisecond) disadvantage: No final consistency Dpos is a more professional solution based on POS, which is similar to the voting mechanism of the board of directors, electing n billing nodes, The proposal submitted by the sponsor in the node is voted by these billing nodes to determine who is right.

Advantages: Reduce the size of the accounting node, belong to the weak center, improve efficiency. Disadvantage: Sacrificing the concept of going central, not suitable for the public chain.

The first three phases of the Ether square are Frontier (frontier), Homestead (Home), Metropolis (Metropolis). The fourth phase, the Serenity (Serenity), will use the POS mechanism. Casper: The first three stages of the ether square is the POW consensus mechanism, the fourth phase will use its own POS mechanism, known as betting consensus. This mechanism increases the penalty mechanism, and selects the authenticator in the accounting node based on the idea of Pos. For more details, see the violet Leather Book of Ether square. dbft: Small ant block Chain (delegated BFT, authorized Byzantine fault-tolerant mechanism) Use the right to select the bookkeeper, and then the accounting people through the Byzantine fault-tolerant algorithm to reach a consensus.

Advantages: Professional accounting people can tolerate any type of error accounting by a number of people in collaboration to complete, each block has a final, does not fork the reliability of the algorithm has strict mathematical proof disadvantage: when One-third or more of the accounting person to stop working, the system will not be able to provide services when one-third or more of the accounting person joint evil, And all the other accounting people just split into two network islands, malicious bookkeeper can make the system appear bifurcation, but will leave the cryptography evidence pbft:fabric use of the classical algorithm (Byzantine fault tolerance) This is a message-passing consistency algorithm, The algorithm is consistent over three phases, and these phases may be repeated for failure.

Assume that the total number of nodes is 3f+1,f for the Byzantine error node: When the node discovers that leader is doing evil, the other replica is elected as leader by the algorithm. Leader broadcasts its selected value to other replica nodes through Pre-prepare (the first Protocol stage) message, and the other replica node sends the prepare if it is accepted (the second Protocol phase) and does not send if it fails. Once the 2f node accepts the prepare message, the node sends a commit (third protocol phase) message. When a 2f+1 node accepts a commit message, the value is determined to indicate that the following figure represents 4 nodes, 0 is leader, and Node 3 is a fault node, which does not respond and emit any messages. When the final node state reaches commited, it indicates that the consensus has been successfully reached. Note: Pre-preparation stage (Pre-prepare): The master node assigns a serial number N to the received request, then prepares the message to all the backup nodes, and prepares the message in the format of <<pre-prepare,v,n,d>,m>, where V is the view number, M is the request message sent by the client, and D is the summary of the request message M. Preparation phase (Prepare): If the backup node I received the prepared message <<pre-prepare,v,n,d>,m>, then enter the preparation phase. At the same time as the preparation phase, the node sends ready message <PREPARE,V,N,D,I> to all replica nodes, and prepares the prepared message and prepares the message to its own message log. If you look at the preparation of the news is not pleasing to the eye, do nothing. Confirmation phase (Commit): When the (m,v,n,i) condition is true, copy I broadcasts <commit,v,n,d (m),i> to the other replica nodes, and then it goes to the confirmation stage.

Advantages: The above other algorithms are out of the existence of the currency, the existence of the currency and its reward mechanism will make the block chain this single world poor people poorer, richer people richer. Consensus efficiency, high frequency trading can be achieved. Disadvantage: The system will stop running when only 33% of the nodes in the system are running.

The consensus mechanism of non-Byzantine fault tolerant is not to consider the situation of malicious node, people consider the Paxos consensus algorithm proposed by Leslie Lamport in 1990, and realize a mechanism of maximizing the consistency of distributed system (the existence of a minimum probability cannot be achieved) in engineering perspective. Paxos The typical example of Paxos used in distributed systems is zookeeper, the first proven consensus algorithm based on two-phase commit and extension.

The Paxos algorithm divides the nodes into three types: proposer: Put forward a proposal and wait for everyone's approval to close the case. It is often the client who takes the role acceptor: to vote on a proposal. Often the server serves as the role learner: The defendant is informed of the result and is not involved in the voting process. A proposal may be made for the client or server-side base process including proposer, and first get the support of most acceptor, when more than half of the support, then send the result of the completion of the case for everyone to confirm. A potential problem is that proposer fails during this process and can be resolved by the time-out mechanism. Coincidentally, every new round of proposals is proposer, and the system will never be able to reach a consensus (a small probability). Paxos can ensure that the system can reach a consensus when more than 50% of the normal nodes exist. Paft The raft algorithm is a simple implementation of the Paxos algorithm.

It consists of three roles: leader, candiate and follower, the basic process of which is: Leader election: Each candidate at random time will propose the election plan, the most recent phase of the most votes were selected leader synchronization Log:leader Will find the log of the latest records in the system, and force all the follower to refresh to this record, where log refers to the occurrence of various events record pool verification pool: The fabric ratio block chain based on the traditional distributed consistency technology, coupled with data validation mechanism.

Advantages: Do not need tokens can also work, in the mature distributed consistency algorithm (Pasox, Raft) based on the realization of second-level consensus verification. Disadvantages: The degree of bictoin is not as good as the other, more suitable for multi-party business model participation.

Original address: https://bitshuo.com/topic/58ad85b108d6a0f32a5bc045

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.