为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

区块链共识失败的原因,区块链共识失败案例

发布时间:2023-12-06-06:26:00 来源:网络 区块链知识 区块   共识

区块链共识失败的原因,区块链共识失败案例


请查看相关英文文档

A. What is blockchain expansion

Expansion is when a container or carrier is not enough to support or carry the needs of existing things, we expand the container A means of increasing the capacity or volume of a load to meet increasing demand, thereby alleviating the pressure on the current container or load.
At the beginning of the birth of Bitcoin, Bitcoin founder Satoshi Nakamoto did not specifically limit the size of blocks. The maximum block size could reach 32MB. At that time, the average block size was 1~2KB.
At that time, there were few Bitcoin users and the transaction volume was not that large, which did not cause block congestion. However, with the linear rise in the price of Bitcoin from 2013 to the present, more and more users have caused congestion on the Bitcoin network. The problem of rising user transaction fees gradually emerged.
Up to now, there is a backlog of hundreds of thousands of transactions on the Bitcoin blockchain at its peak. The average transaction fee of Bitcoin has increased 376 times since September 2010. The processing speed of 7 transactions per second is obviously too high. To meet user needs, the Bitcoin community began to explore how to “expand” Bitcoin.
By modifying the underlying code of Bitcoin, the purpose of improving transaction processing capabilities is achieved.
There are two development and design solutions for Bitcoin expansion itself, namely first-layer and second-layer expansion technologies.
· The first layer of expansion technology is to improve the blockchain itself, making the blockchain itself faster and larger in capacity. In general, it is to change the content of the consensus part of the blockchain.
· The purpose of the second-layer expansion technology is to move calculations off-chain, that is, to solve problems through side-chain technology.
Expansion protocol and outcome
Expansion protocol generally requires the support of miners, and can be roughly divided into methods such as modifying the block size, soft fork, hard fork, and segregated witness.
Take Bitcoin as an example:
Bitcoin is now split into the large block Bitcoin Cash (BCH) and Segregated Witness. Segregated Witness is now recognized as Bitcoin in the market, and the big block coin is named Bitcoin Cash. It is foreseeable that in the future development direction, Bitcoin will be dominated by off-chain transactions. Including Lightning Network and side chains. These two new things are currently immature, but many people have high hopes.
Bitcoin will develop a large number of Segregated Witness transactions and make more derivative technologies based on Segregated Witness. It is most likely that technology will drive Bitcoin forward.
Bitcoin Cash will focus on on-chain transactions, focus on developing currency functions, reduce transaction friction as the main method, and profit from a wider range of on-chain users as the main development direction.
The Xueshuo Innovation Blockchain Technology Workstation under Lianqiao Education Online is the only approved "Blockchain Technology Professional" pilot of the "Smart Learning Workshop 2020- Xueshuo Innovation Workstation" launched by the School Planning, Construction and Development Center of the Ministry of Education of China. workstation. The professional base provides students with diversified growth paths and promotes the reform of the training model integrating professional degree research, production, and research.Build an application-oriented and compound talent training system.

B. How to understand the consensus mechanism in the blockchain

The so-called consensus simply means that everyone has reached an agreement.

In the blockchain, it is actually a rule. Each node confirms its own data according to this rule, and finally maintains the consistency of the database of the entire network.

If we take an example from life, for example, the company held a meeting today, but since the boss is not here, everyone needs to discuss and decide whether to do a project.

In such a leaderless environment?

C. Several major blockchain consensus mechanisms and their advantages and disadvantages

