A consensus method, consensus node and electronic device for blockchain
By employing an erasure code-based RBC protocol to distribute transaction data blocks and utilizing Merkle tree proofs within a fault-tolerant RAFT protocol, the method addresses the bandwidth bottleneck in blockchain consensus, improving efficiency and throughput.
Patent Information
- Application Number
- CN202111124497.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-24
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-09-24
AI Technical Summary
The existing RAFT consensus protocol in blockchain systems results in high network bandwidth overhead for the leader node due to the need to send multiple copies of proposal data, which becomes a bottleneck as blockchain throughput requirements increase.
Implementing an erasure code-based reliable broadcast transmission (RBC) protocol to split transaction sets into data blocks and distribute them among follower nodes, followed by a replication and fault-tolerant RAFT protocol using Merkle tree proofs to reduce bandwidth consumption and improve consensus efficiency.
The proposed method reduces network bandwidth and storage overhead on the leader node while maintaining consensus efficiency by distributing data blocks and using smaller Merkle tree proofs for consensus, thereby enhancing the system's ability to handle increased throughput.
Smart Images

Figure CN113873030B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of data processing technology, and in particular to a blockchain consensus method, consensus node and electronic device. Background Art
[0002] Based on the characteristics of blockchain, in the replication and fault-tolerant RAFT consensus protocol, the proposal data of each round of consensus proposal is packaged by the leader node and synchronously transmitted to each follower node of the blockchain. Assuming that the number of consensus nodes in the blockchain is N (both the leader node and the follower node are consensus nodes), for one round of consensus proposal, the leader node needs to send N-1 copies of proposal data, which generates a huge overhead for the network bandwidth of the leader node.
[0003] With the explosive growth of blockchain business in the future, to achieve higher throughput, it is necessary to reach consensus on more data per unit time, which will put a greater burden on the leader node and lead to a decrease in consensus efficiency. Therefore, there is an urgent need for a technical solution that can reduce the bandwidth consumed by the leader node to initiate a consensus proposal. Summary of the invention
[0004] The purpose of the embodiments of this specification is to provide a blockchain consensus method, consensus node and electronic device, which can complete the blockchain consensus with a smaller bandwidth overhead on the leader node side.
[0005] In order to achieve the above purpose, the embodiments of this specification are implemented as follows:
[0006] First, a blockchain consensus method is provided, including:
[0007] The leader node of the blockchain executes a reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using an erasure code algorithm, and sends the corresponding data blocks to each follower node of the blockchain based on an Rval message, wherein the data blocks into which the first transaction set is split correspond to the Merkle tree proof calculated based on the erasure code algorithm, and N is the number of consensus nodes of the blockchain;
[0008] The follower node executes the RBC protocol to forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks into the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain;
[0009] After executing the RBC protocol on the first transaction set, the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set;
[0010] The follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proof for all data blocks of the first transaction set;
[0011] After the Merkle tree proofs of all data blocks of the first transaction set reach consensus, the leader node and the follower node match the transactions corresponding to the Merkle tree proofs that have reached consensus from their respective first transaction sets to perform block write operations on the matched transactions.
[0012] Second, a blockchain consensus method is provided, including:
[0013] The leader node executes the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and sends the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and broadcasts the Ready message to the blockchain after receiving Nf Echo messages, and after receiving 2f+1 Ready messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
[0014] After executing the RBC protocol on the first transaction set, the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower nodes respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proofs of all data blocks of the first transaction set;
[0015] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the leader node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the first transaction set to perform a write block operation on the matched transactions.
[0016] Thirdly, a blockchain consensus method is provided, including:
[0017] The follower node of the blockchain receives the data block corresponding to the follower node sent by the leader node of the blockchain when executing the RBC protocol, wherein the data block corresponding to the follower node is the data block sent to the follower node based on the Rval message by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus node of the blockchain;
[0018] The follower node executes the RBC protocol, forwards the corresponding data block received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data block into the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain;
[0019] After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set;
[0020] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the follower node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set to perform a write block operation on the matched transactions.
[0021] Fourthly, a consensus node of a blockchain is provided, including:
[0022] A first RBC execution module, in which the leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using an erasure code algorithm, and sends corresponding data blocks to each follower node of the blockchain based on an Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through an Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to Merkle tree proofs calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of consensus nodes of the blockchain;
[0023] A first RAFT execution module, wherein the leader node executes a replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set after executing the RBC protocol on the first transaction set, so as to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower nodes respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proofs of all data blocks of the first transaction set;
[0024] The first block writing module, after the Merkle tree proofs of all data blocks of the first transaction set have reached consensus, the leader node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the first transaction set to perform block writing operations on the matched transactions.
[0025] In a fifth aspect, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor:
[0026] Execute the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and send the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
[0027] After executing the RBC protocol on the first transaction set, executing the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proofs of all data blocks of the first transaction set;
[0028] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the first transaction set to perform a block write operation on the matched transactions.
[0029] In a sixth aspect, a computer readable storage medium is provided, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
[0030] Execute the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and send the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
[0031] After executing the RBC protocol on the first transaction set, executing the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proofs of all data blocks of the first transaction set;
[0032] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the first transaction set to perform block write operations on the matched transactions.
[0033] In a seventh aspect, a consensus node of a blockchain is provided, including:
[0034] A receiving module receives a data block corresponding to a follower node sent by the leader node of the blockchain when executing the RBC protocol, wherein the data block corresponding to the follower node is the data block sent to the follower node by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using an erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus node of the blockchain, and sending the data block to the follower node based on an Rval message;
[0035] The second RBC execution module executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and restores the received data blocks into the first transaction set based on the erasure code algorithm after receiving N-2f Echo messages, where f is the consensus node fault tolerance number of the blockchain;
[0036] A second RAFT execution module, after the leader node executes a replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, responds to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set;
[0037] The second block writing module, after the Merkle tree proofs of all data blocks of the first transaction set have completed consensus, the follower node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set to perform block writing operations on the matched transactions.
[0038] In an eighth aspect, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor:
[0039] Receive the data blocks corresponding to the follower nodes sent by the leader node of the blockchain when executing the RBC protocol, wherein the data blocks corresponding to the follower nodes are the data blocks sent to the follower nodes by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and sending them to the follower nodes based on the Rval message;
[0040] Execute the RBC protocol, forward the corresponding data blocks received from the Rval message to other follower nodes through Echo messages, broadcast Ready messages to the blockchain after receiving Nf Echo messages, and restore the received data blocks to the first transaction set based on the erasure code algorithm after receiving 2f+1 Ready messages, where f is the consensus node fault tolerance number of the blockchain;
[0041] After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, respond to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set;
[0042] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the restored first transaction set to perform a block write operation on the matched transactions.
[0043] In a ninth aspect, a computer readable storage medium is provided, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
[0044] Receive the data blocks corresponding to the follower nodes sent by the leader node of the blockchain when executing the RBC protocol, wherein the data blocks corresponding to the follower nodes are the data blocks sent to the follower nodes by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and sending them to the follower nodes based on the Rval message;
[0045] Execute the RBC protocol, forward the corresponding data blocks received from the Rval message to other follower nodes through Echo messages, broadcast Ready messages to the blockchain after receiving Nf Echo messages, and restore the received data blocks to the first transaction set based on the erasure code algorithm after receiving 2f+1 Ready messages, where f is the consensus node fault tolerance number of the blockchain;
[0046] After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, respond to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set;
[0047] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the restored first transaction set to perform a block write operation on the matched transactions.
[0048] The scheme of the embodiments of this specification realizes consensus through the RBC protocol and the RAFT protocol. In the RBC protocol stage, the leader node uses the erasure code transmission mechanism of the RBC protocol to split the transaction set as the proposed data into data blocks corresponding to the follower nodes, and sends the split data blocks to the corresponding follower nodes, which are then forwarded by the follower nodes to each other, thereby amortizing the transmission of the proposed data, and achieving transmission fault tolerance with a smaller network bandwidth and storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal with the Merkle tree proof of the data block of the RBC protocol result as the consensus object, thereby matching the consensus Merkle tree proof back to the corresponding transaction to complete the write block operation. Since the amount of data in the Merkle tree proof is relatively small, the execution time of the RAFT protocol can be effectively reduced, thereby improving the consensus efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0050] Figure 1 A flowchart of a consensus method for a blockchain provided in an embodiment of this specification.
[0051] Figure 2 A schematic diagram of the first structure of a consensus node provided in an embodiment of this specification.
[0052] Figure 3 A second structural diagram of a consensus node provided in an embodiment of this specification.
[0053] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0054] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0055] As mentioned above, in the existing RAFT protocol consensus, the proposal data of each round of consensus proposals is packaged by the leader node and synchronously transmitted to each follower node of the blockchain. Assuming that the number of consensus nodes in the blockchain is N, for one round of consensus proposals, the leader node needs to send N-1 copies of proposal data, which creates a huge overhead for the network bandwidth of the leader node. With the explosive growth of blockchain business in the future, in order to achieve higher throughput, it is necessary to reach a consensus on more data per unit time, which is more burdensome for the leader node, resulting in a decrease in consensus efficiency. In view of this, this document aims to propose a technical solution that can achieve blockchain consensus with a smaller leader node bandwidth overhead to meet the needs of future blockchain business growth.
[0056] Figure 1 It is a flow chart of the consensus method of the blockchain embodiment of this specification. Figure 1 The method shown can be performed by the corresponding device below, including the following steps:
[0057] S102, the leader node of the blockchain executes the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain by using the erasure code algorithm, and sends the corresponding data blocks to each follower node of the blockchain based on the Rval message, wherein the data blocks into which the first transaction set is split correspond to the Merkle tree proof calculated based on the erasure code algorithm, and N is the number of consensus nodes of the blockchain.
[0058] Erasure coding (EC) is a method of data fault tolerance protection that divides data into fragments, expands and encodes redundant data blocks, and stores them in different locations, such as disks, storage nodes, or other geographical locations. From a data function perspective, the protection provided by erasure coding can be expressed as follows: x = k + y. The variable x" represents the value of the original data or symbol. The variable "y" represents the value of the additional or redundant symbols added to provide protection after the failure. The variable "x" represents the total value of the symbols created after the erasure coding process. For example, in an EC 10 / 16 configuration, 6 additional symbols (variable m) are added to the 10 original symbols (variable k). These 16 data fragments (variable n) can be spread across 16 drives, nodes, or geographical locations, and the original file can be reconstructed from the 10 verified fragments. In other words, even if 6 drives, nodes, or geographical locations are lost or unavailable, the original file can still be recovered. It can be seen that erasure coding only requires a small amount of redundancy to achieve data recovery.
[0059] In the embodiment of this specification, the leader node executes the RBC protocol in order to use the erasure coding technology to synchronize the first transaction set (subsequently used as proposal data) that needs consensus in its own transaction pool to the follower nodes summarized by the blockchain. Based on the erasure coding technology, after the leader node splits the transaction set in its own transaction pool into data blocks corresponding to each consensus node, it only needs to send the data block corresponding to the follower node itself to each follower node. In other words, during this synchronization process, the amount of data sent by the leader node is only the amount of data of the first transaction set.
[0060] S104, the follower node executes the RBC protocol to forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks into the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain.
[0061] It should be understood that the leader node of the embodiment of this specification only provides the data block corresponding to the follower node to the follower node through the Rval message when executing the RBC protocol. In order for the follower node to obtain the complete first transaction set, in this step, each follower node of the blockchain also needs to forward the corresponding data block to other follower nodes through the Echo message of the RBC protocol. When any follower node receives N-2f Echo messages (indicating that the data blocks sufficient to restore the first transaction set based on the erasure code algorithm have been collected), it attempts to restore the first intersection to achieve data synchronization of the first intersection.
[0062] It can be seen that in the process of transmitting the first transaction set based on the RBC protocol using the erasure coding algorithm, the follower node also consumes network bandwidth to assist the leader node in forwarding its corresponding data blocks, thereby sharing the transmission pressure on the leader node side.
[0063] S106, after executing the RBC protocol on the first transaction set, the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set.
[0064] It should be understood that the consensus proposal of the Merkle tree proof of all data blocks of the first transaction set is generated by the leader node executing the RBC protocol and is the result of the execution of the RBC protocol. The Merkle tree proof specifically refers to the root hash value of the Merkle tree, and the data block can be represented by a Merkle tree proof with a smaller amount of data. That is, in this step, when the leader node executes the RAFT protocol on the Merkle tree proof of all data blocks of the first transaction set, the amount of data transmitted by the RAFT protocol can be saved.
[0065] S108, the follower node responds to the above consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proof for all data blocks of the first transaction set.
[0066] It should be understood that in the embodiments of this specification, the consensus object of the RAFT protocol is replaced by Merkle tree proof from traditional transaction set data, but the consensus principle has not changed, so the traditional RAFT protocol logic can be used to complete the consensus.
[0067] S110, after the Merkle tree proofs of all data blocks in the first transaction set have reached consensus, the leader node and the follower node match the transactions corresponding to the Merkle tree proofs that have reached consensus from their respective first transaction sets to perform block write operations on the matched transactions.
[0068] Compared with the traditional RAFT protocol, since the consensus object is replaced by the Merkle tree proof from the transaction set data, the result of the RAFT protocol determines the Merkle tree proof of consensus. The leader node and the follower node need to match the corresponding transactions from their respective determined transaction sets, and then perform the write block operation on the matched transactions (also understood as the consensus transactions).
[0069] It should be understood here that the first transaction set on the follower node side is synchronized by the leader node executing the RBC protocol, while the first transaction set on the leader node side itself comes from the transaction pool of the target consensus node.
[0070] The method of the embodiment of this specification realizes consensus through the RBC protocol and the RAFT protocol. In the RBC protocol stage, the leader node uses the erasure code transmission mechanism of the RBC protocol to split the transaction set as the proposed data into data blocks corresponding to the follower nodes, and sends the split data blocks to the corresponding follower nodes, which are then forwarded by the follower nodes to each other, thereby amortizing the transmission of the proposed data, and achieving transmission fault tolerance with a smaller network bandwidth and storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal with the Merkle tree proof of the data block of the RBC protocol result as the consensus object, thereby matching the consensus Merkle tree proof back to the corresponding transaction to complete the write block operation. Since the amount of data in the Merkle tree proof is relatively small, the execution time of the RAFT protocol can be effectively reduced, thereby improving the consensus efficiency.
[0071] The consensus method of the embodiment of this specification is introduced in detail below.
[0072] In the method of the embodiment of this specification, the consensus node of the blockchain realizes the consensus on-chain of transactions based on the RBC protocol + RAFT protocol. Here, the number of consensus nodes of the blockchain is set to N, and the number of Byzantine consensus node fault tolerance is f, N>=3f+1.
[0073] The RAFT protocol divides consensus nodes into three types: Leader, Follower, and Candidate:
[0074] Leader: responsible for log synchronization management, processing requests from clients, and maintaining heartbeat contact with followers;
[0075] Follower: When it is first started, all consensus nodes are in the Follower state; they respond to the Leader's log synchronization request; they respond to the Candidate's request and forward the transaction requested to the Follower to the Leader;
[0076] Candidate: Responsible for election voting. When RAFT is first started, a node switches from Follower to Candidate to initiate an election. After the Leader is elected, the node switches from Candidate to Leader state.
[0077] In addition, the RAFT protocol divides time into terms of arbitrary lengths. Terms are represented by consecutive numbers. Each term begins with an election, where one or more candidates attempt to become the leader. If a candidate wins the election, it will serve as the leader for the remainder of the term.
[0078] The corresponding consensus process is as follows:
[0079] RBC Protocol Phases:
[0080] The leader node selects several transactions to be agreed upon from the leader node's transaction pool to form the first transaction set.
[0081] The leader node uses the erasure coding algorithm to split the first transaction set into N ordered data blocks corresponding to the consensus nodes of the blockchain in a one-to-one manner according to the consensus order. Here, each data block contains at least one transaction in the first transaction set and corresponds to the Merkle tree proof (root hash) calculated by the erasure coding algorithm.
[0082] For ease of understanding, assume that the blockchain is set with 6 consensus nodes including the leader node (the rest are follower nodes), and there are 20 transactions in the first transaction set, namely tx1 to tx20, then the first transaction set can be split into 6 data blocks, namely root hash 1 to root hash 6. Correspondingly, the correspondence between the Merkle tree proof and the transaction is as follows:
[0083] root hash 1: {tx1, tx2, tx3, tx4}
[0084] root hash 2:{tx5,tx6,tx7}
[0085] root hash 3: {tx8, tx9, tx10}
[0086] root hash 4: {tx11, tx12, tx13}
[0087] root hsh 5:{tx14, tx15, tx16}
[0088] root hash 6: {tx17, tx18, tx19, tx20}
[0089] Afterwards, the leader node sends the corresponding data block to each follower node of the blockchain through the Rval message.
[0090] Here, consensus node 1 is taken as the leader node. If consensus node 2 corresponds to a data block with a Merkle tree proof of roothash 2, then the Rval message sent by consensus node 1 to consensus node 2 carries the Merkle tree proof of roothash 2; similarly, consensus node 3 corresponds to a data block with a Merkle tree proof of root hash 3, then the Rval message sent by consensus node 1 to consensus node 3 carries the Merkle tree proof of root hash 3; ...consensus node 6 corresponds to a data block with a Merkle tree proof of root hash 6, then the Rval message sent by consensus node 1 to consensus node 6 carries the Merkle tree proof of root hash 6.
[0091] Afterwards, after receiving the Rval message from the leader node, the follower node forwards the Merkle tree proof in the Rval message to other follower nodes through the Echo message.
[0092] For example, consensus node 2 sends an Echo message carrying root hash 2 to consensus nodes 1, 3, 4, 5, and 6; consensus node 3 sends an Echo message carrying root hash 3 to consensus nodes 1, 2, 4, 5, and 6, and so on; consensus node 6 sends an Echo message carrying root hash 6 to consensus nodes 1, 2, 3, 4, and 5.
[0093] After receiving N-2f Echo messages, any follower node attempts to use the erasure code algorithm to restore the received data blocks (data blocks in the Rval message sent by the leader node and data blocks in the Echo message sent by other follower nodes) back to the first transaction set, and reconstruct the Merkle tree of the first transaction set to verify whether the reconstructed Merkle tree is consistent with the received Merkle tree proof. If consistent, the Ready message is broadcast to the blockchain.
[0094] In addition, based on the above, if the data blocks obtained by any follower node from the Echo message and the Rval message are not sufficient to restore the first transaction set, it can also obtain the data blocks in the Rval messages received by other follower nodes from other follower nodes to try to restore the first transaction set.
[0095] Afterwards, for each consensus node, when it receives f+1 identical Ready messages from different nodes, it determines whether it has broadcast the Ready message. If not, it broadcasts the Ready message. When it receives 2f+1 Ready messages from different consensus nodes, it means that the correct first transaction set has been received, that is, the leader node correctly synchronizes the first transaction set in its own transaction pool to the follower node.
[0096] Here, the leader node maintains a consensus execution queue locally to store the Merkle tree proofs to be agreed upon. After the leader node splits the first transaction set into N data blocks, it adds the N data blocks into which the first transaction set is split to the consensus execution queue of the leader node in order.
[0097] After the RBC protocol phase ends, the leader node selects Merkle tree proofs from the consensus execution queue in order as consensus objects to initiate a consensus proposal for the RAFT protocol. It should be understood that if the Merkle tree proofs in the consensus execution queue exceed the maximum number of Merkle tree proofs supported by one consensus proposal, the leader node may choose to initiate at least two rounds of consensus proposals to reach consensus on the Merkle tree proofs in the consensus execution queue.
[0098] RAFT protocol phase:
[0099] First, the leader node uses the Merkle tree proofs of each data block in the first transaction set as proposal data and initiates a consensus proposal. The consensus process includes:
[0100] The leader node distributes the Merkle tree proof of each data block of the first transaction set in the form of a log and tries to copy it to the follower node for storage. In addition, the log also contains the command, the corresponding Terms epoch number and the index of the log. The additional information in the log helps the followers determine the legitimacy of the log and the subsequent data synchronization security logic.
[0101] The fact that the log is copied to the follower node does not mean that the commands contained in the log are effective. The copied log still needs to go through a confirmation and commit process. When the Leader confirms that the log has been successfully copied by the majority of consensus nodes, the instructions contained in the log can be formally submitted and take effect.
[0102] When the leader node believes that data reliability is guaranteed (provided that replication is completed on more than half of the nodes), the leader notifies other consensus nodes (including itself) to submit this instruction in their respective state machines (i.e. execute it in the state machine). As long as the state machine conversion logic of each consensus node is consistent and the executed instructions are consistent (including the order), the state consistency between all RAFT nodes can be guaranteed, thereby achieving consensus.
[0103] After all the Merkle tree proofs in the consensus execution queue of the leader node have reached consensus, the leader node and the follower node match the transactions corresponding to the Merkle tree proofs that have reached consensus from their respective first transaction sets to perform block write operations on the matched transactions.
[0104] For ease of understanding, assuming that the Merkle tree proofs of root hash 1 and root hash 5 reach a consensus, the leader node and the follower node perform write block operations on the transactions {tx1, tx2, tx3, tx4} corresponding to root hash 1 and the transactions {tx14, tx15, tx16} corresponding to root hsh 5, that is, the transactions {tx1, tx2, tx3, tx4 tx14, tx15, tx16} are completed on the chain.
[0105] The above is an introduction to a round of RBC protocol + RAFT protocol. It should be understood that when the Merkle tree proofs of all data blocks of the first transaction set have reached consensus, if the blockchain has not changed the term of the RAFT protocol (that is, the leader node has not been changed), the leader node can continue to execute a new round of RBC protocol for the second transaction set in the leader node's transaction pool (the second transaction set is the transaction set in the leader node's transaction pool that has not yet been executed by the leader node for the RBC protocol), and subsequently initiate a consensus proposal for the RAFT protocol for the Merkle tree proofs of each data block split from the second transaction set to complete the on-chain of the second transaction set.
[0106] In addition, based on the above, the leader node can persist the data of the consensus execution queue local to the leader node. If the leader node goes down, the consensus execution queue of the leader node can be restored to the state before the restart based on the persistent data of the leader node after restart.
[0107] The above is an introduction to the method of the embodiment of this specification. It should be understood that appropriate changes can be made without departing from the above principles, and these changes should also be regarded as the protection scope of the embodiment of this specification.
[0108] With the above Figure 1 Corresponding to the consensus method shown, the embodiment of this specification also provides a consensus node of a blockchain.
[0109] Figure 2 It is a structural diagram of the consensus node 200 of the embodiment of this specification, including:
[0110] The first RBC execution module 210, the leader node executes the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and sends the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
[0111] A first RAFT execution module 220, wherein the leader node executes a replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set after executing the RBC protocol on the first transaction set, so as to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower nodes respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proofs of all data blocks of the first transaction set;
[0112] The first block writing module 230, after the Merkle tree proofs of all data blocks in the first transaction set have reached consensus, the leader node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the first transaction set to perform block writing operations on the matched transactions.
[0113] The consensus nodes of the embodiments of this specification achieve consensus through the RBC protocol and the RAFT protocol. In the RBC protocol stage, the erasure code transmission mechanism of the RBC protocol is used to split the transaction set as the proposed data into data blocks corresponding to the follower nodes, and the split data blocks are sent to the corresponding follower nodes, and then forwarded by the follower nodes to each other, thereby amortizing the transmission of the proposed data, and achieving transmission fault tolerance with a smaller network bandwidth and storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal with the Merkle tree proof of the data block of the RBC protocol result as the consensus object, thereby matching the consensus Merkle tree proof back to the corresponding transaction to complete the write block operation. Since the amount of data in the Merkle tree proof is relatively small, the execution time of the RAFT protocol can be effectively reduced, thereby improving the consensus efficiency.
[0114] Optionally, the consensus node of the embodiment of this specification also includes:
[0115] The queue maintenance module, after the first RBC execution module 210 uses the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, adds the N data blocks split into the first transaction set in sequence to the consensus execution queue of the leader node; correspondingly, the first RAFT execution module 220 can select the Merkle tree proofs of the data blocks of the first transaction set in sequence from the consensus execution queue to initiate at least one round of consensus proposals until the Merkle tree proofs of all data blocks of the first transaction set complete consensus.
[0116] Optionally, the first RBC execution module 210 and the first RAFT execution module 220 are in a serial relationship.
[0117] After the Merkle tree proofs of all data blocks of the first transaction set have reached consensus, if the blockchain has not changed the term of the RAFT protocol, the first RBC execution module 210 executes a new round of RBC protocol on the second transaction set in the transaction pool of the leader node, wherein the second transaction set refers to the transaction set in the transaction pool of the leader node that has not yet been executed by the leader node through the RBC protocol.
[0118] Optionally, the consensus execution queue of the leader node is used as the persistent data of the leader node. If the leader node is restarted, the queue maintenance module can also restore the consensus execution queue of the leader node to the state before the restart based on the persistent data of the leader node.
[0119] Optionally, when the leader node executes the RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set, the leader node sends the Merkle tree proof as the object of this round of consensus to other consensus nodes based on the Pre-prepare message of the RAFT protocol.
[0120] Obviously, the consensus node in the embodiment of this specification can be used as the above Figure 1 The execution subject of the leader node in the method shown can realize the leader node in Figure 1 The corresponding functions in the method shown in the figure are not described in detail in this article because the principles are the same.
[0121] With the above Figure 1 Corresponding to the consensus method shown, the embodiment of this specification also provides a consensus node of a blockchain. Figure 3 It is a structural diagram of the consensus node 300 of the embodiment of this specification, including:
[0122] The receiving module 310 receives the data blocks corresponding to the follower nodes sent by the leader node of the blockchain when executing the RBC protocol, wherein the data blocks corresponding to the follower nodes are the data blocks sent to the follower nodes by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and sending the data blocks to the follower nodes based on the Rval message;
[0123] The second RBC execution module 320 executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and restores the received data blocks into the first transaction set based on the erasure code algorithm after receiving N-2f Echo messages, where f is the consensus node fault tolerance number of the blockchain;
[0124] A second RAFT execution module 330, after the leader node executes a replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, responds to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set;
[0125] The second block writing module 340, after the Merkle tree proofs of all data blocks of the first transaction set have reached consensus, the follower node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set to perform block writing operations on the matched transactions.
[0126] The consensus nodes of the embodiments of this specification achieve consensus through the RBC protocol and the RAFT protocol. In the RBC protocol stage, the leader node uses the erasure code transmission mechanism of the RBC protocol to split the transaction set as the proposed data into data blocks corresponding to the follower nodes, and sends the split data blocks to the corresponding follower nodes, which are then forwarded by the follower nodes to each other, thereby amortizing the transmission of the proposed data, and achieving transmission fault tolerance with a smaller network bandwidth and storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal with the Merkle tree proof of the data block of the RBC protocol result as the consensus object, thereby matching the consensus Merkle tree proof back to the corresponding transaction to complete the write block operation. Since the amount of data in the Merkle tree proof is relatively small, the execution time of the RAFT protocol can be effectively reduced, thereby improving the consensus efficiency.
[0127] Obviously, the consensus node in the embodiment of this specification can be used as the above Figure 1 The execution subject of the follower node in the method shown in FIG. Figure 1 The corresponding functions in the method shown are not described in detail in this article because the principles are the same.
[0128] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 4 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0129] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0130] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0131] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a consensus device of the blockchain at the logical level. The consensus device can be used as a leader node of the blockchain or a component in the consensus master node. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0132] Execute the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and send the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
[0133] After executing the RBC protocol on the first transaction set, executing the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proofs of all data blocks of the first transaction set;
[0134] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the first transaction set to perform a block write operation on the matched transactions.
[0135] Alternatively, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a consensus device of the blockchain at the logical level. The consensus device can be used as a follower node of the blockchain or a component in the consensus backup node. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0136] Receive data blocks corresponding to follower nodes sent by the leader node of the blockchain when executing the RBC protocol, wherein the data blocks corresponding to the follower nodes are the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to use the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and send them to the follower nodes based on the Rval message.
[0137] Execute the RBC protocol, forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, broadcast the Ready message to the blockchain after receiving Nf Echo messages, and after receiving 2f+1 Ready messages, restore the received data blocks to the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain.
[0138] After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proof of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proof of all data blocks of the first transaction set, respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proof of all data blocks of the first transaction set.
[0139] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the restored first transaction set to perform a block write operation on the matched transactions.
[0140] The above is as in this manual Figure 1The consensus method disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of this specification can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0141] It should be understood that the electronic device of the embodiment of this specification can realize the leader node or the follower node in Figure 1 The functions of the illustrated embodiments will not be described in detail herein.
[0142] Of course, in addition to software implementation, the electronic device of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0143] In addition, an embodiment of the present specification also proposes a computer-readable storage medium, which stores one or more programs, and the one or more programs include instructions.
[0144] When the above instructions are executed by a portable electronic device including multiple application programs, the portable electronic device can execute Figure 1 The method of the embodiment shown is specifically used to execute the following steps corresponding to the leader node:
[0145] A reliable broadcast transmission RBC protocol is executed on the first transaction set in the transaction pool of the leader node, so as to use an erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and send corresponding data blocks to each follower node of the blockchain based on an Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through an Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to Merkle tree proofs calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of consensus nodes of the blockchain.
[0146] After executing the RBC protocol on the first transaction set, a replication and fault-tolerant RAFT protocol is executed on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower nodes respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proofs of all data blocks of the first transaction set.
[0147] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the first transaction set to perform a block write operation on the matched transactions.
[0148] Alternatively, when the above instructions are executed by a portable electronic device including a plurality of application programs, the portable electronic device can execute Figure 1 The method of the embodiment shown is specifically used to execute the following steps corresponding to the follower node:
[0149] Receive data blocks corresponding to follower nodes sent by the leader node of the blockchain when executing the RBC protocol, wherein the data blocks corresponding to the follower nodes are the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to use the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and send them to the follower nodes based on the Rval message.
[0150] Execute the RBC protocol, forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, broadcast the Ready message to the blockchain after receiving Nf Echo messages, and after receiving 2f+1 Ready messages, restore the received data blocks to the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain.
[0151] After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proof of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proof of all data blocks of the first transaction set, respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proof of all data blocks of the first transaction set.
[0152] After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the restored first transaction set to perform a block write operation on the matched transactions.
[0153] It should be understood that when the above instructions are executed by a portable electronic device including multiple applications, the leader node or follower node described above can be implemented. Figure 1 The functions of the illustrated embodiment will not be described in detail herein.
[0154] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0155] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0156] The above are only embodiments of this specification and are not intended to limit this specification. For those skilled in the art, this specification may be subject to various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the scope of the claims of this specification. In addition, all other embodiments obtained by ordinary technicians in this field without creative work shall fall within the scope of protection of this document.
Claims
1. A consensus method for blockchain, comprising: The leader node of the blockchain executes a reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using an erasure code algorithm, and sends the corresponding data blocks to each follower node of the blockchain based on an Rval message, wherein the data blocks into which the first transaction set is split correspond to the Merkle tree proof calculated based on the erasure code algorithm, and N is the number of consensus nodes of the blockchain; The follower node executes the RBC protocol to forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks into the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain; After executing the RBC protocol on the first transaction set, the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set; The follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proof for all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks of the first transaction set reach consensus, the leader node and the follower node match the transactions corresponding to the Merkle tree proofs that have reached consensus from their respective first transaction sets to perform block write operations on the matched transactions.
2. The method according to claim 1, further comprising: After the leader node uses an erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, the N data blocks split into the first transaction set are added to the consensus execution queue of the leader node in order; After executing the RBC protocol on the first transaction set, the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, including: The leader node sequentially selects the Merkle tree proofs of the data blocks of the first transaction set from the consensus execution queue of the leader node to initiate at least one round of consensus proposal until the Merkle tree proofs of all data blocks of the first transaction set reach consensus.
3. The method according to claim 1, The leader node executes the RBC protocol and the RAFT protocol in series, and the method further includes: After the Merkle tree proofs of all data blocks of the first transaction set have reached consensus, if the blockchain has not changed the term of the RAFT protocol, the leader node executes the RBC protocol on the second transaction set in the transaction pool of the leader node, wherein the second transaction set refers to the transaction set in the transaction pool of the leader node that has not yet been executed by the leader node.
4. The method according to claim 2, The consensus execution queue of the leader node is used as persistent data of the leader node, and the method further includes: If the leader node is restarted, the consensus execution queue of the leader node is restored to the state before the restart based on the persistent data of the leader node.
5. The method according to claim 2, When the leader node executes the RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set, the leader node sends the Merkle tree proofs that are the objects of this round of consensus to other consensus nodes based on the Log log of the RAFT protocol.
6. A consensus method for a blockchain, comprising: The leader node executes the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and sends the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and restores the received data blocks back to the first transaction set based on the erasure code algorithm after receiving Nf Echo messages to reconstruct the Merkle tree of the first transaction set, and broadcasts the Ready message to the blockchain after verifying that the reconstructed Merkle tree is consistent with the received Merkle tree proof, and after receiving 2f+1 Ready messages from different consensus nodes, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the consensus node fault tolerance number of the blockchain; After executing the RBC protocol on the first transaction set, the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower nodes respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proofs of all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the leader node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the first transaction set to perform a write block operation on the matched transactions.
7. A consensus method for a blockchain, comprising: The follower node of the blockchain receives the data block corresponding to the follower node sent by the leader node of the blockchain when executing the RBC protocol, wherein the data block corresponding to the follower node is the data block sent to the follower node based on the Rval message by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus node of the blockchain; The follower node executes the RBC protocol, forwards the corresponding data block received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data block into the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain; After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the follower node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set to perform a write block operation on the matched transactions.
8. A consensus node of a blockchain, comprising: A first RBC execution module, in which the leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using an erasure code algorithm, and sends corresponding data blocks to each follower node of the blockchain based on an Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through an Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to Merkle tree proofs calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of consensus nodes of the blockchain; A first RAFT execution module, wherein the leader node executes a replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set after executing the RBC protocol on the first transaction set, so as to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower nodes respond to the consensus proposal based on the RAFT protocol to complete the consensus on the Merkle tree proofs of all data blocks of the first transaction set; The first block writing module, after the Merkle tree proofs of all data blocks of the first transaction set have reached consensus, the leader node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the first transaction set to perform block writing operations on the matched transactions.
9. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor: Execute the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and send the corresponding data blocks to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein the data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain; After executing the RBC protocol on the first transaction set, executing the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proofs of all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the first transaction set to perform a block write operation on the matched transactions.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the following steps: The reliable broadcast transmission RBC protocol is executed on the first transaction set in the transaction pool of the leader node to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain using the erasure code algorithm, and the corresponding data blocks are sent to each follower node of the blockchain based on the Rval message, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and after receiving N-2f Echo messages, restores the received data blocks to the first transaction set based on the erasure code algorithm, wherein, The data blocks split into the first transaction set correspond to the Merkle tree proof calculated based on the erasure code algorithm, N is the number of consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain; After executing the RBC protocol on the first transaction set, executing the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, so that the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the Merkle tree proofs of all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the first transaction set to perform a block write operation on the matched transactions.
11. A consensus node of a blockchain, comprising: A receiving module receives a data block corresponding to a follower node sent by the leader node of the blockchain when executing the RBC protocol, wherein the data block corresponding to the follower node is the data block sent to the follower node by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using an erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus node of the blockchain, and sending the data block to the follower node based on an Rval message; The second RBC execution module executes the RBC protocol, forwards the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and restores the received data blocks into the first transaction set based on the erasure code algorithm after receiving N-2f Echo messages, where f is the consensus node fault tolerance number of the blockchain; A second RAFT execution module, after the leader node executes a replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, responds to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set; The second block writing module, after the Merkle tree proofs of all data blocks of the first transaction set have completed consensus, the follower node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set to perform block writing operations on the matched transactions.
12. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor: Receive the data blocks corresponding to the follower nodes sent by the leader node of the blockchain when executing the RBC protocol, wherein the data blocks corresponding to the follower nodes are the data blocks sent to the follower nodes by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, using the erasure code algorithm to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain, and sending them to the follower nodes based on the Rval message; Execute the RBC protocol, forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and restore the received data blocks to the first transaction set based on the erasure code algorithm after receiving N-2f Echo messages to reconstruct the Merkle tree of the first transaction set, and broadcast the Ready message to the blockchain after verifying that the reconstructed Merkle tree is consistent with the received Merkle tree proof, and after receiving 2f+1 Ready messages from different consensus nodes, restore the received data blocks to the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain; After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, respond to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the transactions corresponding to the Merkle tree proofs that have reached consensus are matched from the restored first transaction set to perform a block write operation on the matched transactions.
13. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the following steps: The data block corresponding to the follower node sent by the leader node of the receiving blockchain when executing the RBC protocol, where: The data block corresponding to the follower node is generated by the leader node executing the reliable broadcast transmission RBC protocol on the first transaction set in the transaction pool of the leader node, so as to split the first transaction set into N data blocks corresponding to the consensus node of the blockchain using the erasure code algorithm, and sending the data blocks to the follower node based on the Rval message; Execute the RBC protocol, forward the corresponding data blocks received from the Rval message to other follower nodes through the Echo message, and restore the received data blocks to the first transaction set based on the erasure code algorithm after receiving N-2f Echo messages to reconstruct the Merkle tree of the first transaction set, and broadcast the Ready message to the blockchain after verifying that the reconstructed Merkle tree is consistent with the received Merkle tree proof, and after receiving 2f+1 Ready messages from different consensus nodes, restore the received data blocks to the first transaction set based on the erasure code algorithm, where f is the consensus node fault tolerance number of the blockchain; After the leader node executes the replication and fault-tolerant RAFT protocol on the Merkle tree proofs of all data blocks of the first transaction set to initiate a consensus proposal for the Merkle tree proofs of all data blocks of the first transaction set, respond to the consensus proposal based on the RAFT protocol to complete the consensus for the Merkle tree proofs of all data blocks of the first transaction set; After the Merkle tree proofs of all data blocks of the first transaction set reach consensus, matching the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set, so as to perform a block write operation on the matched transactions; After the Merkle tree proofs of all data blocks in the first transaction set reach consensus, the follower node matches the transactions corresponding to the Merkle tree proofs that have reached consensus from the restored first transaction set to perform a write block operation on the matched transactions.
