WO2023016426A1 - Asynchronous binary agreement method and apparatus, and electronic device and storage medium - Google Patents
Asynchronous binary agreement method and apparatus, and electronic device and storage medium Download PDFInfo
- Publication number
- WO2023016426A1 WO2023016426A1 PCT/CN2022/110993 CN2022110993W WO2023016426A1 WO 2023016426 A1 WO2023016426 A1 WO 2023016426A1 CN 2022110993 W CN2022110993 W CN 2022110993W WO 2023016426 A1 WO2023016426 A1 WO 2023016426A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- consensus
- value
- voting
- type
- round
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 91
- 238000012545 processing Methods 0.000 claims description 30
- 238000004891 communication Methods 0.000 claims description 19
- 238000004590 computer program Methods 0.000 claims description 6
- ACWBQPMHZXGDFX-QFIPXVFZSA-N valsartan Chemical class C1=CC(CN(C(=O)CCCC)[C@@H](C(C)C)C(O)=O)=CC=C1C1=CC=CC=C1C1=NN=NN1 ACWBQPMHZXGDFX-QFIPXVFZSA-N 0.000 description 19
- 238000010586 diagram Methods 0.000 description 12
- 230000008569 process Effects 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 4
- 230000010076 replication Effects 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 238000011160 research Methods 0.000 description 3
- 238000012795 verification Methods 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 101100046877 Oryza sativa subsp. japonica TRAB1 gene Proteins 0.000 description 1
- 101150022366 ZEP gene Proteins 0.000 description 1
- 101150055324 aba1 gene Proteins 0.000 description 1
- 101150117319 aba2 gene Proteins 0.000 description 1
- 239000006227 byproduct Substances 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1097—Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/32—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
- H04L9/3247—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2209/00—Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
- H04L2209/46—Secure multiparty computation, e.g. millionaire problem
- H04L2209/463—Electronic voting
Definitions
- the present application relates to the field of computer technology, in particular to an asynchronous binary consensus method, device, electronic equipment and storage medium.
- Binary consensus is the main component of Byzantine Fault Tolerant Protocol (Byzantine Consensus, BFT).
- BFT Byzantine Consensus
- asynchronous Byzantine consensus protocols rely directly or indirectly on binary consensus, which enables distributed systems to reach consensus in an asynchronous environment.
- binary consensus can also be used to construct state machine replication, and then use state machine replication to establish a foundation for distributed fault-tolerant systems.
- binary consensus can also be applied to technical fields such as databases. Therefore, the research on binary consensus is an important research direction in the industry at present.
- the embodiment of the present application provides an asynchronous binary consensus method, device, electronic equipment and storage medium, which are used to solve the problem of low consensus efficiency in the prior art.
- an asynchronous binary consensus method is provided, which is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, where N ⁇ 3f+ 1.
- the f is an integer greater than 0, and the method includes:
- the initial voting value corresponding to the consensus proposal, and the initial auxiliary value; wherein, the voting value includes the first voting value and the second voting value, and the auxiliary value includes the first voting value, The second voting value and empty, the initial voting value is the first voting value or the second voting value;
- Each round of consensus steps is cyclically executed until the consensus result for the proposal to be consensus is obtained, wherein each round of consensus steps includes:
- the public coin toss value of the current round of consensus is obtained, and based on the public coin toss value and the received second type of consensus messages, the consensus result or the first type of consensus in the next round of consensus is determined.
- the voting value and auxiliary value carried by the message After receiving the quorum of the second type of consensus messages, the public coin toss value of the current round of consensus is obtained, and based on the public coin toss value and the received second type of consensus messages, the consensus result or the first type of consensus in the next round of consensus is determined The voting value and auxiliary value carried by the message.
- the re-determining the voting value and the auxiliary value based on the received first type of consensus message includes:
- the voting value and the auxiliary value are re-determined as voting values in the first set.
- the method also includes:
- the voting value in the first set is compared with the public coin toss value of the previous round, and the voting value and auxiliary value are re-determined according to the comparison result and the first type of consensus message received.
- the re-determining the voting value and the auxiliary value according to the comparison result and the received first type of consensus message includes:
- the voting value in the first set is equal to the public coin toss value of the previous round
- the voting values carried in the received first type of consensus messages are all voting values in the first set
- the auxiliary value carried are all voting values in the first set or empty, then determine the voting value and auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the first set Voting value in .
- the method also includes:
- the voting value in the first set is not equal to the public coin toss value of the previous round, if the voting value and the auxiliary value carried in the received first type of consensus message are both voting values in the first set, Then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the voting value in the first set.
- the determination of the consensus result or the voting value and auxiliary value carried by the first type of consensus message in the next round of consensus based on the public coin toss value and the received second type of consensus message includes:
- the voting value in the received second type of consensus message is added to the second set, if there are more than the quorum of the second type of consensus messages received in the second type of consensus message are the same, and the second type of consensus message If the voting value in the consensus message is the same as the auxiliary value, 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 the consensus result for that vote value;
- the voting value and the auxiliary value carried in the first type of consensus message in the next round are both determined as the voting value in the second type of consensus message.
- the method also includes:
- 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 with auxiliary values of this kind of voting value, then Compare this voting value with the public coin toss value of the previous round of consensus and the public coin toss value of the current round of consensus;
- this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
- the method also includes:
- the voting value in the second set is a voting value and empty, and the If the voting value is the same as the public coin toss value of the previous round of consensus, the voting value and auxiliary value in the first type of consensus message in the next round of consensus will be set as this kind of voting value.
- the method also includes:
- the voting value in the second set is a voting value and empty, and this type of voting value is different from the previous round of public coin toss; the public coin toss value of this round of consensus will be used as the voting value of the next round of the first type of consensus message; if the current round of consensus is the first round, the next round of consensus will be The auxiliary value in the first type of consensus message of a round is set as the public coin toss value of this round; if the current round of consensus is not the first round, the auxiliary value in the first consensus message of the next round is determined as the occurrence in the second set The number of times exceeds the value of the preset number of times.
- an asynchronous binary consensus device is provided, the device is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, where N ⁇ 3f+1, the f is an integer greater than 0, and the device includes:
- the processing module is used to determine the initial voting value corresponding to the consensus proposal for any consensus node, and the initial auxiliary value; wherein, the voting value includes the first voting value and the second voting value, and the auxiliary value includes The first voting value, the second voting value and empty, the initial voting value is the first voting value or the second voting value; execute each round of consensus steps in a loop until the consensus result for the proposal to be consensus is obtained;
- the communication module is used to broadcast the voting value and auxiliary value in the first type of consensus message; receive the first type of consensus message broadcast by other consensus nodes; re-determine the voting value and auxiliary value based on the received first type of consensus message , and broadcast the re-determined voting value and auxiliary value in the second type of consensus message;
- the processing module is also used to obtain the public coin toss value of the current round of consensus after receiving the quorum of the second type of consensus message, and determine the consensus result or the next The voting value and auxiliary value carried by the first type of consensus message in a round of consensus.
- the processing module is further configured to re-determine the voting value and the auxiliary value based on the received first-type consensus message, if f+1 first-type consensus messages are received in the current consensus round, and the If the voting value in the f+1 first-type consensus messages is the same as that of the local current round of consensus broadcast through the first-type consensus message, the local voting value is changed to the f+1 first-type consensus The voting value in the message; the communication module is also used to rebroadcast the first type of consensus message carrying the voting value and auxiliary value.
- the processing module is specifically configured to, after receiving a quorum of first-type consensus messages, and if the voting values carried by the quorum of first-type consensus messages are the same, set the voting value add to the first set;
- the voting value and the auxiliary value are re-determined as voting values in the first set.
- the processing module is also used to compare the voting value in the first set with the public coin toss value of the previous round when the current consensus round is not the first round, and according to the comparison result and received
- the first type of consensus message re-determines the voting value and auxiliary value.
- the processing module is specifically used for when the voting value in the first set is equal to the public coin toss value of the previous round, if the voting value carried in the received first type of consensus message is the The voting value in the first set, the auxiliary value carried is the voting value in the first set or empty, then the voting value and the auxiliary value are determined as the voting value in the first set; otherwise, the voting value is determined as NULL, and determine the auxiliary value as the voting value in this first set.
- the processing module is also used to: if the voting value carried in the received first type of consensus message and the auxiliary If the values are all voting values in the first set, then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the first set Voting value in .
- the processing module is specifically used to add the voting value in the received second type of consensus message to the second set, if there are more than the quorum of the second type of voting value in the received second type of consensus message
- the consensus messages are the same, and the voting value in the second type of consensus message is the same as the auxiliary value, then compare the voting value in the second type of consensus message with the current round of public coin toss value, if the voting value is the same as the current round If the public coin toss values are the same, the target consensus node determines that the consensus result is the voting value; voting value.
- the processing module is further configured to: if only legal consensus messages of the second type have been received, the voting value in the second set is one type of voting value and empty, and there are at least a quorum of second-type consensus messages.
- the auxiliary value of the consensus message is the voting value, and the voting value is compared with the public coin value of the previous round of consensus and the public coin value of the current round of consensus;
- this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
- the processing module is further configured to: if a quorum of legitimate second-type consensus messages is received, and the auxiliary values carried by the quorum of second-type consensus messages are not all the same, the votes in the second set
- the value is a voting value and empty, and this voting value is the same as the public coin toss value of the previous round of consensus, then the voting value and auxiliary value in the first type of consensus message in the next round of consensus are set to this voting value value.
- the processing module is further configured to if the received second consensus message includes two kinds of voting values; or, if the auxiliary value carried by the quorum of legitimate second-type consensus messages received by the target node is different,
- the voting value in the second set is a voting value and empty, and the voting value is different from the previous round of public coin toss; the public coin toss value of this round of consensus will be used as the vote for the next round of the first consensus message value; if the current round of consensus is the first round, the auxiliary value in the first type of consensus message in the next round will be set as the current round of public coin value; if the current round of consensus is not the first round, the next round of the first consensus
- the auxiliary value in is determined to be a value whose occurrence number in the second set exceeds a preset number of times.
- 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 voting value and auxiliary value without any public key cryptography, digital signature or threshold signature, so that each consensus node can quickly reach consensus proposals. Consensus greatly improves the consensus efficiency of each consensus node.
- Figure 1 is a schematic flow diagram of an asynchronous binary consensus method in the embodiment of this specification
- FIG. 2 is a schematic diagram of a consensus node maintaining each ABA instance according to an embodiment of this specification
- FIG. 3 is a schematic flow diagram of a broadcast consensus message according to an embodiment of this specification.
- Fig. 4 is a schematic diagram of each round of consensus process in the embodiment of this specification.
- FIG. 5 is a schematic structural diagram of an asynchronous binary consensus device according to an embodiment of this specification.
- Fig. 6 is a schematic structural diagram of a device for configuring the device of the embodiment of the present specification.
- Binary consensus is the main component of the Byzantine Fault Tolerant Protocol (BFT).
- BFT Byzantine Fault Tolerant Protocol
- asynchronous Byzantine consensus protocols rely directly or indirectly on binary consensus, which can enable distributed systems such as blockchains to be reached in an asynchronous environment. consensus.
- binary consensus can also be used to construct state machine replication, and then use state machine replication to establish a foundation for distributed fault-tolerant systems.
- binary consensus can also be applied to technical fields such as databases.
- binary refers to two values, usually represented by 0 and 1. Each node in a distributed system can reach a consensus on one of the two values, and this value often has a certain value for a distributed system. important practical significance.
- the data of each node in the blockchain network needs to be consistent. If the binary consensus method is used, when each node reaches a consensus of 1 for a certain batch of transactions, each node will Store the data. When each node reaches a consensus of 0 for a certain batch of transactions, each node does not store the data, thus ensuring the consistency of the data stored by each node. It is understandable that if the execution efficiency of the binary consensus method is higher, the performance of the distributed system will be better. Therefore, how to improve the efficiency of the binary consensus method is an important research direction in the industry at present.
- the embodiment of this application provides an asynchronous binary consensus method, which is applied to any consensus node in the distributed system.
- the node broadcasts consensus messages including voting values and auxiliary values, and based on other received
- the voting value sent by the consensus node and the auxiliary value determine the consensus result, so that each node in the system reaches a 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 consensus proposal can be understood as the data sent by any consensus node, and it is hoped that other consensus nodes will participate in the consensus on the data, and the voting value is used to represent the consensus opinion of each consensus node on the data, where
- the voting value includes the first voting value and the second voting value, that is, each consensus node can have two kinds of consensus opinions on the consensus proposal. It means that in other embodiments, other forms and symbols can also be used for representation.
- This specification does not limit the specific forms of the first voting value and the second voting value, as long as it can be used to distinguish the first voting value and the second voting value Any value can be used.
- the auxiliary value is an auxiliary opinion proposed in this specification to assist each node to reach a consensus on the proposal to be consensus, which includes the first voting value, the second voting value and null.
- the pending consensus proposal can be a batch of transactions obtained by any consensus node from the local transaction pool, and it is hoped that other consensus nodes can receive and store the batch of transactions, and the voting value is used to represent the transaction value of each consensus node. Whether to agree to store the pending consensus proposal.
- the consensus proposal and voting value will have other different actual meanings, which are not limited in this specification.
- FIG. 2 it is a schematic diagram of a binary consensus instance to be executed by any node in the distributed system
- Any node in the distributed system will use the asynchronous binary consensus method proposed in this note for each consensus node (including itself) to determine the consensus result of the consensus proposal proposed by the consensus node, as shown in the example ABA 1 in the figure -ABA n is a schematic diagram of the asynchronous binary agreement method ABA (asynchronous binary agreement) for N consensus nodes, ABA1 is a schematic diagram of the target node performing asynchronous binary consensus on the pending consensus proposal proposed by consensus node 1, and ABA2 is the target It is an indication that the node performs asynchronous binary consensus on the pending consensus proposal proposed by the consensus node 2, and so on.
- ABA asynchronous binary agreement
- the target node will determine an initial voting value (0 or 1) when performing consensus on each proposal to be consensus, and finally the binary consensus method proposed based on this description will also get The consensus result (0 or 1) for .
- this specification proposes an asynchronous binary consensus method, which is a method executed by any consensus node in the distributed system.
- the consensus node is called the target node .
- a distributed system includes at least N consensus nodes.
- a consensus node refers to a node that participates in the consensus process. It is understandable that there are usually other nodes that do not participate in the consensus in a distributed system. These nodes only receive and store the consensus node’s The consensus result does not participate in the consensus process; in addition, when there are too many malicious nodes or Byzantine nodes in the system, any consensus method cannot ensure that the consensus nodes in the system reach a consensus, so this specification stipulates that the distributed system includes N Consensus nodes, at most f malicious nodes are allowed to exist among the N consensus nodes, N ⁇ 3f+1, both f and N are integers greater than 0, and this method is applied to any of the plurality of consensus nodes For the correct node, it is understandable that other correct consensus nodes are also executing the above method asynchronously. When the target node proposes the consensus result of the pending consensus proposal for any consensus node, other correct consensus nodes will eventually get the same consensus proposal for the pending consensus
- the method includes:
- 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 different data in different application scenarios. For example, in a blockchain network, it can be determined according to whether the proposal to be consensus is received: if the target node receives the proposal to be consensus (broadcast by other consensus nodes through the reliable broadcast RBC protocol), then determine the The initial voting value is the first voting value. If it is determined that the consensus proposals from N-f consensus nodes have been received, the initial voting value of the unreceived consensus proposals can be set as the second voting value. In other application scenarios, the initial voting value of the proposal to be consensus can also be determined according to different data. In this specification, the first voting value is 1 and the second voting value is 0 as an example for illustration.
- Each round of consensus steps is cyclically executed until the consensus result for the proposal to be consensus is obtained, wherein each round of consensus steps includes:
- the consensus method proposed in this specification is executed in consensus rounds, each round includes the stage of exchanging voting values and auxiliary values with other consensus nodes, and the stage of determining the consensus result based on the interaction results after the interaction is completed, that is, S102-S103.
- the target node may specifically execute the method as described in Figure 3:
- the target node can determine the initial voting value and initial auxiliary value according to the method described in S101 above; if it is not the first round of consensus, the method of determining the voting value and auxiliary value can refer to the section about S303 below, here Not detailed.
- the target node can add the locally determined voting value and auxiliary value to the first type of consensus message, and transmit 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 round 0, maj r can be set to empty, r is the number of consensus rounds, the first round is round 0, r increments in steps of 1.
- the target node if the target node receives f+1 first-type consensus messages in the current consensus round, that is, the first-type consensus messages exceeding the number of malicious nodes, if the f+1 first-type consensus messages The voting value is the same and inconsistent with the voting value broadcast by the local consensus message of the first type of consensus in this round, and the target node modifies the local voting value of the current round to the same value as the voting value in f+1 first type consensus messages, And broadcast the first type of consensus message again.
- the target node receives f+1 bval r (b,*) messages, and b is not equal to the voting value est r of the target node’s first broadcast in the current round, the target node will broadcast Where * can be 0, 1 or any value in the air, The purpose of this step is to allow the local node to correct the local voting value.
- the target node After the target node receives the quorum of the first type of consensus message, it can re-determine the voting value and auxiliary value according to the received first type of consensus message, where the quorum is 2f+1, (including its own node), Unless otherwise specified, the quorum below is 2f+1.
- 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 voting value and auxiliary value can be determined as the first set The voting value in , and broadcast the second type of consensus message; Continuing the above example, if b is added to the first set, that is, the set bin_values r , you can re-determine that both the voting value and the auxiliary value are b, and start broadcasting the first set
- the second type of consensus message aux r (b,b), where aux r is the format of the second type of consensus message.
- the target node will compare the voting value in the first set with the public coin toss value of the previous round, and determine the second type of consensus based on the comparison result The voting value and auxiliary value carried in the message.
- the public coin toss value only has 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.
- the method of obtaining the public coin toss value can be to use
- the interactive threshold pseudo-random number protocol, threshold signature protocol, trusted platform (TEE) and other methods are implemented. For specific content, please refer to related technologies, which will not be described in detail 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 received first type of consensus message are all the voting values in the first set, the carried If the auxiliary values are all voting values in the first set or empty, the voting value and auxiliary value in the second type of consensus message are determined as the voting values in the first set and broadcast; if other voting values are received value of the first type of consensus message, 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 broadcasts the second consensus information only once per round.
- the above method is a method for the target node to determine the voting value and auxiliary value carried in the second type of consensus message.
- 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 to obtain a consensus result based on the received voting value and auxiliary value. If no consensus result is obtained, it determines the next round of voting value and auxiliary value, and restarts execution of S101.
- 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 the target node receives 2f+1 aux r () messages, it can store the voting value and auxiliary value in the received aux r () messages into the sets vals r (second set) and avals r ( in the third set). 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 node can use the current round of public coin toss value as the voting value of the next round of the first type of consensus message.
- the target node will also set the auxiliary value in the first type of consensus message in the next round as the public coin value of the current round.
- the target node will set the auxiliary value of the next round
- the auxiliary value in the first consensus message is set to the value whose occurrence times in the second set exceeds the preset number, and enters into the next round of consensus.
- the target node will use the current round of public coin toss value as the next round input (ie set est r+1 to S r ).
- each consensus node in the distributed system in an asynchronous environment can Quickly reach a consensus state on a certain value, where the probability of reaching a consensus in the first round is 1-(1/2) 1 , the probability of reaching a consensus in the second round is 1-(1/2) 2 ... and so on, that is, with the consensus With the increase in the number of rounds, the probability of reaching a consensus increases exponentially.
- the average number of rounds to complete the consensus is two rounds, that is, the mathematical expectation of the total number of running rounds is two rounds, and only 2-3 steps need to be executed in each round, which greatly improves the Consensus efficiency of distributed systems in an asynchronous environment, and the above-mentioned consensus method does not need to rely on any public key cryptography, does not need to assume digital signatures, or threshold signatures, and only needs to determine a fair coin toss.
- the proposed The asynchronous binary consensus method is currently the most efficient binary consensus method.
- each consensus node first adds the voting value and auxiliary value to the first type of consensus message and broadcasts it to other nodes, and based on the information broadcast by other consensus nodes
- the first type of consensus message determines the voting value and auxiliary value carried by the second type of consensus message, and finally determines the consensus result based on the interactive voting value and auxiliary value.
- each correct consensus node will get the same consensus result, which is a sequence containing 0 and 1. Further, corresponding transaction processing can be performed based on the sequence. Still taking the blockchain network as an example, 0 or 1 is used to indicate whether to pack the corresponding consensus proposal into blocks. 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
- the consensus proposal proposed by consensus node 4 is P4.
- the 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 without storing P4, that is, each According to the consensus results, the consensus nodes have carried out consistent processing on each consensus proposal to ensure the data consistency of each consensus node.
- the target node can randomly obtain a preset number of transactions from the local transaction pool, or preferentially obtain a preset number of transactions stored earlier according to the order in which the transactions are stored. 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 erasure coding 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.
- 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-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.
- the target node can determine the initial voting value of the pending consensus proposal, for example, determine the initial voting value as the first voting value 1, and execute the S101-S103, that is, the initial voting value of each pending consensus proposal can be determined according to the reception of the pending consensus proposal to trigger the execution of the asynchronous binary consensus method proposed in this specification, and then the pending consensus broadcast by each consensus node in the blockchain network can be Consensus proposals reach consensus separately.
- the above is only a specific implementation manner of the reliable broadcast RBC protocol, and the reliable broadcast RBC protocol can also be implemented in other ways.
- specific content of the reliable broadcast RBC protocol reference can be made to related technologies, which is not limited in this specification.
- the above is also an example of applying the asynchronous binary consensus method proposed in this specification to the blockchain network.
- the initial voting value of any proposal to be consensus can also be determined based on different data, and trigger the execution
- the asynchronous binary consensus method proposed in this specification enables each consensus node to reach a consensus.
- any b ⁇ 0,1 ⁇ ; * When used as a parameter in a message, it can represent b, or ⁇ ; for example, aux r (*,b) might represent or aux r ( ⁇ ,b); bval r (b,*) might represent or bval r (b, ⁇ ); aux r () can represent aux r (*,*); vals is a vector (multiset) consisting of 0, 1 and ⁇ .
- the replica p i receives f+1 bval r (b,*) messages, and b is not equal to the input est r of the replica, the replica will broadcast bval r
- replica p i receives 2f+1 bval r (b,*) messages, b ⁇ 0,1 ⁇ . Then p i adds b to the set bin_values r .
- pi checks the maj r variable values in the received 2f+1 bval r (b,*) messages and stores these values in the set majs.
- the replica p i compares b with the value S r - 1 of the public toss of round r–1.
- p i After receiving Nf aux r () messages, p i stores the first variable and the second variable in the aux r () messages into the sets vals r and avls r respectively, obtains the public coin toss value, makes a judgment and enters the next round. At this point, there are four situations:
- this specification also provides an asynchronous binary consensus device, which is characterized in that the device is applied to any consensus node in the distributed system , the distributed system includes at least N consensus nodes, where N ⁇ 3f+1, the f is an integer greater than 0, and the device includes:
- the processing module 520 is configured to determine an initial voting value corresponding to the consensus proposal for any consensus node, and an initial auxiliary value; wherein, the voting value includes a first voting value and a second voting value, and the auxiliary value Including the first voting value, the second voting value and empty, the initial voting value is the first voting value or the second voting value; execute each round of consensus steps in a loop until the consensus result for the proposal to be consensus is obtained;
- the communication module 510 is used to broadcast the consensus message of the current round, and the consensus message carries the voting value of the current round and the auxiliary value;
- the processing module 520 is further configured to determine whether to obtain a consensus result based on the received voting values and auxiliary values broadcast by other consensus nodes.
- the communication module 510 is specifically configured to broadcast the voting value and auxiliary value in the first type of consensus message; receive the first type of consensus message broadcast by other consensus nodes;
- the processing module 520 is specifically configured to re-determine the voting value and the auxiliary value based on the received first type of consensus message,
- the communication module 510 is configured to broadcast the re-determined voting value and auxiliary value in the second type of consensus message.
- the processing module 520 is further configured to receive f+1 first-type consensus messages in the current consensus round, and the voting values in the f+1 first-type consensus messages are the same, Different from the voting value broadcast by the first type of consensus message in the local current round of consensus, the local voting value is modified to the voting value in the f+1 first type of consensus message; the communication module 510 is used to broadcast again The first type of consensus message carrying voting value and auxiliary value.
- the processing module 520 is specifically configured to, after receiving a quorum of first-type consensus messages, and if the voting values carried by the quorum of first-type consensus messages are the same, The vote value is added to the first set;
- the voting value and the auxiliary value are determined as voting values in the first set.
- the voting value in the first set is compared with the public coin toss value of the previous round, and the voting value and auxiliary value are re-determined according to the comparison result and the first type of consensus message received.
- the processing module 520 is specifically configured to: if the voting value carried in the received first type of consensus message is are all voting values in the first set, and the auxiliary values carried are all voting values in the first set or empty, then the voting value and auxiliary value are determined as the voting values in the first set; otherwise, the voting The value is determined to be null, and the auxiliary value is determined to be the voting value in the first set.
- the processing module 520 is specifically configured to: if the vote value carried in the received first type of consensus message is not equal to the value of the public coin toss in the previous round value and the auxiliary value are voting values in the first set, then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the voting value in the first set The vote value in the first set.
- the processing module 520 is specifically configured to determine whether to obtain a consensus result based on the vote value and auxiliary value in the received second type of consensus message.
- the processing module 520 is specifically configured to add the voting value in the received second type of consensus message to the second set when a quorum of the second type of consensus messages is received, And determine the public coin toss value of this round of consensus based on the preset algorithm;
- the voting value in the second type of consensus messages is the same as the auxiliary value, then the second type of consensus messages in the second type of consensus messages The voting value 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;
- the voting value and the auxiliary value carried in the first type of consensus message in the next round are both determined as the voting value in the second type of consensus message.
- the processing module 520 is specifically configured to: if only legal consensus messages of the second type have been received, the voting value in the second set is one voting value and empty, and there are at least a quorum
- the auxiliary value of the second type of consensus message is the voting value, and the voting value is compared with the public coin toss value of the previous round of consensus and the public coin toss value of the current round of consensus;
- this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
- the processing module 520 is specifically configured to, if a quorum of legal second-type consensus messages are received, and the auxiliary values carried by the quorum of second-type consensus messages are not all the same, the second set
- the voting value in is a voting value and empty, and this voting value is the same as the public coin toss value of the previous round of consensus, then the voting value and auxiliary value in the first type of consensus message in the next round of consensus are set to the voting value.
- the processing module 520 is specifically configured to use the public coin toss value of the current round of consensus as the next round of the first type of consensus message when the received second type of consensus message does not satisfy the above-mentioned embodiment if the current round of consensus is the first round, then set the auxiliary value in the first type of consensus message in the next round as the public coin toss value of the current round; if the current round of consensus is not the first
- the auxiliary value in the common message is determined as a value whose occurrence times in the second set exceeds a preset number of times.
- 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. 1 above.
- FIG. 6 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. 1 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)
- Business, Economics & Management (AREA)
- Computer Security & Cryptography (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Economics (AREA)
- Development Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer And Data Communications (AREA)
- Hardware Redundancy (AREA)
Abstract
Provided in the embodiments of the present application are an asynchronous binary agreement method and apparatus, and an electronic device and a storage medium, which are applied to any agreement node in a distributed system. The distributed system comprises at least N agreement nodes, wherein N ≥ 3f + 1, with f being an integer greater than 0. The method comprises: for a proposal, to be agreed, of any agreement node, determining an initial voting value corresponding to said proposal, and an initial auxiliary value, wherein a voting value comprises a first voting value and a second voting value, and the initial voting value is the first voting value or the second voting value; and cyclically executing agreement steps of each round until an agreement result for said proposal is obtained, wherein the agreement steps of each round comprise: broadcasting an agreement message of the current round, wherein the agreement message carries a voting value and an auxiliary value of the current round, and on the basis of received voting values and auxiliary values, which are broadcast by other agreement nodes, determining whether the agreement result is obtained.
Description
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202110925730.2、申请日为2021年08月12日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with application number 202110925730.2 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.
本申请涉及计算机技术领域,具体地,涉及一种异步二元共识方法、装置、电子设备及存储介质。The present application relates to the field of computer technology, in particular to an asynchronous binary consensus method, device, electronic equipment and storage medium.
二元共识是拜占庭容错协议(拜占庭共识,BFT)的主要组成部分,目前已知的异步拜占庭共识协议都直接或者间接依赖二元共识,其可以使分布式系统在异步环境下达成共识。同时,二元共识也可以用于构造状态机复制(state machine replication),进而使用状态机复制为分布式容错系统建立基础,另外,二元共识还可以应用在数据库等技术领域。因此,对于二元共识的研究是目前业界重要的研究方向。Binary consensus is the main component of Byzantine Fault Tolerant Protocol (Byzantine Consensus, BFT). Currently known asynchronous Byzantine consensus protocols rely directly or indirectly on binary consensus, which enables distributed systems to reach consensus in an asynchronous environment. At the same time, binary consensus can also be used to construct state machine replication, and then use state machine replication to establish a foundation for distributed fault-tolerant systems. In addition, binary consensus can also be applied to technical fields such as databases. Therefore, the research on binary consensus is an important research direction in the industry at present.
发明内容Contents of the invention
本申请实施例中提供了一种异步二元共识方法、装置、电子设备及存储介质,用于解决现有技术中共识效率较低的问题。The embodiment of the present application provides an asynchronous binary consensus method, device, electronic equipment and storage medium, which are used to solve the problem of low consensus efficiency in the prior art.
为了达到上述目的,本申请提供如下技术方案:In order to achieve the above object, the application provides the following technical solutions:
根据本申请实施例的第一个方面,提供了一种异步二元共识方法,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,其中N≥3f+1,所述f为大于0的整数,所述方法包括:According to the first aspect of the embodiments of the present application, an asynchronous binary consensus method is provided, which is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, where N≥3f+ 1. The f is an integer greater than 0, and the method includes:
针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值,以及初始辅助值;其中,投票值包括第一投票值以及第二投票值,辅助值包括第一投票值、第二投票值以及空,初始投票值为第一投票值或第二投票值;For the consensus proposal of any consensus node, determine the initial voting value corresponding to the consensus proposal, and the initial auxiliary value; wherein, the voting value includes the first voting value and the second voting value, and the auxiliary value includes the first voting value, The second voting value and empty, the initial voting value is the first voting value or the second voting value;
循环执行每轮共识步骤,直到得到针对该待共识提议的共识结果,其中,每轮共识步骤包括:Each round of consensus steps is cyclically executed until the consensus result for the proposal to be consensus is obtained, wherein each round of consensus steps includes:
将投票值和辅助值携带在第一类共识消息中进行广播;Carry the voting value and auxiliary value in the first type of consensus message for broadcast;
接收其他共识节点广播的第一类共识消息;Receive the first type of consensus messages broadcast by other consensus nodes;
基于接收到的第一类共识消息重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播;Re-determine the voting value and auxiliary value based on the received first type of consensus message, and broadcast the re-determined voting value and auxiliary value in the second type of consensus message;
在接收到法定数量的第二类共识消息后获得本轮共识的公共抛币值,基于公共抛币值以及接收到的第二类共识消息的情况,确定共识结果或者下一轮共识中第一类共识消息携带的投票值以及辅助值。After receiving the quorum of the second type of consensus messages, the public coin toss value of the current round of consensus is obtained, and based on the public coin toss value and the received second type of consensus messages, the consensus result or the first type of consensus in the next round of consensus is determined The voting value and auxiliary value carried by the message.
上述方案中,在所述基于接收到的第一类共识消息重新确定投票值以及辅助值之前还包括:In the above solution, before re-determining the voting value and the auxiliary value based on the received first type of consensus message, it also includes:
若在当前共识轮接收到f+1个第一类共识消息,且所述f+1个第一类共识消息中的投票值相同、与本地本轮共识通过第一类共识消息广播的投票值不同,则将本地投票值修改为所述f+1个第一类共识消息中的投票值,并再次广播携带投票值以及辅助值的第一类共识消息。If f+1 first-type consensus messages are received in the current consensus round, and the voting value in the f+1 first-type consensus messages is the same as the voting value broadcast by the local consensus in this round through the first-type consensus message If not, modify the local voting value to the voting value in the f+1 first-type consensus messages, and broadcast the first-type consensus message carrying the voting value and auxiliary value again.
上述方案中,所述基于接收到的第一类共识消息重新确定投票值以及辅助值,包括:In the above solution, the re-determining the voting value and the auxiliary value based on the received first type of consensus message includes:
在接收到法定数量的第一类共识消息后,在所述法定数量的第一类共识消息所携带的投票值相同的情况下,将该投票值添加到第一集合中;After receiving a quorum of first-type consensus messages, if the quorum of first-type consensus messages carry the same voting value, add the voting value to the first set;
若当前共识轮为首轮,则将投票值以及辅助值重新确定为所述第一集合中的投票值。If the current consensus round is the first round, the voting value and the auxiliary value are re-determined as voting values in the first set.
上述方案中,所述方法还包括:In the above scheme, the method also includes:
若当前共识轮不为首轮,则将所述第一集合中的投票值与上一轮的公共抛币值进行比较,根据比较结果以及接收到的第一类共识消息重新确定投票值以及辅助值。If the current consensus round is not the first round, the voting value in the first set is compared with the public coin toss value of the previous round, and the voting value and auxiliary value are re-determined according to the comparison result and the first type of consensus message received.
上述方案中,所述根据比较结果以及接收到的第一类共识消息重新确定投票值以及辅助值,包括:In the above solution, the re-determining the voting value and the auxiliary value according to the comparison result and the received first type of consensus message includes:
在第一集合中的投票值与上一轮的公共抛币值相等的情况下,若接收过的第一类共识消息中携带的投票值均为该第一集合中的投票值,携带的辅助值均为该第一集合中的投票值或空,则将投票值以及辅助值确定为该第一集合中的投票值;否则,将投票值确定为空,并且将辅助值确定为该第一集合中的投 票值。In the case where the voting value in the first set is equal to the public coin toss value of the previous round, if the voting values carried in the received first type of consensus messages are all voting values in the first set, the auxiliary value carried are all voting values in the first set or empty, then determine the voting value and auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the first set Voting value in .
上述方案中,所述方法还包括:In the above scheme, the method also includes:
在第一集合中的投票值与上一轮的公共抛币值不相等的情况下,若接收过的第一类共识消息中携带的投票值以及辅助值均为该第一集合中的投票值,则将投票值以及辅助值确定为该第一集合中的投票值;否则,则将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In the case that the voting value in the first set is not equal to the public coin toss value of the previous round, if the voting value and the auxiliary value carried in the received first type of consensus message are both voting values in the first set, Then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the voting value in the first set.
上述方案中,所述基于公共抛币值以及接收到的第二类共识消息的情况,确定共识结果或者下一轮共识中第一类共识消息携带的投票值以及辅助值,包括:In the above scheme, the determination of the consensus result or the voting value and auxiliary value carried by the first type of consensus message in the next round of consensus based on the public coin toss value and the received second type of consensus message includes:
将接收到的第二类共识消息中的投票值添加到第二集合中,若接收到的第二类共识消息中存在超过法定数量的第二类共识消息是相同的,且所述第二类共识消息中投票值与辅助值相同,则将该第二类共识消息中的投票值与本轮公共抛币值进行比较,如果该投票值与本轮公共抛币值相同,则目标共识节点确定共识结果为该投票值;Add the voting value in the received second type of consensus message to the second set, if there are more than the quorum of the second type of consensus messages received in the second type of consensus message are the same, and the second type of consensus message If the voting value in the consensus message is the same as the auxiliary value, 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 the consensus result for that vote value;
若不相同,则将下一轮第一类共识消息中携带的投票值以及辅助值均确定为所述第二类共识消息中的投票值。If they are different, the voting value and the auxiliary value carried in the first type of consensus message in the next round are both determined as the voting value in the second type of consensus message.
上述方案中,所述方法还包括:In the above scheme, the method also includes:
若只接收到过合法第二类共识消息,所述第二集合中的投票值为一种投票值和空,并且至少有法定数量条第二类共识消息的辅助值为该种投票值,则将该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值分别进行比较;If only legitimate second-type consensus messages have been received, 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 with auxiliary values of this kind of voting value, then Compare this voting value with the public coin toss value of the previous round of consensus and the public coin toss value of the current round of consensus;
若该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值均相同,则确定共识结果该为该种投票值;若该种投票值与上一轮共识的公共抛币值和/或本轮共识的抛币值不相同,则将下一轮第一类共识消息中的投票值以及辅助值均设置为该种投票值。If this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
上述方案中,所述方法还包括:In the above scheme, the method also includes:
若接收到了法定数量的合法第二类共识消息,所述法定数量的第二类共识消息携带的辅助值不全相同,所述第二集合中的投票值为一种投票值和空,且该种投票值与上一轮共识的公共抛币值相同,则将下一轮共识中第一类共识消息中的投票值以及辅助值均设置为该种投票值。If a quorum of legitimate second-type consensus messages is received, the auxiliary values carried by the quorum of second-type consensus messages are not all the same, the voting value in the second set is a voting value and empty, and the If the voting value is the same as the public coin toss value of the previous round of consensus, the voting value and auxiliary value in the first type of consensus message in the next round of consensus will be set as this kind of voting value.
上述方案中,所述方法还包括:In the above scheme, the method also includes:
若接收到的第二共识消息中包括两种投票值;或者,目标节点接收到的法定数量的合法第二类共识消息携带的辅助值不相同,第二集合中的投票值为一种投票值和空,且该种投票值与上一轮公共抛币值不相同;则将本轮共识的公共抛币值作为下一轮第一类共识消息的投票值;若本轮共识为首轮,则将下一轮的第一类共识消息中的辅助值设置为本轮公共抛币值;若本轮共识不为首轮,则将下一轮的第一共消息中的辅助值确定为第二集合中的出现次数超过预设次数的值。If the received second consensus message includes two voting values; or, the quorum of legal second consensus messages received by the target node carry different auxiliary values, the voting value in the second set is a voting value and empty, and this type of voting value is different from the previous round of public coin toss; the public coin toss value of this round of consensus will be used as the voting value of the next round of the first type of consensus message; if the current round of consensus is the first round, the next round of consensus will be The auxiliary value in the first type of consensus message of a round is set as the public coin toss value of this round; if the current round of consensus is not the first round, the auxiliary value in the first consensus message of the next round is determined as the occurrence in the second set The number of times exceeds the value of the preset number of times.
根据本申请实施例的第二个方面,提供了一种异步二元共识装置,所述装置应用于分布式系统中的任一共识节点中,所述分布式系统至少包括N个共识节点,其中N≥3f+1,所述f为大于0的整数,所述装置包括:According to the second aspect of the embodiments of the present application, an asynchronous binary consensus device is provided, the device is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, where N≥3f+1, the f is an integer greater than 0, and the device includes:
处理模块,用于针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值,以及初始辅助值;其中,投票值包括第一投票值以及第二投票值,辅助值包括第一投票值、第二投票值以及空,初始投票值为第一投票值或第二投票值;循环执行执行每轮共识步骤,直到得到针对该待共识提议的共识结果;The processing module is used to determine the initial voting value corresponding to the consensus proposal for any consensus node, and the initial auxiliary value; wherein, the voting value includes the first voting value and the second voting value, and the auxiliary value includes The first voting value, the second voting value and empty, the initial voting value is the first voting value or the second voting value; execute each round of consensus steps in a loop until the consensus result for the proposal to be consensus is obtained;
在每轮共识中:In each round of consensus:
通信模块,用于将投票值和辅助值携带在第一类共识消息中进行广播;接收其他共识节点广播的第一类共识消息;基于接收到的第一类共识消息重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播;The communication module is used to broadcast the voting value and auxiliary value in the first type of consensus message; receive the first type of consensus message broadcast by other consensus nodes; re-determine the voting value and auxiliary value based on the received first type of consensus message , and broadcast the re-determined voting value and auxiliary value in the second type of consensus message;
所述处理模块,还用于在接收到法定数量的第二类共识消息后获得本轮共识的公共抛币值,基于公共抛币值以及接收到的第二类共识消息的情况,确定共识结果或者下一轮共识中第一类共识消息携带的投票值以及辅助值。The processing module is also used to obtain the public coin toss value of the current round of consensus after receiving the quorum of the second type of consensus message, and determine the consensus result or the next The voting value and auxiliary value carried by the first type of consensus message in a round of consensus.
上述方案中,所述处理模块,还用于在基于接收到的第一类共识消息重新确定投票值以及辅助值之前,若在当前共识轮接收到f+1个第一类共识消息,且所述f+1个第一类共识消息中的投票值相同、与本地本轮共识通过第一类共识消息广播的投票值不同,则将本地投票值修改为所述f+1个第一类共识消息中的投票值;所述通信模块,还用于再次广播携带投票值以及辅助值的第一类共识消息。In the above scheme, the processing module is further configured to re-determine the voting value and the auxiliary value based on the received first-type consensus message, if f+1 first-type consensus messages are received in the current consensus round, and the If the voting value in the f+1 first-type consensus messages is the same as that of the local current round of consensus broadcast through the first-type consensus message, the local voting value is changed to the f+1 first-type consensus The voting value in the message; the communication module is also used to rebroadcast the first type of consensus message carrying the voting value and auxiliary value.
上述方案中,所述处理模块,具体用于在接收到法定数量的第一类共识消息后,在所述法定数量的第一类共识消息所携带的投票值相同的情况下,将该投票值添加到第一集合中;In the above scheme, the processing module is specifically configured to, after receiving a quorum of first-type consensus messages, and if the voting values carried by the quorum of first-type consensus messages are the same, set the voting value add to the first set;
若当前共识轮为首轮,则将投票值以及辅助值重新确定为所述第一集合中的投票值。If the current consensus round is the first round, the voting value and the auxiliary value are re-determined as voting values in the first set.
上述方案中,所述处理模块,还用于在当前共识轮不为首轮的情况下,将所述第一集合中的投票值与上一轮的公共抛币值进行比较,根据比较结果以及接收到的第一类共识消息重新确定投票值以及辅助值。In the above solution, the processing module is also used to compare the voting value in the first set with the public coin toss value of the previous round when the current consensus round is not the first round, and according to the comparison result and received The first type of consensus message re-determines the voting value and auxiliary value.
上述方案中,所述处理模块,具体用于在第一集合中的投票值与上一轮的公共抛币值相等的情况下,若接收过的第一类共识消息中携带的投票值均为该第一集合中的投票值,携带的辅助值均为该第一集合中的投票值或空,则将投票值以及辅助值确定为该第一集合中的投票值;否则,将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In the above solution, the processing module is specifically used for when the voting value in the first set is equal to the public coin toss value of the previous round, if the voting value carried in the received first type of consensus message is the The voting value in the first set, the auxiliary value carried is the voting value in the first set or empty, then the voting value and the auxiliary value are determined as the voting value in the first set; otherwise, the voting value is determined as NULL, and determine the auxiliary value as the voting value in this first set.
上述方案中,所述处理模块,还用于在第一集合中的投票值与上一轮的公共抛币值不相等的情况下,若接收过的第一类共识消息中携带的投票值以及辅助值均为该第一集合中的投票值,则将投票值以及辅助值确定为该第一集合中的投票值;否则,则将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In the above scheme, the processing module is also used to: if the voting value carried in the received first type of consensus message and the auxiliary If the values are all voting values in the first set, then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the first set Voting value in .
上述方案中,所述处理模块,具体用于将接收到的第二类共识消息中的投票值添加到第二集合中,若接收到的第二类共识消息中存在超过法定数量的第二类共识消息是相同的,且所述第二类共识消息中投票值与辅助值相同,则将该第二类共识消息中的投票值与本轮公共抛币值进行比较,如果该投票值与本轮公共抛币值相同,则目标共识节点确定共识结果为该投票值;若不相同,则将下一轮第一类共识消息中携带的投票值以及辅助值均确定为所述第二类共识消息中的投票值。In the above scheme, the processing module is specifically used to add the voting value in the received second type of consensus message to the second set, if there are more than the quorum of the second type of voting value in the received second type of consensus message The consensus messages are the same, and the voting value in the second type of consensus message is the same as the auxiliary value, then compare the voting value in the second type of consensus message with the current round of public coin toss value, if the voting value is the same as the current round If the public coin toss values are the same, the target consensus node determines that the consensus result is the voting value; voting value.
上述方案中,所述处理模块,还用于若只接收到过合法第二类共识消息,所述第二集合中的投票值为一种投票值和空,并且至少有法定数量条第二类共识消息的辅助值为该种投票值,则将该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值分别进行比较;In the above scheme, the processing module is further configured to: if only legal consensus messages of the second type have been received, the voting value in the second set is one type of voting value and empty, and there are at least a quorum of second-type consensus messages. The auxiliary value of the consensus message is the voting value, and the voting value is compared with the public coin value of the previous round of consensus and the public coin value of the current round of consensus;
若该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值均相同,则确定共识结果该为该种投票值;若该种投票值与上一轮共识的公共抛币值和/或本轮共识的抛币值不相同,则将下一轮第一类共识消息中的投票值以及辅助值均设置为该种投票值。If this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
上述方案中,所述处理模块,还用于若接收到了法定数量的合法第二类共识消息,所述法定数量的第二类共识消息携带的辅助值不全相同,所述第二集合中的投票值为一种投票值和空,且该种投票值与上一轮共识的公共抛币值相同,则将下一轮共识中第一类共识消息中的投票值以及辅助值均设置为该种投票值。In the above scheme, the processing module is further configured to: if a quorum of legitimate second-type consensus messages is received, and the auxiliary values carried by the quorum of second-type consensus messages are not all the same, the votes in the second set The value is a voting value and empty, and this voting value is the same as the public coin toss value of the previous round of consensus, then the voting value and auxiliary value in the first type of consensus message in the next round of consensus are set to this voting value value.
上述方案中,所述处理模块,还用于若接收到的第二共识消息中包括两种投票值;或者,目标节点接收到的法定数量的合法第二类共识消息携带的辅助值不相同,第二集合中的投票值为一种投票值和空,且该种投票值与上一轮公共抛币值不相同;则将本轮共识的公共抛币值作为下一轮第一类共识消息的投票值;若本轮共识为首轮,则将下一轮的第一类共识消息中的辅助值设置为本轮公共抛币值;若本轮共识不为首轮,则将下一轮的第一共消息中的辅助值确定为第二集合中的出现次数超过预设次数的值。In the above solution, the processing module is further configured to if the received second consensus message includes two kinds of voting values; or, if the auxiliary value carried by the quorum of legitimate second-type consensus messages received by the target node is different, The voting value in the second set is a voting value and empty, and the voting value is different from the previous round of public coin toss; the public coin toss value of this round of consensus will be used as the vote for the next round of the first consensus message value; if the current round of consensus is the first round, the auxiliary value in the first type of consensus message in the next round will be set as the current round of public coin value; if the current round of consensus is not the first round, the next round of the first consensus The auxiliary value in is determined to be a value whose occurrence number in the second set exceeds a preset number of times.
根据本申请实施例的第三个方面,提供了一种计算机设备,包括存储器、处理器、通信接口及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如上述第一方面所述方法的步骤。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.
采用本申请实施例中提供的共识方法,各个共识节点通过广播投票值和辅助值,不需要任何公钥密码学、不需要假设数字签名或门限签名,可以使各个共识节点就待共识提议快速达成共识,大大提高了各个共识节点的共识效率。By adopting the consensus method provided in the embodiment of this application, each consensus node broadcasts the voting value and auxiliary value without any public key cryptography, digital signature or threshold signature, so that each consensus node can quickly reach consensus proposals. Consensus greatly improves the consensus efficiency of each consensus node.
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中: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为本说明书实施例的一种异步二元共识方法的流程示意图Figure 1 is a schematic flow diagram of an asynchronous binary consensus method in the embodiment of this specification
图2为本说明书实施例的一种共识节点维护各个ABA实例的示意图;FIG. 2 is a schematic diagram of a consensus node maintaining each ABA instance according to an embodiment of this specification;
图3为本说明书实施例的一种广播共识消息的流程示意图;FIG. 3 is a schematic flow diagram of a broadcast consensus message according to an embodiment of this specification;
图4为本说明书实施例的一种每轮共识过程的示意图;Fig. 4 is a schematic diagram of each round of consensus process in the embodiment of this specification;
图5为本说明书实施例的一种异步二元共识装置的结构示意图;FIG. 5 is a schematic structural diagram of an asynchronous binary consensus device according to an embodiment of this specification;
图6是用于配置本说明书实施例装置的一种设备的结构示意图。Fig. 6 is a schematic structural diagram of a device for configuring the device of the embodiment of the present specification.
二元共识是拜占庭容错协议(拜占庭共识,BFT)的主要组成部分,目前已知的异步拜占庭共识协议都直接或者间接依赖二元共识,其可以使区块链等分布式系统在异步环境下达成共识。同时,二元共识也可以用于构造状态机复制(state machine replication),进而使用状态机复制为分布式容错系统建立基础,另外,二元共识还可以应用在数据库等技术领域。Binary consensus is the main component of the Byzantine Fault Tolerant Protocol (BFT). Currently known asynchronous Byzantine consensus protocols rely directly or indirectly on binary consensus, which can enable distributed systems such as blockchains to be reached in an asynchronous environment. consensus. At the same time, binary consensus can also be used to construct state machine replication, and then use state machine replication to establish a foundation for distributed fault-tolerant systems. In addition, binary consensus can also be applied to technical fields such as databases.
二元共识中,二元是指两个值,通常用0和1表示,分布式系统中各个节点可以就两个值中的某个值达成一致,而该值对于分布式系统来说往往具有重要的实际意义。以二元共识应用在区块链网络为例,区块链网络中各个节点的数据需要保持一致,如果利用二元共识方法,当各个节点针对某批交易达成共识为1时,则各个节点都存储该数据,当各个节点针对某批交易达成共识为0时,则各个节点都不存储该数据,这样就保证了各个节点存储数据的一致性。可以理解的是,如果二元共识方法的执行效率越高,则分布式系统的性能也就越好,因此如何提高二元共识的效率是目前业界重要的研究方向。In binary consensus, binary refers to two values, usually represented by 0 and 1. Each node in a distributed system can reach a consensus on one of the two values, and this value often has a certain value for a distributed system. important practical significance. Taking the application of binary consensus in the blockchain network as an example, the data of each node in the blockchain network needs to be consistent. If the binary consensus method is used, when each node reaches a consensus of 1 for a certain batch of transactions, each node will Store the data. When each node reaches a consensus of 0 for a certain batch of transactions, each node does not store the data, thus ensuring the consistency of the data stored by each node. It is understandable that if the execution efficiency of the binary consensus method is higher, the performance of the distributed system will be better. Therefore, how to improve the efficiency of the binary consensus method is an important research direction in the industry at present.
针对上述问题,本申请实施例中提供了一种异步二元共识方法,应用于分布式系统中的任一个共识节点,该节点广播包括投票值和辅助值的共识消息,并基于接收到的其他共识节点发送的投票值以及辅助值确定共识结果,从而使系统中各个节点达成共识。In view of the above problems, the embodiment of this application provides an asynchronous binary consensus method, which is applied to any consensus node in the distributed system. The node broadcasts consensus messages including voting values and auxiliary values, and based on other received The voting value sent by the consensus node and the auxiliary value determine the consensus result, so that each node in the system reaches a 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.
为了便于本领域技术人员理解本说明书中的内容,下面对本说明书中涉及到的名词进行说明。In order to facilitate those skilled in the art to understand the contents of this specification, the nouns involved in this specification are described below.
在本说明书中,待共识提议可以理解为任一共识节点发出的数据,并希望其他共识节点共同参与对该数据的共识,而投票值则用于表示各个共识节点对该数据的共识意见,其中投票值包括第一投票值以及第二投票值,即各个共识节点可以对待共识提议存在共两种共识意见,第一投票值以及第二投票值在一个实施例中,可以用1和0分别进行表示,在其他实施例中,还可以用其他形式和符号进行表示,本说明书对于第一投票值以及第二投票值的具体形式不行进行限定,只要能够用于区分第一投票值和第二投票值均可。辅助值则为本说明书提出的用于协助各个节点就待共识提议达成共识的一种辅助意见,其包括第一投票值、第二投票值以及空。In this specification, the consensus proposal can be understood as the data sent by any consensus node, and it is hoped that other consensus nodes will participate in the consensus on the data, and the voting value is used to represent the consensus opinion of each consensus node on the data, where The voting value includes the first voting value and the second voting value, that is, each consensus node can have two kinds of consensus opinions on the consensus proposal. It means that in other embodiments, other forms and symbols can also be used for representation. This specification does not limit the specific forms of the first voting value and the second voting value, as long as it can be used to distinguish the first voting value and the second voting value Any value can be used. The auxiliary value is an auxiliary opinion proposed in this specification to assist each node to reach a consensus on the proposal to be consensus, which includes the first voting value, the second voting value and null.
以区块链场景为例,待共识提议可以是任一共识节点从本地交易池中获取的一批交易,并希望其他共识节点可以接收并存储该批交易,而投票值用于表示各个共识节点是否同意存储该待共识提议。Taking the blockchain scenario as an example, the pending consensus proposal can be a batch of transactions obtained by any consensus node from the local transaction pool, and it is hoped that other consensus nodes can receive and store the batch of transactions, and the voting value is used to represent the transaction value of each consensus node. Whether to agree to store the pending consensus proposal.
在其他应用场景中,待共识提议以及投票值会具有其他不同的实际含义,本说明书对此不进行限定。In other application scenarios, the consensus proposal and voting value will have other different actual meanings, which are not limited in this specification.
如图2所示,为分布式系统中的任一节点所要执行的二元共识实例的示意图,As shown in Figure 2, it is a schematic diagram of a binary consensus instance to be executed by any node in the distributed system,
分布式系统中的任一节点会针对每一个共识节点(包括其自身)分别利用本说明提出的异步二元共识方法确定针对该共识节点提出的待共识提议的共识结果,如图中实例ABA
1-ABA
n,分别为针对N个共识节点进行异步二元共识方法ABA(asynchronous binary agreement)的示意图,ABA1为目标节点针对共识节点1提出的待共识提议进行异步二元共识的示意,ABA2为目标节点针对共识节点2提出的待共识提议进行异步二元共识的示意,以此类推。
Any node in the distributed system will use the asynchronous binary consensus method proposed in this note for each consensus node (including itself) to determine the consensus result of the consensus proposal proposed by the consensus node, as shown in the example ABA 1 in the figure -ABA n is a schematic diagram of the asynchronous binary agreement method ABA (asynchronous binary agreement) for N consensus nodes, ABA1 is a schematic diagram of the target node performing asynchronous binary consensus on the pending consensus proposal proposed by consensus node 1, and ABA2 is the target It is an indication that the node performs asynchronous binary consensus on the pending consensus proposal proposed by the consensus node 2, and so on.
从示意图中可以看出,目标节点在针对每个待共识提议进行共识时,会确定一个初始投票值(0或1),最终基于本说明提出的二元共识方法也会得到针对该待共识提议的共识结果(0或1)。It can be seen from the schematic diagram that the target node will determine an initial voting value (0 or 1) when performing consensus on each proposal to be consensus, and finally the binary consensus method proposed based on this description will also get The consensus result (0 or 1) for .
如图1所示,基于以上说明,本说明书提出了一种异步二元共识方法,该方法为分布式系统中的任一共识节点所执行的方法,为了方便说明将该共识节点称为目标节点。As shown in Figure 1, based on the above description, this specification proposes an asynchronous binary consensus method, which is a method executed by any consensus node in the distributed system. For the convenience of description, the consensus node is called the target node .
分布式系统至少包括N个共识节点,共识节点是指参与共识过程的节点,可以理解的是,在分布式系统中通常还会存在其他不参与共识的节点,这些节点仅接收和存储共识节点的共识结果而不参与共识过程;另外,当系统中的恶意节点或称拜占庭节点过多时任何一种共识方法均无法确保系统中的共识节点达成共识,因此本说明书中规定该分布式系统包括N个共识节点,所述N个共识节点中最多允许存在f个恶意节点,N≥3f+1,所述f和N均为大于0的整数,该方法应用于所述多个共识节点中的任一正确节点,可以理解的是其他正确共识节点也在异步执行上述方法,当目标节点针对任一共识节点提出的待共识提议的共识结果时,其他正确共识节点最终也会针对该待共识提议得到相同的共识结果。A distributed system includes at least N consensus nodes. A consensus node refers to a node that participates in the consensus process. It is understandable that there are usually other nodes that do not participate in the consensus in a distributed system. These nodes only receive and store the consensus node’s The consensus result does not participate in the consensus process; in addition, when there are too many malicious nodes or Byzantine nodes in the system, any consensus method cannot ensure that the consensus nodes in the system reach a consensus, so this specification stipulates that the distributed system includes N Consensus nodes, at most f malicious nodes are allowed to exist among the N consensus nodes, N≥3f+1, both f and N are integers greater than 0, and this method is applied to any of the plurality of consensus nodes For the correct node, it is understandable that other correct consensus nodes are also executing the above method asynchronously. When the target node proposes the consensus result of the pending consensus proposal for any consensus node, other correct consensus nodes will eventually get the same consensus proposal for the pending consensus proposal. consensus results.
该方法包括:The method includes:
S101,针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值,以及初始辅助值;S101, for any consensus node's pending consensus proposal, determine the initial voting value corresponding to the pending consensus proposal, and the initial auxiliary value;
根据上述图2、以及对于图2的说明可知,目标节点会针对每个共识节点的待共识提议分别确定共 识结果,图1所描述的即为针对每个待共识提议所要执行共识过程。According to the above Figure 2 and the description of Figure 2, it can be known that the target node will determine the consensus result for each consensus node’s proposal to be consensus, and Figure 1 describes the consensus process to be executed for each consensus proposal.
本步骤中,针对待共识提议确定初始投票值以及初始辅助值,初始辅助值可以默认为空,而初始投票值在不同应用场景中,可以根据不同的数据确定。例如在区块链网络中,可以根据是否在收到待共识提议的情况确定:如果目标节点接收到了该待共识提议(其他共识节点通过可靠广播RBC协议广播的),则确定该待共识提议的初始投票值为第一投票值,如果已经确定收到N-f个共识节点的待共识提议,则可以将还未收到的待共识提议的初始投票值置为第二投票值。在其他应用场景中,还可以根据不同的数据确定待共识提议的初始投票值。在本说明书中,均由第一投票值为1、第二投票值为0为例,进行说明。In this step, 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 different data in different application scenarios. For example, in a blockchain network, it can be determined according to whether the proposal to be consensus is received: if the target node receives the proposal to be consensus (broadcast by other consensus nodes through the reliable broadcast RBC protocol), then determine the The initial voting value is the first voting value. If it is determined that the consensus proposals from N-f consensus nodes have been received, the initial voting value of the unreceived consensus proposals can be set as the second voting value. In other application scenarios, the initial voting value of the proposal to be consensus can also be determined according to different data. In this specification, the first voting value is 1 and the second voting value is 0 as an example for illustration.
循环执行每轮共识步骤,直到得到针对该待共识提议的共识结果,其中,每轮共识步骤包括:Each round of consensus steps is cyclically executed until the consensus result for the proposal to be consensus is obtained, wherein each round of consensus steps includes:
S102,广播本轮共识消息,所述共识消息中携带投票值以及辅助值;S102. Broadcast the current round of consensus messages, where the consensus messages carry voting values and auxiliary values;
S103,基于接收到的其他共识节点广播的投票值和辅助值,确定是否得到共识结果。S103, based on the received voting values and auxiliary values broadcast by other consensus nodes, determine whether to obtain a consensus result.
本说明书提出的共识方法是按共识轮执行的,每轮中包括与其他共识节点交互投票值和辅助值的阶段,以及在交互完成后基于交互的结果确定共识结果的阶段,即S102-S103。The consensus method proposed in this specification is executed in consensus rounds, each round includes the stage of exchanging voting values and auxiliary values with other consensus nodes, and the stage of determining the consensus result based on the interaction results after the interaction is completed, that is, S102-S103.
下面对S102以及S103进行详细说明:S102 and S103 are described in detail below:
在上述S102中,目标节点具体可以是执行如图3所述的方法:In the above S102, the target node may specifically execute the method as described in Figure 3:
S301,将投票值和辅助值携带在第一类共识消息中进行广播;S301, carrying the voting value and the auxiliary value in the first type of consensus message for broadcasting;
如果是首轮共识,目标节点可以按照上述S101中所述的方法,确定初始投票值以及初始辅助值;如果是非首轮共识,确定投票值以及辅助值的方法可以参照下文关于S303的部分,这里不进行详述。If it is the first round of consensus, the target node can determine the initial voting value and initial auxiliary value according to the method described in S101 above; if it is not the first round of consensus, the method of determining the voting value and auxiliary value can refer to the section about S303 below, here Not detailed.
目标节点可以将本地确定的投票值以及辅助值添加到第一类共识消息中,并通过认证信道将第一类共识消息传输至分布式系统中的其他共识节点,当然在没有认证信道时,为了保证数据传输的安全性,还可以通过数字签名或公钥技术设施等密码学工具保证共识消息传输的安全性,本说明书对此不进行限定。The target node can add the locally determined voting value and auxiliary value to the first type of consensus message, and transmit the first type of consensus message to other consensus nodes in the distributed system through the authentication channel. Of course, when there is no authentication channel, for 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.
在一个实施例中,第一类共识消息可以是bval
r格式的消息,目标节点可以广播形如bval
r(est
r,maj
r)消息,其中est
r为投票值,maj
r为辅助值,投票值est
r是一个二进制数(0或1),maj
r∈{0,1,⊥},在第0轮中,maj
r可以设置为空,r为共识轮数,首轮即为0轮,r以1为步长递增。
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 round 0, maj r can be set to empty, r is the number of consensus rounds, the first round is round 0, r increments in steps of 1.
S302,接收其他共识节点广播的第一类共识消息;S302, receiving the first type of consensus message broadcast by other consensus nodes;
可以理解的是,分布式系统中的全部正确节点都在执行目标节点所执行的步骤,即其他共识节点也会发送包括投票值以及辅助值的第一类共识消息;此时,目标节点会接收到来自其他共识节点发送的第一类共识消息。It is understandable that all 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 type of consensus message including voting value and auxiliary value; at this time, the target node will receive To the first type of consensus messages sent from other consensus nodes.
在一个实施例中,如果目标节点在当前共识轮接收到f+1个第一类共识消息,即超过恶意节点数量的第一类共识消息,如果这f+1个第一类共识消息中的投票值相同,且与本地本轮共识通过第一类共识消息广播的投票值不一致,目标节点则将本轮本地投票值修改为与f+1个第一类共识消息中投票值相同的值,并再次广播第一类共识消息。例如,如果目标节点收到f+1个bval
r(b,*)消息,且b与该目标节点的当前轮首次广播的投票值est
r不相等,该目标节点将广播
其中*可以是0,1或空中的任意一个值,
本步骤目的是为了让本地节点可以更正本地投票值。
In one embodiment, if the target node receives f+1 first-type consensus messages in the current consensus round, that is, the first-type consensus messages exceeding the number of malicious nodes, if the f+1 first-type consensus messages The voting value is the same and inconsistent with the voting value broadcast by the local consensus message of the first type of consensus in this round, and the target node modifies the local voting value of the current round to the same value as the voting value in f+1 first type consensus messages, And broadcast the first type of consensus message again. For example, if the target node receives f+1 bval r (b,*) messages, and b is not equal to the voting value est r of the target node’s first broadcast in the current round, the target node will broadcast Where * can be 0, 1 or any value in the air, The purpose of this step is to allow the local node to correct the local voting value.
S303,基于接收到的第一类共识消息重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播。S303. Re-determine the voting value and 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.
目标节点在接收到法定数量的第一类共识消息后,即可以根据接收到的第一类共识消息重新确定投票值以及辅助值,其中,法定数量即为2f+1,(包括自身节点),如无特殊规定,下文中的法定数量均为2f+1。After the target node receives the quorum of the first type of consensus message, it can re-determine the voting value and auxiliary value according to the received first type of consensus message, where the quorum is 2f+1, (including its own node), Unless otherwise specified, the quorum below is 2f+1.
具体的,如果这2f+1个第一类共识消息中的投票值相同,目标节点则将该投票值添加到第一集合中。例如,如果目标节点收到2f+1个bval
r(b,*)消息,b∈{0,1}。则目标节点将b添加到第一集合bin_values
r中。此外,目标节点将上述2f+1个第一类共识消息中的辅助值,也添加到辅助值集合majs中。本步骤中,在接收到法定数量的相同投票值的情况下,则将该投票值存储到第一集合中,意味着系统中大多数节点可能达成了共识。
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.
在将该投票值存储到第一集合之后,如果当前共识轮为首轮即第0轮(共识轮从0开始以1为步长递增),则可以将投票值以及辅助值确定为该第一集合中的投票值,并广播第二类共识消息;延续上述举的例子,如果将b添加到了第一集合即集合bin_values
r中,则可以重新确定投票值和辅助值均为b,并开始广播第二类共识消息aux
r(b,b),其中aux
r为第二类共识消息格式。
After storing the voting value in the first set, if the current consensus round is the first round, that is, round 0 (the consensus round starts from 0 and increments by 1), then the voting value and auxiliary value can be determined as the first set The voting value in , and broadcast the second type of consensus message; Continuing the above example, if b is added to the first set, that is, the set bin_values r , you can re-determine that both the voting value and the auxiliary value are b, and start broadcasting the first set The second type of consensus message aux r (b,b), where aux r is the format of the second type of consensus message.
另外,如果当前共识轮并非是首轮即并非为第0轮共识,目标节点则将第一集合中的投票值,与上一轮的公共抛币值进行比较,并根据比较结果确定第二类共识消息中携带的投票值以及辅助值。其中,公共抛币值,只有0或1两种值,各个共识节点可以在某一轮中获得相同的公共抛币值,且每一轮的抛 币值是随机的,获得公共抛币值的方法可以是使用交互的门限伪随机数协议,门限签名协议,可信平台(TEE)等方式实现,具体内容可以参照相关技术,这里不进行详述。In addition, if the current consensus round is not the first round or the 0th round of consensus, the target node will compare the voting value in the first set with the public coin toss value of the previous round, and determine the second type of consensus based on the comparison result The voting value and auxiliary value carried in the message. Among them, the public coin toss value only has 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. The method of obtaining the public coin toss value can be to use The interactive threshold pseudo-random number protocol, threshold signature protocol, trusted platform (TEE) and other methods are implemented. For specific content, please refer to related technologies, which will not be described in detail here.
根据比较结果确定第二类共识消息中携带的投票值以及辅助值的方式如下:The way to determine the voting value and auxiliary value carried in the second type of consensus message according to the comparison result is as follows:
一种情况是,如果第一集合中的投票值与上一轮的公共抛币值相等,并且接收过的第一类共识消息中携带的投票值均为该第一集合中的投票值,携带的辅助值均为该第一集合中的投票值或空,则将第二类共识消息中的投票值以及辅助值确定为该第一集合中的投票值并进行广播;如果还接收过携带其他投票值的第一类共识消息,则将第二类共识消息中的投票值设置为空,并且将第二类共识消息中的辅助值设置为该第一集合中的投票值。延续上述的例子,如果第一集合中的投票值为b,上一轮的公共抛币值为S
r-1,如果b=S
r-1,并且目标节点仅接收过bval
r(b,b)和bval
r(b,⊥)消息,则直接广播aux
r(b,b),如果还接收过携带其他投票值的第一类共识消息,则广播aux
r(⊥,b)。
One case is, 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 received first type of consensus message are all the voting values in the first set, the carried If the auxiliary values are all voting values in the first set or empty, the voting value and auxiliary value in the second type of consensus message are determined as the voting values in the first set and broadcast; if other voting values are received value of the first type of consensus message, 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 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,如果
其中,
由于抛币值只有两个值0或1,投票值也只有两个值0或1,因此在投票值b不等于抛币值S
r-1时,则等于1-S
r-1即
在这种情况下,且目标节点仅接收过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 in, 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 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 broadcasts the second consensus information only once per round. The above method is a method for the target node to determine the voting value and auxiliary value carried in the second type of consensus message.
目标节点在发送第二类共识消息时,由于其他共识节点也会异步的发送第二类共识消息,因此目标节点会接收到其他共识节点发的的第二类共识消息。目标节点在接收到其他共识节点发送的共识消息后,可以先将一些明显非法的第二类共识消息删除,根据上述内容可知,由于正确的共识节点仅会广播形如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.
上述S103中,目标共识节点基于接收到的投票值和辅助值确定是否得到共识结果,如果没有得到共识结果,则基于确定下一轮的投票值以及辅助值,并重新开始执行S101。In the above S103, the target consensus node determines whether to obtain a consensus result based on the received voting value and auxiliary value. If no consensus result is obtained, it determines the next round of voting value and auxiliary value, and restarts execution of S101.
下面对目标共识节点基于接收到的投票值和辅助值确定共识结果,以及确定下一轮投票值和辅助值的方法进行详述: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 the target node receives 2f+1 aux r () messages, it can store the voting value and auxiliary value in the received aux r () messages into the sets vals r (second set) and avals r ( in the third set). 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 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, the auxiliary values carried by the quorum of second-type consensus messages are different, and the voting value in the second set is a voting value and 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 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 the voting value of this type is different from the value of the last public coin toss. Then the target node can use the current round of public coin toss value as the voting value of the next round of the first type of consensus message. In addition, if the current consensus round is the first round, the target node will also set the auxiliary value in the first type of consensus message in the next round as the public coin value of the current round. If the current consensus round is not the first round, the target node will set the auxiliary value of the next round The auxiliary value in the first consensus message is set to the value whose occurrence times in the second set exceeds the preset number, and enters into the next round of consensus.
例如,如果目标节点接收到的第二共识消息的情况不属于上述三种情况,目标节点将当轮公共抛币值作为下一轮输入(即将est
r+1设置为S
r)。此外,若轮数r=0,目标节点将maj
r+1设置为S
r;若r>0,目标节点将maj
r+1设置为majority(vals
r),其中,majority(vals
r)=b,b∈{0,1},代表b在vals
r中出现次数占大多数,即vals
r中b的数量不小于
若不存在这样的b,则令majority(vals
r)=⊥。
For example, if the second consensus message received by the target node does not belong to the above three situations, the target node will use the current round of public coin toss value as the next round input (ie set est r+1 to S r ). In addition, if the number of rounds r=0, the target node sets maj r+1 as S r ; if r>0, the target node sets maj r+1 as majority(vals r ), where majority(vals r )=b , b ∈ {0, 1}, representing the majority of occurrences of b in vals r , that is, the number of b in vals r is not less than If there is no such b, let majority(vals r )=⊥.
可以理解的是,上述方式是共识节点中的任一正确节点所执行的方法,其他正确共识节点也在异步执行上述方法,采用上述方式,可以使异步环境下的分布式系统中的各个共识节点快速就某个值达到共识状态,其中首轮达成共识的概率为1-(1/2)
1,次轮达成共识的概率为1-(1/2)
2…以此类推,即随着共识轮数的增加,达成共识的概率成指数级增加,完成共识的轮数平均为两轮,即总运行轮数的数学期望是两轮,并且每轮仅需要执行2-3步,大大提升了异步环境下分布式系统的共识效率,且上述共识方法不需要依赖任何公钥密码学,不需要假设数字签名,或者门限签名,只需确定公平抛币的即可,经过实验证明本说明书提出的异步二元共识方法是目前共识效率最高的二元共识方法。
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, each consensus node in the distributed system in an asynchronous environment can Quickly reach a consensus state on a certain value, where the probability of reaching a consensus in the first round is 1-(1/2) 1 , the probability of reaching a consensus in the second round is 1-(1/2) 2 ... and so on, that is, with the consensus With the increase in the number of rounds, the probability of reaching a consensus increases exponentially. The average number of rounds to complete the consensus is two rounds, that is, the mathematical expectation of the total number of running rounds is two rounds, and only 2-3 steps need to be executed in each round, which greatly improves the Consensus efficiency of distributed systems in an asynchronous environment, and the above-mentioned consensus method does not need to rely on any public key cryptography, does not need to assume digital signatures, or threshold signatures, and only needs to determine a fair coin toss. Experiments have proved that the proposed The asynchronous binary consensus method is currently the most efficient binary consensus method.
如图4所示,为上述102-103中每轮共识过程的示意图,即各个共识节点首先将投票值以及辅助值添加到第一类共识消息中广播至其他节点,并基于其他共识节点广播的第一类共识消息确定第二类共识消息所携带的投票值和辅助值,最终基于交互的投票值以及辅助值确定共识结果。As shown in Figure 4, it is a schematic diagram of each round of consensus process in the above 102-103, that is, each consensus node first adds the voting value and auxiliary value to the first type of consensus message and broadcasts it to other nodes, and based on the information broadcast by other consensus nodes The first type of consensus message determines the voting value and auxiliary value carried by the second type of consensus message, and finally determines the consensus result based on the interactive voting value and auxiliary value.
结合上述图2以及图4,在针对全部共识节点提出的共识提议达成共识之后,各个正确的共识节点会得到相同的共识结果,结果为包含0和1的序列。进一步即可以基于该序列执行相应的事务处理,仍以区块链网络为例,0或1用于指示是否将相应的共识提议打包成块。例如共有四个共识节点,共识节点1提出的共识提议为P1,共识节点2提出的共识提议为P2,共识节点3提出的共识提议为P3,共识节点4提出的共识提议为P4,使用上述共识方法进行共识后得到一个01序列,例如得到的序列为(1,1,1,0),则达成的共识结果为所有节点将P1、P2以及P3打包成块存储在本地不存储P4,即各个共识节点根据共识结果对各共识提议进行了一致性处理,保证各个共识节点的数据一致性。Combining the above Figure 2 and Figure 4, after reaching a consensus on the consensus proposals put forward by all consensus nodes, each correct consensus node will get the same consensus result, which is a sequence containing 0 and 1. Further, corresponding transaction processing can be performed based on the sequence. Still taking the blockchain network as an example, 0 or 1 is used to indicate whether to pack the corresponding consensus proposal into blocks. 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. Using the above consensus The 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 without storing P4, that is, each According to the consensus results, the consensus nodes have carried out consistent processing on each consensus proposal to ensure the data consistency of each consensus node.
为了使本领域技术人员更为清楚的了解上述共识方法,下面以区块链场景为例,对目标节点接收其他共识节点的待共识提议,以及向其他共识节点发送待共识提议的过程进行说明:In order for those skilled in the art to understand the above consensus method more clearly, the following takes the blockchain scenario as an example to explain the process of the target node receiving the pending consensus proposal from other consensus nodes and sending the pending consensus proposal to other consensus nodes:
目标节点可以是从本地交易池中随机获取预设数量的交易,或者按照交易存储的先后顺序,优先获取较早存储的预设数量的交易。可以理解的是,由于各个共识节点都会接收客户端请求的交易,因此各个共识节点都可以在本地维护自己的交易池。目标节点在获取了交易后,可以将获取的交易打包成为本次的待共识提议。目标节点在获取了本地待共识提议后,即可以基于可靠广播RBC协议,向其他共识节点广播本地待共识提议,同时也可以基于可靠广播RBC协议接收其他共识节点广播的待共识提议。下面以一种可靠广播RBC协议的具体实现方式进行举例说明:The target node can randomly obtain a preset number of transactions from the local transaction pool, or preferentially obtain a preset number of transactions stored earlier according to the order in which the transactions are stored. 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 erasure coding 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. Calculate Hash1 and Hash2 to get Hash12, and calculate Hash3 and Hash4 to get 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消息。Through the above method, consensus node 2-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.
各个共识节点可以同时发出本地的待共识提议,因此目标节点可能会先后接收到不同共识节点发送的待共识提议。目标节点在接收到其他共识节点发的的任一待共识提议后,即可以确定待共识提议的初始投票值,例如将初始投票值确定为第一投票值1,并可以针对该待共识提议执行S101-S103,即可以根据待共识提议的接收情况确定各个待共识提议的初始投票值以触发执行本说明书提出的异步二元共识方法,进而可以针对区块链网络中每个共识节点广播的待共识提议分别达成共识。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 any pending consensus proposal from other consensus nodes, the target node can determine the initial voting value of the pending consensus proposal, for example, determine the initial voting value as the first voting value 1, and execute the S101-S103, that is, the initial voting value of each pending consensus proposal can be determined according to the reception of the pending consensus proposal to trigger the execution of the asynchronous binary consensus method proposed in this specification, and then the pending consensus broadcast by each consensus node in the blockchain network can be Consensus proposals reach consensus separately.
可以理解的是,上述仅为可靠广播RBC协议的一种具体实现方式,还可以通过其他方式实现可靠广播RBC协议的具体内容可以参照相关技术,本说明书对此不进行限定。上述举的也是将本说明书提出的异步二元共识方法应用在区块链网络中的例子,在其他应用场景中,还可以基于不同的数据确定任一待共识提议的初始投票值,并触发执行本说明书提出的异步二元共识方法,以使各个共识节点达成共识。It can be understood that the above is only a specific implementation manner of the reliable broadcast RBC protocol, and the reliable broadcast RBC protocol can also be implemented in other ways. For specific content of the reliable broadcast RBC protocol, reference can be made to related technologies, which is not limited in this specification. The above is also an example of applying the asynchronous binary consensus method proposed in this specification to the blockchain network. In other application scenarios, the initial voting value of any proposal to be consensus can also be determined based on different data, and trigger the execution The asynchronous binary consensus method proposed in this specification enables each consensus node to reach a consensus.
下面从代码实现角度对本说明书的S101-S103进行说明:The following describes S101-S103 of this manual from the perspective of code implementation:
伪代码如下:The pseudocode is as follows:
上述伪代码中,任意b∈{0,1};
*在某消息中作为参数时,可以代表b,
或者⊥;例如,aux
r(*,b)可能代表
或aux
r(⊥,b);bval
r(b,*)可能代表
或bval
r(b,⊥);aux
r()可以代表aux
r(*,*);vals是由0、1和⊥组成的向量(多集)。V
1(vals)=b当且仅当vals集合中仅包含b,b∈{0,1,⊥};V
1(vals,b)=t当且仅当vals中仅包含b或仅包含b与⊥,其中b∈{0,1},b在vals中共出现了t次。majority(vals)=b,b∈{0,1},代表b在vals中出现次数占大多数,即vals中b的数量不小于
若不存在这样的b,则令majority(vals)=⊥。
In the above pseudo code, any b∈{0,1}; * When used as a parameter in a message, it can represent b, or ⊥; for example, aux r (*,b) might represent or aux r (⊥,b); bval r (b,*) might represent or bval r (b,⊥); aux r () can represent aux r (*,*); vals is a vector (multiset) consisting of 0, 1 and ⊥. V 1 (vals)=b if and only if the vals set contains only b, b∈{0,1,⊥}; V 1 (vals,b)=t if and only if the vals contains only b or only b With ⊥, where b∈{0, 1}, b appears t times in vals. majority(vals)=b,b∈{0,1}, which means that b appears in the majority of vals, that is, the number of b in vals is not less than If there is no such b, let majority(vals)=⊥.
上述伪代码中,共有两种消息类型:bval
r()和aux
r(),在每一轮中,副本(节点)p
i有一个输入值est
r和一个辅助输入值maj
r。其中est
r是一个二进制数(0或1),maj
r∈{0,1,⊥}。第r轮协议步骤如下:
In the above pseudo-code, there are two message types: bval r () and aux r (), in each round, replica (node) p i has an input value est r and an auxiliary input value maj r. where est r is a binary number (0 or 1), maj r ∈ {0,1,⊥}. The steps of the r-round agreement are as follows:
(1)在第r轮中,p
i(目标节点)首先广播bval
r(est
r,maj
r)消息。第0轮中maj
r设置为⊥。r轮中正确的副本不会更改其maj
r。
(1) In round r, p i (target node) first broadcasts bval r (est r ,maj r ) message. In round 0, maj r is set to ⊥. A correct replica in round r does not change its maj r .
a.如果副本p
i收到f+1个bval
r(b,*)消息,且b与该副本的输入est
r不相等,该副本将广播bval
r
a. If the replica p i receives f+1 bval r (b,*) messages, and b is not equal to the input est r of the replica, the replica will broadcast bval r
b.如果副本p
i收到2f+1个bval
r(b,*)消息,b∈{0,1}。则p
i将b添加到集合bin_values
r中。
b. If replica p i receives 2f+1 bval r (b,*) messages, b∈{0,1}. Then p i adds b to the set bin_values r .
此外,p
i检查收到的2f+1个bval
r(b,*)消息中的maj
r变量值,并将这些值存入集合majs。
In addition, pi checks the maj r variable values in the received 2f+1 bval r (b,*) messages and stores these values in the set majs.
在满足以下条件时,将r(b)设置为1。Set r(b) to 1 when the following conditions are satisfied.
如果r=0,无论b=1或b=0,都将r(b)设置为1;If r=0, set r(b) to 1 regardless of b=1 or b=0;
如果r>0,副本p
i将b与第r–1轮公共抛币值S
r-1进行比较。
If r > 0, the replica p i compares b with the value S r - 1 of the public toss of round r–1.
若b=Sr-1,且p
i仅接收过bval
r(b,b)和bval
r(b,⊥)消息,则将r(b)设置为1;
If b=Sr-1, and p i has only received bval r (b,b) and bval r (b,⊥) messages, then set r(b) to 1;
若
且p
i仅接收过bval
r(b,b)消息(即V1(majs)=b),则将r(b)设置为1。p
i收到sf+1个bval
r(b,*)消息后,若r(b)=1,则广播aux
r(b,b);否则广播aux
r(⊥,b)。一个正确的副本每轮只发送一个aux
r()信息。
like And pi has only received bval r (b,b) messages (that is, V1(majs)=b), then r(b) is set to 1. After p i receives sf+1 bval r (b,*) messages, if r(b)=1, then broadcast aux r (b,b); otherwise broadcast aux r (⊥,b). A correct replica sends only one aux r () message per round.
(2)p
i在接收aux
r()消息时,只有V1与V2都属于集合bin_values
r中,才接收相应的aux
r(v1,v2)消息。副本不接受形如
或aux
r(*,⊥)这样的消息,因为按照我们的协议规定,这些消息不是按照协议合法提出的。此外,如果副本在当轮已经设置r(b)=1,后收到的
消息将被丢弃。
(2) When p i receives the aux r () message, only when both V1 and V2 belong to the set bin_values r , can it receive the corresponding aux r (v1, v2) message. Copies in the form of or messages like aux r (*,⊥), because according to our agreement, these messages are not legally proposed according to the agreement. In addition, if the replica has set r(b)=1 in the current round, the later received The message will be discarded.
收到N-f个aux
r()消息后,p
i将aux
r()消息中的第一个变量和第二个变量分别存入集合vals
r和avls
r,获取公共抛币值,进行判断并进入下一轮。此时有以下四种情况:
After receiving Nf aux r () messages, p i stores the first variable and the second variable in the aux r () messages into the sets vals r and avls r respectively, obtains the public coin toss value, makes a judgment and enters the next round. At this point, there are four situations:
a.如果p
i收到法定人数(由于N=3f+1,此时法定人数为2f+1=n-f)条aux
r(b,b)信息,p
i将b与公 共抛币S
r进行比较。如果b=Sr,pi决定b;否则,pi将est
r+1与maj
r+1都设置为b,并进入下一轮。
a. If p i receives a quorum (because N=3f+1, the quorum is 2f+1=nf) aux r (b,b) information, p i compares b with the public coin toss S r . If b=Sr, pi decides b; otherwise, pi sets both est r+1 and maj r+1 to b, and enters the next round.
b.如果p
i只接收到了aux
r(b,*)和aux
r(⊥,*),且至少有法定人数条消息的格式为aux
r(*,b),此时p
i将b与两轮公共抛币S
r-1与S
r进行比较。如果b=S
r-1且b=S
r,p
i决定b。否则p
i将est
r+1与maj
r+1都设置为b,并进入下一轮。
b. If pi only receives aux r (b,*) and aux r (⊥,*), and there are at least quorum messages in the format of aux r (*,b), then pi will combine b and two A round of public coin tosses Sr-1 is compared with Sr. If b=Sr -1 and b= Sr , pi determines b. Otherwise, p i sets both est r+1 and maj r+1 to b, and enters the next round.
c.如果p
i接收了N-f条aux
r(b,*)和aux
r(⊥,*)消息,其中同时包含aux
r(*,0)与aux
r(*,1),且b=S
r-1,则p
i将est
r+1与maj
r+1都设置为b,并进入下一轮。
c. If p i receives Nf aux r (b,*) and aux r (⊥,*) messages, which contain both aux r (*,0) and aux r (*,1), and b=S r -1 , then p i sets both est r+1 and maj r+1 to b, and enters the next round.
d.如果这三种情况都不适用,p
i使用当轮公共抛币值作为下一轮输入(即将est
r+1设置为S
r)。此外,若轮数r=0,p
i将maj
r+1设置为S
r;若r>0,将maj
r+1设置为majority(vals
r)。
d. If none of the three cases apply, p i uses the public coin toss value of the current round as the input for the next round (that is, set est r+1 to S r ). In addition, if the number of rounds r=0, p i sets maj r+1 as S r ; if r>0, sets maj r+1 as majority(vals r ).
随后,p
i进入r+1轮。
Subsequently, p i enters r+1 rounds.
如图5所示,与前述一种异步二元共识方法相对应,本说明书还提供了一种异步二元共识装置,其特征在于,所述装置应用于分布式系统中的任一共识节点中,所述分布式系统至少包括N个共识节点,其中N≥3f+1,所述f为大于0的整数,所述装置包括:As shown in Figure 5, corresponding to the aforementioned asynchronous binary consensus method, this specification also provides an asynchronous binary consensus device, which is characterized in that the device is applied to any consensus node in the distributed system , the distributed system includes at least N consensus nodes, where N≥3f+1, the f is an integer greater than 0, and the device includes:
处理模块520,用于针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值,以及初始辅助值;其中,投票值包括第一投票值以及第二投票值,辅助值包括第一投票值、第二投票值以及空,初始投票值为第一投票值或第二投票值;循环执行执行每轮共识步骤,直到得到针对该待共识提议的共识结果;The processing module 520 is configured to determine an initial voting value corresponding to the consensus proposal for any consensus node, and an initial auxiliary value; wherein, the voting value includes a first voting value and a second voting value, and the auxiliary value Including the first voting value, the second voting value and empty, the initial voting value is the first voting value or the second voting value; execute each round of consensus steps in a loop until the consensus result for the proposal to be consensus is obtained;
在每轮共识中:In each round of consensus:
通信模块510,用于广播本轮共识消息,所述共识消息中携带本轮投票值以及辅助值;The communication module 510 is used to broadcast the consensus message of the current round, and the consensus message carries the voting value of the current round and the auxiliary value;
所述处理模块520,还用于基于接收到的其他共识节点广播的投票值和辅助值,确定是否得到共识结果。The processing module 520 is further configured to determine whether to obtain a consensus result based on the received voting values and auxiliary values broadcast by other consensus nodes.
在一个实施例中,所述通信模块510,具体用于将投票值和辅助值携带在第一类共识消息中进行广播;接收其他共识节点广播的第一类共识消息;In one embodiment, the communication module 510 is specifically configured to broadcast the voting value and auxiliary value in the first type of consensus message; receive the first type of consensus message broadcast by other consensus nodes;
所述处理模块520,具体用于基于接收到的第一类共识消息重新确定投票值以及辅助值,The processing module 520 is specifically configured to re-determine the voting value and the auxiliary value based on the received first type of consensus message,
所述通信模块510,用于将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播。The communication module 510 is configured to broadcast the re-determined voting value and auxiliary value in the second type of consensus message.
在一个实施例中,所述处理模块520,还用于若在当前共识轮接收到f+1个第一类共识消息,且所述f+1个第一类共识消息中的投票值相同、与本地本轮共识通过第一类共识消息广播的投票值不同,则将本地投票值修改为所述f+1个第一类共识消息中的投票值;所述通信模块510,用于再次广播携带投票值以及辅助值的第一类共识消息。In one embodiment, the processing module 520 is further configured to receive f+1 first-type consensus messages in the current consensus round, and the voting values in the f+1 first-type consensus messages are the same, Different from the voting value broadcast by the first type of consensus message in the local current round of consensus, the local voting value is modified to the voting value in the f+1 first type of consensus message; the communication module 510 is used to broadcast again The first type of consensus message carrying voting value and auxiliary value.
在一个实施例中,所述处理模块520,具体用于在接收到法定数量的第一类共识消息后,在所述法定数量的第一类共识消息所携带的投票值相同的情况下,将该投票值添加到第一集合中;In one embodiment, the processing module 520 is specifically configured to, after receiving a quorum of first-type consensus messages, and if the voting values carried by the quorum of first-type consensus messages are the same, The vote value is added to the first set;
若当前共识轮为首轮,则将投票值以及辅助值确定为所述第一集合中的投票值。If the current consensus round is the first round, the voting value and the auxiliary value are determined as voting values in the first set.
若当前共识轮不为首轮,则将所述第一集合中的投票值与上一轮的公共抛币值进行比较,根据比较结果以及接收到的第一类共识消息重新确定投票值以及辅助值。If the current consensus round is not the first round, the voting value in the first set is compared with the public coin toss value of the previous round, and the voting value and auxiliary value are re-determined according to the comparison result and the first type of consensus message received.
在一个实施例中,所述处理模块520,具体用于在第一集合中的投票值与上一轮的公共抛币值相等的情况下,若接收过的第一类共识消息中携带的投票值均为该第一集合中的投票值,携带的辅助值均为该第一集合中的投票值或空,则将投票值以及辅助值确定为该第一集合中的投票值;否则,将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In one embodiment, the processing module 520 is specifically configured to: if the voting value carried in the received first type of consensus message is are all voting values in the first set, and the auxiliary values carried are all voting values in the first set or empty, then the voting value and auxiliary value are determined as the voting values in the first set; otherwise, the voting The value is determined to be null, and the auxiliary value is determined to be the voting value in the first set.
在一个实施例中,所述处理模块520,具体用于在第一集合中的投票值与上一轮的公共抛币值不相等的情况下,若接收过的第一类共识消息中携带的投票值以及辅助值均为该第一集合中的投票值,则将投票值以及辅助值确定为该第一集合中的投票值;否则,则将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In one embodiment, the processing module 520 is specifically configured to: if the vote value carried in the received first type of consensus message is not equal to the value of the public coin toss in the previous round value and the auxiliary value are voting values in the first set, then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the voting value in the first set The vote value in the first set.
在一个实施例中,所述处理模块520,具体用于基于接收到的第二类共识消息中的投票值以及辅助值确定是否得到共识结果。In one embodiment, the processing module 520 is specifically configured to determine whether to obtain a consensus result based on the vote value and auxiliary value in the received second type of consensus message.
在一个实施例中,所述处理模块520,具体用于在接收到法定数量的第二类共识消息的情况下,将接收到的第二类共识消息中的投票值添加到第二集合中,并基于预设算法确定本轮共识的公共抛币值;In one embodiment, the processing module 520 is specifically configured to add the voting value in the received second type of consensus message to the second set when a quorum of the second type of consensus messages is received, And determine the public coin toss value of this round of consensus based on the preset algorithm;
若接收到的第二类共识消息中存在超过法定数量的第二类共识消息是相同的,且所述第二类共识消息中投票值与辅助值相同,则将该第二类共识消息中的投票值与本轮公共抛币值进行比较,如果该投票值与本轮公共抛币值相同,则目标共识节点确定共识结果为该投票值;If there are more than a quorum of the second type of consensus messages received in the second type of consensus messages that are the same, and the voting value in the second type of consensus messages is the same as the auxiliary value, then the second type of consensus messages in the second type of consensus messages The voting value 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 they are different, the voting value and the auxiliary value carried in the first type of consensus message in the next round are both determined as the voting value in the second type of consensus message.
在一个实施例中,所述处理模块520,具体用于若只接收到过合法第二类共识消息,所述第二集合 中的投票值为一种投票值和空,并且至少有法定数量条第二类共识消息的辅助值为该种投票值,则将该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值分别进行比较;In one embodiment, the processing module 520 is specifically configured to: if only legal consensus messages of the second type have been received, the voting value in the second set is one voting value and empty, and there are at least a quorum The auxiliary value of the second type of consensus message is the voting value, and the voting value is compared with the public coin toss value of the previous round of consensus and the public coin toss value of the current round of consensus;
若该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值均相同,则确定共识结果该为该种投票值;若该种投票值与上一轮共识的公共抛币值和/或本轮共识的抛币值不相同,则将下一轮第一类共识消息中的投票值以及辅助值均设置为该种投票值。If this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
在一个实施例中,所述处理模块520,具体用于若接收到了法定数量的合法第二类共识消息,所述法定数量的第二类共识消息携带的辅助值不全相同,所述第二集合中的投票值为一种投票值和空,且该种投票值与上一轮共识的公共抛币值相同,则将下一轮共识中第一类共识消息中的投票值以及辅助值均设置为该种投票值。In one embodiment, the processing module 520 is specifically configured to, if a quorum of legal second-type consensus messages are received, and the auxiliary values carried by the quorum of second-type consensus messages are not all the same, the second set The voting value in is a voting value and empty, and this voting value is the same as the public coin toss value of the previous round of consensus, then the voting value and auxiliary value in the first type of consensus message in the next round of consensus are set to the voting value.
在一个实施例中,所述处理模块520,具体用于在接收到的第二类共识消息不满足上述实施例的情况下,将本轮共识的公共抛币值作为下一轮第一类共识消息的投票值;若本轮共识为首轮,则将下一轮的第一类共识消息中的辅助值设置为本轮公共抛币值;若本轮共识不为首轮,则将下一轮的第一共消息中的辅助值确定为第二集合中的出现次数超过预设次数的值。In one embodiment, the processing module 520 is specifically configured to use the public coin toss value of the current round of consensus as the next round of the first type of consensus message when the received second type of consensus message does not satisfy the above-mentioned embodiment if the current round of consensus is the first round, then set the auxiliary value in the first type of consensus message in the next round as the public coin toss value of the current round; if the current round of consensus is not the first The auxiliary value in the common message is determined as a value whose occurrence times in the second set exceeds a preset number of times.
上述设备中各个模块的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。For the implementation process of the functions and effects of each module in the above device, please refer to the implementation process of the corresponding steps in the above 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.
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现前述的方法。该方法至少包括上述图1所示的方法。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. 1 above.
图6示出了本说明书实施例所提供的一种更为具体的计算设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。FIG. 6 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.
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现前述的方法。该方法至少包括上述图1所示的方法。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. 1 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 make a computer device (which may be a personal computer, a server, or a network device, etc.) 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 (13)
- 一种异步二元共识方法,其特征在于,应用于分布式系统中的任一共识节点,所述分布式系统至少包括N个共识节点,其中N≥3f+1,所述f为大于0的整数,所述方法包括:An asynchronous binary consensus 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, where N≥3f+1, and f is greater than 0 Integer, the methods include:针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值,以及初始辅助值;其中,投票值包括第一投票值以及第二投票值,辅助值包括第一投票值、第二投票值以及空,初始投票值为第一投票值或第二投票值;For the consensus proposal of any consensus node, determine the initial voting value corresponding to the consensus proposal, and the initial auxiliary value; wherein, the voting value includes the first voting value and the second voting value, and the auxiliary value includes the first voting value, The second voting value and empty, the initial voting value is the first voting value or the second voting value;循环执行每轮共识步骤,直到得到针对该待共识提议的共识结果,其中,每轮共识步骤包括:Each round of consensus steps is cyclically executed until the consensus result for the proposal to be consensus is obtained, wherein each round of consensus steps includes:将投票值和辅助值携带在第一类共识消息中进行广播;Carry the voting value and auxiliary value in the first type of consensus message for broadcast;接收其他共识节点广播的第一类共识消息;Receive the first type of consensus messages broadcast by other consensus nodes;基于接收到的第一类共识消息重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播;Re-determine the voting value and auxiliary value based on the received first type of consensus message, and broadcast the re-determined voting value and auxiliary value in the second type of consensus message;在接收到法定数量的第二类共识消息后获得本轮共识的公共抛币值,基于公共抛币值以及接收到的第二类共识消息的情况,确定共识结果或者下一轮共识中第一类共识消息携带的投票值以及辅助值。After receiving the quorum of the second type of consensus messages, the public coin toss value of the current round of consensus is obtained, and based on the public coin toss value and the received second type of consensus messages, the consensus result or the first type of consensus in the next round of consensus is determined The voting value and auxiliary value carried by the message.
- 根据权利要求1所述的方法,其特征在于,在所述基于接收到的第一类共识消息重新确定投票值以及辅助值之前还包括:The method according to claim 1, further comprising:若在当前共识轮接收到f+1个第一类共识消息,且所述f+1个第一类共识消息中的投票值相同、与本地本轮共识通过第一类共识消息广播的投票值不同,则将本地投票值修改为所述f+1个第一类共识消息中的投票值,并再次广播携带投票值以及辅助值的第一类共识消息。If f+1 first-type consensus messages are received in the current consensus round, and the voting value in the f+1 first-type consensus messages is the same as the voting value broadcast by the local consensus in this round through the first-type consensus message If not, modify the local voting value to the voting value in the f+1 first-type consensus messages, and broadcast the first-type consensus message carrying the voting value and auxiliary value again.
- 根据权利要求2所述的方法,其特征在于,所述基于接收到的第一类共识消息重新确定投票值以及辅助值,包括:The method according to claim 2, wherein the re-determining the voting value and the auxiliary value based on the received first type of consensus message includes:在接收到法定数量的第一类共识消息后,在所述法定数量的第一类共识消息所携带的投票值相同的情况下,将该投票值添加到第一集合中;After receiving a quorum of first-type consensus messages, if the quorum of first-type consensus messages carry the same voting value, add the voting value to the first set;若当前共识轮为首轮,则将投票值以及辅助值重新确定为所述第一集合中的投票值。If the current consensus round is the first round, the voting value and the auxiliary value are re-determined as voting values in the first set.
- 根据权利要求3所述的方法,其特征在于,还包括:The method according to claim 3, further comprising:若当前共识轮不为首轮,则将所述第一集合中的投票值与上一轮的公共抛币值进行比较,根据比较结果以及接收到的第一类共识消息重新确定投票值以及辅助值。If the current consensus round is not the first round, the voting value in the first set is compared with the public coin toss value of the previous round, and the voting value and auxiliary value are re-determined according to the comparison result and the first type of consensus message received.
- 根据权利要求4所述的方法,其特征在于,根据比较结果以及接收到的第一类共识消息重新确定投票值以及辅助值,包括:The method according to claim 4, characterized in that, re-determining the voting value and the auxiliary value according to the comparison result and the received first type of consensus message, including:在第一集合中的投票值与上一轮的公共抛币值相等的情况下,若接收过的第一类共识消息中携带的投票值均为该第一集合中的投票值,携带的辅助值均为该第一集合中的投票值或空,则将投票值以及辅助值确定为该第一集合中的投票值;否则,将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In the case where the voting value in the first set is equal to the public coin toss value of the previous round, if the voting values carried in the received first type of consensus messages are all voting values in the first set, the auxiliary value carried are all voting values in the first set or empty, then determine the voting value and auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the first set Voting value in .
- 根据权利要求5所述的方法,其特征在于,还包括:The method according to claim 5, further comprising:在第一集合中的投票值与上一轮的公共抛币值不相等的情况下,若接收过的第一类共识消息中携带 的投票值以及辅助值均为该第一集合中的投票值,则将投票值以及辅助值确定为该第一集合中的投票值;否则,则将投票值确定为空,并且将辅助值确定为该第一集合中的投票值。In the case that the voting value in the first set is not equal to the public coin toss value of the previous round, if the voting value and the auxiliary value carried in the received first type of consensus message are both voting values in the first set, Then determine the voting value and the auxiliary value as the voting value in the first set; otherwise, determine the voting value as empty, and determine the auxiliary value as the voting value in the first set.
- 根据权利要求6所述的方法,其特征在于,所述基于公共抛币值以及接收到的第二类共识消息的情况,确定共识结果或者下一轮共识中第一类共识消息携带的投票值以及辅助值,包括:The method according to claim 6, characterized in that, based on the public coin toss value and the situation of the second type of consensus message received, determine the consensus result or the voting value carried by the first type of consensus message in the next round of consensus and Auxiliary values, including:将接收到的第二类共识消息中的投票值添加到第二集合中,若接收到的第二类共识消息中存在超过法定数量的第二类共识消息是相同的,且所述第二类共识消息中投票值与辅助值相同,则将该第二类共识消息中的投票值与本轮公共抛币值进行比较,如果该投票值与本轮公共抛币值相同,则目标共识节点确定共识结果为该投票值;Add the voting value in the received second type of consensus message to the second set, if there are more than the quorum of the second type of consensus messages received in the second type of consensus message are the same, and the second type of consensus message If the voting value in the consensus message is the same as the auxiliary value, 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 the consensus result for that vote value;若不相同,则将下一轮第一类共识消息中携带的投票值以及辅助值均确定为所述第二类共识消息中的投票值。If they are different, the voting value and the auxiliary value carried in the first type of consensus message in the next round are both determined as the voting value in the second type of consensus message.
- 根据权利要求7所述的方法,其特征在于,还包括:The method according to claim 7, further comprising:若只接收到过合法第二类共识消息,所述第二集合中的投票值为一种投票值和空,并且至少有法定数量条第二类共识消息的辅助值为该种投票值,则将该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值分别进行比较;If only legitimate second-type consensus messages have been received, 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 with auxiliary values of this kind of voting value, then Compare this voting value with the public coin toss value of the previous round of consensus and the public coin toss value of the current round of consensus;若该种投票值与上一轮共识的公共抛币值、本轮共识的公共抛币值均相同,则确定共识结果该为该种投票值;若该种投票值与上一轮共识的公共抛币值和/或本轮共识的抛币值不相同,则将下一轮第一类共识消息中的投票值以及辅助值均设置为该种投票值。If this kind of voting value is the same as the public coin toss value of the previous round of consensus and the public coin toss value of this round of consensus, then it is determined that the consensus result should be this kind of voting value; and/or the coin toss value of the current round of consensus is different, then the voting value and auxiliary value in the first type of consensus message in the next round are set to this kind of voting value.
- 根据权利要求8所述的方法,其特征在于,还包括:The method according to claim 8, further comprising:若接收到了法定数量的合法第二类共识消息,所述法定数量的第二类共识消息携带的辅助值不全相同,所述第二集合中的投票值为一种投票值和空,且该种投票值与上一轮共识的公共抛币值相同,则将下一轮共识中第一类共识消息中的投票值以及辅助值均设置为该种投票值。If a quorum of legitimate second-type consensus messages is received, the auxiliary values carried by the quorum of second-type consensus messages are not all the same, the voting value in the second set is a voting value and empty, and the If the voting value is the same as the public coin toss value of the previous round of consensus, the voting value and auxiliary value in the first type of consensus message in the next round of consensus will be set as this kind of voting value.
- 根据权利要求9所述的方法,其特征在于,还包括:The method according to claim 9, further comprising:若接收到的第二共识消息中包括两种投票值;或者,目标节点接收到的法定数量的合法第二类共识消息携带的辅助值不相同,第二集合中的投票值为一种投票值和空,且该种投票值与上一轮公共抛币值不相同;则将本轮共识的公共抛币值作为下一轮第一类共识消息的投票值;若本轮共识为首轮,则将下一轮的第一类共识消息中的辅助值设置为本轮公共抛币值;若本轮共识不为首轮,则将下一轮的第一共消息中的辅助值确定为第二集合中的出现次数超过预设次数的值。If the received second consensus message includes two voting values; or, the quorum of legal second consensus messages received by the target node carry different auxiliary values, the voting value in the second set is a voting value and empty, and this type of voting value is different from the previous round of public coin toss; the public coin toss value of this round of consensus will be used as the voting value of the next round of the first type of consensus message; if the current round of consensus is the first round, the next round of consensus will be The auxiliary value in the first type of consensus message of a round is set as the public coin toss value of this round; if the current round of consensus is not the first round, the auxiliary value in the first consensus message of the next round is determined as the occurrence in the second set The number of times exceeds the value of the preset number of times.
- 一种异步二元共识装置,其特征在于,所述装置应用于分布式系统中的任一共识节点中,所述分布式系统至少包括N个共识节点,其中N≥3f+1,所述f为大于0的整数,所述装置包括:An asynchronous binary consensus device, characterized in that the device is applied to any consensus node in a distributed system, and the distributed system includes at least N consensus nodes, where N≥3f+1, and the f is an integer greater than 0, and the device includes:处理模块,用于针对任一共识节点的待共识提议,确定对应于该待共识提议的初始投票值,以及初始辅助值;其中,投票值包括第一投票值以及第二投票值,辅助值包括第一投票值、第二投票值以及空,初始投票值为第一投票值或第二投票值;循环执行执行每轮共识步骤,直到得到针对该待共识提议的共识结果;The processing module is used to determine the initial voting value corresponding to the consensus proposal for any consensus node, and the initial auxiliary value; wherein, the voting value includes the first voting value and the second voting value, and the auxiliary value includes The first voting value, the second voting value and empty, the initial voting value is the first voting value or the second voting value; execute each round of consensus steps in a loop until the consensus result for the proposal to be consensus is obtained;在每轮共识中:In each round of consensus:通信模块,将投票值和辅助值携带在第一类共识消息中进行广播;接收其他共识节点广播的第一类 共识消息;基于接收到的第一类共识消息重新确定投票值以及辅助值,并将重新确定的投票值以及辅助值携带在第二类共识消息中进行广播;The communication module broadcasts the voting value and auxiliary value in the first type of consensus message; receives the first type of consensus message broadcast by other consensus nodes; re-determines the voting value and auxiliary value based on the received first type of consensus message, and Carry the re-determined voting value and auxiliary value in the second type of consensus message for broadcast;所述处理模块,还用于在接收到法定数量的第二类共识消息后获得本轮共识的公共抛币值,基于公共抛币值以及接收到的第二类共识消息的情况,确定共识结果或者下一轮共识中第一类共识消息携带的投票值以及辅助值。The processing module is also used to obtain the public coin toss value of the current round of consensus after receiving the quorum of the second type of consensus message, and determine the consensus result or the next The voting value and auxiliary value carried by the first type of consensus message in a round of consensus.
- 一种计算机设备,包括存储器、处理器、通信接口及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求1至10任一项所述的方法。A computer device, comprising a memory, a processor, a communication interface, and a computer program stored on the memory and operable on the processor, wherein the processor implements any one of claims 1 to 10 when executing the program the method described.
- 一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如权利要求1至10任一项所述的方法。A computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method according to any one of claims 1 to 10 is realized.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110925730.2A CN113810465B (en) | 2021-08-12 | 2021-08-12 | Asynchronous binary consensus method and device |
CN202110925730.2 | 2021-08-12 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023016426A1 true WO2023016426A1 (en) | 2023-02-16 |
Family
ID=78893499
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/110993 WO2023016426A1 (en) | 2021-08-12 | 2022-08-09 | Asynchronous binary agreement method and apparatus, and electronic device and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113810465B (en) |
WO (1) | WO2023016426A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116846916A (en) * | 2023-09-01 | 2023-10-03 | 武汉趣链数字科技有限公司 | Data synchronization method, device, electronic equipment and computer readable storage medium |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113810465B (en) * | 2021-08-12 | 2022-08-12 | 清华大学 | Asynchronous binary consensus method and device |
CN115396432B (en) * | 2022-07-29 | 2023-08-01 | 北京理工大学 | Binary negotiation method and device, electronic equipment and storage medium |
CN116389507B (en) * | 2023-06-06 | 2023-08-04 | 中铱数字科技有限公司 | Management consensus strategy system based on block chain |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010039630A1 (en) * | 2000-01-14 | 2001-11-08 | Klaus Kursawe | Method of achieving multiple processor agreement in asynchronous networks |
CN109246122A (en) * | 2018-09-29 | 2019-01-18 | 上海海事大学 | A kind of Byzantine failure tolerance block chain generation method based on gossip propagation agreement |
CN111522800A (en) * | 2020-07-03 | 2020-08-11 | 支付宝(杭州)信息技术有限公司 | Block chain consensus method, node and system of badger Byzantine fault-tolerant consensus mechanism |
CN113810465A (en) * | 2021-08-12 | 2021-12-17 | 清华大学 | Asynchronous binary consensus method and device |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
SG10201911700PA (en) * | 2015-08-28 | 2020-02-27 | Swirlds Inc | Methods and apparatus for a distributed database within a network |
AU2018300147B2 (en) * | 2017-07-11 | 2020-07-16 | Hedera Hashgraph, Llc | Methods and apparatus for efficiently implementing a distributed database within a network |
CN110569395B (en) * | 2018-05-18 | 2024-07-23 | 北京天德科技有限公司 | Stable and reliable block chain Bayesian-busy consensus flow design method |
-
2021
- 2021-08-12 CN CN202110925730.2A patent/CN113810465B/en active Active
-
2022
- 2022-08-09 WO PCT/CN2022/110993 patent/WO2023016426A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010039630A1 (en) * | 2000-01-14 | 2001-11-08 | Klaus Kursawe | Method of achieving multiple processor agreement in asynchronous networks |
CN109246122A (en) * | 2018-09-29 | 2019-01-18 | 上海海事大学 | A kind of Byzantine failure tolerance block chain generation method based on gossip propagation agreement |
CN111522800A (en) * | 2020-07-03 | 2020-08-11 | 支付宝(杭州)信息技术有限公司 | Block chain consensus method, node and system of badger Byzantine fault-tolerant consensus mechanism |
CN113810465A (en) * | 2021-08-12 | 2021-12-17 | 清华大学 | Asynchronous binary consensus method and device |
Non-Patent Citations (1)
Title |
---|
LIU CHAO; DUAN SISI; ZHANG HAIBIN: "EPIC: Efficient Asynchronous BFT with Adaptive Security", 2020 50TH ANNUAL IEEE/IFIP INTERNATIONAL CONFERENCE ON DEPENDABLE SYSTEMS AND NETWORKS (DSN), IEEE, 29 June 2020 (2020-06-29), pages 437 - 451, XP033800663, DOI: 10.1109/DSN48063.2020.00058 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116846916A (en) * | 2023-09-01 | 2023-10-03 | 武汉趣链数字科技有限公司 | Data synchronization method, device, electronic equipment and computer readable storage medium |
CN116846916B (en) * | 2023-09-01 | 2023-12-08 | 武汉趣链数字科技有限公司 | Data synchronization method, device, electronic equipment and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113810465A (en) | 2021-12-17 |
CN113810465B (en) | 2022-08-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2023016426A1 (en) | Asynchronous binary agreement method and apparatus, and electronic device and storage medium | |
WO2023016428A1 (en) | Byzantine fault tolerance method and apparatus, and electronic device and storage medium | |
CN110915164B (en) | Processing blockchain data based on smart contract operations performed in trusted execution environments | |
US11451400B2 (en) | Blockchain transaction method and apparatus | |
EP3559891B1 (en) | Executing multi-party transactions using smart contracts | |
CN110945550B (en) | Processing and storing blockchain data in a trusted execution environment | |
US20210314167A1 (en) | Methods and systems for consensus in blockchains | |
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 | |
WO2023045620A1 (en) | Transaction data processing method and apparatus, computer device and storage medium | |
CN109687953B (en) | Transaction classification method, apparatus and storage medium | |
CN113055188B (en) | Data processing method, device, equipment and storage medium | |
CN112907369B (en) | Block chain-based data consensus method and device, electronic equipment and storage medium | |
US20230097738A1 (en) | Data processing method and apparatus, device, and storage medium | |
CN112150141A (en) | Block chain consensus method, device and system | |
EP3934164A1 (en) | Consensus methods and systems in consortium blockchain | |
WO2023016429A1 (en) | Binary consensus method and apparatus capable of revoting, electronic device, and storage medium | |
WO2023185051A1 (en) | Method for generating random number seeds on blockchain, and system and consensus node | |
CN112069169B (en) | Block data storage method and device, electronic equipment and readable storage medium | |
CN114726517A (en) | Method, system and consensus node for generating random number seeds on block chain | |
CN111327680B (en) | Authentication data synchronization method, device, system, computer equipment and storage medium | |
CN113824755A (en) | Method, system and related device for processing block chain data | |
WO2020174375A1 (en) | Integer conversion for locally stored data in priority queues | |
CN113783946B (en) | Re-voted binary consensus method and device based on threshold signature | |
CN113779155B (en) | Block chain transaction processing method, device and equipment |
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: 22855407 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: 22855407 Country of ref document: EP Kind code of ref document: A1 |