First of all, no consensus mechanism is perfect, and each consensus mechanism has Its advantages and disadvantages, some consensus mechanisms are born to solve some specific problems.
1.pow (Proof of Work) Proof of Work
One sentence introduction: The more you work, the more you receive.
Relying on machines to perform mathematical operations to obtain accounting rights, the resource consumption is higher than other consensus mechanisms and the supervision is weak. At the same time, each time a consensus is reached, the entire network needs to participate in the operation. The performance efficiency is relatively low, and fault tolerance is not allowed. 50% of the nodes in the entire network are faulty.
Advantages:
1) The algorithm is simple and easy to implement;
2) Nodes can reach consensus without exchanging additional information;
3) Destroying the system requires a huge cost ;
Disadvantages:
1) Waste of energy;
2) Block confirmation time is difficult to shorten;
3) The new blockchain must find a different hashing algorithm , otherwise you will face Bitcoin’s computing power attack;
4) It is easy to produce forks and need to wait for multiple confirmations;
5) There is never finality, and a checkpoint mechanism is needed to make up for finality;
br />2.POS Proof of Stake, Proof of Stake
In one sentence: the more you hold, the more you get.
The main idea is that the difficulty of obtaining node accounting rights is inversely proportional to the equity held by the node. Compared with PoW, the resource consumption caused by mathematical operations is reduced to a certain extent, and the performance has been improved accordingly, but it is still The method of obtaining accounting rights based on hash operation competition has weak supervision. The fault tolerance of this consensus mechanism is the same as PoW. It is an upgraded consensus mechanism of Pow. According to the proportion of tokens and time occupied by each node, the mining difficulty is reduced in an equal proportion, thereby speeding up the speed of finding random numbers
Advantages: shortened to a certain extent The time it takes to reach consensus; there is no longer a need to consume a lot of energy for mining.
Disadvantages: Mining is still required, which essentially does not solve the pain points of commercial applications; all confirmations are only probabilistic expressions, not deterministic things. In theory, there may be other attacks. For example, the DAO attack on Ethereum causedThe hard fork of Ethereum, and the emergence of ETC from this incident, actually proved the failure of this hard fork.
The principle of DPOS is the same as that of POS, except that some "people's congress representatives" are selected.
The BitShares community first proposed the DPoS mechanism.
The main difference from PoS is that nodes elect several agents, who verify and keep accounts. Its compliance supervision, performance, resource consumption and fault tolerance are similar to PoS. Similar to board voting, currency holders vote for a certain number of nodes to perform verification and accounting on their behalf.
The working principle of DPoS is:
Decentralization means that each shareholder has influence according to the proportion of his shareholding, and the result of the vote of 51% shareholders will be irreversible and binding. The challenge is to achieve 51% approval in a timely and efficient manner. To achieve this goal, each shareholder may grant his or her voting rights to a representative. The top 100 representatives with the most votes take turns to generate blocks according to a set schedule. Each representative is assigned a time slot to produce blocks. All representatives will receive compensation equal to 10% of the transaction fees included in an average block. If an average block contains 100 shares as a transaction fee, a representative will receive 1 share as compensation.
Network delays may prevent some representatives from broadcasting their blocks in time, which will cause the blockchain to fork. However, this is unlikely to happen because representatives of the manufacturing block can have direct connections with representatives of the pre- and post-manufacturing blocks. The purpose of establishing this direct connection to the rep after you (and perhaps the rep after you) is to ensure that you get paid.
This mode can generate a new block every 30 seconds, and the possibility of a blockchain fork under normal network conditions is extremely small, and even if it occurs, it can be resolved within a few minutes.
Become a representative:
To become a representative, you must register your public key on the network and then be assigned a 32-bit unique identifier. This identifier is then referenced in the "header" of each transaction data.
Authorization votes:
Each wallet has a parameter setting window in which the user can select one or more representatives and rank them. Once set up, every transaction a user makes will move votes from "Input Representatives" to "Output Representatives". Generally, users will not create transactions specifically for the purpose of voting because that will cost them a transaction fee. But in an emergency, some users may find it worthwhile to pay a fee to change their vote in a more positive way.
Keep representatives honest:
Each wallet will display a status indicator to let users know how their representatives are performing. If they miss too many blocks, the system will recommend the user to switch to a new representative. If any representative is found to have signed an invalid block, all standard wallets will require the election of a new representative before each wallet can conduct further transactions.
Resistant to attacks:
In terms of resisting attacks, because the power rights obtained by the top 100 representatives are the same, each representative has an equal voting right. Therefore, power cannot be concentrated in a single representative by gaining more than 1% of the vote. Since there are only 100 representatives, it is conceivable that an attacker could perform a denial of service attack on each representative whose turn it is to produce a block in turn. Fortunately, the threat of this particular attack is easily mitigated due to the fact that each representative is identified by his public key rather than his IP address. This will make it more difficult to identify the target of a DDOS attack. The potential direct connection between representatives will make it more difficult to prevent them from producing blocks.
Advantages: Significantly reduces the number of nodes participating in verification and accounting, and can achieve second-level consensus verification.
Disadvantages: The entire consensus mechanism still relies on tokens, and many commercial applications do not require the existence of tokens.
3.PBFT: Practical Byzantine Fault Tolerance, Practical Byzantine Fault Tolerance
Introduction: It provides (n-1)/3 fault tolerance on the premise of ensuring liveness & safety.
In distributed computing, different computers try to reach a consensus through message exchange; but sometimes, the coordination computer (Coordinator/Commander) or member computer (Member/Lieutanent) on the system may exchange errors due to system errors. messages, affecting the final system consistency.
The Byzantine Generals Problem looks for possible solutions based on the number of faulty computers. This cannot find an absolute answer, but it can only be used to verify the effectiveness of a mechanism.
The possible solution to the Byzantine problem is:
Consistency is possible in the case of N ≥ 3F + 1. Among them, N is the total number of computers, and F is the total number of problematic computers. After information is exchanged between computers, each computer lists all the information obtained and uses the majority of the results as a solution.
1) System operation can be separated from the existence of coins. Each node of the pbft algorithm consensus is composed of business participants or supervisors, and security and stability are guaranteed by business stakeholders.
2) The consensus delay is about 2 to 5 seconds, which basically meets the requirements of commercial real-time processing.
3) The consensus efficiency is high and can meet the needs of high-frequency transaction volume.
Disadvantages:
1) When 1/3 or more of the bookkeepers stop working, the system will not be able to provide services;
2) When 1/3 or more of the bookkeepers jointly commit evil , and when all other bookkeepers are divided into two network islands, malicious bookkeepers can cause the system to fork, but will leave cryptographic evidence
Let’s talk about two domestic ones~
4.dBFT: delegated BFT authorizes ByzantineByzantine Fault Tolerance Algorithm
Introduction: The dBFT mechanism adopted by Xiaoyi selects bookkeepers based on equity, and then the bookkeepers reach a consensus through the Byzantine Fault Tolerance Algorithm.
This algorithm has made the following improvements based on PBFT:
Improved the request response mode of the C/S architecture into a peer-to-peer node mode suitable for P2P networks;
Modified the static consensus participating nodes Improved to a dynamic consensus participating node that can dynamically enter and exit;
A voting mechanism based on the proportion of equity held is designed for the generation of consensus participating nodes, and consensus participating nodes (accounting nodes) are determined through voting;
/>Introducing digital certificates into the blockchain solves the problem of authenticating the true identity of accounting nodes in voting.
Advantages:
1) Professional bookkeeper;
2) Can tolerate any type of errors;
3) Bookkeeping is completed by multiple people, each block All are final and will not fork;
4) The reliability of the algorithm has strict mathematical proof;
Disadvantages:
1) When 1/3 or more bookkeepers stop working Afterwards, the system will be unable to provide services;
2) When 1/3 or more of the bookkeepers jointly commit evil, and all other bookkeepers are divided into two network islands, the malicious bookkeeper can use The system bifurcates, but cryptographic evidence will be left;
In summary, the core point of the dBFT mechanism is to ensure the finality of the system to the greatest extent, so that the blockchain can be suitable for real financial applications Scenes.
5.POOL verification pool
Based on traditional distributed consistency technology, plus data verification mechanism.
Advantages: It can work without tokens. Based on mature distributed consensus algorithms (Pasox, Raft), it can achieve second-level consensus verification.
Disadvantages: The degree of decentralization is not as good as bictoin; it is more suitable for a multi-center business model with multi-party participation.

