WO2023016428A1 - Byzantine fault tolerance method and apparatus, and electronic device and storage medium - Google Patents

Byzantine fault tolerance method and apparatus, and electronic device and storage medium Download PDF

Info

Publication number
WO2023016428A1
WO2023016428A1 PCT/CN2022/111000 CN2022111000W WO2023016428A1 WO 2023016428 A1 WO2023016428 A1 WO 2023016428A1 CN 2022111000 W CN2022111000 W CN 2022111000W WO 2023016428 A1 WO2023016428 A1 WO 2023016428A1
Authority
WO
WIPO (PCT)
Prior art keywords
consensus
voting
proposal
value
voting value
Prior art date
Application number
PCT/CN2022/111000
Other languages
French (fr)
Chinese (zh)
Inventor
段斯斯
张海滨
Original Assignee
清华大学
山东区块链研究院
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 清华大学, 山东区块链研究院 filed Critical 清华大学
Publication of WO2023016428A1 publication Critical patent/WO2023016428A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast

Definitions

  • the present application relates to the field of computer technology, in particular, to a Byzantine fault tolerance method, device, electronic equipment and storage medium.
  • the Byzantine fault tolerance method based on binary consensus is one of the commonly used methods for dealing with Byzantine problems in distributed systems.
  • any consensus node in the distributed system will The consensus proposal proposed by each consensus node interacts with other consensus nodes to reach a consensus, and finally outputs the consensus result of each consensus proposal.
  • the consensus node usually cannot completely parallelize each consensus proposal. Therefore, the current Byzantine fault-tolerant method based on binary consensus has low consensus efficiency.
  • the embodiment of the present application provides a Byzantine fault tolerance method, device, electronic equipment and storage medium, which are used to solve the problem of low execution efficiency of the binary consensus-based Byzantine fault tolerance method in the prior art.
  • a Byzantine fault-tolerant method is provided, which is applied to any consensus node in a distributed system.
  • the distributed system includes at least N consensus nodes, and among the N consensus nodes, at most F malicious nodes are allowed, where N ⁇ 3f+1, the f is an integer greater than 0, and the method includes: broadcasting the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
  • the initial The voting value is determined as the priority voting value; if the re-voting binary consensus algorithm has been executed for the pending consensus proposal, and the consensus result of the pending consensus proposal has not been obtained, the initial voting of the pending consensus proposal The value is determined as the priority voting value;
  • the initial voting value of the pending consensus proposal that has not started to execute the re-voting binary consensus algorithm is determined as other voting value
  • a re-voting binary consensus algorithm is used to determine the consensus result.
  • a re-voting binary consensus algorithm is used to determine the consensus result, including:
  • the initial voting value will be used as the input of the re-voting binary consensus algorithm, and the output of the algorithm will be used as the consensus proposal consensus results.
  • the method further includes: after obtaining the consensus results of the N proposals to be agreed upon, determining a set consisting of at least one proposal to be agreed upon whose consensus result is a priority voting value as the set to be agreed upon;
  • a Byzantine fault-tolerant device which is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, and among the N consensus nodes, at most F malicious nodes are allowed, where N ⁇ 3f+1, the f is an integer greater than 0, and the device includes:
  • the communication module is used to broadcast the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
  • the processing module in the case of receiving a consensus proposal broadcast by any consensus node through the reliable broadcast RBC protocol, if the binary consensus algorithm that can be voted again has not been started for the consensus proposal, then the consensus proposal
  • the initial voting value of the proposal is determined as the priority voting value; if the re-voting binary consensus algorithm has been implemented for the pending consensus proposal, and the consensus result of the pending consensus proposal has not been obtained, the pending consensus proposal will be re-
  • the initial voting value of is determined as the priority voting value; in the case of receiving the consensus proposal broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposal that has not started to execute the re-voting binary consensus algorithm is determined as other Voting value; For any proposal to be consensus with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result.
  • the processing module is specifically configured to, for any proposal to be consensus, if it is determined that the proposal to be consensus has an initial voting value, the initial voting value is used as the voting value of the binary consensus algorithm that can be voted again. Input, take the output of the algorithm as the consensus result of the proposal to be consensused.
  • the re-voting binary consensus algorithm includes: a binary consensus that allows the input of any proposal to be consensus to be changed from other voting values to priority voting values, and the output consensus result is biased towards the priority voting value algorithm.
  • the processing module is also used to determine the set consisting of at least one proposal to be consensus whose consensus result is a priority voting value after obtaining the consensus results of the N proposals to be consensused as the set to be agreed upon; After all the pending consensus proposals in the consensus set, execute the pending consensus proposals in the set according to the preset order.
  • a computer device including a memory, a processor, a communication interface, and a computer program stored in the memory and operable on the processor, wherein the processor executes the When the program is described, the steps of the method described in the first aspect above are realized.
  • a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in the above-mentioned first aspect are implemented.
  • each consensus node broadcasts the local consensus proposals based on the reliable broadcast RBC protocol, and determines the initial voting value for each consensus proposal based on the local reception situation.
  • the meta-consensus algorithm determines the consensus results of each pending consensus proposal, so that the consensus nodes can completely parallelize the consensus processing for each pending consensus proposal, shortening the time-consuming of each consensus, improving the efficiency of the consensus, and further improving the efficiency of the distributed system. processing power.
  • FIG. 1 is a schematic structural diagram of an existing Byzantine fault-tolerant method according to an embodiment of this specification
  • Fig. 2 is a schematic flow chart of a Byzantine fault tolerance method implemented in this description
  • FIG. 3 is a schematic structural diagram of a Byzantine fault-tolerant method according to an embodiment of the present specification
  • FIG. 4 is a schematic flow diagram of a re-voting binary consensus algorithm according to an embodiment of this specification
  • FIG. 5 is a schematic flow diagram of a broadcast consensus message according to an embodiment of this specification.
  • FIG. 6 is a schematic flow diagram of another re-voting binary consensus algorithm according to the embodiment of this specification.
  • FIG. 7 is a schematic structural diagram of a Byzantine fault-tolerant device according to an embodiment of the present specification.
  • Fig. 8 is a schematic structural diagram of a device for configuring the device of the embodiment of this specification.
  • a centralized system refers to a central node composed of one or more host computers. Data is stored centrally in this central node, and all business units of the entire system are deployed centrally on this central node, and all functions of the system are centralized by it. Processing, each terminal or client connected to the centralized system is only responsible for data input and output, and the processing and storage of data is completely handed over to the central node.
  • the centralized system deployment structure is simple and easy to implement, when the host of the central node fails, such as downtime, the entire system will be in an unavailable state, which will cause quite serious consequences. Therefore, the industry has begun to use distributed systems to solve the above problems.
  • One solution is to partition the data, that is, store the data in blocks on different computer devices; the other solution is to use multiple computer devices to store the same data separately. and provide the same service.
  • the above-mentioned first solution still cannot fundamentally solve the problem. When a certain computer equipment fails, some data will be lost, and the usability is still not strong.
  • Using the above-mentioned second solution can ensure the availability of the system to the greatest extent and reduce the harm caused by a single computer equipment failure.
  • many service systems are deployed using the above-mentioned second solution, such as blockchain networks. In this way of deployment, it is necessary to ensure that each computer device in the system can store the same data to ensure data consistency, so the consensus problem arises as the times require.
  • any consensus node will maintain N pairs of RBC +ABA instance, each pair of instances is used to determine the consensus result of a pending consensus proposal, and in a distributed system, each consensus node will obtain all the consensus results of the pending consensus proposal at the same time in a consensus process before determining the consensus
  • any consensus node will broadcast local consensus proposals to other consensus nodes based on the reliable broadcast RBC protocol, and will also receive its own consensus proposals broadcast by other consensus nodes based on the reliable broadcast RBC protocol.
  • N is 7 and f is 2.
  • This figure shows the RBC+ABA instance maintained internally by any consensus node, which needs to maintain 7 pairs of RBC+ABA instances. That is, RBC+ABA is used to consensus the consensus proposal of each consensus node. For the convenience of explanation, any consensus node is called the target node.
  • the target node After the target node receives the consensus proposal of node 0-node 4 based on the reliable broadcast RBC protocol , start to execute ABA for the pending consensus proposals of node 0-node 4, that is, set the inputs of ABA0-ABA4 to 1 and start execution, instead of continuing to receive the pending consensus proposals of node 5 and node 6, that is, for N-f(7 -2) ABA is performed on the pending consensus proposals of consensus nodes. After executing the ABA process for the consensus proposal for node 0-node 4, 5 ABA output results will be obtained, that is, 5 consensus results will be obtained.
  • the target node After confirming that the consensus results are all 1, at this time, the target node will correspond to The input of ABA5 and ABA6 of node 5 and node 6 is set to 0 and starts to execute. As shown in the figure, ABA2 is the last one in ABA0-ABA4 to be executed. After the execution of ABA2 is completed, ABA5 and ABA6 will be executed. The execution process is not complete until ABA5 and ABA6 are executed and the output results are obtained, that is, a total of 7 consensus results are obtained (consensus is reached based on all consensus proposals of all consensus nodes).
  • the embodiment of this application provides a Byzantine fault-tolerant method, which is applied to any consensus node in the distributed system, based on the reliable broadcast RBC protocol to broadcast and receive consensus proposals from other consensus nodes, and determine based on local reception conditions
  • the initial voting value of the proposal to be consensus, and based on the re-voting binary consensus algorithm to reach a consensus on each proposal to be consensus, can effectively improve the efficiency of each consensus.
  • the solutions in the embodiments of the present application can be realized by using various computer languages, for example, the object-oriented programming language Java and the literal translation scripting language JavaScript.
  • the distributed system includes at least N consensus nodes, where the consensus node refers to participating in the consensus process It is understandable that there are usually other nodes that do not participate in the consensus in the distributed system. These nodes only receive and store the consensus results of the consensus nodes and do not participate in the consensus process; in addition, when malicious nodes in the system or It is said that when there are too many Byzantine nodes, any consensus method cannot ensure that the consensus nodes in the system reach a consensus. Therefore, this specification stipulates that the distributed system includes N consensus nodes, and there are at most f malicious nodes among the N consensus nodes. N ⁇ 3f+1, both f and N are integers greater than 0, the method includes:
  • S202 for any consensus node's pending consensus proposal, determine the initial voting value of the pending consensus proposal based on the local reception situation; the initial voting value is the priority voting value or other voting values;
  • the consensus proposal can have different actual meanings in different distributed system application scenarios.
  • the pending consensus proposal can be a batch of transactions obtained by a consensus node in the consensus node from the local transaction pool and needs to be stored together by other consensus nodes, and the voting value proposed by a certain node represents Whether to agree to store the batch of transactions; in other application scenarios, the consensus proposal and voting value may have other specific meanings, which are not limited in this manual.
  • the node executing the method is referred to as the target node hereinafter.
  • the target node can use any reliable broadcast RBC protocol to broadcast the local consensus proposal to other consensus nodes.
  • each node does not directly have a master-slave distinction, and other consensus nodes are also performing the same steps, so the target node can receive consensus proposals broadcast by other consensus nodes based on the reliable broadcast RBC protocol.
  • the target node can randomly obtain a preset number of transactions from the local transaction pool, or obtain the transactions stored earlier in priority according to the order in which transactions are stored. A preset amount of transactions. It is understandable that since each consensus node will receive the transaction requested by the client, each consensus node can maintain its own transaction pool locally. After the target node obtains the transaction, it can package the obtained transaction into the consensus proposal for this time. After the target node obtains the local pending consensus proposal, it can broadcast the local pending consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol, and can also receive the pending consensus proposal broadcast by other consensus nodes based on the reliable broadcast RBC protocol.
  • the target node can use the erasure code to process the consensus proposal to obtain N data blocks; build a Merkle tree based on the hash values of the obtained N data blocks, and obtain the root hash and the Merkle tree corresponding to each data block.
  • Merkel proof of Merkel path save some of the N data blocks locally, and send other data blocks, root hashes, and Merkel paths corresponding to other data blocks to other consensus nodes, so that Other consensus nodes broadcast and verify the data block.
  • consensus node 1 splits the local pending consensus proposal into 4 data blocks after processing with erasure codes, which are respectively Data block 1-data block 4, use the preset Hash algorithm to perform Hash operation on the 4 data blocks, get the Hash values of the 4 data blocks, and build a Merkle tree based on the hash values of the 4 data blocks, the data block
  • the hash value of 1 is Hash1
  • the hash value of data block 2 is Hash2
  • the hash value of data block 3 is Hash3
  • the hash value of data block 4 is Hash4.
  • Hash12 is obtained by calculating Hash1 and Hash2, and Hash3 and Hash4 are calculated.
  • Hash34 calculate Hash12 and Hash34 to get the root Hash, so as to get the Merkle tree. It can be understood that the above only takes 4 nodes as an example. In practical applications, more complex Merkle trees can be constructed according to different numbers of consensus nodes. After building the Merkle tree, consensus node 1 can store data block 1 locally, send data block 2, Hash1, Hash34 and root Hash to consensus node 2; send data block 3, Hash4, Hash12 and root Hash To consensus node 3; send data block 4, Hash3, Hash12 and root Hash to consensus node 4.
  • Consensus node 1 can send the above content to other consensus nodes in Rval message format. After other consensus nodes receive the above content sent by consensus node 1, they can broadcast the above content to other consensus nodes in Echo message format. After receiving the Echo message, other consensus nodes can verify whether the message is legal. Specifically, after receiving the message, for the data block in the message, use the Merkle proof of the Merkle path corresponding to the data block , root hash for verification; if the verification is passed, it is determined that the message is legal.
  • the consensus node 3 determines that the content of the message is: data block 4, Hash3, Hash12 and root Hash, then it can calculate the data block 4 to get Hash4, and combine Hash4 with the received Hash3 is calculated to get Hash34, and Hash34 is calculated with the received Hash12 to get the root Hash. If the calculated root Hash is the same as the received root Hash, it means that the Echo message is legal. If the verification fails, the root Hash can be discarded directly. Echo messages to avoid tampering of messages by malicious nodes.
  • consensus node 2 to consensus node 4 can receive all data blocks sent by consensus node 1 (target node) (in the case that no node intentionally does not send data blocks), any node can receive N-f Echo After the message, and the N-f Echo messages are all verified, select any N-2f data blocks to restore the consensus proposal, and the Merkle tree can be reconstructed, and the root of the reconstructed Merkle tree can be compared Whether the Hash is consistent with the root Hash in the Echo received before, and if it is consistent, the Ready message will be broadcast.
  • each consensus node has no primary and secondary distinction, that is, any consensus node is a target node, and any consensus node Nodes can obtain consensus proposals from other consensus nodes through the above methods; any consensus node can also send local consensus proposals to other consensus nodes through the above methods.
  • Each consensus node can send local pending consensus proposals at the same time, so the target node may successively receive pending consensus proposals sent by different consensus nodes. After receiving the pending consensus proposals sent by other consensus nodes, the target node can execute S201-S203 for each pending consensus proposal, that is, it can reach consensus on the pending consensus proposals broadcast by each consensus node in the blockchain network.
  • the target node may specifically receive the proposal to be consensus broadcast by any consensus node through the reliable broadcast RBC protocol, if the proposal to be consensus has not yet started to implement the binary consensus that can be voted again Algorithm, the initial voting value of the proposed consensus proposal is determined as the priority voting value;
  • the initial voting value of the proposal to be consensus will be re-determined as the priority vote value
  • the initial voting value of the pending consensus proposals that have not started to execute the re-voting binary consensus algorithm is determined as other voting values.
  • the voting value includes the priority voting value and other voting values.
  • This manual proposes to set one of the voting values as the priority voting value, that is, it is hoped that each consensus node will reach a consensus on the priority voting value.
  • 1 and 0 can be used to represent the priority voting value and other voting values respectively, wherein the priority voting value can be 1 or 0, and the following descriptions will take the priority voting value of 1 and other voting values of 0 as an example.
  • the target node determines whether it has started to execute the binary consensus algorithm of re-voting for the consensus proposal after receiving the consensus proposal broadcast by any consensus node, if not , then the initial voting value of the proposal to be consensus is determined as the priority voting value 1, and the priority voting value 1 is used as the input of the re-voting binary consensus algorithm to obtain the consensus result for the proposal to be consensus.
  • the binary consensus algorithm that can be voted again has started to be executed with the priority voting value 1 as input for the 5 consensus proposals.
  • the initial voting value of the remaining two proposals to be consensus that have not started to implement the re-voting binary consensus algorithm can be determined as the other voting value 0, and start to execute the re-voting binary consensus algorithm.
  • the target node receives the pending consensus proposal broadcast by any consensus node, if it has started to execute the binary consensus algorithm that can be voted again for the pending consensus proposal, and the initial voting value of the pending consensus proposal is 0 , and the consensus result of the pending consensus proposal has not been obtained, the initial voting value of the pending consensus proposal is re-determined as the priority voting value.
  • the reliable broadcast RBC protocol can ensure that the target node will only receive once when receiving any pending consensus proposal, instead of receiving the same pending consensus proposal multiple times. consensus algorithm, and then receive the proposal to be consensus, it means that the initial voting value of the proposal to be The voting value of 1 is the input to trigger the execution of the re-voting binary consensus algorithm again.
  • the binary consensus algorithm that can be voted for is then used to determine the consensus result of the proposal to be agreed upon.
  • the initial voting value will be used as the input of the re-voting binary consensus algorithm, and the output of the algorithm will be used as the consensus proposal consensus results.
  • the Byzantine fault tolerance method proposed in this specification does not need to wait for the execution of the binary consensus steps of the N-f consensus nodes to be proposed before starting to execute the binary consensus steps of the remaining f pending consensus proposals. Instead, it is based on The reception of each pending consensus submission directly determines the initial voting value of each pending consensus proposal, and triggers the execution of the binary consensus process of each pending consensus proposal. From this perspective, the execution of any pending consensus proposal’s binary consensus process , does not need to rely on the completion of the consensus of other pending consensus proposals, so the consensus process of each pending consensus proposal is processed in parallel, thus shortening the duration of each consensus process and improving consensus efficiency.
  • node 3 starts to execute RABA 3 with 1 as input , the inputs of RABA 5 and RABA 6 are both set to 0, triggering the execution of RABA 5 and RABA 6 .
  • the input of RABA 5 and RABA 6 of node 5 and node 6 is set to 0, and the output results of RABA 5 and RABA 6 have not been obtained, if the pending consensus proposal of node 5 and node 6 is received, then it can Change the input of RABA 5 and RABA 6 to 1, and trigger the execution of RABA 5 and RABA 6 again to get the output of RABA 5 and RABA 6 .
  • the Byzantine fault tolerance method proposed in this specification does not execute ABA 5 and ABA 6 after the ABA process of node 0-node 4 to be proposed by consensus is executed.
  • the meta-consensus process that is, the ABA process, takes a long time. If you wait for the end of the binary consensus process of Nf consensus proposals to be proposed, and then serially execute the remaining f ABA processes to be proposed by consensus, the overall consensus process will take a long time. Long, in the Byzantine fault tolerance method proposed in this note, it can guarantee that the binary consensus process of each proposal to be consensus is basically processed and occurred in parallel. Therefore, the duration of each consensus process is significantly shortened and the consensus rate of each consensus is improved efficiency.
  • the new parallel binary consensus method proposed in this manual is the proposed Byzantine Fault Tolerance method.
  • it can also be applied to multiple directions such as multi-party secure computing and interactive consistency.
  • the re-voting binary consensus algorithm in the above S203 is described below.
  • the re-voting binary consensus algorithm proposed in this manual refers to allowing the input of any proposal to be consensus to be changed from other voting values to priority voting value, and the output consensus result is biased towards the binary consensus algorithm of the priority voting value.
  • a re-voting binary consensus algorithm can be implemented in a variety of ways. The implementation of a specific re-voting binary consensus algorithm will be described below. It is understandable that other re-voting binary consensus algorithms can also be used. The algorithm implements the Byzantine fault tolerance method proposed in this specification, and this specification does not limit the specific implementation of the re-voting binary consensus algorithm.
  • the algorithm includes:
  • Voting value which is used to represent the consensus opinion of each consensus node on the data, where the voting value includes two values: priority voting value and other voting value, that is, each consensus node can have two kinds of consensus opinions on consensus proposals, priority voting value and In an embodiment, other voting values may be represented by 1 and 0 respectively.
  • the auxiliary value is a kind of auxiliary opinion proposed in this specification to assist each node to reach a consensus on the proposal to be consensus, which includes the priority voting value, other voting values and null values.
  • the initial voting value and the initial auxiliary value are determined for the consensus proposal.
  • the initial auxiliary value can be empty by default, and the initial voting value can be determined according to the content in S202 above. It will not be described in detail here, and it is directly based on the results obtained in S202.
  • Execute S402 for the initial voting value which can be understood here as the re-voting binary consensus algorithm receives the input of the upload protocol and determines the initial voting value of the consensus proposal;
  • the target node when the target node determines the initial voting value, regardless of whether the initial voting value is the priority voting value or other voting values, the target node can execute S402, that is, broadcast the initial voting value and initial auxiliary value, and receive other voting values.
  • the consensus node broadcasts the initial voting value and initial auxiliary value for the consensus proposal.
  • this specification proposes that in order to enable each consensus node to quickly reach a consensus on the priority voting value in the first round of consensus process, it allows the target node to receive the priority voting value in the case of the determined initial voting value.
  • the initial voting value can be re-determined as the priority voting value.
  • the target node can add the locally determined initial voting value and initial auxiliary value to the first round of the first type of consensus message, and transmit the first round of the first type of consensus message to other consensus nodes in the distributed system through the authentication channel.
  • cryptographic tools such as digital signatures or public key technology facilities can also be used to ensure the security of consensus message transmission, which is not limited in this specification.
  • the first type of consensus message can be a message in bval r format
  • the target node can broadcast a message in the form of bval r (est r , maj r ), where est r is a voting value, maj r is an auxiliary value, and voting
  • est r is a binary number (0 or 1), maj r ⁇ ⁇ 0,1, ⁇ , in the first round, maj r is set to be empty, r is the consensus round, the first round is the 0th round, and the consensus round starts from Start with 0 and increment in steps of 1.
  • the target node if the target node receives f+1 first-round consensus messages in the first round of consensus, that is, the first-round consensus messages exceeding the number of malicious nodes, if the f+1 first-round consensus messages The voting values in one type of consensus messages are the same and inconsistent with the voting values of the local broadcast.
  • the target node modifies the local initial voting value to the voting value in the f+1 first type of consensus messages, and broadcasts the first type of consensus messages again. Consensus news. For example, if the target node receives f+1 bval 0 (b, ⁇ ) messages, and b is not equal to the vote value of the target node’s first broadcast in the current round, the target node will broadcast bval 0 (b, ⁇ ). The purpose of this step is to allow the local node to correct the local voting value.
  • each consensus node only sends the second type of consensus message once per round, and the specific way to determine the information carried in the second type of consensus message can be as follows:
  • the initial voting value broadcast locally through the first type of consensus message is the priority voting value for the first time
  • the initial voting value is added to the first set; and the first set The voting value of is determined as the voting value and auxiliary value in the second type of consensus message in the first round.
  • the initial voting value broadcast by the target node through the first type of consensus message for the first time is not the priority voting value
  • f+1 first-round first-type consensus messages broadcast by other consensus nodes are received, And the voting values carried in the f+1 first-type consensus messages are priority voting values, then the priority voting values are added to the first set of the first round, and the first set of the first round
  • the voting value of is determined as the voting value and auxiliary value in the second type of consensus message in the first round.
  • the initial voting value broadcast by the target node through the first type of consensus message for the first time is not the priority voting value
  • a quorum of the first round of the first type of consensus message broadcast by other consensus nodes is received, and If the voting values carried in the quorum of first-class consensus messages are not priority voting values, that is, they are all other voting values, the other voting values are added to the first set of the first round, and the first round
  • the voting value in the first set is determined as the voting value and auxiliary value in the second type of consensus message in the first round.
  • the quorum is 2f+1 consensus nodes (including its own nodes). Unless otherwise specified, the quorum below is 2f+1.
  • the target node receives 2f+1 bval 0 (b, ⁇ ) messages, where b is 0, that is, it is not a priority voting value, the target node will add b to the set bin_values 0. If the target node is still If no aux 0 () message has been sent, broadcast aux 0 (0,0).
  • the target node after the target node locally broadcasts the priority voting value through the first type of consensus message, it can directly broadcast the priority voting value through the second type of consensus message without referring to the opinions of other consensus nodes.
  • the purpose is also to make each node A consensus can be quickly reached on the priority voting value, and at the same time, after re-voting, the consensus progress for the priority voting value can exceed the consensus progress for other voting values.
  • the target node After the target node receives the first-round consensus message broadcast by other consensus nodes, it can determine whether it can reach a consensus on the priority voting value according to the first-round consensus strategy.
  • the first-round consensus strategy is to make each consensus node Strategies that enable rapid consensus on said preferred voting value in the first round.
  • the first-round consensus strategy can specifically be:
  • the voting value in the second-type consensus messages received will be stored in the second set of the first round, and the auxiliary value will be stored in the third set of the first round ;Set the value of the first round of public coin toss as the priority voting value;
  • the consensus result is determined to be the priority Voting value; if more than (N+f+1)/2 second-type consensus messages carrying other voting values are received, the voting value and auxiliary value carried in the second-round first-type consensus message are set as other voting values value.
  • the target node After the target node receives Nf aux 0 () messages (the second type of consensus messages in the first round), the target node will store the voting value and auxiliary value in the received aux 0 () messages in vals 0 (first round in the second set of the round) and avals 0 (the third set of the first round).
  • the voting value and auxiliary value carried in the second-round first-type consensus message are set as priority voting value.
  • est r+1 and maj r+1 are set to 1.
  • S401-S403 are the first-round consensus method of the re-voting binary consensus algorithm, and the other rounds of consensus methods are introduced below:
  • S601-S602 can be executed cyclically until the consensus result for the pending consensus proposal is obtained:
  • S601c Re-determine the voting value and the auxiliary value based on the received first-type consensus message, and broadcast the re-determined voting value and auxiliary value in the second-type consensus message.
  • the process of S601a-S601b can refer to the content in the above-mentioned S501-S502, which will not be described in detail here.
  • the voting value and auxiliary value broadcast in the first type of consensus message are not the initial voting value and initial auxiliary value. , but after the first round of consensus, the voting value and auxiliary value are re-determined based on the message transmission results.
  • the voting value and auxiliary value are re-determined based on the message transmission results.
  • the target node after receiving a quorum of first-type consensus messages, the target node re-determines the voting value and the auxiliary value according to the received first-type consensus messages.
  • the target node will add the voting values to the first set. For example, if the target node receives 2f+1 bval r (b,*) messages, b ⁇ 0,1 ⁇ . Then the target node adds b to the first set bin_values r . In addition, the target node also adds the auxiliary values in the above 2f+1 first-type consensus messages to the auxiliary value set majs. In this step, if a quorum of the same voting value is received, the voting value is stored in the first set, which means that most nodes in the system may have reached a consensus.
  • the target node can compare the voting value in the first set with the public coin toss value of the previous round, and determine the voting value and auxiliary value carried in the second type of consensus message according to the comparison result.
  • the public coin toss value has only two values of 0 or 1.
  • Each consensus node can obtain the same public coin toss value in a certain round, and the value of each round of coin toss is random except for the first round.
  • the method of currency value can be obtained by means of threshold signature algorithm, etc., and the specific content can refer to related technologies, which are not limited here.
  • voting value in the first set is equal to the public coin toss value of the previous round, and the voting values carried in the first type of consensus messages received by the target node are all voting values in the first set,
  • the auxiliary values carried are all voting values in the first set or empty, then set the voting values and auxiliary values in the second type of consensus message as the voting values in the first set and broadcast; if the carrying For the first type of consensus message with other voting values, the voting value in the second type of consensus message is set to be empty, and the auxiliary value in the second type of consensus message is set as the voting value in the first set.
  • the voting value in the first set is b
  • the value of the public coin toss in the last round is S r-1
  • the target node has only received bval r (b,b) and bval r (b, ⁇ ) messages, broadcast aux r (b,b) directly, and broadcast aux r ( ⁇ ,b) if the first type of consensus message carrying other voting values is also received.
  • voting value in the first set is not equal to the public coin toss value of the previous round, and the voting value and auxiliary value carried in the first type of consensus message received by the target node are both the first set
  • set the voting value and auxiliary value in the second type of consensus message as the voting value in the first set and broadcast it; If one type of consensus message is used, the voting value in the second type of consensus message is set to be empty, and the auxiliary value in the second type of consensus message is set as the voting value in the first set.
  • the voting value in the first set is b
  • the value of the public coin toss in the last round is S r-1
  • the voting value b is not equal to the coin toss value S r-1
  • it is equal to 1-S r-1 , that is In this case, and the target node has only received the bval r (b, b) message, it will broadcast aux r (b, b) directly. If it has also received the first type of consensus message carrying other voting values or auxiliary values, Then broadcast aux r ( ⁇ ,b).
  • Each consensus node only broadcasts the second consensus information once in each round.
  • the above method is the method for the target node to determine the voting value and auxiliary value carried in the second type of consensus message not in the first round.
  • the target node When the target node sends the second type of consensus message, since other consensus nodes will also send the second type of consensus message asynchronously, the target node will receive the second type of consensus message sent by other consensus nodes. After the target node receives the consensus messages sent by other consensus nodes, it can first delete some obviously illegal second-type consensus messages. According to the above content, since the correct consensus node will only broadcast aux r (b,b) And the second type of consensus message of aux r ( ⁇ ,b), so when receiving a message carrying other voting values or auxiliary values, it can be discarded directly, because the voting value in the second type of consensus message is stored in the first set Therefore, after receiving the second type of consensus message, the first set can be used to determine legal and illegal messages.
  • the target consensus node determines whether a consensus result is obtained based on the received voting value and auxiliary value. If no consensus result is obtained, the next round of voting value and auxiliary value is determined, and execution of S601 is restarted.
  • the target consensus node determines the consensus result based on the received voting value and auxiliary value, and determines the next round of voting value and auxiliary value:
  • the target node After the target node receives a quorum of second-type consensus messages, it can store the voting value and auxiliary value in the second-type consensus messages received in the second set vals r and the third set avals r respectively, and obtain The unified public coin toss value of all consensus nodes in this round. For example, after receiving 2f+1 aux r () messages, the target node can store the voting value and auxiliary value in the received aux r () messages into the sets vals r ( second set) and avals r (the second set) respectively three sets). The target node can determine the consensus result, or the voting value and auxiliary value carried by the first type of consensus message in the next round of consensus according to the situation of the second type of consensus message received:
  • the target node If there are more than quorum of the second consensus messages received by the target node that are the same, and the voting value in these second consensus messages is the same as the auxiliary value, the target node will The voting value in the second type of consensus message is compared with the current round of public coin toss value. If the voting value is the same as the current round of public coin toss value, the target consensus node determines that the consensus result is the voting value; if not, the target node will The voting value and auxiliary value carried in the first type of consensus message in the next round are set as the voting value in these second type of consensus messages, and the next round of consensus is started.
  • the target node receives a quorum of aux r (b, b) information
  • the target node If the target node has only received legitimate second-type consensus messages, and the voting value in the second set is a voting value and empty, and there are at least a quorum of second-type consensus messages whose auxiliary values are For this type of voting value, compare this type of voting value with the public coin value of the previous round of consensus and the current round of consensus. If this type of voting value is the same as the public coin toss value of the previous round and this round, the target node determines that the consensus result should be this type of voting value. If the currency values are different, the target consensus node will set the voting value and auxiliary value in the first type of consensus message in the next round as this type of voting value, and start the next round of consensus.
  • the target consensus node will set the voting value and auxiliary value in the first type of consensus message in the next round of consensus as this type of voting value, and start to execute the next round of consensus.
  • the second type of consensus message received by the target node does not belong to the above three situations, that is, if the received second consensus message includes two voting values;
  • the auxiliary value carried by the second type of consensus message is different, the voting value in the second set is a kind of voting value and empty, and this kind of voting value is different from the previous round of public coin flip;
  • the coin toss value is used as the voting value of the first type of consensus message in the next round, and the auxiliary value in the first consensus message of the next round is set to a value whose occurrence times in the second set exceeds the preset number of times, and enters the next round of consensus .
  • the target node will use the public coin toss value of the current round as the next round input (that is, set est r+1 to S r ).
  • the above method is the method executed by any correct node among the consensus nodes, and other correct consensus nodes are also executing the above method asynchronously.
  • set the priority voting value, and each consensus node in the first round Probability can reach a consensus on the priority voting value, and can make each consensus node in the distributed system in the asynchronous environment quickly reach a consensus state on the priority voting value, which greatly improves the consensus efficiency of the distributed system in the asynchronous environment.
  • the target node can determine the initial voting value multiple times for any proposal to be consensus, specifically when the initial voting value of a proposal to be consensus is determined to be 0 for other voting values , start to execute the binary consensus algorithm that can be voted again with the other voting value 0 as input, and if the consensus result is not obtained, and the pending consensus proposal is received, then you can vote again, that is, re-determine the consensus of the pending consensus proposal
  • the result is the priority voting value of 1
  • the re-voting binary consensus algorithm is executed again with the priority voting value of 1 as input, and because the re-voting binary consensus algorithm is biased towards the priority voting value to reach a consensus, and the high probability is in
  • consensus can be reached based on the priority voting value, and consensus cannot be reached based on other voting values in the first round of consensus.
  • the algorithm executes faster when the input is 1, therefore, the Byzantine fault-tolerant method proposed in this specification can be realized by using the
  • Unanimous termination when all correct nodes broadcast the same voting value v and do not broadcast other voting values again, then all correct nodes can terminate the consensus operation, that is, reach a consensus;
  • Biased validity If f+1 correct nodes broadcast the voting value v, then the correct node can determine that the voting value v is the consensus result when terminating the consensus;
  • Integrity Correct nodes reach consensus on a proposal only once.
  • N consensus results can be obtained for the pending consensus proposals proposed by the N consensus nodes in the distributed system.
  • the consensus results are at least A set of pending consensus proposals is determined as the pending consensus set; after receiving all the pending consensus proposals in the pending consensus set, execute the pending consensus proposals in the set according to the preset order.
  • each correct consensus node will get the same consensus result, which is a sequence containing 0 and 1.
  • consensus result is a sequence containing 0 and 1.
  • the consensus result of the 6 pending consensus proposals corresponding to P 1 -P 6 is 1, and the consensus result of the pending consensus proposal corresponding to P 7 is 0, then the set of pending consensus proposals corresponding to P 1 -P 6 is determined to be consensus Set S, any correct consensus node at this time will get such a set to be consensus, but it may not have received some proposals to be consensus in the set S to be consensus, because it uses the reliable broadcast RBC protocol
  • the broadcasted consensus proposal therefore, can ensure that the consensus node can receive all the consensus proposals in the consensus set S.
  • the consensus node can continue to wait until it receives all the consensus proposals in the consensus set S After that, all the proposals to be agreed in the consensus set S can be executed according to the preset execution sequence, that is, the proposals to be agreed on P 1 -P 6 are executed.
  • 0 or 1 is used to indicate whether to pack the corresponding consensus proposal into a block.
  • the consensus proposal proposed by consensus node 1 is P1
  • the consensus proposal proposed by consensus node 2 is P2
  • the consensus proposal proposed by consensus node 3 is P3
  • the consensus proposal proposed by consensus node 4 is P4.
  • the fault-tolerant method obtains a 01 sequence after consensus, for example, the obtained sequence is (1,1,1,0), then the consensus result reached is that all nodes pack P1, P2, and P3 into blocks and store them locally, and do not store P4. That is, each consensus node performs consistent processing on each consensus proposal according to the consensus result to ensure the data consistency of each consensus node.
  • the framework includes n parallel RBC instances and n parallel RABA instances.
  • each replica p i broadcasts a proposal m i for the RBC instance RBC i . If p i r-delivers proposal m j in RBC j instance, p i will start running RABA j and propose1 in RABA j . After Nf RBC instances have r-delivered the proposal, p i does not need to wait for the termination of nf RABA instances, but directly propose0 in those RABA instances that have not started running. If p i propose0 in RABA j , r-deliver the proposal m j , and RABA j has not terminated, then p i will repropose1 in RABA j .
  • S denote the set of RABA instance numbers for which the value of decide is 1. If p i is decide 1 in the RABA j instance, add the proposal m j proposed by p j for RBC j to the set C. If for any j ⁇ S, r-deliver([e,j],m j ) has been done in the RBC j instance, then confirm and execute the messages in the C set in a deterministic order.
  • this specification also provides a Byzantine fault-tolerant device, which is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes , wherein N ⁇ 3f+1, the f is an integer greater than 0, and the device includes:
  • the communication module 710 is used to broadcast the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
  • the processing module 720 is used to determine the initial voting value of the consensus proposal based on the local reception situation for any consensus node's pending consensus proposal; the initial voting value is the priority voting value or other voting values; for any consensus node with the initial voting value When the consensus is proposed, a re-voting binary consensus algorithm is used to determine the consensus result.
  • the processing module 720 is specifically configured to, in the case of receiving a proposal to be consensus broadcast by any consensus node through the reliable broadcast RBC protocol, if the proposal to be consensus has not yet started to execute the reproducible In the binary consensus algorithm for voting, the initial voting value of the proposed consensus proposal is determined as the priority voting value;
  • the initial voting value of the proposal to be consensus is re-determined as the priority voting value
  • the initial voting value of the pending consensus proposals that have not started to execute the re-voting binary consensus algorithm is determined as other voting values.
  • the processing module 720 is specifically configured to use the initial voting value as the re-voting binary if it is determined that the consensus proposal has an initial voting value for any proposal to be agreed upon.
  • the input of the consensus algorithm takes the output of the algorithm as the consensus result of the proposal to be consensused.
  • the re-voting binary consensus algorithm includes: a binary algorithm that allows the input of any proposal to be consensus to be changed from other voting values to priority voting values, and the output consensus result is biased towards the priority voting value.
  • Meta Consensus Algorithm Meta Consensus Algorithm.
  • the processing module 720 is specifically configured to, after obtaining the consensus results of the N proposals to be consensus, determine a set consisting of at least one proposal to be consensus whose consensus result is a priority voting value as the set to be agreed upon; After receiving all the pending consensus proposals in the pending consensus set, execute the pending consensus proposals in the pending consensus set in a preset order.
  • the device embodiment since it basically corresponds to the method embodiment, for related parts, please refer to the part description of the method embodiment.
  • the device embodiments described above are illustrative only. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution in this specification. It can be understood and implemented by those skilled in the art without creative effort.
  • the embodiment of this specification also provides a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and operable on the processor, wherein the aforementioned method is implemented when the processor executes the program.
  • the method includes at least the method shown in FIG. 2 above.
  • FIG. 8 shows a schematic diagram of a more specific hardware structure of a computing device provided by the embodiment of this specification.
  • the device may include: a processor 1010 , a memory 1020 , an input/output interface 1030 , a communication interface 1040 and a bus 1050 .
  • the processor 1010 , the memory 1020 , the input/output interface 1030 and the communication interface 1040 are connected to each other within the device through the bus 1050 .
  • the processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit, central processing unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute related programs to realize the technical solutions provided by the embodiments of this specification.
  • a general-purpose CPU Central Processing Unit, central processing unit
  • a microprocessor an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits
  • ASIC Application Specific Integrated Circuit
  • the memory 1020 can be implemented in the form of ROM (Read Only Memory, read-only memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc.
  • the memory 1020 can store operating systems and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 1020 and invoked by the processor 1010 for execution.
  • the input/output interface 1030 is used to connect the input/output module to realize information input and output.
  • the input/output/module can be configured in the device as a component (not shown in the figure), or can be externally connected to the device to provide corresponding functions.
  • the input device may include a keyboard, mouse, touch screen, microphone, various sensors, etc.
  • the output device may include a display, a speaker, a vibrator, an indicator light, and the like.
  • the communication interface 1040 is used to connect a communication module (not shown in the figure), so as to realize the communication interaction between the device and other devices.
  • the communication module can realize communication through wired means (such as USB, network cable, etc.), and can also realize communication through wireless means (such as mobile network, WIFI, Bluetooth, etc.).
  • Bus 1050 includes a path that carries information between the various components of the device (eg, processor 1010, memory 1020, input/output interface 1030, and communication interface 1040).
  • the above device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components.
  • the above-mentioned device may only include components necessary to implement the solutions of the embodiments of this specification, and does not necessarily include all the components shown in the figure.
  • the embodiment of the present specification also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the aforementioned method is implemented.
  • the method includes at least the method shown in FIG. 2 above.
  • Computer-readable media including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information.
  • Information may be computer readable instructions, data structures, modules of a program, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, A magnetic tape cartridge, disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
  • a typical implementing device is a computer, which may take the form of a personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media player, navigation device, e-mail device, game control device, etc. desktops, tablets, wearables, or any combination of these.
  • each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments.
  • the description is relatively simple, and for relevant parts, please refer to part of the description of the method embodiments.
  • the device embodiments described above are only illustrative, and the modules described as separate components may or may not be physically separated, and the functions of each module may be integrated in the same or multiple software and/or hardware implementations. Part or all of the modules can also be selected according to actual needs to achieve the purpose of the solution of this embodiment. It can be understood and implemented by those skilled in the art without creative effort.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Hardware Redundancy (AREA)

Abstract

Provided in the embodiments of the present application is a Byzantine fault tolerance method, which is applied to any consensus node in a distributed system. The distributed system comprises at least N consensus nodes, wherein N ≥ 3f +1, f being an integer greater than 0. The method comprises: on the basis of a reliable broadcast (RBC) protocol, broadcasting to other consensus nodes a local proposal on which a consensus is to be reached; for a proposal, on which a consensus is to be reached, of any consensus node, determining, on the basis of a local receiving condition, an initial voting value of the proposal on which a consensus is to be reached, wherein the initial voting value is a priority voting value or another voting value; and for any proposal on which a consensus is to be reached that has the initial voting value, determining a consensus result thereof by using a re-votable binary consensus algorithm. By using the method provided in the present embodiment, binary consensus processes of proposals on which a consensus is to be reached can be concurrently processed, such that the time consumed by each instance of reaching a consensus is shortened, and the efficiency of reaching a consensus is improved, thereby improving the processing capability of a distributed system.

Description

一种拜占庭容错方法、装置、电子设备及存储介质A Byzantine fault tolerance method, device, electronic equipment and storage medium
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202110925724.7、申请日为2021年08月12日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with application number 202110925724.7 and a filing date of August 12, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated by reference into this application.
技术领域technical field
本申请涉及计算机技术领域,具体地,涉及一种拜占庭容错方法、装置、电子设备及存储介质。The present application relates to the field of computer technology, in particular, to a Byzantine fault tolerance method, device, electronic equipment and storage medium.
背景技术Background technique
基于二元共识的拜占庭容错方法是分布式系统中常用的用于处理拜占庭问题的方法之一,在该方法中,在每次共识过程中,分布式系统中的任一共识节点,会针对每个共识节点提出的待共识提议分别与其他共识节点交互意见以达成共识,并最终输出每个待共识提议的共识结果,在每次共识过程中,共识节点通常并不能针对各个待共识提议完全并行的进行共识处理,因此,目前基于二元共识的拜占庭容错方法共识效率较低。The Byzantine fault tolerance method based on binary consensus is one of the commonly used methods for dealing with Byzantine problems in distributed systems. In this method, in each consensus process, any consensus node in the distributed system will The consensus proposal proposed by each consensus node interacts with other consensus nodes to reach a consensus, and finally outputs the consensus result of each consensus proposal. In each consensus process, the consensus node usually cannot completely parallelize each consensus proposal. Therefore, the current Byzantine fault-tolerant method based on binary consensus has low consensus efficiency.
发明内容Contents of the invention
本申请实施例中提供了一种拜占庭容错方法、装置、电子设备及存储介质,用于解决现有技术中基于二元共识的拜占庭容错方法执行效率低下的问题。The embodiment of the present application provides a Byzantine fault tolerance method, device, electronic equipment and storage medium, which are used to solve the problem of low execution efficiency of the binary consensus-based Byzantine fault tolerance method in the prior art.
为了达到上述目的,本申请提供如下技术方案:In order to achieve the above object, the application provides the following technical solutions:
根据本申请实施例的第一个方面,提供了一种拜占庭容错方法,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,该N个共识节点中最多允许存在f个恶意节点,其中N≥3f+1,所述f为大于0的整数,所述方法包括:基于可靠广播RBC协议将本地待共识提议广播至其他共识节点;According to the first aspect of the embodiment of the present application, a Byzantine fault-tolerant method is provided, which is applied to any consensus node in a distributed system. The distributed system includes at least N consensus nodes, and among the N consensus nodes, at most F malicious nodes are allowed, where N≥3f+1, the f is an integer greater than 0, and the method includes: broadcasting the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
在接收到任一个共识节点通过可靠广播RBC协议广播的待共识提议的情况下,若还未针对该待共识提议开始执行所述可再投票的二元共识算法,则将该待共识提议的初始投票值确定为优先投票值;若已针对该待共识提议开始执行所述可再投票的二元共识算法,且还未得到该待共识提议的共识结果,则重新将该待共识提议的初始投票值确定为优先投票值;In the case of receiving a consensus proposal broadcast by any consensus node through the reliable broadcast RBC protocol, if the re-voting binary consensus algorithm has not been started for the consensus proposal, the initial The voting value is determined as the priority voting value; if the re-voting binary consensus algorithm has been executed for the pending consensus proposal, and the consensus result of the pending consensus proposal has not been obtained, the initial voting of the pending consensus proposal The value is determined as the priority voting value;
在接收到N-f个共识节点广播的待共识提议的情况下,将还未开始执行可再投票的二元共识算法的待共识提议的初始投票值确定为其他投票值;In the case of receiving the pending consensus proposal broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposal that has not started to execute the re-voting binary consensus algorithm is determined as other voting value;
针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果。For any pending consensus proposal with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result.
上述方案中,所述针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果,包括:In the above scheme, for any proposal to be agreed upon with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result, including:
针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,即将该初始投票值作为所述可再投票的二元共识算法的输入,以该算法的输出作为该待共识提议的共识结果。For any consensus proposal, if it is determined that the consensus proposal has an initial voting value, the initial voting value will be used as the input of the re-voting binary consensus algorithm, and the output of the algorithm will be used as the consensus proposal consensus results.
上述方案中,所述方法还包括:在得到N个待共识提议的共识结果后,将共识结果为优先投票值的至少一个待共识提议组成的集合确定为待共识集合;In the above scheme, the method further includes: after obtaining the consensus results of the N proposals to be agreed upon, determining a set consisting of at least one proposal to be agreed upon whose consensus result is a priority voting value as the set to be agreed upon;
在接收到待共识集合中的全部待共识提议后,按照预设的顺序执行该集合中的待共识提议。After receiving all the proposals to be agreed in the set to be agreed, execute the proposals to be agreed in the set according to the preset order.
根据本申请实施例的第二个方面,提供了一种拜占庭容错装置,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,该N个共识节点中最多允许存在f个恶意节点,其中N≥3f+1,所述f为大于0的整数,所述装置包括:According to the second aspect of the embodiment of the present application, a Byzantine fault-tolerant device is provided, which is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, and among the N consensus nodes, at most F malicious nodes are allowed, where N≥3f+1, the f is an integer greater than 0, and the device includes:
通信模块,用于基于可靠广播RBC协议将本地待共识提议广播至其他共识节点;The communication module is used to broadcast the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
处理模块,在接收到任一个共识节点通过可靠广播RBC协议广播的待共识提议的情况下,若还未针对该待共识提议开始执行所述可再投票的二元共识算法,则将该待共识提议的初始投票值确定为优先投票值;若已针对该待共识提议开始执行所述可再投票的二元共识算法,且还未得到该待共识提议的共识结果,则重新将该待共识提议的初始投票值确定为优先投票值;在接收到N-f个共识节点广播的待共识提议的情况下,将还未开始执行可再投票的二元共识算法的待共识提议的初始投票值确定为其他投票值; 针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果。The processing module, in the case of receiving a consensus proposal broadcast by any consensus node through the reliable broadcast RBC protocol, if the binary consensus algorithm that can be voted again has not been started for the consensus proposal, then the consensus proposal The initial voting value of the proposal is determined as the priority voting value; if the re-voting binary consensus algorithm has been implemented for the pending consensus proposal, and the consensus result of the pending consensus proposal has not been obtained, the pending consensus proposal will be re- The initial voting value of is determined as the priority voting value; in the case of receiving the consensus proposal broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposal that has not started to execute the re-voting binary consensus algorithm is determined as other Voting value; For any proposal to be consensus with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result.
上述方案中,所述处理模块,具体用于针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,即将该初始投票值作为所述可再投票的二元共识算法的输入,以该算法的输出作为该待共识提议的共识结果。In the above solution, the processing module is specifically configured to, for any proposal to be consensus, if it is determined that the proposal to be consensus has an initial voting value, the initial voting value is used as the voting value of the binary consensus algorithm that can be voted again. Input, take the output of the algorithm as the consensus result of the proposal to be consensused.
上述方案中,所述可再投票的二元共识算法,包括:允许针对任一待共识提议的输入由其他投票值更改为优先投票值、且输出的共识结果偏向于优先投票值的二元共识算法。In the above scheme, the re-voting binary consensus algorithm includes: a binary consensus that allows the input of any proposal to be consensus to be changed from other voting values to priority voting values, and the output consensus result is biased towards the priority voting value algorithm.
上述方案中,所述处理模块,还用于在得到N个待共识提议的共识结果后,将共识结果为优先投票值的至少一个待共识提议组成的集合确定为待共识集合;在接收到待共识集合中的全部待共识提议后,按照预设的顺序执行该集合中的待共识提议。In the above scheme, the processing module is also used to determine the set consisting of at least one proposal to be consensus whose consensus result is a priority voting value after obtaining the consensus results of the N proposals to be consensused as the set to be agreed upon; After all the pending consensus proposals in the consensus set, execute the pending consensus proposals in the set according to the preset order.
根据本申请实施例的第三个方面,提供了一种计算机设备,包括存储器、处理器、通信接口及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如上述第一方面所述方法的步骤。According to a third aspect of the embodiments of the present application, a computer device is provided, including a memory, a processor, a communication interface, and a computer program stored in the memory and operable on the processor, wherein the processor executes the When the program is described, the steps of the method described in the first aspect above are realized.
根据本申请实施例的第四个方面,提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如上述第一方面所述方法的步骤。According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in the above-mentioned first aspect are implemented.
采用本申请实施例中提供的拜占庭容错方法,各个共识节点相互基于可靠广播RBC协议广播本地的待共识提议,并基于本地接收情况针对每个待共识提议确定初始投票值,采用可再投票的二元共识算法确定各待共识提议的共识结果,使共识节点能够针对各个待共识提议完全并行的进行共识处理,缩短了每次共识的耗时,提高了共识的效率,进而提高了分布式系统的处理能力。Using the Byzantine Fault Tolerance method provided in the embodiment of this application, each consensus node broadcasts the local consensus proposals based on the reliable broadcast RBC protocol, and determines the initial voting value for each consensus proposal based on the local reception situation. The meta-consensus algorithm determines the consensus results of each pending consensus proposal, so that the consensus nodes can completely parallelize the consensus processing for each pending consensus proposal, shortening the time-consuming of each consensus, improving the efficiency of the consensus, and further improving the efficiency of the distributed system. processing power.
附图说明Description of drawings
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described here are used to provide a further understanding of the application and constitute a part of the application. The schematic embodiments and descriptions of the application are used to explain the application and do not constitute an improper limitation to the application. In the attached picture:
图1为本说明书实施例的一种现有的拜占庭容错方法的结构示意图;FIG. 1 is a schematic structural diagram of an existing Byzantine fault-tolerant method according to an embodiment of this specification;
图2为本说明书实施的一种拜占庭容错方法的流程示意图;Fig. 2 is a schematic flow chart of a Byzantine fault tolerance method implemented in this description;
图3为本说明书实施例的一种拜占庭容错方法的结构示意图;FIG. 3 is a schematic structural diagram of a Byzantine fault-tolerant method according to an embodiment of the present specification;
图4为本说明书实施例的一种可再投票的二元共识算法的流程示意图;FIG. 4 is a schematic flow diagram of a re-voting binary consensus algorithm according to an embodiment of this specification;
图5为本说明书实施例的一种广播共识消息的流程示意图;FIG. 5 is a schematic flow diagram of a broadcast consensus message according to an embodiment of this specification;
图6为本说明书实施例的另一种可再投票的二元共识算法的流程示意图;FIG. 6 is a schematic flow diagram of another re-voting binary consensus algorithm according to the embodiment of this specification;
图7为本说明书实施例的一种拜占庭容错装置的结构示意图;FIG. 7 is a schematic structural diagram of a Byzantine fault-tolerant device according to an embodiment of the present specification;
图8是用于配置本说明书实施例装置的一种设备的结构示意图。Fig. 8 is a schematic structural diagram of a device for configuring the device of the embodiment of this specification.
具体实施方式Detailed ways
集中式系统是指由一台或多台主计算机组成中心节点,数据集中存储于这个中心节点中,并且整个系统的所有业务单元都集中部署在这个中心节点上,系统所有的功能均由其集中处理,集中式系统连接的每个终端或客户端仅仅负责数据的录入和输出,数据的处理与存储完全交由该中心节点来完成。虽然集中式系统部署结构简单易于实现,但是当中心节点的主机出现故障时,例如出现宕机等状态时,整个系统会处于不可用状态,这会造成相当严重的后果。因此,目前业界已经开始采用分布式系统来解决上述问题,一种方案是将数据分区,即将数据分块存储到不同计算机设备上;另一种方案是采用多台计算机设备分别存储相同的数据,并提供相同的服务。上述第一种方案,还是无法从根本上解决问题,当某台计算机设备出现故障时,会有部分数据丢失,可用性还是不强。采用上述第二种方案,可以最大程度的确保系统的可用性,减少单台计算机设备发生故障时产生的危害,目前有较多的服务系统采用上述第二种方案进行部署,例如区块链网络。在这种部署的方式下,就要确保系统中各台计算机设备能够存储有相同的数据,保证数据的一致性,因此共识问题也就应运而生。另外,目前多数网络环境是异步的,即系统中各个节点发送的消息并不能保证在一个已知的时间内到达,并且系统中通常会出现单个节点计算机设备故障或作恶的情况,上述作恶的节点可以称为拜占庭节点,如何在这种情况下保证系统中的各正常节点可以进行共识,是目前业界主要的研究方向。A centralized system refers to a central node composed of one or more host computers. Data is stored centrally in this central node, and all business units of the entire system are deployed centrally on this central node, and all functions of the system are centralized by it. Processing, each terminal or client connected to the centralized system is only responsible for data input and output, and the processing and storage of data is completely handed over to the central node. Although the centralized system deployment structure is simple and easy to implement, when the host of the central node fails, such as downtime, the entire system will be in an unavailable state, which will cause quite serious consequences. Therefore, the industry has begun to use distributed systems to solve the above problems. One solution is to partition the data, that is, store the data in blocks on different computer devices; the other solution is to use multiple computer devices to store the same data separately. and provide the same service. The above-mentioned first solution still cannot fundamentally solve the problem. When a certain computer equipment fails, some data will be lost, and the usability is still not strong. Using the above-mentioned second solution can ensure the availability of the system to the greatest extent and reduce the harm caused by a single computer equipment failure. At present, many service systems are deployed using the above-mentioned second solution, such as blockchain networks. In this way of deployment, it is necessary to ensure that each computer device in the system can store the same data to ensure data consistency, so the consensus problem arises as the times require. In addition, most of the current network environments are asynchronous, that is, the messages sent by each node in the system cannot be guaranteed to arrive within a known time, and there will usually be a single node computer equipment failure or malicious behavior in the system. It can be called a Byzantine node. How to ensure that all normal nodes in the system can achieve consensus in this case is the main research direction in the industry at present.
针对上述分布式系统中的问题,业界存在多种解决方案,其中一种为基于二元共识的拜占庭方法,该方案中是采用可靠广播RBC协议以及二元共识,对各个共识节点的待共识提议进行共识。任一共识节 点会在本地针对每个共识节点提出的待共识提议利用可靠广播RBC以及二元共识ABA(asynchronous binary agreement)确定该待共识提议的共识结果。例如,分布式系统中共存在N个共识节点,其中该分布式系统中最多允许存在f个恶意节点或称拜占庭节点,N≥3f+1,f>0,那么任一共识节点会维护N对RBC+ABA的实例,每对实例用于确定一个待共识提议的共识结果,并且分布式系统中,各个共识节点会在一次共识过程中,同时得到全部待共识提议的共识结果后才确定本次共识过程结束,该方法中,任一共识节点,会基于可靠广播RBC协议向其他共识节点广播本地的待共识提议,同时也会基于可靠广播RBC协议接收其他共识节点广播的自身的待共识提议,其会在接收到一个目标节点的待共识提议后,确定该待共识提议的初始投票值为1,并开始与其他共识节点交互投票值从而执行二元共识即执行ABA,并且在接收到N-f个共识节点广播的待共识提议后,就针对这N-f个待共识提议分别执行ABA,直到针对这N-f个待共识提议分别执行完成ABA即得到N-f个共识结果后,才串行的针对剩下的f个待共识提议执行ABA,在得N个待共识提议的共识结果后,本次共识过程才算完成。For the above-mentioned problems in the distributed system, there are many solutions in the industry, one of which is the Byzantine method based on binary consensus. Make a consensus. Any consensus node will locally use reliable broadcast RBC and binary consensus ABA (asynchronous binary agreement) to determine the consensus result of the pending consensus proposal proposed by each consensus node. For example, there are N consensus nodes in a distributed system, where there are at most f malicious nodes or Byzantine nodes in the distributed system, N≥3f+1, f>0, then any consensus node will maintain N pairs of RBC +ABA instance, each pair of instances is used to determine the consensus result of a pending consensus proposal, and in a distributed system, each consensus node will obtain all the consensus results of the pending consensus proposal at the same time in a consensus process before determining the consensus At the end of the process, in this method, any consensus node will broadcast local consensus proposals to other consensus nodes based on the reliable broadcast RBC protocol, and will also receive its own consensus proposals broadcast by other consensus nodes based on the reliable broadcast RBC protocol. After receiving a consensus proposal from a target node, it will determine that the initial voting value of the consensus proposal is 1, and start to exchange voting values with other consensus nodes to perform binary consensus, which is to execute ABA, and after receiving N-f consensus After the node broadcasts the pending consensus proposals, ABA is executed separately for the N-f pending consensus proposals, until the ABA is executed for the N-f pending consensus proposals and N-f consensus results are obtained, and then the remaining f ones are serially targeted. The consensus process is not complete until the consensus proposals are executed with ABA, and the consensus results of N pending consensus proposals are obtained.
如图1所示,该实施例中共存在7个共识节点,即N为7,f为2,该图为任一共识节点内部维护的RBC+ABA实例,其需要维护7对RBC+ABA实例,即采用RBC+ABA对每个共识节点的待共识提议进行共识,为了方便说明将任一共识节点称为目标节点,目标节点在基于可靠广播RBC协议接收到了节点0-节点4的待共识提议后,就开始针对节点0-节点4的待共识提议分别执行ABA,即将ABA0-ABA4的输入均设置为1并开始执行,而不在继续接收节点5和节点6的待共识提议,即针对N-f(7-2)个共识节点的待共识提议进行ABA。在执行完针对节点0-节点4的待共识提议的ABA过程后会得到5个ABA输出结果即得到5个共识结果,在确定共识结果均为1后,此时,目标节点才会将对应于节点5和节点6的ABA5和ABA6的输入设置为0并开始执行,如图中所示,ABA2是ABA0-ABA4中最后一个执行完的,则在ABA2执行完成后,才开始执行ABA5和ABA6,直到得到ABA5和ABA6执行完毕得到输出结果后,即一共得到7个共识结果(基于全部共识节点的待共识提议均达成共识)后,本次的执行过程才算完成。As shown in Figure 1, there are 7 consensus nodes in this embodiment, that is, N is 7 and f is 2. This figure shows the RBC+ABA instance maintained internally by any consensus node, which needs to maintain 7 pairs of RBC+ABA instances. That is, RBC+ABA is used to consensus the consensus proposal of each consensus node. For the convenience of explanation, any consensus node is called the target node. After the target node receives the consensus proposal of node 0-node 4 based on the reliable broadcast RBC protocol , start to execute ABA for the pending consensus proposals of node 0-node 4, that is, set the inputs of ABA0-ABA4 to 1 and start execution, instead of continuing to receive the pending consensus proposals of node 5 and node 6, that is, for N-f(7 -2) ABA is performed on the pending consensus proposals of consensus nodes. After executing the ABA process for the consensus proposal for node 0-node 4, 5 ABA output results will be obtained, that is, 5 consensus results will be obtained. After confirming that the consensus results are all 1, at this time, the target node will correspond to The input of ABA5 and ABA6 of node 5 and node 6 is set to 0 and starts to execute. As shown in the figure, ABA2 is the last one in ABA0-ABA4 to be executed. After the execution of ABA2 is completed, ABA5 and ABA6 will be executed. The execution process is not complete until ABA5 and ABA6 are executed and the output results are obtained, that is, a total of 7 consensus results are obtained (consensus is reached based on all consensus proposals of all consensus nodes).
综上可见,现有的基于二元共识的拜占庭容错方法中,需要针对N-f个待共识提议(如图1中,N-f=5)分别执行完二元共识之后,才能开始针对剩下的f个待共识提议执行二元共识过程,因此每次的共识过程耗时较长,效率较低。To sum up, in the existing Byzantine fault-tolerant method based on binary consensus, it is necessary to implement binary consensus for N-f pending consensus proposals (as shown in Figure 1, N-f=5) before starting to target the remaining f proposals. The pending consensus proposal implements a binary consensus process, so each consensus process takes a long time and is inefficient.
针对上述问题,本申请实施例中提供了一种拜占庭容错方法,应用于分布式系统中的任一个共识节点,基于可靠广播RBC协议广播和接收其他共识节点的待共识提议,基于本地接收情况确定该待共识提议的初始投票值,并基于可再投票的二元共识算法对各个待共识提议达成共识,可以有效提高每次共识的效率。In view of the above problems, the embodiment of this application provides a Byzantine fault-tolerant method, which is applied to any consensus node in the distributed system, based on the reliable broadcast RBC protocol to broadcast and receive consensus proposals from other consensus nodes, and determine based on local reception conditions The initial voting value of the proposal to be consensus, and based on the re-voting binary consensus algorithm to reach a consensus on each proposal to be consensus, can effectively improve the efficiency of each consensus.
本申请实施例中的方案可以采用各种计算机语言实现,例如,面向对象的程序设计语言Java和直译式脚本语言JavaScript等。The solutions in the embodiments of the present application can be realized by using various computer languages, for example, the object-oriented programming language Java and the literal translation scripting language JavaScript.
为了使本申请实施例中的技术方案及优点更加清楚明白,以下结合附图对本申请的示例性实施例进行进一步详细的说明,显然,所描述的实施例仅是本申请的一部分实施例,而不是所有实施例的穷举。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。In order to make the technical solutions and advantages in the embodiments of the present application clearer, the exemplary embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. Apparently, the described embodiments are only part of the embodiments of the present application, and Not an exhaustive list of all embodiments. It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
如图2所示,基于以上说明本说明书提出的一种拜占庭容错方法,应用于分布式系统中的任一共识节点,分布式系统至少包括N个共识节点,其中,共识节点是指参与共识过程的节点,可以理解的是,在分布式系统中通常还会存在其他不参与共识的节点,这些节点仅接收和存储共识节点的共识结果而不参与共识过程;另外,当系统中的恶意节点或称拜占庭节点过多时任何一种共识方法均无法确保系统中的共识节点达成共识,因此本说明书中规定该分布式系统包括N个共识节点,该N个共识节点中最多允许存在f个恶意节点,N≥3f+1,所述f和N均为大于0的整数,该方法包括:As shown in Figure 2, based on the above description, a Byzantine fault tolerance method proposed in this specification is applied to any consensus node in the distributed system. The distributed system includes at least N consensus nodes, where the consensus node refers to participating in the consensus process It is understandable that there are usually other nodes that do not participate in the consensus in the distributed system. These nodes only receive and store the consensus results of the consensus nodes and do not participate in the consensus process; in addition, when malicious nodes in the system or It is said that when there are too many Byzantine nodes, any consensus method cannot ensure that the consensus nodes in the system reach a consensus. Therefore, this specification stipulates that the distributed system includes N consensus nodes, and there are at most f malicious nodes among the N consensus nodes. N≥3f+1, both f and N are integers greater than 0, the method includes:
S201,基于可靠广播RBC协议将本地待共识提议广播至其他共识节点;S201, broadcast the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
S202,针对任一共识节点的待共识提议,基于本地接收情况确定该待共识提议的初始投票值;初始投票值为优先投票值或其他投票值;S202, for any consensus node's pending consensus proposal, determine the initial voting value of the pending consensus proposal based on the local reception situation; the initial voting value is the priority voting value or other voting values;
S203,针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果。S203. For any proposal to be agreed upon with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result.
待共识提议在不同分布式系统的应用场景中可以表示不同的实际含义。例如,在区块链网络中,待共识提议可以是共识节点中某个共识节点从本地交易池获取的、需要其他共识节点一同存储的一批交易,而某一节点的提出的投票值则表示是否同意存储该批交易;在其他应用场景中,待共识提议和投票值可以具体有其他具体含义,本说明书对此不进行限定。为了方便说明,下文中将执行该方法的节点称为目标节点。The consensus proposal can have different actual meanings in different distributed system application scenarios. For example, in a blockchain network, the pending consensus proposal can be a batch of transactions obtained by a consensus node in the consensus node from the local transaction pool and needs to be stored together by other consensus nodes, and the voting value proposed by a certain node represents Whether to agree to store the batch of transactions; in other application scenarios, the consensus proposal and voting value may have other specific meanings, which are not limited in this manual. For convenience of description, the node executing the method is referred to as the target node hereinafter.
在上述S201中,目标节点可以采用任意可靠广播RBC协议将本地的待共识提议广播至其他共识节点。In the above S201, the target node can use any reliable broadcast RBC protocol to broadcast the local consensus proposal to other consensus nodes.
由于本说明书提出的拜占庭容错方法中,各节点直接没有主副之分,其他共识节点也在执行相同的步骤,因此目标节点可以基于可靠广播RBC协议接收到其他共识节点广播的待共识提议。In the Byzantine Fault Tolerance method proposed in this manual, each node does not directly have a master-slave distinction, and other consensus nodes are also performing the same steps, so the target node can receive consensus proposals broadcast by other consensus nodes based on the reliable broadcast RBC protocol.
下面以分布式系统为区块链网络为例对上述广播过程进行说明,目标节点可以是从本地交易池中随 机获取预设数量的交易,或者按照交易存储的先后顺序,优先获取较早存储的预设数量的交易。可以理解的是,由于各个共识节点都会接收客户端请求的交易,因此各个共识节点都可以在本地维护自己的交易池。目标节点在获取了交易后,可以将获取的交易打包成为本次的待共识提议。目标节点在获取了本地待共识提议后,即可以基于可靠广播RBC协议,向其他共识节点广播本地待共识提议,同时也可以基于可靠广播RBC协议接收其他共识节点广播的待共识提议。下面以一种可靠广播RBC协议的具体实现方式进行举例说明:The following is an example of the distributed system as a blockchain network to illustrate the above broadcast process. The target node can randomly obtain a preset number of transactions from the local transaction pool, or obtain the transactions stored earlier in priority according to the order in which transactions are stored. A preset amount of transactions. It is understandable that since each consensus node will receive the transaction requested by the client, each consensus node can maintain its own transaction pool locally. After the target node obtains the transaction, it can package the obtained transaction into the consensus proposal for this time. After the target node obtains the local pending consensus proposal, it can broadcast the local pending consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol, and can also receive the pending consensus proposal broadcast by other consensus nodes based on the reliable broadcast RBC protocol. The following is an example of a specific implementation of the reliable broadcast RBC protocol:
目标节点可以将待共识提议采用纠删码处理,得到N个数据块;基于得到的N个数据块的哈希值构建默克尔树,得到根哈希以及对应于每个数据块的默克尔路径的默克尔证明;将所述N个数据块中的部分数据块保存在本地,将其他数据块、根哈希以及其他数据块对应的默克尔路径发送至其他共识节点,以使其他共识节点对所述数据块进行广播和验证。以共有4个共识节点(共识节点1-共识节点4)为例,目标节点为共识节点1,共识节点1将本地的待共识提议采用纠删码处理后拆分成4个数据块,分别为数据块1-数据块4,采用预设的Hash算法对4个数据块进行Hash运算,得到4个数据块的Hash值,并基于4个数据块的哈希值构建默克尔树,数据块1的Hash值为Hash1,数据块2的Hash值为Hash2,数据块3的Hash值为Hash3,数据块4的Hash值为Hash4,对Hash1和Hash2进行计算得到Hash12,对Hash3和Hash4进行计算得到Hash34,对Hash12和Hash34进行计算得到根Hash,从而得到默克尔树。可以理解的是,上述仅以4个节点为例,实际应用中可以根据不同数量的共识节点构建更为复杂的默克尔树。在构建了默克尔树之后,共识节点1可以将数据块1存储在本地,将数据块2、Hash1、Hash34以及根Hash发送至共识节点2;将数据块3、Hash4、Hash12以及根Hash发送至共识节点3;将数据块4、Hash3、Hash12以及根Hash发送至共识节点4。以发送给共识节点2的内容为例,其中Hash1、Hash34即为数据块2对应的默克尔路径的默克尔证明。共识节点1可以将上述内容以Rval消息格式发送到其他共识节点。其他共识节点在接收到共识节点1发送的上述内容后,可以将上述内容以Echo消息格式广播至其他共识节点。其他共识节点在接收到Echo消息后,即可以验证该消息是否合法,具体可以是在接收到消息后,针对该消息中的数据块,利用该数据块对应的默克尔路径的默克尔证明、根哈希进行验证;如果验证通过,则确定该消息合法。The target node can use the erasure code to process the consensus proposal to obtain N data blocks; build a Merkle tree based on the hash values of the obtained N data blocks, and obtain the root hash and the Merkle tree corresponding to each data block. Merkel proof of Merkel path; save some of the N data blocks locally, and send other data blocks, root hashes, and Merkel paths corresponding to other data blocks to other consensus nodes, so that Other consensus nodes broadcast and verify the data block. Taking a total of 4 consensus nodes (consensus node 1-consensus node 4) as an example, the target node is consensus node 1, and consensus node 1 splits the local pending consensus proposal into 4 data blocks after processing with erasure codes, which are respectively Data block 1-data block 4, use the preset Hash algorithm to perform Hash operation on the 4 data blocks, get the Hash values of the 4 data blocks, and build a Merkle tree based on the hash values of the 4 data blocks, the data block The hash value of 1 is Hash1, the hash value of data block 2 is Hash2, the hash value of data block 3 is Hash3, and the hash value of data block 4 is Hash4. Hash12 is obtained by calculating Hash1 and Hash2, and Hash3 and Hash4 are calculated. Hash34, calculate Hash12 and Hash34 to get the root Hash, so as to get the Merkle tree. It can be understood that the above only takes 4 nodes as an example. In practical applications, more complex Merkle trees can be constructed according to different numbers of consensus nodes. After building the Merkle tree, consensus node 1 can store data block 1 locally, send data block 2, Hash1, Hash34 and root Hash to consensus node 2; send data block 3, Hash4, Hash12 and root Hash To consensus node 3; send data block 4, Hash3, Hash12 and root Hash to consensus node 4. Take the content sent to consensus node 2 as an example, where Hash1 and Hash34 are the Merkel proofs of the Merkel path corresponding to data block 2. Consensus node 1 can send the above content to other consensus nodes in Rval message format. After other consensus nodes receive the above content sent by consensus node 1, they can broadcast the above content to other consensus nodes in Echo message format. After receiving the Echo message, other consensus nodes can verify whether the message is legal. Specifically, after receiving the message, for the data block in the message, use the Merkle proof of the Merkle path corresponding to the data block , root hash for verification; if the verification is passed, it is determined that the message is legal.
延续上述的例子,共识节点3在接收到Echo消息后,确定该消息内容为:数据块4、Hash3、Hash12以及根Hash,则可以对该数据块4进行计算得到Hash4,将Hash4与接收到的Hash3计算得到Hash34,将Hash34与接收到的Hash12进行计算得到根Hash,如果该计算得到的根Hash与接收到的根Hash相同,则说明该Echo消息合法,如果验证不通过,则可以直接丢弃该Echo消息,以避免恶意节点对消息的篡改。Continuing the above example, after receiving the Echo message, the consensus node 3 determines that the content of the message is: data block 4, Hash3, Hash12 and root Hash, then it can calculate the data block 4 to get Hash4, and combine Hash4 with the received Hash3 is calculated to get Hash34, and Hash34 is calculated with the received Hash12 to get the root Hash. If the calculated root Hash is the same as the received root Hash, it means that the Echo message is legal. If the verification fails, the root Hash can be discarded directly. Echo messages to avoid tampering of messages by malicious nodes.
通过上述方式共识节点2至共识节点4可以接收到共识节点1(目标节点)发送的出所有数据块(在没有节点故意不发送数据块的情况下),任一节点可以在接收到N-f个Echo消息后,且该N-f个Echo消息均验证通过的情况下,选取其中任意N-2f个数据块还原待共识提议,并且可以重构默克尔树,比较重构得到的默克尔树的根Hash与之前接收到的Echo中的根Hash是否一致,如果一致则广播Ready消息。In the above way, consensus node 2 to consensus node 4 can receive all data blocks sent by consensus node 1 (target node) (in the case that no node intentionally does not send data blocks), any node can receive N-f Echo After the message, and the N-f Echo messages are all verified, select any N-2f data blocks to restore the consensus proposal, and the Merkle tree can be reconstructed, and the root of the reconstructed Merkle tree can be compared Whether the Hash is consistent with the root Hash in the Echo received before, and if it is consistent, the Ready message will be broadcast.
可以理解的是,虽然上述是以目标节点1为例进行说明,但是在本说明书示出的共识方法中,各个共识节点没有主副之分,即任一个共识节点均为目标节点,任一共识节点均可以通过上述方式得到其他共识节点的待共识提议;任一共识节点也均是通过上述方式将本地的待共识提议发送至其他共识节点。It is understandable that, although the above description takes target node 1 as an example, in the consensus method shown in this specification, each consensus node has no primary and secondary distinction, that is, any consensus node is a target node, and any consensus node Nodes can obtain consensus proposals from other consensus nodes through the above methods; any consensus node can also send local consensus proposals to other consensus nodes through the above methods.
各个共识节点可以同时发出本地的待共识提议,因此目标节点可能会先后接收到不同共识节点发送的待共识提议。目标节点在接收到其他共识节点发的的待共识提议后,可以针对每一个待共识均提议执行S201-S203,即可以针对区块链网络中每个共识节点广播的待共识提议分别达成共识。Each consensus node can send local pending consensus proposals at the same time, so the target node may successively receive pending consensus proposals sent by different consensus nodes. After receiving the pending consensus proposals sent by other consensus nodes, the target node can execute S201-S203 for each pending consensus proposal, that is, it can reach consensus on the pending consensus proposals broadcast by each consensus node in the blockchain network.
可以理解的是,上述仅为可靠广播RBC协议的一种具体实现方式,还可以通过其他方式实现可靠广播RBC,具体可以参照相关技术,本说明书对此不进行限定。It can be understood that, the foregoing is only a specific implementation manner of the reliable broadcast RBC protocol, and the reliable broadcast RBC may also be implemented in other ways, for details, reference may be made to related technologies, which is not limited in this description.
在上述S202中,目标节点具体可以是在接收到任一个共识节点通过可靠广播RBC协议广播的待共识提议的情况下,若还未针对该待共识提议开始执行所述可再投票的二元共识算法,则将该待共识提议的初始投票值确定为优先投票值;In the above S202, the target node may specifically receive the proposal to be consensus broadcast by any consensus node through the reliable broadcast RBC protocol, if the proposal to be consensus has not yet started to implement the binary consensus that can be voted again Algorithm, the initial voting value of the proposed consensus proposal is determined as the priority voting value;
另外,若已针对该待共识提议开始执行可再投票的二元共识算法,且还未得到该待共识提议的共识结果的情况下,则重新将该待共识提议的初始投票值确定为优先投票值;In addition, if the binary consensus algorithm that can be voted again has been implemented for the proposal to be consensus, and the consensus result of the proposal to be consensus has not been obtained, the initial voting value of the proposal to be consensus will be re-determined as the priority vote value;
在接收到N-f个共识节点广播的待共识提议的情况下,将还未开始执行可再投票的二元共识算法的待共识提议的初始投票值确定为其他投票值。In the case of receiving the pending consensus proposals broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposals that have not started to execute the re-voting binary consensus algorithm is determined as other voting values.
其中,投票值包括优先投票值以及其他投票值两种值,本说明书提出设置其中一种投票值为优先投票值,即希望各个共识节点偏向于该优先投票值达成共识,在一个具体的示例中可以用1和0分别表示优先投票值以及其他投票值,其中,优先投票值可以为1也可以为0,下文中均以优先投票值为1,以其他投票值为0为例进行说明。Among them, the voting value includes the priority voting value and other voting values. This manual proposes to set one of the voting values as the priority voting value, that is, it is hoped that each consensus node will reach a consensus on the priority voting value. In a specific example 1 and 0 can be used to represent the priority voting value and other voting values respectively, wherein the priority voting value can be 1 or 0, and the following descriptions will take the priority voting value of 1 and other voting values of 0 as an example.
以N为7,f为2为例进行说明,目标节点在接收到任一共识节点广播的待共识提议之后,确定是否已经开始针对该待共识提议执行了再投票的二元共识算法,如果没有,则将该待共识提议的初始投票值确定为优先投票值1,并以优先投票值1作为可再投票的二元共识算法的输入,以得到针对该待共识提议的共识结果。Taking N as 7 and f as 2 as an example, the target node determines whether it has started to execute the binary consensus algorithm of re-voting for the consensus proposal after receiving the consensus proposal broadcast by any consensus node, if not , then the initial voting value of the proposal to be consensus is determined as the priority voting value 1, and the priority voting value 1 is used as the input of the re-voting binary consensus algorithm to obtain the consensus result for the proposal to be consensus.
另外,在确定接收到N-f即7-2=5个共识节点广播的待共识提议,即已经开始针对5个待共识提议分别以优先投票值1作为输入,开始执行可再投票的二元共识算法时,可以将剩余的其他还未开始执行可再投票的二元共识算法的2个待共识提议的初始投票值确定为其他投票值0,并开始执行可再投票的二元共识算法。In addition, after it is determined that the consensus proposals broadcast by N-f, that is, 7-2=5 consensus nodes, have been received, the binary consensus algorithm that can be voted again has started to be executed with the priority voting value 1 as input for the 5 consensus proposals. , the initial voting value of the remaining two proposals to be consensus that have not started to implement the re-voting binary consensus algorithm can be determined as the other voting value 0, and start to execute the re-voting binary consensus algorithm.
同时,目标节点在接收到任一共识节点广播的待共识提议之后,若已针对该待共识提议开始执行可再投票的二元共识算法,并且该待共识提议的初始投票值为其他投票值0,且还未得到该待共识提议的共识结果,则重新将该待共识提议的初始投票值确定为优先投票值。At the same time, after the target node receives the pending consensus proposal broadcast by any consensus node, if it has started to execute the binary consensus algorithm that can be voted again for the pending consensus proposal, and the initial voting value of the pending consensus proposal is 0 , and the consensus result of the pending consensus proposal has not been obtained, the initial voting value of the pending consensus proposal is re-determined as the priority voting value.
可靠广播RBC协议可以保证目标节点在接收任一待共识提议时,仅会接收到一次,而非多次接收同一待共识提议,因此在针对某一待共识提议已经开始执行可再投票的二元共识算法,而后才接收到该待共识提议,则说明该待共识提议的初始投票值为其他投票值0,进一步可以将该待共识提议的初始投票值修改为优先投票值1,并再次以优先投票值1为输入再次触发执行可再投票的二元共识算法。The reliable broadcast RBC protocol can ensure that the target node will only receive once when receiving any pending consensus proposal, instead of receiving the same pending consensus proposal multiple times. consensus algorithm, and then receive the proposal to be consensus, it means that the initial voting value of the proposal to be The voting value of 1 is the input to trigger the execution of the re-voting binary consensus algorithm again.
上述S203中,可以是针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,则开始采用可再投票的二元共识算法确定该待共识提议的共识结果,具体可以是针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,即将该初始投票值作为所述可再投票的二元共识算法的输入,以该算法的输出作为该待共识提议的共识结果。In the above S203, it can be for any proposal to be agreed upon. When it is determined that the proposal to be agreed upon has an initial voting value, the binary consensus algorithm that can be voted for is then used to determine the consensus result of the proposal to be agreed upon. Specifically, it can be For any consensus proposal, if it is determined that the consensus proposal has an initial voting value, the initial voting value will be used as the input of the re-voting binary consensus algorithm, and the output of the algorithm will be used as the consensus proposal consensus results.
可见,本说明书中提出的拜占庭容错方法,不需要等待N-f个共识节点的待共识提议的二元共识步骤执行完成后,才开始执行剩下f个待共识提议的二元共识步骤,而是基于每个待共识提交的接收情况直接确定各个待共识提议的初始投票值,并触发执行各待共识提议的二元共识过程,从这个层面而言,任何一个待共识提议的二元共识过程的执行,不需要依赖其他待共识提议的共识完成情况,因此各个待共识提议的共识过程是并行处理的,从而缩短了每次共识过程的时长,提高了共识效率。It can be seen that the Byzantine fault tolerance method proposed in this specification does not need to wait for the execution of the binary consensus steps of the N-f consensus nodes to be proposed before starting to execute the binary consensus steps of the remaining f pending consensus proposals. Instead, it is based on The reception of each pending consensus submission directly determines the initial voting value of each pending consensus proposal, and triggers the execution of the binary consensus process of each pending consensus proposal. From this perspective, the execution of any pending consensus proposal’s binary consensus process , does not need to rely on the completion of the consensus of other pending consensus proposals, so the consensus process of each pending consensus proposal is processed in parallel, thus shortening the duration of each consensus process and improving consensus efficiency.
如图3所述,对标图1所示的现有的基于二元共识的拜占庭容错算法,图中仍共存在7个共识节点,即N为7,f为2,目标节点在接收到了节点0-节点4的待共识提议后,就开始针对节点0-节点4的待共识提议分别执行可再投票的二元共识算法RABA(reproposable asynchronous binary agreement),即将RABA 0-RABA 4的输入均设置为1(优先投票值)并开始执行,并且直接将对应于节点5和节点6的RABA 5和RABA 6的输入均设置为0(其他投票值)并开始执行,即在接收到N-f个共识节点的待共识提议的最后一个待共识提议的情况下,就开始触发剩余f个还未开始执行RABA的待共识提议开始执行,如图中所示,在节点3开始以1为输入执行开始RABA 3时,就将RABA 5和RABA 6的输入均设置为0,触发开始执行RABA 5和RABA 6。另外,节点5和节点6的RABA 5和RABA 6的输入设置为0之后,且还未得到RABA 5和RABA 6的输出结果时,如果又接收到了节点5和节点6的待共识提议,那么可以将RABA 5和RABA 6的输入更改为1,再次触发执行RABA 5和RABA 6,以得到RABA 5和RABA 6的输出结果。与图1所示出的不同,本说明书提出的拜占庭容错方法不是在执行完节点0-节点4的待共识提议的ABA过程后,才执行ABA 5和ABA 6,通常情况下各个共识节点的二元共识过程即ABA过程耗时较长,如果等待N-f个待共识提议的二元共识过程结束后,才串行的执行剩下的f个待共识提议的ABA过程,整体共识过程耗时会较长,本说明提出的拜占庭容错方法中,可以保障各个待共识提议的二元共识过程基本上是在并行处理和发生的,因此,明显缩短了每次共识过程的时长,提高了每次共识的效率。 As shown in Figure 3, compared to the existing Byzantine fault-tolerant algorithm based on binary consensus shown in Figure 1, there are still 7 consensus nodes in the figure, that is, N is 7, f is 2, and the target node receives the node After the pending consensus proposal of node 0-node 4, the re-voting binary consensus algorithm RABA (reproposable asynchronous binary agreement) will be executed for the pending consensus proposal of node 0-node 4, that is, the input of RABA 0 -RABA 4 will be set 1 (priority voting value) and start execution, and directly set the inputs of RABA 5 and RABA 6 corresponding to nodes 5 and 6 to 0 (other voting values) and start execution, that is, after receiving Nf consensus nodes In the case of the last consensus proposal of the pending consensus proposal, it starts to trigger the execution of the remaining f pending consensus proposals that have not yet started to execute RABA. As shown in the figure, node 3 starts to execute RABA 3 with 1 as input , the inputs of RABA 5 and RABA 6 are both set to 0, triggering the execution of RABA 5 and RABA 6 . In addition, after the input of RABA 5 and RABA 6 of node 5 and node 6 is set to 0, and the output results of RABA 5 and RABA 6 have not been obtained, if the pending consensus proposal of node 5 and node 6 is received, then it can Change the input of RABA 5 and RABA 6 to 1, and trigger the execution of RABA 5 and RABA 6 again to get the output of RABA 5 and RABA 6 . Different from what is shown in Figure 1, the Byzantine fault tolerance method proposed in this specification does not execute ABA 5 and ABA 6 after the ABA process of node 0-node 4 to be proposed by consensus is executed. The meta-consensus process, that is, the ABA process, takes a long time. If you wait for the end of the binary consensus process of Nf consensus proposals to be proposed, and then serially execute the remaining f ABA processes to be proposed by consensus, the overall consensus process will take a long time. Long, in the Byzantine fault tolerance method proposed in this note, it can guarantee that the binary consensus process of each proposal to be consensus is basically processed and occurred in parallel. Therefore, the duration of each consensus process is significantly shortened and the consensus rate of each consensus is improved efficiency.
本说明书提出的新的并行运行二元共识的方法即提出的拜占庭容错方法,除了应用在区块链网络中,还可以应用在多方安全计算、和interactive consistency等多个方向中。The new parallel binary consensus method proposed in this manual is the proposed Byzantine Fault Tolerance method. In addition to being applied to the blockchain network, it can also be applied to multiple directions such as multi-party secure computing and interactive consistency.
下面对上述S203中的可再投票的二元共识算法进行说明,本说明书提出的可再投票的二元共识算法,是指允许针对任一待共识提议的输入由其他投票值更改为优先投票值、且输出的共识结果偏向于优先投票值的二元共识算法。The re-voting binary consensus algorithm in the above S203 is described below. The re-voting binary consensus algorithm proposed in this manual refers to allowing the input of any proposal to be consensus to be changed from other voting values to priority voting value, and the output consensus result is biased towards the binary consensus algorithm of the priority voting value.
可以采用多种方式实现可再投票的二元共识算法,下面以对于一个具体的可再投票的二元共识算法的实施方式进行说明,可以理解的是还可以采用其他可再投票的二元共识算法实现本说明书提出的拜占庭容错方法,本说明书对可再投票二元共识算法的具体实现方式不进行限定。A re-voting binary consensus algorithm can be implemented in a variety of ways. The implementation of a specific re-voting binary consensus algorithm will be described below. It is understandable that other re-voting binary consensus algorithms can also be used. The algorithm implements the Byzantine fault tolerance method proposed in this specification, and this specification does not limit the specific implementation of the re-voting binary consensus algorithm.
如图4所示,该算法包括:As shown in Figure 4, the algorithm includes:
S401,针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值以及初始辅助值;S401, for any consensus node's pending consensus proposal, determine the initial voting value and initial auxiliary value corresponding to the pending consensus proposal;
S402,广播携带有初始投票值以及初始辅助值的首轮共识消息;S402, broadcasting the first-round consensus message carrying the initial voting value and the initial auxiliary value;
S403,根据其他共识节点广播的针对该待共识提议的首轮共识消息以及首轮共识策略,就所述优先投票值达成共识。S403. Reach a consensus on the priority voting value according to the first-round consensus message and the first-round consensus strategy for the proposal to be consensus broadcast by other consensus nodes.
投票值,用于表示各个共识节点对该数据的共识意见,其中投票值包括优先投票值以及其他投票值两种值,即各个共识节点可以对待共识提议存在共两种共识意见,优先投票值以及其他投票值在一个实施例中,可以用1和0分别进行表示。辅助值则为本说明书提出的用于协助各个节点就待共识提议达成共识的一种辅助意见,其包括优先投票值以及其他投票值以及空值。Voting value, which is used to represent the consensus opinion of each consensus node on the data, where the voting value includes two values: priority voting value and other voting value, that is, each consensus node can have two kinds of consensus opinions on consensus proposals, priority voting value and In an embodiment, other voting values may be represented by 1 and 0 respectively. The auxiliary value is a kind of auxiliary opinion proposed in this specification to assist each node to reach a consensus on the proposal to be consensus, which includes the priority voting value, other voting values and null values.
在S401中,针对待共识提议确定初始投票值以及初始辅助值,初始辅助值可以默认为空,而初始投票值可以根据上述S202中的内容确定,这里不再进行详述,直接基于S202中得到的初始投票值执行S402,这里可以理解为可再投票的二元共识算法接收上传协议的输入,确定待共识提议的初始投票值;In S401, the initial voting value and the initial auxiliary value are determined for the consensus proposal. The initial auxiliary value can be empty by default, and the initial voting value can be determined according to the content in S202 above. It will not be described in detail here, and it is directly based on the results obtained in S202. Execute S402 for the initial voting value, which can be understood here as the re-voting binary consensus algorithm receives the input of the upload protocol and determines the initial voting value of the consensus proposal;
在S401中,目标节点在确定了初始投票值的情况下,不论初始投票值为优先投票值还是其他投票值,目标节点均可以执行S402,即广播该初始投票值以及初始辅助值,并接收其他共识节点广播的针对该待共识提议的初始投票值以及初始辅助值。In S401, when the target node determines the initial voting value, regardless of whether the initial voting value is the priority voting value or other voting values, the target node can execute S402, that is, broadcast the initial voting value and initial auxiliary value, and receive other voting values. The consensus node broadcasts the initial voting value and initial auxiliary value for the consensus proposal.
另外,本说明书提出为了使各个共识节点能够在首轮共识过程中就该优先投票值快速达成共识,因此允许目标节点在确定的初始投票值为其他投票值的情况下,在又接收到了该待共识提议后可以重新将所述初始投票值确定为优先投票值可以参考上述S202的过程,并再次执行触发执行S401-S403。In addition, this specification proposes that in order to enable each consensus node to quickly reach a consensus on the priority voting value in the first round of consensus process, it allows the target node to receive the priority voting value in the case of the determined initial voting value. After the consensus proposal, the initial voting value can be re-determined as the priority voting value. The process of S202 above can be referred to, and S401-S403 can be triggered again.
上述S402中,具体可以是执行图5所示的方法:In the above S402, specifically, the method shown in FIG. 5 may be executed:
S501,将初始投票值和初始辅助值携带在首轮第一类共识消息中进行广播;S501, carrying the initial voting value and the initial auxiliary value in the first round of the first type of consensus message for broadcasting;
目标节点可以将本地确定的初始投票值以及初始辅助值添加到首轮第一类共识消息中,并通过认证信道将首轮第一类共识消息传输至分布式系统中的其他共识节点,当然在没有认证信道时,为了保证数据传输的安全性,还可以通过数字签名或公钥技术设施等密码学工具保证共识消息传输的安全性,本说明书对此不进行限定。在一个实施例中,第一类共识消息可以是bval r格式的消息,目标节点可以广播形如bval r(est r,maj r)消息,其中est r为投票值,maj r为辅助值,投票值est r是一个二进制数(0或1),maj r∈{0,1,⊥},在首轮中,maj r设置为空,r为共识轮,首轮即第0轮,共识轮从0开始以1为步长递增。 The target node can add the locally determined initial voting value and initial auxiliary value to the first round of the first type of consensus message, and transmit the first round of the first type of consensus message to other consensus nodes in the distributed system through the authentication channel. When there is no authentication channel, in order to ensure the security of data transmission, cryptographic tools such as digital signatures or public key technology facilities can also be used to ensure the security of consensus message transmission, which is not limited in this specification. In one embodiment, the first type of consensus message can be a message in bval r format, and the target node can broadcast a message in the form of bval r (est r , maj r ), where est r is a voting value, maj r is an auxiliary value, and voting The value est r is a binary number (0 or 1), maj r ∈ {0,1,⊥}, in the first round, maj r is set to be empty, r is the consensus round, the first round is the 0th round, and the consensus round starts from Start with 0 and increment in steps of 1.
S502,接收其他共识节点广播的首轮第一类共识消息;S502, receiving the first round of first-type consensus messages broadcast by other consensus nodes;
可以理解的是,分布式系统中的全部正确节点都在执行目标节点所执行的步骤,即其他共识节点也会发送包括针对该待共识提议的初始投票值以及初始辅助值的首轮第一类共识消息;此时,目标节点会接收到来自其他共识节点发送的首轮第一类共识消息。It is understandable that all the correct nodes in the distributed system are executing the steps performed by the target node, that is, other consensus nodes will also send the first round of the first category including the initial voting value and initial auxiliary value for the proposal to be consensus. Consensus message; at this point, the target node will receive the first round of the first type of consensus message sent by other consensus nodes.
在一个实施例中,如果目标节点在首轮共识接收到f+1个首轮第一类共识消息,即超过恶意节点数量的首轮第一类共识消息,如果这f+1个首轮第一类共识消息中的投票值相同,且与本地广播的投票值不一致,目标节点则将本地初始投票值修改为所述f+1个第一类共识消息中的投票值,再次广播第一类共识消息。例如,如果目标节点收到f+1个bval 0(b,⊥)消息,且b与该目标节点的当前轮首次广播的投票值不相等,该目标节点将广播bval 0(b,⊥)。本步骤目的是为了让本地节点可以更正本地投票值。 In one embodiment, if the target node receives f+1 first-round consensus messages in the first round of consensus, that is, the first-round consensus messages exceeding the number of malicious nodes, if the f+1 first-round consensus messages The voting values in one type of consensus messages are the same and inconsistent with the voting values of the local broadcast. The target node modifies the local initial voting value to the voting value in the f+1 first type of consensus messages, and broadcasts the first type of consensus messages again. Consensus news. For example, if the target node receives f+1 bval 0 (b,⊥) messages, and b is not equal to the vote value of the target node’s first broadcast in the current round, the target node will broadcast bval 0 (b,⊥). The purpose of this step is to allow the local node to correct the local voting value.
S503,基于所述初始投票值以及其他共识节点广播的首轮第一类共识消息,重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在首轮第二类共识消息中进行广播。S503. Re-determine the voting value and auxiliary value based on the initial voting value and the first-round first-type consensus message broadcast by other consensus nodes, and carry the re-determined voting value and auxiliary value in the first-round second-type consensus message to broadcast.
其中,各个共识节点每轮仅发送一次第二类共识消息,具体确定第二类共识消息中携带信息的方式可以如下:Among them, each consensus node only sends the second type of consensus message once per round, and the specific way to determine the information carried in the second type of consensus message can be as follows:
在一个实施例中,可以是在本地首次通过第一类共识消息广播的初始投票值为优先投票值的情况下,将该初始投票值添加到第一集合中;并将所述第一集合中的投票值确定为首轮第二类共识消息中的投票值以及辅助值。In one embodiment, when the initial voting value broadcast locally through the first type of consensus message is the priority voting value for the first time, the initial voting value is added to the first set; and the first set The voting value of is determined as the voting value and auxiliary value in the second type of consensus message in the first round.
结合上述例子,目标节点广播bval 0(est 0,maj 0)消息,其中est 0为1(优先投票值),则可以直接将1存入bin_values 0(首轮第一集合,r=0)并广播aux 0(1,1)。其中aux r为第二类共识消息格式。 Combined with the above example, the target node broadcasts bval 0 (est 0 , maj 0 ) message, where est 0 is 1 (priority voting value), then 1 can be directly stored in bin_values 0 (the first set of the first round, r=0) and Broadcast aux 0 (1,1). Where aux r is the second type of consensus message format.
在一个实施例中,在目标节点首次通过第一类共识消息广播的初始投票值不为优先投票值的情况下,若接收到其他共识节点广播的f+1个首轮第一类共识消息,且所述f+1个第一类共识消息中的携带的投票值均为优先投票值,则将所述优先投票值添加到首轮第一集合中,并将所述首轮第一集合中的投票值确定为首轮第二类共识消息中的投票值以及辅助值。In one embodiment, when the initial voting value broadcast by the target node through the first type of consensus message for the first time is not the priority voting value, if f+1 first-round first-type consensus messages broadcast by other consensus nodes are received, And the voting values carried in the f+1 first-type consensus messages are priority voting values, then the priority voting values are added to the first set of the first round, and the first set of the first round The voting value of is determined as the voting value and auxiliary value in the second type of consensus message in the first round.
例如,目标节点收到f+1个bval 0(b,⊥)消息,其中,b=1,即为优先投票值,则将b存入bin_values 0;若此时目标节点还没发送过aux 0()消息,则广播aux 0(1,1)。 For example, if the target node receives f+1 bval 0 (b,⊥) messages, where b=1 is the priority voting value, then store b in bin_values 0 ; if the target node has not sent aux 0 at this time () message, broadcast aux 0 (1,1).
在一个实施例中,在目标节点首次通过第一类共识消息广播的初始投票值不为优先投票值的情况下,若接收到其他共识节点广播的法定数量的首轮第一类共识消息,且所述法定数量的第一类共识消息中的携带的投票值均不为优先投票值即均为其他投票值,则将该其他投票值添加到首轮第一集合中,并将所述首轮第一集合中的投票值确定为首轮第二类共识消息中的投票值以及辅助值。其中,法定数量即为2f+1个共识节点(包括自身节点),如无特殊规定,下文中的法定数量均为2f+1。In one embodiment, when the initial voting value broadcast by the target node through the first type of consensus message for the first time is not the priority voting value, if a quorum of the first round of the first type of consensus message broadcast by other consensus nodes is received, and If the voting values carried in the quorum of first-class consensus messages are not priority voting values, that is, they are all other voting values, the other voting values are added to the first set of the first round, and the first round The voting value in the first set is determined as the voting value and auxiliary value in the second type of consensus message in the first round. Among them, the quorum is 2f+1 consensus nodes (including its own nodes). Unless otherwise specified, the quorum below is 2f+1.
例如,目标节点接收到了2f+1个bval 0(b,⊥)消息,其中,b为0,即不为优先投票值,则目标节点 将b添加到集合bin_values 0中,如果此时目标节点还没发过aux 0()消息,则广播aux 0(0,0)。 For example, if the target node receives 2f+1 bval 0 (b,⊥) messages, where b is 0, that is, it is not a priority voting value, the target node will add b to the set bin_values 0. If the target node is still If no aux 0 () message has been sent, broadcast aux 0 (0,0).
上述方式中,在目标节点本地通过第一类共识消息广播优先投票值后,即可以直接通过第二类共识消息广播优先投票值,而无需参考其他共识节点的意见,目的也是在于可以使各个节点可以就优先投票值快速达成共识,同时也可以使再投票后,针对优先投票值进行的共识进度可以超过针对其他投票值的共识进度。In the above method, after the target node locally broadcasts the priority voting value through the first type of consensus message, it can directly broadcast the priority voting value through the second type of consensus message without referring to the opinions of other consensus nodes. The purpose is also to make each node A consensus can be quickly reached on the priority voting value, and at the same time, after re-voting, the consensus progress for the priority voting value can exceed the consensus progress for other voting values.
目标节点在接收到其他共识节点广播的首轮第二类共识消息后,即可以根据首轮共识策略,确定是否能够就所述优先投票值达成共识,其中,首轮共识策略为使各个共识节点在首轮能够就所述优先投票值快速达成共识的策略。After the target node receives the first-round consensus message broadcast by other consensus nodes, it can determine whether it can reach a consensus on the priority voting value according to the first-round consensus strategy. The first-round consensus strategy is to make each consensus node Strategies that enable rapid consensus on said preferred voting value in the first round.
在一个实施例中,首轮共识策略具体可以是:In one embodiment, the first-round consensus strategy can specifically be:
在接收到法定数量的首轮第二类共识消息后,将接收到的第二类共识消息中的投票值存入到首轮第二集合中,将辅助值存入到首轮第三集合中;将首轮公共抛币值置为所述优先投票值;After receiving a quorum of first-round consensus messages of the second type, the voting value in the second-type consensus messages received will be stored in the second set of the first round, and the auxiliary value will be stored in the third set of the first round ;Set the value of the first round of public coin toss as the priority voting value;
在首轮第二集合中仅包含一种投票值的情况下,若接收到了超过(N+f+1)/2个携带优先投票值的第二类共识消息,则确定共识结果为所述优先投票值;若接收到了超过(N+f+1)/2个携带其他投票值的第二类共识消息,则将次轮第一类共识消息中携带的投票值以及辅助值均设置为其他投票值。In the case that only one voting value is included in the second set of the first round, if more than (N+f+1)/2 second-type consensus messages carrying priority voting values are received, the consensus result is determined to be the priority Voting value; if more than (N+f+1)/2 second-type consensus messages carrying other voting values are received, the voting value and auxiliary value carried in the second-round first-type consensus message are set as other voting values value.
例如,目标节点在收到N-f个aux 0()消息(首轮第二类共识消息)后,目标节点将接收到的aux 0()消息中的投票值和辅助值均存储在vals 0(首轮第二集合)和avals 0(首轮第三集合)中。如果,集合vals 0中仅包含b,其中b为0或1,并且接收到了超过(N+f+1)/2个相同b的aux 0(b,*),*可以是0、1或空中的任意一个值,且b=1(优先投票值),则确定共识结果为1;如果b=0,目标节点则将est r+1(下一共识轮的投票值)与maj r+1(下一共识轮的辅助值)都设置为b。 For example, after the target node receives Nf aux 0 () messages (the second type of consensus messages in the first round), the target node will store the voting value and auxiliary value in the received aux 0 () messages in vals 0 (first round in the second set of the round) and avals 0 (the third set of the first round). If, the set vals 0 contains only b, where b is 0 or 1, and more than (N+f+1)/2 aux 0 (b,*) of the same b is received, * can be 0, 1 or empty Any value of , and b=1 (priority voting value), then the consensus result is determined to be 1; if b=0, the target node will compare est r+1 (the voting value of the next consensus round) with maj r+1 ( The auxiliary value of the next consensus round) are all set to b.
另外,若未收到超过(N+f+1)/2个携带相同投票值的第二类共识消息,则将次轮第一类共识消息中携带的投票值以及辅助值均设置为优先投票值。In addition, if no more than (N+f+1)/2 second-type consensus messages carrying the same voting value are received, the voting value and auxiliary value carried in the second-round first-type consensus message are set as priority voting value.
结合上述例子,若目标节点未收到超过(N+f+1)/2个携带相同投票值的第二类共识消息,则将est r+1与maj r+1都设置为1。 Combining the above example, if the target node does not receive more than (N+f+1)/2 second-type consensus messages carrying the same voting value, then both est r+1 and maj r+1 are set to 1.
可见,采用上述首轮共识策略,可以使各个共识节点就优先投票值快速达成共识,提高了共识效率。It can be seen that adopting the above-mentioned first-round consensus strategy can enable each consensus node to quickly reach a consensus on the priority voting value, which improves the consensus efficiency.
上述S401-S403为可再投票的二元共识算法的首轮共识的方式,下面介绍其他轮共识的方式:The above S401-S403 are the first-round consensus method of the re-voting binary consensus algorithm, and the other rounds of consensus methods are introduced below:
除了首轮以外,其他轮的共识均是采用如图6所示的方法达成共识:Except for the first round, the consensus of the other rounds is reached by the method shown in Figure 6:
在首轮没有就优先投票值达成共识的情况下,则可以开始循环执行S601-S602,直到得到针对该待共识提议的共识结果:In the case that no consensus is reached on the priority voting value in the first round, S601-S602 can be executed cyclically until the consensus result for the pending consensus proposal is obtained:
S601,广播本轮共识消息,所述共识消息中携带本轮投票值以及辅助值;S601. Broadcast the consensus message of the current round, and the consensus message carries the voting value of the current round and the auxiliary value;
S602,基于接收到的其他共识节点广播的针对该待共识提议的投票值和辅助值,确定是否得到共识结果。S602. Based on the received voting value and auxiliary value for the proposal to be consensus broadcast by other consensus nodes, determine whether to obtain a consensus result.
其中,在S601中具体可以是:Wherein, in S601, it may specifically be:
S601a,将投票值和辅助值携带在第一类共识消息中进行广播;S601a, carrying the voting value and the auxiliary value in the first type of consensus message for broadcasting;
S601b,接收其他共识节点广播的第一类共识消息;S601b, receiving the first type of consensus message broadcast by other consensus nodes;
S601c,基于接收到的第一类共识消息重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播。S601c. Re-determine the voting value and the auxiliary value based on the received first-type consensus message, and broadcast the re-determined voting value and auxiliary value in the second-type consensus message.
其中,S601a-S601b的过程可以参照上述S501-S502中的内容,这里不在进行详述,区别仅在于携带在第一类共识消息中广播的投票值以及辅助值不为初始投票值和初始辅助值,而是首轮共识之后,基于消息传输结果重新确定的投票值和辅助值,具体可以参照上述关于S403以及后续S602的部分,这里不进行详述。Among them, the process of S601a-S601b can refer to the content in the above-mentioned S501-S502, which will not be described in detail here. The only difference is that the voting value and auxiliary value broadcast in the first type of consensus message are not the initial voting value and initial auxiliary value. , but after the first round of consensus, the voting value and auxiliary value are re-determined based on the message transmission results. For details, please refer to the above-mentioned part about S403 and subsequent S602, which will not be described in detail here.
S601c中,可以是目标节点在接收到法定数量的第一类共识消息后,根据接收到的第一类共识消息重新确定投票值以及辅助值。In S601c, after receiving a quorum of first-type consensus messages, the target node re-determines the voting value and the auxiliary value according to the received first-type consensus messages.
具体的,如果这2f+1个第一类共识消息中的投票值相同,目标节点则将该投票值添加到第一集合中。例如,如果目标节点收到2f+1个bval r(b,*)消息,b∈{0,1}。则目标节点将b添加到第一集合bin_values r中。此外,目标节点将上述2f+1个第一类共识消息中的辅助值,也添加到辅助值集合majs中。本步骤中,在接收到法定数量的相同投票值的情况下,则将该投票值存储到第一集合中,意味着系统中大多数节点可能达成了共识。目标节点可以将第一集合中的投票值,与上一轮的公共抛币值进行比较,并根据比较结果确定第二类共识消息中携带的投票值以及辅助值。其中,公共抛币值,只有0或1两种值,各个共识节点可以在某一轮中获得相同的公共抛币值,且除了首轮以外其他的每一轮的抛币值是随机的,获得公共抛币值的方法可以是采用门限签名算法等方式获得,具体内容可以参照相关技术,这里不进行限定。 Specifically, if the voting values in the 2f+1 first-type consensus messages are the same, the target node will add the voting values to the first set. For example, if the target node receives 2f+1 bval r (b,*) messages, b∈{0,1}. Then the target node adds b to the first set bin_values r . In addition, the target node also adds the auxiliary values in the above 2f+1 first-type consensus messages to the auxiliary value set majs. In this step, if a quorum of the same voting value is received, the voting value is stored in the first set, which means that most nodes in the system may have reached a consensus. The target node can compare the voting value in the first set with the public coin toss value of the previous round, and determine the voting value and auxiliary value carried in the second type of consensus message according to the comparison result. Among them, the public coin toss value has only two values of 0 or 1. Each consensus node can obtain the same public coin toss value in a certain round, and the value of each round of coin toss is random except for the first round. The method of currency value can be obtained by means of threshold signature algorithm, etc., and the specific content can refer to related technologies, which are not limited here.
具体的根据比较结果确定第二类共识消息中携带的投票值以及辅助值的方式可以如下:The specific way to determine the voting value and auxiliary value carried in the second type of consensus message according to the comparison result can be as follows:
一种情况是,如果第一集合中的投票值与上一轮的公共抛币值相等,并且目标节点接收过的第一类共识消息中携带的投票值均为该第一集合中的投票值,携带的辅助值均为该第一集合中的投票值或空,则将第二类共识消息中的投票值以及辅助值设置为该第一集合中的投票值并进行广播;如果还接收过携带其他投票值的第一类共识消息,则将第二类共识消息中的投票值设置为空,并且将第二类共识消息中的辅助值设置为该第一集合中的投票值。One situation is that if the voting value in the first set is equal to the public coin toss value of the previous round, and the voting values carried in the first type of consensus messages received by the target node are all voting values in the first set, The auxiliary values carried are all voting values in the first set or empty, then set the voting values and auxiliary values in the second type of consensus message as the voting values in the first set and broadcast; if the carrying For the first type of consensus message with other voting values, the voting value in the second type of consensus message is set to be empty, and the auxiliary value in the second type of consensus message is set as the voting value in the first set.
延续上述的例子,如果第一集合中的投票值为b,上一轮的公共抛币值为S r-1,如果b=S r-1,并且目标节点仅接收过bval r(b,b)和bval r(b,⊥)消息,则直接广播aux r(b,b),如果还接收过携带其他投票值的第一类共识消息,则广播aux r(⊥,b)。 Continuing the above example, if the voting value in the first set is b, the value of the public coin toss in the last round is S r-1 , if b=S r-1 , and the target node has only received bval r (b,b) and bval r (b,⊥) messages, broadcast aux r (b,b) directly, and broadcast aux r (⊥,b) if the first type of consensus message carrying other voting values is also received.
另一种情况是,如果第一集合中的投票值与上一轮的公共抛币值不相等,并且目标节点接收过的第一类共识消息中携带的投票值以及辅助值均为该第一集合中的投票值的情况下,则将第二类共识消息中的投票值以及辅助值设置为该第一集合中的投票值,并进行广播;如果还接收过携带其他投票值或辅助值的第一类共识消息,则将第二类共识消息中的投票值设置为空,并且将第二类共识消息中的辅助值设置为该第一集合中的投票值。延续上述的例子,如果第一集合中的投票值为b,上一轮的公共抛币值为S r-1,如果
Figure PCTCN2022111000-appb-000001
其中,
Figure PCTCN2022111000-appb-000002
由于抛币值只有两个值0或1,投票值也只有两个值0或1,因此在投票值b不等于抛币值S r-1时,则等于1-S r-1
Figure PCTCN2022111000-appb-000003
在这种情况下,且目标节点仅接收过bval r(b,b)消息,则直接广播aux r(b,b),如果还接收过携带其他投票值或辅助值的第一类共识消息,则广播aux r(⊥,b)。
Another situation is that if the voting value in the first set is not equal to the public coin toss value of the previous round, and the voting value and auxiliary value carried in the first type of consensus message received by the target node are both the first set In the case of the voting value in the second consensus message, set the voting value and auxiliary value in the second type of consensus message as the voting value in the first set and broadcast it; If one type of consensus message is used, the voting value in the second type of consensus message is set to be empty, and the auxiliary value in the second type of consensus message is set as the voting value in the first set. Continuing the above example, if the voting value in the first set is b, the value of the public coin toss in the last round is S r-1 , if
Figure PCTCN2022111000-appb-000001
in,
Figure PCTCN2022111000-appb-000002
Since the coin toss value has only two values, 0 or 1, and the voting value has only two values, 0 or 1, so when the voting value b is not equal to the coin toss value S r-1 , it is equal to 1-S r-1 , that is
Figure PCTCN2022111000-appb-000003
In this case, and the target node has only received the bval r (b, b) message, it will broadcast aux r (b, b) directly. If it has also received the first type of consensus message carrying other voting values or auxiliary values, Then broadcast aux r (⊥,b).
每个共识节点每轮只广播一次第二共识信息,上述方式为目标节点确定非首轮第二类共识消息中携带的投票值以及辅助值的方式。Each consensus node only broadcasts the second consensus information once in each round. The above method is the method for the target node to determine the voting value and auxiliary value carried in the second type of consensus message not in the first round.
目标节点在发送第二类共识消息时,由于其他共识节点也会异步的发送第二类共识消息,因此目标节点会接收到其他共识节点发的第二类共识消息。目标节点在接收到其他共识节点发送的共识消息后,可以先将一些明显非法的第二类共识消息删除,根据上述内容可知,由于正确的共识节点仅会广播形如aux r(b,b)以及aux r(⊥,b)的第二类共识消息,因此在接收到携带其他投票值或辅助值的消息时可以直接丢弃,由于第二类共识消息中的投票值是存储在第一集合中的,因此可以在接收到第二类共识消息后,利用第一集合确定合法和非法消息。 When the target node sends the second type of consensus message, since other consensus nodes will also send the second type of consensus message asynchronously, the target node will receive the second type of consensus message sent by other consensus nodes. After the target node receives the consensus messages sent by other consensus nodes, it can first delete some obviously illegal second-type consensus messages. According to the above content, since the correct consensus node will only broadcast aux r (b,b) And the second type of consensus message of aux r (⊥,b), so when receiving a message carrying other voting values or auxiliary values, it can be discarded directly, because the voting value in the second type of consensus message is stored in the first set Therefore, after receiving the second type of consensus message, the first set can be used to determine legal and illegal messages.
在上述S602中,目标共识节点基于接收到的投票值和辅助值确定是否得到共识结果,如果没有得到共识结果,则确定下一轮的投票值以及辅助值,并重新开始执行S601。In the above S602, the target consensus node determines whether a consensus result is obtained based on the received voting value and auxiliary value. If no consensus result is obtained, the next round of voting value and auxiliary value is determined, and execution of S601 is restarted.
下面对目标共识节点基于接收到的投票值和辅助值确定共识结果,以及确定下一轮投票值和辅助值的方法进行详述:The following is a detailed description of how the target consensus node determines the consensus result based on the received voting value and auxiliary value, and determines the next round of voting value and auxiliary value:
目标节点在接收到法定数量的第二类共识消息后,可以将接收到的第二类共识消息中的投票值以及辅助值分别存入第二集合vals r以及第三集合avals r中,并获得本轮全部共识节点统一的公共抛币值。例如,目标节点在接收到2f+1个aux r()消息后,可以将接收到的aux r()消息中的投票值和辅助值分别存入集合vals r第二集合)和avals r(第三集合)中。目标节点可以根据接收到的第二类共识消息的情况,按照下述方式确定共识结果、或下一轮共识中第一类共识消息所携带的投票值以及辅助值: After the target node receives a quorum of second-type consensus messages, it can store the voting value and auxiliary value in the second-type consensus messages received in the second set vals r and the third set avals r respectively, and obtain The unified public coin toss value of all consensus nodes in this round. For example, after receiving 2f+1 aux r () messages, the target node can store the voting value and auxiliary value in the received aux r () messages into the sets vals r ( second set) and avals r (the second set) respectively three sets). The target node can determine the consensus result, or the voting value and auxiliary value carried by the first type of consensus message in the next round of consensus according to the situation of the second type of consensus message received:
(a)如果目标节点接收到的第二类共识消息中,存在超过法定数量的第二类共识消息是相同的,且这些第二类共识消息中投票值与辅助值相同,目标节点则将该第二类共识消息中的投票值与本轮公共抛币值进行比较,如果该投票值与本轮公共抛币值相同,则目标共识节点确定共识结果为该投票值;如果不相同,目标节点则将下一轮第一类共识消息中携带的投票值以及辅助值均设置为这些第二类共识消息中的投票值,并开始执行下一轮共识。(a) If there are more than quorum of the second consensus messages received by the target node that are the same, and the voting value in these second consensus messages is the same as the auxiliary value, the target node will The voting value in the second type of consensus message is compared with the current round of public coin toss value. If the voting value is the same as the current round of public coin toss value, the target consensus node determines that the consensus result is the voting value; if not, the target node will The voting value and auxiliary value carried in the first type of consensus message in the next round are set as the voting value in these second type of consensus messages, and the next round of consensus is started.
例如,如果目标节点收到法定数量条aux r(b,b)信息,目标节点将b与本轮公共抛币S r进行比较。如果b=S r,目标节点确定共识结果为b;否则,目标节点将est r+1与maj r+1都设置为b,并进入下一轮共识。 For example, if the target node receives a quorum of aux r (b, b) information, the target node will compare b with the current round of public coin toss S r . If b=S r , the target node determines that the consensus result is b; otherwise, the target node sets both est r+1 and maj r+1 to b, and enters into the next round of consensus.
(b)如果目标节点只接收到过合法第二类共识消息,且所述第二集合中的投票值为一种投票值和空,并且至少有法定数量条第二类共识消息的辅助值为该种投票值,则将该种投票值与上一轮共识和本轮共识的公共抛币值分别进行比较。如果该种投票值与上一轮和本轮的公共抛币值均相同,则目标节点确定共识结果该为该种投票值,如果该种投票值与上一轮公共抛币值和/或本轮抛币值不相同,目标共识节点则将下一轮第一类共识消息中的投票值以及辅助值均设置为该种投票值,并开始执行下一轮共识。(b) If the target node has only received legitimate second-type consensus messages, and the voting value in the second set is a voting value and empty, and there are at least a quorum of second-type consensus messages whose auxiliary values are For this type of voting value, compare this type of voting value with the public coin value of the previous round of consensus and the current round of consensus. If this type of voting value is the same as the public coin toss value of the previous round and this round, the target node determines that the consensus result should be this type of voting value. If the currency values are different, the target consensus node will set the voting value and auxiliary value in the first type of consensus message in the next round as this type of voting value, and start the next round of consensus.
例如,如果目标节点只接收到了aux r(b,*)和aux r(⊥,*),并且至少有法定数量的第二类共识消息为aux r(*,b),则目标节点将b与两轮公共抛币S r-1与S r进行比较。如果b=S r-1且b=S r,目标节点确定共识结果为b,否则目标节点将est r+1与maj r+1都设置为b,并进入下一轮。 For example, if the target node has only received aux r (b,*) and aux r (⊥,*), and there is at least a quorum of second-class consensus messages for aux r (*,b), then the target node compares b with Two rounds of public coin flips S r - 1 are compared with S r . If b=S r-1 and b=S r , the target node determines that the consensus result is b, otherwise the target node sets both est r+1 and maj r+1 to b, and enters the next round.
(c)如果目标节点接收到了法定数量的合法第二类共识消息,所述法定数量条第二类共识消息携带的辅助值不完全相同,第二集合中的投票值为一种投票值和空,且该种投票值与上一轮公共抛币值相 同,则目标共识节点将下一轮共识中第一类共识消息中的投票值以及辅助值均设置为该种投票值,并开始执行下一轮共识。例如,如果目标节点接收了N-f条aux r(b,*)和aux r(⊥,*)消息,其中同时包含aux r(*,0)与aux r(*,1),且b=S r-1,则目标节点将est r+1与maj r+1都设置为b,并进入下一轮共识。 (c) If the target node has received a quorum of legitimate second-type consensus messages, and the auxiliary values carried by the quorum of second-type consensus messages are not exactly the same, the voting value in the second set is a voting value and an empty , and this type of voting value is the same as the previous round of public coin toss, the target consensus node will set the voting value and auxiliary value in the first type of consensus message in the next round of consensus as this type of voting value, and start to execute the next round of consensus. For example, if the target node receives Nf aux r (b,*) and aux r (⊥,*) messages, which contain both aux r (*,0) and aux r (*,1), and b=S r -1 , the target node sets both est r+1 and maj r +1 to b, and enters the next round of consensus.
(d)如果目标节点接收到的第二类共识消息的情况不属于上述三种情况,即若接收到的第二共识消息中包括两种投票值;或者,目标节点接收到的法定数量的合法第二类共识消息携带的辅助值不相同,第二集合中的投票值为一种投票值和空,且该种投票值与上一轮公共抛币值不相同;则目标节点可以将本轮公共抛币值作为下一轮第一类共识消息的投票值,将下一轮的第一共消息中的辅助值设置为第二集合中的出现次数超过预设次数的值,并进入下一轮共识。(d) If the second type of consensus message received by the target node does not belong to the above three situations, that is, if the received second consensus message includes two voting values; The auxiliary value carried by the second type of consensus message is different, the voting value in the second set is a kind of voting value and empty, and this kind of voting value is different from the previous round of public coin flip; The coin toss value is used as the voting value of the first type of consensus message in the next round, and the auxiliary value in the first consensus message of the next round is set to a value whose occurrence times in the second set exceeds the preset number of times, and enters the next round of consensus .
例如,如果目标节点接收到的第二类共识消息的情况不属于上述三种情况,目标节点将当轮公共抛币值作为下一轮输入(即将est r+1设置为S r)。目标节点将maj r+1设置为majority(vals r),其中,majority(vals r)=b,b∈{0,1},代表b在vals r中出现次数占大多数,即vals r中b的数量不小于
Figure PCTCN2022111000-appb-000004
若不存在这样的b,则令majority(vals r)=⊥。
For example, if the second type of consensus message received by the target node does not belong to the above three situations, the target node will use the public coin toss value of the current round as the next round input (that is, set est r+1 to S r ). The target node sets maj r+1 as majority(vals r ), where majority(vals r )=b, b∈{0,1}, which means that b appears in the majority of vals r , that is, b in vals r The number is not less than
Figure PCTCN2022111000-appb-000004
If there is no such b, let majority(vals r )=⊥.
可以理解的是,上述方法是共识节点中的任一正确节点所执行的方法,其他正确共识节点也在异步执行上述方法,采用上述方式,设于优先投票值,在首轮中各个共识节点大概率可以就优先投票值达成共识,可以使异步环境下的分布式系统中的各个共识节点快速就优先投票值达到共识状态,大大提升了异步环境下分布式系统的共识效率。由于,可再投票的二元共识算法,可以允许目标节点针对任一待共识提议,多次确定初始投票值,具体是在确定某个待共识提议的初始投票值为其他投票值0的情况下,以其他投票值0作为输入开始执行可再投票的二元共识算法,且未得到共识结果的情况下,又接收到了该待共识提议,那么可以再次投票,即再次确定该待共识提议的共识结果为优先投票值1,并以优先投票值1作为输入再次执行可再投票的二元共识算法,并且由于该再投票的二元共识算法是偏向于优先投票值达成共识的,且大概率在共识首轮就可以基于优先投票值达成共识,并且在共识首轮无法基于其他投票值达成共识,即该可再投票的二元共识算法偏向于输出为1,且在输入为0和输入为1的两种情况下,在输入为1的情况下该算法执行更快,因此,可以使用可再投票的二元共识算法来实现本说明书提出的拜占庭容错方法。It can be understood that the above method is the method executed by any correct node among the consensus nodes, and other correct consensus nodes are also executing the above method asynchronously. Using the above method, set the priority voting value, and each consensus node in the first round Probability can reach a consensus on the priority voting value, and can make each consensus node in the distributed system in the asynchronous environment quickly reach a consensus state on the priority voting value, which greatly improves the consensus efficiency of the distributed system in the asynchronous environment. Because of the binary consensus algorithm that can be voted again, the target node can determine the initial voting value multiple times for any proposal to be consensus, specifically when the initial voting value of a proposal to be consensus is determined to be 0 for other voting values , start to execute the binary consensus algorithm that can be voted again with the other voting value 0 as input, and if the consensus result is not obtained, and the pending consensus proposal is received, then you can vote again, that is, re-determine the consensus of the pending consensus proposal The result is the priority voting value of 1, and the re-voting binary consensus algorithm is executed again with the priority voting value of 1 as input, and because the re-voting binary consensus algorithm is biased towards the priority voting value to reach a consensus, and the high probability is in In the first round of consensus, consensus can be reached based on the priority voting value, and consensus cannot be reached based on other voting values in the first round of consensus. In both cases, the algorithm executes faster when the input is 1, therefore, the Byzantine fault-tolerant method proposed in this specification can be realized by using the re-voting binary consensus algorithm.
同时,采用可再投票的共识算法可以保证分布式系统中的共识节点满足以下性质,即以下技术效果:At the same time, adopting a re-voting consensus algorithm can ensure that the consensus nodes in the distributed system meet the following properties, that is, the following technical effects:
有效性:在所有正确节点广播的投票值均为v、且没有再次广播其他投票值的情况下,那么所有正确节点的共识结果均为该投票值v;Validity: In the case that the voting value broadcast by all correct nodes is v, and no other voting value is broadcast again, then the consensus result of all correct nodes is the voting value v;
一致终止:在所有正确节点广播的投票值为相同值v、且没有再次广播其他投票值的情况下,那么所有正确节点均可以终止共识操作,即达成共识;Unanimous termination: when all correct nodes broadcast the same voting value v and do not broadcast other voting values again, then all correct nodes can terminate the consensus operation, that is, reach a consensus;
共识性:如果任一个正确节点确定某一投票值v为共识结果,那么其他终止共识操作的正确节点也会确定该投票值v为共识结果;Consensus: If any correct node determines that a certain voting value v is the consensus result, then other correct nodes that terminate the consensus operation will also determine that the voting value v is the consensus result;
有偏有效性:如果f+1个正确节点广播投票值v,那么正确节点在终止共识时,可以确定该投票值v为共识结果;Biased validity: If f+1 correct nodes broadcast the voting value v, then the correct node can determine that the voting value v is the consensus result when terminating the consensus;
有偏终止:如果Q是正确节点的集合,其中Q1是广播了投票值1没有再次广播投票值0的正确节点的集合,Q2是广播了投票值0又再次广播了投票值1的正确节点的集合,如果
Figure PCTCN2022111000-appb-000005
以及Q=Q1∪Q2,那么所有正确的节点都会达成共识;
Biased termination: If Q is a set of correct nodes, where Q1 is the set of correct nodes that broadcast a vote value of 1 but did not broadcast a vote value of 0 again, and Q2 is the set of correct nodes that broadcast a vote value of 0 and again broadcast a vote value of 1 set if
Figure PCTCN2022111000-appb-000005
And Q=Q1∪Q2, then all correct nodes will reach a consensus;
完整性:正确的节点就一个提议只达成一次共识。Integrity: Correct nodes reach consensus on a proposal only once.
可以理解的是图4、图5、图6以及图4、图5和图6相关部分涉及的内容均为可再投票的二元共识算法的一种具体实施方式,还可以采用其他可再投票的二元共识算法实现本说明书所述的拜占庭共识方法,本说明书对此不进行限定,也并不对其他可再投票的二元共识算法进行赘述,只要是允许针对任一待共识提议的输入由其他投票值更改为优先投票值、且输出的共识结果偏向于优先投票值的二元共识算法,并且满足上述所述的可再投票的二元共识算法的相关性质的二元共识算法,均包括在本说明书提出的可再投票的二元共识算法的范围之内。It can be understood that the content involved in Figure 4, Figure 5, Figure 6 and the relevant parts of Figure 4, Figure 5 and Figure 6 are all a specific implementation of the re-voting binary consensus algorithm, and other re-voting can also be used The Binary Consensus Algorithm implements the Byzantine consensus method described in this manual. This manual does not limit this, nor does it describe other binary consensus algorithms that can be voted in detail, as long as the input for any proposal to be consensus is allowed to be determined by Other voting values are changed to the priority voting value, and the output consensus result is biased towards the binary consensus algorithm of the priority voting value, and the binary consensus algorithm that satisfies the relevant properties of the above-mentioned re-voting binary consensus algorithm includes Within the scope of the re-voting binary consensus algorithm proposed in this specification.
采用上述拜占庭容错方法,可以针对分布式系统中的N个共识节点提出的待共识提议分别得到N个共识结果,在得到N个待共识提议的共识结果后,将共识结果为优先投票值的至少一个待共识提议组成的集合确定为待共识集合;在接收到待共识集合中的全部待共识提议后,按照预设的顺序执行该集合中的待共识提议。Using the above Byzantine fault-tolerant method, N consensus results can be obtained for the pending consensus proposals proposed by the N consensus nodes in the distributed system. After obtaining the consensus results of the N pending consensus proposals, the consensus results are at least A set of pending consensus proposals is determined as the pending consensus set; after receiving all the pending consensus proposals in the pending consensus set, execute the pending consensus proposals in the set according to the preset order.
例如,在针对全部共识节点提出的共识提议达成共识之后,各个正确的共识节点会得到相同的共识结果,结果为包含0和1的序列,例如,共存在7个共识节点P 1-P 7,其中P 1-P 6对应的6个待共识提议的共识结果为1,P 7对应的待共识提议的共识结果为0,则确定P 1-P 6对应的待共识提议组成的集合为待共识集合S,此时任一个正确的共识节点,均会得到这样的一个待共识集合,但是其有可能还未接收到该待共识集合S中的某些待共识提议,由于是采用可靠广播RBC协议广播的待共识提议,因此,可以确 保该共识节点一定可以接收到待共识集合S中的全部待共识提议,基于此,共识节点可以持续等待,等到接收到待共识集合S中的全部待共识提议之后,可以按照预设的执行顺序,执行该共识集合S中的全部待共识提议,即执行P 1-P 6的待共识提议。 For example, after reaching a consensus on the consensus proposals proposed by all consensus nodes, each correct consensus node will get the same consensus result, which is a sequence containing 0 and 1. For example, there are 7 consensus nodes P 1 -P 7 , Among them, the consensus result of the 6 pending consensus proposals corresponding to P 1 -P 6 is 1, and the consensus result of the pending consensus proposal corresponding to P 7 is 0, then the set of pending consensus proposals corresponding to P 1 -P 6 is determined to be consensus Set S, any correct consensus node at this time will get such a set to be consensus, but it may not have received some proposals to be consensus in the set S to be consensus, because it uses the reliable broadcast RBC protocol The broadcasted consensus proposal, therefore, can ensure that the consensus node can receive all the consensus proposals in the consensus set S. Based on this, the consensus node can continue to wait until it receives all the consensus proposals in the consensus set S After that, all the proposals to be agreed in the consensus set S can be executed according to the preset execution sequence, that is, the proposals to be agreed on P 1 -P 6 are executed.
仍以区块链网络为例,在区块链网络中,0或1用于指示是否将相应的共识提议打包成块。例如共有四个共识节点,共识节点1提出的共识提议为P1,共识节点2提出的共识提议为P2,共识节点3提出的共识提议为P3,共识节点4提出的共识提议为P4,使用上述拜占庭容错方法进行共识后得到一个01序列,例如得到的序列为(1,1,1,0),则达成的共识结果为所有节点将P1、P2以及P3打包成块存储在本地、不存储P4,即各个共识节点根据共识结果对各共识提议进行了一致性处理,保证各个共识节点的数据一致性。Still taking the blockchain network as an example, in the blockchain network, 0 or 1 is used to indicate whether to pack the corresponding consensus proposal into a block. For example, there are four consensus nodes. The consensus proposal proposed by consensus node 1 is P1, the consensus proposal proposed by consensus node 2 is P2, the consensus proposal proposed by consensus node 3 is P3, and the consensus proposal proposed by consensus node 4 is P4. The fault-tolerant method obtains a 01 sequence after consensus, for example, the obtained sequence is (1,1,1,0), then the consensus result reached is that all nodes pack P1, P2, and P3 into blocks and store them locally, and do not store P4. That is, each consensus node performs consistent processing on each consensus proposal according to the consensus result to ensure the data consistency of each consensus node.
下面从代码实现的角度对本说明书的S201-S203进行说明:The following describes S201-S203 of this manual from the perspective of code implementation:
伪代码如下:The pseudo code is as follows:
Figure PCTCN2022111000-appb-000006
Figure PCTCN2022111000-appb-000006
上述伪代码中,使用了RBC中的r-broadcast和r-deliver原语,以及propose,repropose,和decide等RABA原语。对于每个epoch,框架包括n个并行的RBC实例和n个并行的RABA实例。In the above pseudo-code, the r-broadcast and r-deliver primitives in RBC are used, as well as RABA primitives such as propose, repropose, and decide. For each epoch, the framework includes n parallel RBC instances and n parallel RABA instances.
在RBC阶段,每个副本p i为RBC实例RBC i广播提案m i。如果p i在RBC j实例中r-deliver了提案m j,p i将开始运行RABA j,并在RABA j中propose1。N-f个RBC实例都r-deliver了提案后,p i不需要等待n-f个RABA实例终止,而是直接在那些没开始运行的RABA实例中propose0。如果p i在RABA j中propose0后,r-deliver了提案m j,且RABA j尚未运行终止,此时p i将在RABA j中repropose1。令S代表decide的值为1的RABA实例序号的集合。若p i在RABA j实例中decide 1,则将p j为RBC j提出的提案m j加入到集合C中。若对任意j∈S,RBC j实例中已经r-deliver([e,j],m j),则按照某种确定性的顺序确认执行C集合中的消息。 In the RBC phase, each replica p i broadcasts a proposal m i for the RBC instance RBC i . If p i r-delivers proposal m j in RBC j instance, p i will start running RABA j and propose1 in RABA j . After Nf RBC instances have r-delivered the proposal, p i does not need to wait for the termination of nf RABA instances, but directly propose0 in those RABA instances that have not started running. If p i propose0 in RABA j , r-deliver the proposal m j , and RABA j has not terminated, then p i will repropose1 in RABA j . Let S denote the set of RABA instance numbers for which the value of decide is 1. If p i is decide 1 in the RABA j instance, add the proposal m j proposed by p j for RBC j to the set C. If for any j∈S, r-deliver([e,j],m j ) has been done in the RBC j instance, then confirm and execute the messages in the C set in a deterministic order.
如图7所示,与上述一种拜占庭容错方法相对应,本说明书还提供了一种拜占庭容错装置,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,其中N≥3f+1,所述f为大于0的整数,所述装置包括:As shown in Figure 7, corresponding to the above-mentioned Byzantine fault-tolerant method, this specification also provides a Byzantine fault-tolerant device, which is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes , wherein N≥3f+1, the f is an integer greater than 0, and the device includes:
通信模块710,用于基于可靠广播RBC协议将本地待共识提议广播至其他共识节点;The communication module 710 is used to broadcast the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
处理模块720,用于针对任一共识节点的待共识提议,基于本地接收情况确定该待共识提议的初始投票值;初始投票值为优先投票值或其他投票值;针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果。The processing module 720 is used to determine the initial voting value of the consensus proposal based on the local reception situation for any consensus node's pending consensus proposal; the initial voting value is the priority voting value or other voting values; for any consensus node with the initial voting value When the consensus is proposed, a re-voting binary consensus algorithm is used to determine the consensus result.
在一个实施例中,所述处理模块720,具体用于在接收到任一个共识节点通过可靠广播RBC协议广播的待共识提议的情况下,若还未针对该待共识提议开始执行所述可再投票的二元共识算法,则将该待共识提议的初始投票值确定为优先投票值;In one embodiment, the processing module 720 is specifically configured to, in the case of receiving a proposal to be consensus broadcast by any consensus node through the reliable broadcast RBC protocol, if the proposal to be consensus has not yet started to execute the reproducible In the binary consensus algorithm for voting, the initial voting value of the proposed consensus proposal is determined as the priority voting value;
若已针对该待共识提议开始执行所述可再投票的二元共识算法,且还未得到该待共识提议的共识 结果,则重新将该待共识提议的初始投票值确定为优先投票值;If the binary consensus algorithm that can be voted again has been implemented for the proposal to be consensus, and the consensus result of the proposal to be consensus has not been obtained, the initial voting value of the proposal to be consensus is re-determined as the priority voting value;
在接收到N-f个共识节点广播的待共识提议的情况下,将还未开始执行可再投票的二元共识算法的待共识提议的初始投票值确定为其他投票值。In the case of receiving the pending consensus proposals broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposals that have not started to execute the re-voting binary consensus algorithm is determined as other voting values.
在一个实施例中,所述处理模块720,具体用于针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,即将该初始投票值作为所述可再投票的二元共识算法的输入,以该算法的输出作为该待共识提议的共识结果。In one embodiment, the processing module 720 is specifically configured to use the initial voting value as the re-voting binary if it is determined that the consensus proposal has an initial voting value for any proposal to be agreed upon. The input of the consensus algorithm takes the output of the algorithm as the consensus result of the proposal to be consensused.
在一个实施例中,所述可再投票的二元共识算法,包括:允许针对任一待共识提议的输入由其他投票值更改为优先投票值、且输出的共识结果偏向于优先投票值的二元共识算法。In one embodiment, the re-voting binary consensus algorithm includes: a binary algorithm that allows the input of any proposal to be consensus to be changed from other voting values to priority voting values, and the output consensus result is biased towards the priority voting value. Meta Consensus Algorithm.
在一个实施例中,所述处理模块720,具体用于在得到N个待共识提议的共识结果后,将共识结果为优先投票值的至少一个待共识提议组成的集合确定为待共识集合;在接收到待共识集合中的全部待共识提议后,按照预设的顺序执行该待共识集合中的待共识提议。In one embodiment, the processing module 720 is specifically configured to, after obtaining the consensus results of the N proposals to be consensus, determine a set consisting of at least one proposal to be consensus whose consensus result is a priority voting value as the set to be agreed upon; After receiving all the pending consensus proposals in the pending consensus set, execute the pending consensus proposals in the pending consensus set in a preset order.
上述装置中各个部件的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。For the implementation process of the functions and effects of each component in the above-mentioned device, please refer to the implementation process of the corresponding steps in the above-mentioned method for details, and details will not be repeated here.
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的。可以根据实际的需要选择其中的部分或者全部模块来实现本说明书方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。As for the device embodiment, since it basically corresponds to the method embodiment, for related parts, please refer to the part description of the method embodiment. The device embodiments described above are illustrative only. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution in this specification. It can be understood and implemented by those skilled in the art without creative effort.
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现前述的方法。该方法至少包括上述图2所示的方法。The embodiment of this specification also provides a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and operable on the processor, wherein the aforementioned method is implemented when the processor executes the program. The method includes at least the method shown in FIG. 2 above.
图8示出了本说明书实施例所提供的一种更为具体的计算设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。FIG. 8 shows a schematic diagram of a more specific hardware structure of a computing device provided by the embodiment of this specification. The device may include: a processor 1010 , a memory 1020 , an input/output interface 1030 , a communication interface 1040 and a bus 1050 . The processor 1010 , the memory 1020 , the input/output interface 1030 and the communication interface 1040 are connected to each other within the device through the bus 1050 .
处理器1010可以采用通用的CPU(Central Processing Unit,中央处理器)、微处理器、应用专用集成电路(Application Specific Integrated Circuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本说明书实施例所提供的技术方案。The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit, central processing unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute related programs to realize the technical solutions provided by the embodiments of this specification.
存储器1020可以采用ROM(Read Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、静态存储设备,动态存储设备等形式实现。存储器1020可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器1020中,并由处理器1010来调用执行。The memory 1020 can be implemented in the form of ROM (Read Only Memory, read-only memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc. The memory 1020 can store operating systems and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 1020 and invoked by the processor 1010 for execution.
输入/输出接口1030用于连接输入/输出模块,以实现信息输入及输出。输入输出/模块可以作为组件配置在设备中(图中未示出),也可以外接于设备以提供相应功能。其中输入设备可以包括键盘、鼠标、触摸屏、麦克风、各类传感器等,输出设备可以包括显示器、扬声器、振动器、指示灯等。The input/output interface 1030 is used to connect the input/output module to realize information input and output. The input/output/module can be configured in the device as a component (not shown in the figure), or can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, and the like.
通信接口1040用于连接通信模块(图中未示出),以实现本设备与其他设备的通信交互。其中通信模块可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信。The communication interface 1040 is used to connect a communication module (not shown in the figure), so as to realize the communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.), and can also realize communication through wireless means (such as mobile network, WIFI, Bluetooth, etc.).
总线1050包括一通路,在设备的各个组件(例如处理器1010、存储器1020、输入/输出接口1030和通信接口1040)之间传输信息。 Bus 1050 includes a path that carries information between the various components of the device (eg, processor 1010, memory 1020, input/output interface 1030, and communication interface 1040).
需要说明的是,尽管上述设备仅示出了处理器1010、存储器1020、输入/输出接口1030、通信接口1040以及总线1050,但是在具体实施过程中,该设备还可以包括实现正常运行所必需的其他组件。此外,本领域的技术人员可以理解的是,上述设备中也可以仅包含实现本说明书实施例方案所必需的组件,而不必包含图中所示的全部组件。It should be noted that although the above device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components. In addition, those skilled in the art can understand that the above-mentioned device may only include components necessary to implement the solutions of the embodiments of this specification, and does not necessarily include all the components shown in the figure.
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现前述的方法。该方法至少包括上述图2所示的方法。The embodiment of the present specification also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the aforementioned method is implemented. The method includes at least the method shown in FIG. 2 above.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. Information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, A magnetic tape cartridge, disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本说明书实施例可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本说明书实施例的技术方案本质上或者说对现 有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本说明书实施例各个实施例或者实施例的某些部分所述的方法。It can be known from the above description of the implementation manners that those skilled in the art can clearly understand that the embodiments of this specification can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the essence of the technical solutions of the embodiments of this specification or the part that contributes to the prior art can be embodied in the form of software products, and the computer software products can be stored in storage media, such as ROM/RAM, A magnetic disk, an optical disk, etc., include several instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this specification.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机,计算机的具体形式可以是个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件收发设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任意几种设备的组合。The systems, devices, modules, or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementing device is a computer, which may take the form of a personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media player, navigation device, e-mail device, game control device, etc. desktops, tablets, wearables, or any combination of these.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,在实施本说明书实施例方案时可以把各模块的功能在同一个或多个软件和/或硬件中实现。也可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for relevant parts, please refer to part of the description of the method embodiments. The device embodiments described above are only illustrative, and the modules described as separate components may or may not be physically separated, and the functions of each module may be integrated in the same or multiple software and/or hardware implementations. Part or all of the modules can also be selected according to actual needs to achieve the purpose of the solution of this embodiment. It can be understood and implemented by those skilled in the art without creative effort.
以上所述仅是本说明书实施例的具体实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本说明书实施例原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本说明书实施例的保护范围。The above is only the specific implementation of the embodiment of this specification. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the embodiment of this specification, some improvements and modifications can also be made. These Improvements and modifications should also be regarded as the scope of protection of the embodiments of this specification.

Claims (10)

  1. 一种拜占庭容错方法,其特征在于,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,该N个共识节点中最多允许存在f个恶意节点,其中N≥3f+1,所述f为大于0的整数,所述方法包括:A Byzantine fault-tolerant method, characterized in that it is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, and a maximum of f malicious nodes are allowed to exist in the N consensus nodes, wherein N ≥3f+1, the f is an integer greater than 0, and the method includes:
    基于可靠广播RBC协议将本地待共识提议广播至其他共识节点;Based on the reliable broadcast RBC protocol, the local consensus proposal is broadcast to other consensus nodes;
    在接收到任一个共识节点通过可靠广播RBC协议广播的待共识提议的情况下,若还未针对该待共识提议开始执行所述可再投票的二元共识算法,则将该待共识提议的初始投票值确定为优先投票值;若已针对该待共识提议开始执行所述可再投票的二元共识算法,且还未得到该待共识提议的共识结果,则重新将该待共识提议的初始投票值确定为优先投票值;In the case of receiving a consensus proposal broadcast by any consensus node through the reliable broadcast RBC protocol, if the re-voting binary consensus algorithm has not been started for the consensus proposal, the initial The voting value is determined as the priority voting value; if the re-voting binary consensus algorithm has been executed for the pending consensus proposal, and the consensus result of the pending consensus proposal has not been obtained, the initial voting of the pending consensus proposal The value is determined as the priority voting value;
    在接收到N-f个共识节点广播的待共识提议的情况下,将还未开始执行可再投票的二元共识算法的待共识提议的初始投票值确定为其他投票值;In the case of receiving the pending consensus proposal broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposal that has not started to execute the re-voting binary consensus algorithm is determined as other voting value;
    针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果。For any pending consensus proposal with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result.
  2. 根据权利要求1所述的方法,其特征在于,所述针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果,包括:The method according to claim 1, characterized in that, for any proposal to be agreed upon with an initial voting value, the consensus result is determined using a re-voting binary consensus algorithm, including:
    针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,即将该初始投票值作为所述可再投票的二元共识算法的输入,以该算法的输出作为该待共识提议的共识结果。For any consensus proposal, if it is determined that the consensus proposal has an initial voting value, the initial voting value will be used as the input of the re-voting binary consensus algorithm, and the output of the algorithm will be used as the consensus proposal consensus results.
  3. 根据权利要求2所述的方法,其特征在于,所述可再投票的二元共识算法,包括:The method according to claim 2, wherein the re-voting binary consensus algorithm comprises:
    允许针对任一待共识提议的输入由其他投票值更改为优先投票值、且输出的共识结果偏向于优先投票值的二元共识算法。A binary consensus algorithm that allows the input of any proposal to be consensus to be changed from other voting values to the priority voting value, and the output consensus result is biased towards the priority voting value.
  4. 根据权利要求1所述的方法,其特征在于,还包括:The method according to claim 1, further comprising:
    在得到N个待共识提议的共识结果后,将共识结果为优先投票值的至少一个待共识提议组成的集合确定为待共识集合;After obtaining the consensus results of the N pending consensus proposals, the set of at least one pending consensus proposal whose consensus result is the priority voting value is determined as the pending consensus set;
    在接收到待共识集合中的全部待共识提议后,按照预设的顺序执行该集合中的待共识提议。After receiving all the proposals to be agreed in the set to be agreed, execute the proposals to be agreed in the set according to the preset order.
  5. 一种拜占庭容错装置,其特征在于,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,该N个共识节点中最多允许存在f个恶意节点,其中N≥3f+1,所述f为大于0的整数,所述装置包括:A Byzantine fault-tolerant device is characterized in that it is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, and a maximum of f malicious nodes are allowed to exist in the N consensus nodes, where N ≥3f+1, the f is an integer greater than 0, and the device includes:
    通信模块,用于基于可靠广播RBC协议将本地待共识提议广播至其他共识节点;The communication module is used to broadcast the local consensus proposal to other consensus nodes based on the reliable broadcast RBC protocol;
    处理模块,在接收到任一个共识节点通过可靠广播RBC协议广播的待共识提议的情况下,若还未针对该待共识提议开始执行所述可再投票的二元共识算法,则将该待共识提议的初始投票值确定为优先投票值;若已针对该待共识提议开始执行所述可再投票的二元共识算法,且还未得到该待共识提议的共识结果,则重新将该待共识提议的初始投票值确定为优先投票值;在接收到N-f个共识节点广播的待共识提议的情况下,将还未开始执行可再投票的二元共识算法的待共识提议的初始投票值确定为其他投票值;针对任一具有初始投票值的待共识提议,采用可再投票的二元共识算法确定其共识结果。The processing module, in the case of receiving a consensus proposal broadcast by any consensus node through the reliable broadcast RBC protocol, if the binary consensus algorithm that can be voted again has not been started for the consensus proposal, then the consensus proposal The initial voting value of the proposal is determined as the priority voting value; if the re-voting binary consensus algorithm has been implemented for the pending consensus proposal, and the consensus result of the pending consensus proposal has not been obtained, the pending consensus proposal will be re- The initial voting value of is determined as the priority voting value; in the case of receiving the consensus proposal broadcast by N-f consensus nodes, the initial voting value of the pending consensus proposal that has not started to execute the re-voting binary consensus algorithm is determined as other Voting value: For any proposal to be consensus with an initial voting value, a re-voting binary consensus algorithm is used to determine the consensus result.
  6. 根据权利要求5所述的装置,其特征在于,The device according to claim 5, characterized in that,
    所述处理模块,具体用于针对任一待共识提议,在确定该待共识提议存在初始投票值的情况下,即将该初始投票值作为所述可再投票的二元共识算法的输入,以该算法的输出作为该待共识提议的共识结果。The processing module is specifically configured to, for any proposal to be consensus, when it is determined that the proposal to be consensus has an initial voting value, the initial voting value is used as the input of the re-voting binary consensus algorithm, and the The output of the algorithm is the consensus result of the proposal to be consensused.
  7. 根据权利要求6所述的装置,其特征在于,The device according to claim 6, characterized in that,
    所述可再投票的二元共识算法,包括:允许针对任一待共识提议的输入由其他投票值更改为优先投票值、且输出的共识结果偏向于优先投票值的二元共识算法。The re-voting binary consensus algorithm includes: a binary consensus algorithm that allows the input of any proposal to be consensus to be changed from other voting values to priority voting values, and the output consensus result is biased towards the priority voting value.
  8. 根据权利要求5所述的装置,其特征在于,The device according to claim 5, characterized in that,
    所述处理模块,还用于在得到N个待共识提议的共识结果后,将共识结果为优先投票值的至少一个待共识提议组成的集合确定为待共识集合;在接收到待共识集合中的全部待共识提议后,按照预设的顺序执行该集合中的待共识提议。The processing module is also used to determine, after obtaining the consensus results of the N proposals to be agreed upon, that the consensus result is a set of at least one proposal to be agreed upon with a priority voting value as the set to be agreed upon; After all the pending consensus proposals are executed, the pending consensus proposals in the set are executed in the preset order.
  9. 一种计算机设备,其特征在于,包括存储器、处理器、通信接口及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求1至4任一项所述的方法。A computer device, characterized by comprising a memory, a processor, a communication interface, and a computer program stored on the memory and operable on the processor, wherein, when the processor executes the program, it realizes the following claims 1 to 1: 4. The method described in any one.
  10. 一种计算机可读存储介质,其特征在于,其上存储有计算机程序,该程序被处理器执行时实现如权利要求1至4任一项所述的方法。A computer-readable storage medium, characterized in that a computer program is stored thereon, and when the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
PCT/CN2022/111000 2021-08-12 2022-08-09 Byzantine fault tolerance method and apparatus, and electronic device and storage medium WO2023016428A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110925724.7A CN113783935B (en) 2021-08-12 2021-08-12 Byzantine fault-tolerant method and device
CN202110925724.7 2021-08-12

Publications (1)

Publication Number Publication Date
WO2023016428A1 true WO2023016428A1 (en) 2023-02-16

Family

ID=78837813

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/111000 WO2023016428A1 (en) 2021-08-12 2022-08-09 Byzantine fault tolerance method and apparatus, and electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN113783935B (en)
WO (1) WO2023016428A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116192868A (en) * 2023-04-27 2023-05-30 南方科技大学 Parallel Bayesian fault tolerance consensus method and terminal applied to alliance chain

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113783935B (en) * 2021-08-12 2022-04-01 清华大学 Byzantine fault-tolerant method and device
CN114780987B (en) * 2021-12-29 2023-08-29 张海滨 Data distribution, storage, reading and transmission method and distributed system
CN114861233B (en) * 2022-04-19 2023-12-19 湖南天河国云科技有限公司 Fragmenting asynchronous Bayesian family fault-tolerant consensus method and device without trusted third party
CN114553423B (en) * 2022-04-27 2022-07-29 南京大学 Decentralized quantum Byzantine consensus method
CN115174090B (en) * 2022-05-20 2023-04-25 清华大学 Block chain consensus method, apparatus, computer device and readable storage medium
CN115396432B (en) * 2022-07-29 2023-08-01 北京理工大学 Binary negotiation method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190251007A1 (en) * 2018-02-12 2019-08-15 Ripple Labs Inc. Byzantine agreement in open networks
CN112104482A (en) * 2020-08-11 2020-12-18 佛山赛思禅科技有限公司 Consensus method based on parallel voting
CN112685796A (en) * 2021-03-12 2021-04-20 腾讯科技(深圳)有限公司 Block chain-based block consensus method and related equipment
CN113783708A (en) * 2021-08-25 2021-12-10 山东区块链研究院 Re-voting binary consensus method and device based on reliable broadcast
CN113783935A (en) * 2021-08-12 2021-12-10 清华大学 Byzantine fault-tolerant method and device
CN113794694A (en) * 2021-08-25 2021-12-14 清华大学 Binary consensus method and device based on reliable broadcast

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019012415A (en) * 2017-06-30 2019-01-24 株式会社bitFlyer Method for building consensus in network and nodes constituting network
CN108846659B (en) * 2018-06-13 2021-09-14 深圳前海微众银行股份有限公司 Block chain-based transfer method and device and storage medium
CN109447810B (en) * 2018-11-29 2021-03-09 杭州秘猿科技有限公司 Parallel block chain consensus method, system, electronic device and computer-readable storage medium
CN112689848B (en) * 2019-06-28 2024-06-11 深圳市网心科技有限公司 Method and related equipment for consensus of block chain data
CN110288479B (en) * 2019-06-28 2023-07-14 深圳市迅雷网络技术有限公司 Method and related equipment for consensus of block chain data
CN110708171B (en) * 2019-12-13 2020-06-12 腾讯科技(深圳)有限公司 Block chain consensus voting method, device, equipment and storage medium
CN111522800B (en) * 2020-07-03 2020-10-30 支付宝(杭州)信息技术有限公司 Block chain consensus method, node and system of badger Byzantine fault-tolerant consensus mechanism

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190251007A1 (en) * 2018-02-12 2019-08-15 Ripple Labs Inc. Byzantine agreement in open networks
CN112104482A (en) * 2020-08-11 2020-12-18 佛山赛思禅科技有限公司 Consensus method based on parallel voting
CN112685796A (en) * 2021-03-12 2021-04-20 腾讯科技(深圳)有限公司 Block chain-based block consensus method and related equipment
CN113783935A (en) * 2021-08-12 2021-12-10 清华大学 Byzantine fault-tolerant method and device
CN113783708A (en) * 2021-08-25 2021-12-10 山东区块链研究院 Re-voting binary consensus method and device based on reliable broadcast
CN113794694A (en) * 2021-08-25 2021-12-14 清华大学 Binary consensus method and device based on reliable broadcast

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WENG LIANG: "Research on Byzantine Consensus Algorithm in Asynchronous Environment", CHINA MASTER’S THESES FULL-TEXT DATABASE, 15 February 2020 (2020-02-15), XP093034335 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116192868A (en) * 2023-04-27 2023-05-30 南方科技大学 Parallel Bayesian fault tolerance consensus method and terminal applied to alliance chain
CN116192868B (en) * 2023-04-27 2023-09-08 南方科技大学 Parallel Bayesian fault tolerance consensus method and terminal applied to alliance chain

Also Published As

Publication number Publication date
CN113783935A (en) 2021-12-10
CN113783935B (en) 2022-04-01

Similar Documents

Publication Publication Date Title
WO2023016428A1 (en) Byzantine fault tolerance method and apparatus, and electronic device and storage medium
EP3559891B1 (en) Executing multi-party transactions using smart contracts
WO2023016426A1 (en) Asynchronous binary agreement method and apparatus, and electronic device and storage medium
US20210314167A1 (en) Methods and systems for consensus in blockchains
US20180240114A1 (en) Transaction verification in a consensus network
US11830001B2 (en) Blockchain consensus method, accounting node and node
KR102566892B1 (en) Blockchain consensus method, device and system
WO2023016429A1 (en) Binary consensus method and apparatus capable of revoting, electronic device, and storage medium
WO2023024886A1 (en) Reliable broadcast-based binary consensus method and apparatus, electronic device, and storage medium
WO2023024885A1 (en) Reliable broadcast-based re-votable binary consensus method and apparatus, electronic device, and storage medium
CN113055188B (en) Data processing method, device, equipment and storage medium
WO2023045620A1 (en) Transaction data processing method and apparatus, computer device and storage medium
CN109687953B (en) Transaction classification method, apparatus and storage medium
CN108550038A (en) A kind of data dissemination system and method applied to block chain
US20230097738A1 (en) Data processing method and apparatus, device, and storage medium
US11418323B2 (en) Method and system for securing peer nodes in a blockchain network
CN114070733B (en) Consensus method, device and system based on block chain network
CN116132052A (en) Cross-chain transaction method, device, electronic equipment and storage medium
CN113794566B (en) Re-voting binary consensus method, device and storage medium
CN113824755A (en) Method, system and related device for processing block chain data
WO2023134160A1 (en) Blockchain network-based consensus method and apparatus, and electronic device and storage medium
CN111242778B (en) Data processing method, device, computer equipment and storage medium
US11546171B2 (en) Systems and methods for synchronizing anonymized linked data across multiple queues for secure multiparty computation
CN113783946A (en) Re-voting binary consensus method and device based on threshold signature
EP4325811A1 (en) Data processing method and apparatus for consensus network, program product, device, and medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22855409

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22855409

Country of ref document: EP

Kind code of ref document: A1