D. What are the challenges in the application of blockchain technology in the Internet of Things?

What are the challenges in the application of blockchain technology in the Internet of Things
Blockchain in Challenges in the Internet of Things include but are not limited to the following three points:
1. The deployment and implementation of blockchain are jointly participated by multiple nodes, but the storage and computing capabilities of Internet of Things nodes have certain limitations. . Therefore, the deployment of blockchain technology in IoT nodes, whether the blockchain architecture is hierarchical, and issues that need to be strengthened in existing blockchain technology all need to be taken into consideration.
2. The Internet of Things will be real-time, and the blockchain consensus mechanism generally has delay problems. Therefore, consensus delay may cause feedback delay and alarm delay, which cannot meet the needs of existing IoT applications and requires further technical improvements.
3. The current application of blockchain in the Internet is only carried out within a certain range and limited nodes. Once blockchain is applied to the Internet of Things, the number of nodes willIncreasing exponentially, its frequent relational data query requests will pose very serious challenges to the existing chained data architecture.
In today's society, new technologies and industries are emerging around the world, and network technology is being transformed into productivity at an unprecedented speed. The development prospects of the Internet of Things are broad, but it faces many historical opportunities and challenges; the application of blockchain in the Internet of Things can, to a certain extent, solve the problems and new needs faced by the Internet of Things.

E. Consensus mechanism of blockchain

1. The goal of blockchain consensus mechanism

What is blockchain? Simply put, blockchain is a decentralized database, or it can be called a distributed ledger. Traditionally, all databases are centralized. For example, a bank's ledger is stored in the bank's central server. The disadvantage of a centralized database is that the security and accuracy of the data depend entirely on the database operator (i.e., the bank), because anyone who has access to the centralized database (such as bank employees or hackers) can destroy or modify the data in it.


Blockchain technology allows databases to be stored on thousands of computers around the world. Everyone’s ledger is synchronized through a peer-to-peer network, and anyone in the network can Once a user adds a transaction, the transaction information will be notified to other users through the network for verification and recorded in their respective ledgers. Blockchain gets its name because it is a data structure composed of blocks containing transaction information linked in an orderly manner from back to front.


Many people’s question about blockchain is that if each user has an independent ledger, does it mean that he can add items to his own ledger? Arbitrary transaction information, and how can thousands of ledgers ensure the consistency of accounting? Solving the problem of accounting consistency is the goal of the blockchain consensus mechanism. The blockchain consensus mechanism aims to ensure that the data in all nodes in the distributed system are exactly the same and can reach agreement on a certain proposal (for example, a transaction record). However, due to the introduction of multiple nodes in a distributed system, various very complex situations will occur in the system; as the number of nodes increases, node failure or failure, network communication between nodes is interfered or even blocked, etc. In addition to common problems, solving various boundary conditions and unexpected situations in distributed systems also increases the difficulty of solving distributed consistency problems.


Blockchain can be divided into three types:


Public chain: full Anyone in the world can enter the system at any time to read data, send confirmed transactions, and compete for accounting in the blockchain. Public blockchains are generally considered "completely decentralized" because no one or institution can control or tamper with the reading and writing of data in it.. Public chains generally encourage participants to compete for accounting through a token mechanism to ensure data security.


Alliance chain: Alliance chain refers to a blockchain in which several institutions jointly participate in management. Each institution runs one or more nodes, and the data in it only allows different institutions within the system to read, write and send transactions, and jointly record transaction data. This type of blockchain is considered “partially decentralized.”


Private chain: refers to a blockchain whose write permission is controlled by an organization or institution. The qualifications of participating nodes will be strictly restricted. Since the participating nodes are limited and controllable, private chains can often have extremely fast transaction speeds, better privacy protection, lower transaction costs, and are not prone to malicious attacks. , and can meet the necessary requirements of the financial industry such as identity authentication. Compared with centralized databases, private chains can prevent single nodes within an organization from deliberately concealing or tampering with data. Even if an error occurs, the source can be quickly discovered, so many large financial institutions are currently more inclined to use private chain technology.

2. Classification of blockchain consensus mechanisms

The difficulty of solving distributed consistency problems has given rise to several consensus mechanisms, each of which has its own advantages and disadvantages, and is also suitable for different environment and issues. The consensus mechanisms that are common knowledge include:


l PoW (Proof of Work) workload proof mechanism

l PoS (Proof of Stake) ) Equity/Equity Proof Mechanism

l DPoS (Delegated Proof of Stake) Share Authorization Proof Mechanism

l PBFT (Practical Byzantine Fault Tolerance) Practical Byzantine Fault Tolerance Algorithm

l DBFT (Delegated Byzantine Fault Tolerance) Authorized Byzantine Fault Tolerance Algorithm

l SCP (Stellar Consensus Protocol) Stellar Consensus Protocol

l RPCA (Ripple Protocol Consensus Algorithm) Ripple Consensus Algorithm

p>

l Pool verification pool consensus mechanism


(1) PoW (Proof of Work) workload proof mechanism

< br />

1. Basic introduction


In this mechanism, every node on the network is using the SHA256 hash function to calculate the hash sum of a constantly changing block header. Consensus requires that the calculated value must be equal to or less than a given value. In a distributed network, all participants need to continuously calculate the hash value using different random numbers until the goal is reached. When one node calculates an exact value, all other nodes must confirm with each other that the value is correct. Transactions in new blocks will then be verified to prevent fraud.


In Bitcoin, the above nodes that calculate hash values ​​are called "miners", and the PoW process is called "mining". Mining is a time-consuming process, so incentives have been proposed (such as granting miners a small share of Bitcoin). The advantage of PoW is complete decentralization, but its disadvantage is the waste of resources caused by consuming a lot of computing power, the cycle of reaching consensus is also relatively long, and the consensus efficiency is low, so it is not very suitable for commercial use.



2. Application examples of cryptocurrency


Bitcoin and Litecoin. The first three phases of Ethereum (Frontier, Homestead, and Metropolis) all adopt the PoW mechanism, and its fourth phase (Serenity) will adopt the proof-of-stake mechanism. PoW is suitable for public chains.


Although the PoW mechanism has successfully proved its long-term stability and relative fairness, under the existing framework, using the "mining" form of PoW will consume A lot of energy. The energy it consumes is just to continuously perform SHA256 calculations to ensure fair workload, and has no other meaning of existence. The current transaction efficiency that BTC can achieve is about 5TPS (5 transactions/second). Ethereum is currently subject to the upper limit of the total amount of GAS in a single block, and the transaction frequency that can be achieved is about 25TPS, which is the same as the average thousand times per second and peak performance. There is a huge difference between VISA and MASTERCARD, which can achieve processing efficiency of 10,000 times per second.


3. Simple diagram understanding mode



(ps: The process of calculating hash values ​​by A, B, C, and D is "mining". In order to reward the time cost, the mechanism will use a certain number of Bitcoins as incentives.)


(Ps: PoS moduleUnder the formula, your "mining" income is proportional to your currency age (number of coins * number of days), and has nothing to do with the computing performance of your computer. We can think of any accumulation of probabilistic events as proof of work, such as gold mining. Assuming that the gold content of the ore is p% mass, when you get a certain amount of gold, we can think that you must have dug 1/p mass of ore. And the more gold you get, the more reliable the proof is. )


(2) PoS (Proof of Stake) Equity/Proof of Equity Mechanism


1. Basic introduction


PoS requires people to prove ownership of the currency amount. It believes that people with a large amount of currency are less likely to attack the network. Selection based on account balance is very unfair, as the single richest person is bound to dominate the network, so many solutions have been proposed.


In the proof-of-stake mechanism, whenever a block is created, miners need to create a transaction called "coin rights", which will be determined according to a certain Proportionately sends some coins to miners in advance. Then the equity proof mechanism reduces the mining difficulty of nodes in equal proportions based on the proportion and time of tokens held by each node (coin age) according to the algorithm, so as to speed up the node's search for random numbers and shorten the time required to reach consensus.


Compared with PoW, PoS can save more energy and be more efficient. But since the mining cost is close to 0, it may be vulnerable to attacks. And PoS still essentially requires nodes in the network to perform mining operations, so it is also difficult to apply in the commercial field.



2. Application examples of digital currency


The more mature digital currencies under the PoS mechanism are Peercoin and NXT. Compared with PoW, the PoS mechanism saves energy and introduces the concept of "coin days" to participate in random operations. The PoS mechanism allows more currency holders to participate in the accounting work without the need to purchase additional equipment (mining machines, graphics cards, etc.). The computing power of each unit token is positively related to the length of time it is held. That is, the more tokens a holder holds and the longer the time, the greater the probability that the holder can sign and produce the next block. Once it signs the next block, the currency days held by the currency holder will be cleared and a new cycle will be re-entered.


PoS is suitable for public chains.


3.How block signers are generated


Under the PoS mechanism, because block signers are randomly generated, some currency holders will Hold the tokens to obtain a greater probability of generating blocks and clear as many of his "coin days" as possible. Therefore, the number of circulating tokens in the entire network will decrease, which is not conducive to the circulation of tokens on the chain, and prices will be more susceptible to fluctuations. Since there may be a small number of large investors holding most of the tokens in the entire network, the entire network may become more and more centralized as the running time increases. Compared with PoW, the cost of doing evil under the PoS mechanism is very low, so for forking or double-spending attacks, more mechanisms are needed to ensure consensus. Under stable conditions, approximately 12 transactions can be generated per second, but due to network delays and consensus issues, it takes about 60 seconds to fully broadcast the consensus block. In the long run, the speed of generating blocks (that is, clearing "coin days") is much lower than the speed of network propagation and broadcasting. Therefore, under the PoS mechanism, it is necessary to "limit the speed" of generated blocks to ensure the stability of the main network. run.


4. Simple diagram understanding mode




(PS: The more “shares” you own, the easier it is for you to obtain account rights. It refers to how much currency you get, which depends on the workload you contribute to mining and the performance of your computer. The better, the more mines will be allocated to you.)


(In a pure POS system, such as NXT, there is no mining process, and the initial equity The distribution has been fixed, and then only the equity is transferred among traders, very similar to stocks in the real world.)


(3) DPoS (Delegated Proof of Stake) ) Share authorization certification mechanism


1. Basic introduction


Due to various disadvantages of PoS , thus the DPoS (Delegated Proof of Stake), the first equity representation mechanism pioneered by BitShares, came into being. The core element of the DPoS mechanism is election. Holders of each system's native tokens can participate in elections in the blockchain, and the balance of the tokens they hold is the voting weight. Through voting, shareholders can elect board members and express their attitudes on issues related to the development direction of the platform, all of which form the basis of community autonomy. In addition to voting in elections themselves, shareholders can also vote on their behalf by authorizing their election votes to other accounts they trust.


Specifically, DPoS was invented by the Bitshares project team. Stakeholders elect their representatives to generate and verify blocks. DPoS is similar to a modern corporate board of directors system. The BitShares system calls token holders shareholders, and shareholders vote to elect 101 representatives. These representatives are then responsible for generating and verifying blocks. If a currency holder wants to be called a representative, he must first use his public key to register on the blockchain and obtain a unique 32-bit identity identifier. Shareholders can vote on this identifier in the form of transactions and get votes. The top 101 people were selected as representatives.

Representatives take turns to generate blocks, and the profits (transaction fees) are equally divided. The advantage of DPoS is that it greatly reduces the number of nodes participating in block verification and accounting, thereby shortening the time required for consensus verification and greatly improving transaction efficiency. From a certain perspective, DPoS can be understood as a polycentric system, which has the advantages of both decentralization and centralization. Advantages: It greatly reduces the number of nodes participating in verification and accounting, and can achieve second-level consensus verification. Disadvantages: Voting enthusiasm is not high, and most token holders do not participate in voting; in addition, the entire consensus mechanism still relies on tokens, and many commercial applications do not require the existence of tokens.


The DPoS mechanism requires that before generating the next block, it must be verified that the previous block has been signed by a trusted node. Compared with PoS's "National Mining", DPoS uses a system similar to the "Congress" to directly select trusted nodes, and these trusted nodes (i.e. witnesses) exercise power on behalf of other currency holders. Witnesses Nodes are required to be online for a long time, thus solving a series of problems such as delays in block production that may be caused by PoS block signers not always being online. The DPoS mechanism can usually reach a transaction speed of 10,000 transactions per second, and can reach the level of 100,000 seconds when the network delay is low, which is very suitable for enterprise-level applications. Because Gongxinbao Data Exchange has high requirements for data transaction frequency and long-term stability, DPoS is a very good choice.



2. Institutions and systems under the share authorization certification mechanism


The board of directors is the authority of the blockchain network. The candidates for the board of directors are elected by system shareholders (i.e. currency holders). Board members have the right to initiate motions and vote on motions.


One of the important responsibilities of the Board of Directors is to adjust the variable parameters of the system as needed. These parameters include:


l Fee related: rates for various transaction types.

l Authorization related: access to the networkThird-party platform charging and subsidy related parameters.

l Block production related: block production interval, block reward.

l Identity review related: review and verify the information of abnormal institutional accounts.

l At the same time, matters related to the interests of the Board of Directors will not be set by the Board of Directors.


In the Finchain system, witnesses are responsible for collecting various transactions broadcast when the network is running and packaging them into blocks. Their work is similar to that of the Bitcoin network In the Bitcoin network that adopts PoW (Proof of Work), a lottery method in which the probability of winning depends on the hash power determines which miner node generates the next block. In a financial chain network that adopts the DPoS mechanism, the number of witnesses is determined by voting by the board of directors, and the candidates for the witnesses are determined by voting by currency holders. The selected active witnesses package transactions and produce blocks in order. After each round of block production, the witnesses will randomly shuffle the cards to determine the new order before entering the next round of block production.


3. Application examples of DPoS


Bitshares uses DPoS. DPoS is mainly suitable for alliance chains.


4. Simple diagram understanding mode





(4) PBFT (Practical Byzantine Fault Tolerance) Practical Byzantine Fault Tolerance Algorithm


1. Basic introduction


PBFT is an algorithm based on strict mathematical proof, which requires three stages of information interaction and local consensus to achieve the final unanimous output. The three stages are pre-prepare, prepare, and commit. The PBFT algorithm proves that as long as there are more than 2/3 normal nodes in the system, it can ensure that a consistent consensus result can be output in the end. In other words, in a system using the PBFT algorithm, it can tolerate no more than 1/3 of the total number of nodes in the system (including nodes that intentionally mislead, intentionally damage the system, time out, repeatedly send messages, forge signatures, etc., also known as " Byzantium" node).



2. PApplication examples of BFT


The famous alliance chain Hyperledger Fabric v0.6 uses PBFT, and v1.0 launched an improved version of PBFT, SBFT. PBFT is mainly suitable for private chains and consortium chains.


3. Simple diagram understanding mode




The above figure shows a simplified PBFT protocol communication model, where C is the client, 0 – 3 represents the service node, where 0 is the master node and 3 is the fault node . The basic process of the entire protocol is as follows:


(1) The client sends a request to activate the service operation of the master node;

(2) When the master node receives the request, it starts a three-phase protocol to broadcast the request to each slave node;

(a) Sequence number allocation phase, the master node assigns a sequence number n to the request, broadcasts the sequence number allocation message and the client's request message m, and will construct a pre-prepare message to each slave node;

(b) In the interaction phase, the slave node receives the pre-prepare message and broadcasts the prepare message to other service nodes;

(c) In the sequence number confirmation phase, after each node verifies the request and sequence in the view, it broadcasts the commit message, executes the received client request and responds to the client.

(3) The client waits for responses from different nodes. If m+1 responses are the same, the response is the result of the operation;



p>


(5) DBFT (Delegated Byzantine Fault Tolerance) authorized Byzantine fault tolerance algorithm


1. Basic introduction


DBFT is based on PBFT. In this mechanism, there are two types of participants, one is the "super node" who specializes in accounting , one is an ordinary user in the system who does not participate in accounting. Ordinary users vote for super nodes based on the proportion of their equity holdings. When a consensus (accounting) needs to be passed, a spokesperson is randomly selected among these super nodes to formulate a plan, and then other super nodes use Byzantine fault tolerance to algorithm (see above), that is, the principle of majority submission. If more than 2/3 of the super nodes agree with the speaker plan, a consensus is reached. This proposal becomes the finalThe published block is irreversible and all transactions in it are 100% confirmed. If a consensus proposal has not been reached within a certain period of time, or if illegal transactions are discovered, other super nodes can reinitiate the proposal and repeat the voting process until a consensus is reached.



2. Application examples of DBFT


NEO, a domestic cryptocurrency and blockchain platform, is the developer and adopter of the DBFT algorithm.


3. Simple diagram understanding mode




Assume that there are only four super nodes in the system voted by ordinary users. When a consensus needs to be passed, the system will randomly select one of the representatives to speak. People make plans. The spokesperson will hand over the prepared plan to each representative. Each representative will first determine whether the speaker's calculation results are consistent with their own records, and then discuss with other representatives to verify whether the calculation results are correct. If 2/3 of the representatives unanimously agree that the calculation results of the speaker's plan are correct, then the plan is passed.


If less than 2/3 of the representatives reach a consensus, a new speaker will be randomly selected and the above process will be repeated. This system is designed to protect the system from leaders who are unable to function.


The above figure assumes that all nodes are honest and reach 100% consensus, and plan A (block) will be verified.



Given that the spokesperson is a randomly selected representative, he may be dishonest or malfunctioning . The above figure assumes that the spokesperson sends malicious messages to 2 of the 3 representatives (scenario B), and at the same time sends a correct message to 1 representative (scenario A).


In this case, the malicious information (Option B) cannot pass. The calculation results of the representatives in the middle and on the right were inconsistent with those sent by the spokesperson, so they could not verify the plan drawn up by the spokesperson, causing the two people to reject the plan. The representative on the left received correct information that was consistent with his own calculation results, so he was able to confirm the plan and successfully completed a verification. However, this plan still failed to pass because less than 2/3 of the representatives reached a consensus. A new spokesperson will then be randomly selected and the consensus process will begin again.




The above figure assumes that the spokesperson is honest, but one of the representatives has an abnormality; the representative on the right sends incorrect information to the other representatives (B).


In this case, the correct information (A) formulated by the speaker can still be verified, because both the honest representatives on the left and the middle can verify that the correct information (A) formulated by the spokesperson The plan drawn up by the spokesperson reached a 2/3 consensus. The representative can also determine whether the speaker is lying to the node on the right or the node on the right is being dishonest.


(6) SCP (Stellar Consensus Protocol) Stellar Consensus Protocol


1. Basic introduction


SCP is a consensus algorithm developed and used by Stellar (a decentralized global payment protocol based on the Internet). It is based on the Federated Byzantine Agreement ( Federated Byzantine Agreement). Although traditional non-federated Byzantine protocols (such as PBFT and DBFT above) ensure that consensus can be reached through distributed methods and achieve Byzantine fault tolerance (can tolerate at most failed nodes that do not exceed 1/3 of the total number of nodes in the system), it is a Centralized system - The number and identity of nodes in the network must be known and verified in advance. The difference of the Federated Byzantine Agreement is that it can be decentralized and Byzantine fault-tolerant at the same time.


[…]


(7) RPCA (Ripple Protocol Consensus Algorithm) Ripple Consensus algorithm


1. Basic introduction


RPCA is Ripple (an Internet-based Open source payment protocol, which can realize decentralized currency exchange, payment and settlement functions) consensus algorithm developed and used. In Ripple's network, transactions are initiated by the client (application) and broadcast to the entire network through the tracking node or validating node. The main function of the tracking node is to distribute transaction information and respond to client ledger requests. In addition to all the functions of the tracking node, the verification node can also add new ledger instance data to the ledger through the consensus protocol.


RippleThe consensus is reached between verification nodes. Each verification node is pre-configured with a list of trusted nodes, called UNL (Unique Node List). Nodes on the list can vote on the transaction. The consensus process is as follows:


(1) Each verification node will continuously receive transactions sent from the network. After verification with the local ledger data, they are illegal. The transactions will be discarded directly, and the legal transactions will be summarized into a transaction candidate set (candidate set). The transaction candidate set also includes transactions left over from the previous consensus process that could not be confirmed.

(2) Each verification node sends its own transaction candidate set as a proposal to other verification nodes.

(3) After the verification node receives a proposal from other nodes, if it is not from a node on UNL, it will ignore the proposal; if it is from a node on UNL, it will compare it with the proposal. Transaction and local transaction candidate set, if there is the same transaction, the transaction gets one vote. Within a certain period of time, when a transaction receives more than 50% of the votes, the transaction enters the next round. Transactions that do not exceed 50% will be left for the next consensus process to be confirmed.

(4) The verification node sends transactions with more than 50% of the votes as proposals to other nodes, and at the same time increases the threshold of the required votes to 60%, repeating steps (3) and (4) until the threshold Reach 80%.

(5) The verification node formally writes the transactions confirmed by 80% UNL nodes into the local ledger data, which is called the last closed ledger, which is the last (latest) status of the ledger.


In Ripple's consensus algorithm, the identities of participating voting nodes are known in advance. Therefore, the algorithm is more efficient than anonymous consensus algorithms such as PoW. Transactions The confirmation time only takes a few seconds. This also determines that the consensus algorithm is only suitable for alliance chains or private chains. The Byzantine Fault Tolerance (BFT) capability of the Ripple consensus algorithm is (n-1)/5, which means it can tolerate Byzantine errors in 20% of the nodes in the entire network without affecting the correct consensus.



2. Simple diagram understanding mode


Schematic diagram of node interaction in the consensus process:



Consensus algorithm process:

< br />


(8) POOL verification pool consensus mechanism


The Pool verification pool consensus mechanism is a mechanism developed based on traditional distributed consensus algorithms (Paxos and Raft). The Paxos algorithm is a consensus algorithm based on message passing and highly fault-tolerant proposed in 1990. In the past, Paxos has been the standard for distributed protocols, but Paxos is difficult to understand and even more difficult to implement. Raft is a consensus algorithm released in 2013 that is simpler than Paxos and can realize the problems solved by Paxos. The process of reaching consensus in Paxos and Raft is like an election. Candidates need to convince the majority of voters (servers) to vote for them and follow their actions once selected. The difference between Paxos and Raft lies in the specific process of election. The Pool verification pool consensus mechanism is based on these two mature distributed consensus algorithms, supplemented by a data verification mechanism.






F. Consensus mechanism of blockchain

1. How to confirm and reach consensus on transaction information on the network?

Although the consensus mechanism is often mentioned, the meaning and understanding of the consensus mechanism are not clear. Therefore, it is necessary to understand the relevant concepts, principles and implementation methods of the consensus mechanism.

The transaction information of the blockchain is transmitted to each node in the network through network broadcast. How to confirm the broadcast information and reach a consensus among the entire network nodes and finally write it into the block? If there is no corresponding reliable and secure implementation mechanism, it will be difficult to realize its basic functions. Therefore, the consensus mechanism is a key to the operation of the entire network.

The consensus mechanism solves the problem of how the blockchain can achieve consistency in a distributed scenario. The blockchain can reach a relatively balanced state among many nodes because of the consensus mechanism. So how does the consensus mechanism solve the problem of mutual trust between nodes based on the idea of ​​decentralization?

When the idea of ​​distribution was proposed, people began to design consensus algorithms based on the FLP theorem and the CAP theorem. Standardly speaking, the consistency of an ideal distributed system should meet the following three points:

1. Termination: The consistency result can be completed within a limited time.

2. Consensus: The final decision-making results of different nodes should be the same.

3. Legality (Validity): The result of the decision must be a proposal put forward by other processes.

However, in actual computer clusters, the following problems may exist:

1. Nodes have different transaction processing capabilities, and the data throughput of network nodes is different

2. The communication channel between nodes may be unsafe

3. There may be malicious nodes

4. When asynchronous processing capabilities reach a high degree of consistency, The scalability of the system will become worse (cannot tolerate the addition of new nodes).

Scientists believe that it is impossible to achieve complete consistency in a distributed scenario. However, engineers can sacrifice part of the cost in exchange for the consistency of distributed scenarios. The above two major theorems also have this idea. Therefore, various formula mechanisms based on blockchain design can be regarded as sacrificing part of the cost in exchange for more adaptability. My idea is to make a flexible transformation on this idea, that is, sacrificing part of the cost at the appropriate time and space in exchange for consistency adapted to the scene at that time, and a flexible blockchain system can be realized that is pluggable. Pull-out blockchain system. Today I will introduce my views and analysis on various consensus mechanisms. Distributed systems with or without malicious nodes are divided into Byzantine fault-tolerant and non-Byzantine fault-tolerant mechanisms.

The FLP theorem is the impossibility of FLP. It proves that in a distributed scenario, no matter any algorithm, even if only one process hangs up, there is an inability to reach consensus for other non-failed processes. possible.

FLP is based on the following assumptions:

Can only be modified once: Each process initially records a value (0 or 1). The process can receive messages, change the value, and send messages. When the process enters the decide state, the value will no longer change. The protocol ends successfully when all non-failed processes enter the decided state. This is relaxed to the extent that some processes enter the decided state, even if the agreement is successful.

Asynchronous communication: The biggest difference from synchronous communication is that there is no clock, no time synchronization, no timeout, no detection failure, messages can be delayed arbitrarily, and messages can be out of order.

Communication is robust: As long as the process does not fail, the message will be delayed indefinitely, but will eventually be delivered; and the message will only be delivered once (no duplication).

Fail-Stop model: A process failure is like a downtime and no more messages are processed.

Number of failed processes: At most one process fails.

CAP is a distributed system, especially a distributed storage system.The most discussed theory in the field of storage. CAP was proposed by Eric Brewer at the PODC meeting in 2000. It was a result of Eric Brewer's research on data consistency (consistency), service availability (availability), and partition fault tolerance (partition- tolerance) conjecture:

Data consistency (consistency): If the system returns success for a write operation, then subsequent read requests must read the new data; if the system returns failure, then all read operations No one can read this data. For the caller, the data has strong consistency (also called atomic and linearizable consistency) [5]

Service availability (availability) : All read and write requests are responded to within a certain period of time, can be terminated, and will not wait forever

Partition-tolerance: In the case of network partitions, the separated nodes can still function normally External services

If AP is satisfied at a certain moment, the separated nodes can provide external services at the same time but cannot communicate with each other, which will lead to inconsistent status, that is, C cannot be satisfied; if CP is satisfied, C will not be achieved in the case of network partitions , the request can only wait forever, that is, A is not satisfied; if CA is to be satisfied, the node status must be consistent within a certain period of time, and network partitions must not occur, then P cannot be satisfied.

C, A, and P can only satisfy at most two of them. Like the FLP theorem, the CAP theorem also indicates an unreachable result (impossibility result).

G. What is blockchain consensus

In Bitcoin and other blockchain coins, there is also the problem of how to reach consensus. In other words, the core issue of Bitcoin or other blockchain coins is how to reach consensus in a decentralized environment.

Blockchain is the core technology behind Bitcoin and the infrastructure that supports Bitcoin. Therefore, when talking about blockchain consensus, we must talk about Bitcoin consensus.

The core breakthrough of Bitcoin is to reach a consensus on transaction events in a decentralized manner, that is, to reach a consensus on the validity of a transaction without a central organization.

Bitcoin’s method of achieving this consensus mainly includes two parts:

Incentive; that is, motivating participants by generating a certain amount of new Bitcoins in each block;< br />Introducing external resources to ensure security; that is, through a large number ofExternal calculations are used to ensure the security of the consensus, which is Proof of Power;

This is also the method used by almost all PoW currencies. For example, DECENT, Litecoin, SandCoin, Dogecoin, and more.

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 36369 文章总数
  • 3637265访问次数
  • 3078建站天数