[go: up one dir, main page]

CN113873030B - A consensus method, consensus node and electronic device for blockchain - Google Patents

A consensus method, consensus node and electronic device for blockchain Download PDF

Info

Publication number
CN113873030B
CN113873030B CN202111124497.4A CN202111124497A CN113873030B CN 113873030 B CN113873030 B CN 113873030B CN 202111124497 A CN202111124497 A CN 202111124497A CN 113873030 B CN113873030 B CN 113873030B
Authority
CN
China
Prior art keywords
consensus
data blocks
transaction set
transaction
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111124497.4A
Other languages
Chinese (zh)
Other versions
CN113873030A (en
Inventor
廖校均
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alipay Hangzhou Information Technology Co Ltd
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
Alipay Hangzhou Information Technology Co Ltd
Ant Blockchain Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alipay Hangzhou Information Technology Co Ltd, Ant Blockchain Technology Shanghai Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202111124497.4A priority Critical patent/CN113873030B/en
Publication of CN113873030A publication Critical patent/CN113873030A/en
Application granted granted Critical
Publication of CN113873030B publication Critical patent/CN113873030B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the specification provides a block chain consensus method, a consensus node and electronic equipment. The method comprises the steps that a leader node executes RBC protocol on a first transaction set in a self transaction pool, the first transaction set is split into N data blocks corresponding to consensus nodes of a blockchain by using an erasure coding algorithm, and the corresponding data blocks are sent to each follower node based on Rval information. The follower node executes RBC protocol, forwards the data block received from the Rval message to other follower nodes through the Echo message, and restores the received data block to the first transaction set based on the erasure coding algorithm after receiving the N-2f Echo messages. The leader node initiates a consensus proposal for the merck tree certification of all data blocks of the first transaction set based on the RAFT protocol. The leader node and the follower node match the corresponding transactions of the agreed merck tree evidence from the respective first transaction sets to perform the block writing operation on the corresponding transactions.

Description

Block chain consensus method, consensus node and electronic equipment
Technical Field
The present document relates to the field of data processing technologies, and in particular, to a block chain consensus method, a consensus node, and an electronic device.
Background
Based on the characteristics of the blockchain, in the consensus protocol of replication and fault tolerant RAFT, proposal data for each round of consensus proposal is packaged by the leader node and synchronously transmitted to the follower nodes of the blockchain. Assuming that the number of consensus nodes of the blockchain is N (both the leader node and the follower node belong to the consensus nodes), for a round of consensus proposal, the leader node needs to send N-1 proposal data, which creates a significant overhead for the network bandwidth of the leader node.
With the explosive growth of future blockchain services, to obtain higher throughput, more data consensus needs to be achieved per unit time, and the burden on the leader node is greater, resulting in a decrease in consensus efficiency. For this reason, there is a need for a solution that can reduce the bandwidth overhead of the leader node in initiating the consensus proposal.
Disclosure of Invention
The embodiment of the specification aims to provide a block chain consensus method, a consensus node and electronic equipment, which can complete block chain consensus with smaller bandwidth overhead on the side of a leader node.
In order to achieve the above object, the embodiments of the present specification are implemented as follows:
in a first aspect, a method of consensus of a blockchain is provided, comprising:
a leader node of a blockchain executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and sends corresponding data blocks to follower nodes of the blockchain based on Rval messages, wherein the data blocks split by the first transaction set correspond to merck tree certificates calculated based on the erasure coding algorithm, and N is the number of the consensus nodes of the blockchain;
The follower node executes the RBC protocol to forward corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and after receiving N-2f Echo messages, restores the received data blocks into the first transaction set based on the erasure coding algorithm, wherein f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is executed on the first transaction set, the leader node executes a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set;
The follower node responding to the consensus proposal based on the RAFT protocol to complete a consensus of merck tree evidence for all data blocks of the first transaction set;
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, the leader node and the follower node match the transaction corresponding to the merck tree evidence achieving consensus from the respective first transaction set so as to execute block writing operation on the matched transaction.
In a second aspect, a method of consensus of a blockchain is provided, comprising:
A leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, so that the first transaction set is split into N data blocks corresponding to the common node of the blockchain by using an erasure coding algorithm, and corresponding data blocks are sent to each follower node of the blockchain based on Rval messages, so that the follower node executes the RBC protocol, the corresponding data blocks received from Rval messages are forwarded to other follower nodes through Echo messages, and after receiving N-f Echo messages, ready messages are broadcast to the blockchain, and after receiving 2f+1 Ready messages, the received data blocks are restored to the first transaction set based on the erasure coding algorithm, wherein the data blocks split into the first transaction set correspond to the merck tree calculated based on the erasure coding algorithm, and N is the number of the common node of the blockchain and f is the fault-tolerant node number of the blockchain;
After the RBC protocol is executed on the first transaction set, the leader node executes a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence 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 for the merck tree evidence of all data blocks of the first transaction set;
After the merck tree certificates of all the data blocks of the first transaction set are completely agreed, the leader node matches the transaction corresponding to the agreed merck tree certificates from the first transaction set so as to execute the block writing operation on the matched transaction.
In a third aspect, a method of consensus of a blockchain is provided, comprising:
A follower node of a blockchain receives a data block corresponding to a follower node transmitted when a leader node of the blockchain executes a RBC protocol, wherein the data block corresponding to the follower node is that the leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain using an erasure coding algorithm and transmits to the follower node based on Rval messages;
The follower node executes the RBC protocol, forwards corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein f is the fault tolerance number of the consensus nodes of the blockchain;
after the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, the follower node matches the transaction corresponding to the merck tree evidence achieving consensus from the restored first transaction set so as to execute block writing operation on the matched transaction.
In a fourth aspect, there is provided a consensus node for a blockchain, comprising:
A first RBC execution module, wherein a leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and sends corresponding data blocks to each follower node of the blockchain based on Rval messages, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the split data blocks of the first transaction set correspond to merck tree certificates calculated based on the erasure coding algorithm, and N is the number of consensus nodes of the blockchain and f is the fault tolerance number of the consensus nodes of the blockchain;
A first RAFT execution module, the leader node performing a copy and fault tolerant RAFT protocol on a merck tree evidence of all data blocks of the first transaction set after performing the RBC protocol on the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
And the first writing block module is used for matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, so as to execute writing block operation on the matched transaction.
In a fifth aspect, there is provided an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executable by the processor to:
Performing a reliable broadcast transmission (RBC) protocol on a first transaction set in a transaction pool of a leader node to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain by using an erasure coding algorithm, sending corresponding data blocks to each follower node of the blockchain based on Rval messages, enabling the follower nodes to perform the RBC protocol, forwarding the corresponding data blocks received from Rval messages to other follower nodes by Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the data blocks split by the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm, N is the number of the consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is performed on the first transaction set, performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set so as to execute block writing operation on the matched transaction.
In a sixth aspect, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Performing a reliable broadcast transmission (RBC) protocol on a first transaction set in a transaction pool of a leader node to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain by using an erasure coding algorithm, sending corresponding data blocks to each follower node of the blockchain based on Rval messages, enabling the follower nodes to perform the RBC protocol, forwarding the corresponding data blocks received from Rval messages to other follower nodes by Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the data blocks split by the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm, N is the number of the consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is performed on the first transaction set, performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set so as to execute block writing operation on the matched transaction.
In a seventh aspect, there is provided a consensus node for a blockchain, comprising:
a receiving module, configured to receive a data block corresponding to a follower node sent when a leader node of the blockchain executes an RBC protocol, where the data block corresponding to the follower node is that 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 a consensus node of the blockchain using an erasure coding algorithm, and send the N data blocks to the follower node based on an Rval message;
The second RBC executing module executes the RBC protocol, forwards corresponding data blocks received from Rval messages to other follower nodes through Echo messages, restores the received data blocks to the first transaction set based on an erasure coding algorithm after receiving N-2f Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm, wherein f is the fault tolerance number of the consensus node of the blockchain;
A second RAFT execution module that, after the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
And the second writing block module is used for matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, so as to execute writing block operation on the matched transaction.
In an eighth aspect, there is provided an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executable by the processor to:
Receiving a data block corresponding to a follower node transmitted when a leader node of the blockchain executes a RBC protocol, wherein the data block corresponding to the follower node is obtained by the leader node executing a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, splitting the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and transmitting the N data blocks to the follower node based on Rval messages;
executing the RBC protocol, forwarding corresponding data blocks received from Rval messages to other follower nodes through Echo messages, broadcasting Ready messages to the blockchain after receiving N-f Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving 2f+1 Ready messages, wherein f is the fault tolerance number of the consensus node of the blockchain;
After the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responding to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set so as to execute the block writing operation on the matched transaction.
In a ninth aspect, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Receiving a data block corresponding to a follower node transmitted when a leader node of the blockchain executes a RBC protocol, wherein the data block corresponding to the follower node is obtained by the leader node executing a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, splitting the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and transmitting the N data blocks to the follower node based on Rval messages;
executing the RBC protocol, forwarding corresponding data blocks received from Rval messages to other follower nodes through Echo messages, broadcasting Ready messages to the blockchain after receiving N-f Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving 2f+1 Ready messages, wherein f is the fault tolerance number of the consensus node of the blockchain;
After the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responding to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set so as to execute the block writing operation on the matched transaction.
The schemes of the embodiments of the present description achieve consensus through RBC protocol and RAFT protocol. In the RBC protocol stage, the leader node splits a transaction set serving as proposal data into data blocks corresponding to follower nodes by utilizing an erasure code transmission mechanism of the RBC protocol, the split data blocks are sent to the corresponding follower nodes, and the follower nodes forward the split data blocks to each other so as to allocate the transmission of the proposal data, so that the transmission fault tolerance is realized by the network bandwidth and the storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal by taking the merck tree evidence of the data block of the RBC protocol result as a consensus object, so that the merck tree evidence achieving the consensus is matched back to the corresponding transaction completion writing block operation, and the execution time of the RAFT protocol can be effectively reduced due to the relatively smaller data quantity of the merck tree evidence, so that the consensus efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present description or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some of the embodiments described in the embodiments of the present description, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
Fig. 1 is a flowchart of a block chain consensus method according to an embodiment of the present disclosure.
Fig. 2 is a schematic diagram of a first structure of a common node according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram of a second structure of a common node according to an embodiment of the present disclosure.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
As previously described, in existing RAFT protocol consensus, proposal data for each round of consensus proposal is packaged by the leader node and transmitted synchronously to the follower nodes of the blockchain. Assuming that the number of consensus nodes of the blockchain is N, for a round of consensus proposal, the leader node needs to send N-1 proposal data, which creates a significant overhead for the network bandwidth of the leader node. With the explosive growth of future blockchain services, to obtain higher throughput, more data consensus needs to be achieved per unit time, and the burden on the leader node is greater, resulting in a decrease in consensus efficiency. In view of this, this document aims to propose a solution that can implement blockchain consensus with a small bandwidth overhead of the leader node, so as to adapt to the requirement of future blockchain service growth.
FIG. 1 is a flow chart of a method of consensus of blockchains in an embodiment of the present description. The method shown in fig. 1 may be performed by a corresponding apparatus, comprising the steps of:
S102, a leader node of the blockchain executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and sends corresponding data blocks to each follower node of the blockchain based on Rval messages, wherein the data blocks split by the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm, and N is the number of the consensus nodes of the blockchain.
Erasure Coding (EC) is a method of fault-tolerant protection of data by dividing the data into segments, expanding, encoding, and storing redundant data blocks in different locations, such as disks, storage nodes, or other geographical locations. From a data function perspective, the protection afforded by erasure codes can be expressed by the following equation x=k+y. The variable x "represents the value of the original data or symbol. The variable "y" represents the value of the extra or redundant symbol added after a fault that provides protection. The variable "x" represents the total value of the symbols created after the erasure coding process. For example, in one EC 10/16 configuration, there are 6 additional symbols (variable m) added to 10 original symbols (variable k). The 16 data segments (variable n) may be spread over 16 drives, nodes or geographic locations, and the original file may be reconstructed from 10 verification segments. That is, even if 6 drives, nodes, or geographic locations are lost or unavailable, the original file may be restored. It can be seen that erasure codes require only a small amount of redundancy to achieve data recovery.
In this embodiment of the present description, the leader node performs the RBC protocol in order to synchronize the first transaction set (subsequently as proposal data) in its own transaction pool that needs consensus to the follower nodes of the blockchain summary using erasure coding techniques. Based on erasure code technology, after dividing the transaction set in the own transaction pool into data blocks corresponding to all consensus nodes, the leader node only needs to send the data block corresponding to each follower node. That is, in the synchronization process, the data volume sent by the leader node is only the data volume of one first transaction set.
S104, the follower node executes 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, the follower nodes restore the received data blocks into a first transaction set based on an erasure code algorithm, wherein f is the fault tolerance number of the consensus nodes of the blockchain.
It should be understood that, when executing the RBC protocol, the leader node of the embodiment of the present disclosure provides the follower node with the data block corresponding to the follower node only through Rval messages. In order for the follower nodes to obtain the complete first transaction set, in this step, each follower node of the blockchain also needs to forward the data block corresponding to the block to other follower nodes through the Echo message of the RBC protocol. When any follower node receives N-2f Echo messages (indicating that enough data blocks based on the erasure coding algorithm to restore the first transaction set are collected), it tries to restore the first intersection to achieve data synchronization of the first intersection.
It can be seen that, in the process of transmitting the first transaction set by using the erasure coding algorithm based on the RBC protocol, the follower node also consumes the network bandwidth to assist the leader node in forwarding the corresponding data block, thereby sharing the transmission pressure of the leader node side.
S106, after executing the RBC protocol on the first transaction set, the leader node executes a copy and fault tolerant RAFT protocol on the merck tree certificates of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates of all data blocks of the first transaction set.
It should be appreciated that the merck tree justifies the consensus proposal for all data blocks of the first transaction set. Is the result of the execution of the RBC protocol by the leader node. The merck tree evidence refers specifically to the root hash value of the merck tree, and the data block can be represented by the merck tree evidence with smaller data volume. That is, in this step, when the master node performs the RAFT protocol on the merck tree proof of all the data blocks of the first transaction set, the data amount transmitted by the RAFT protocol may be saved.
S108, the follower node responds to the consensus proposal based on RAFT protocol to complete the consensus of the merck tree evidence for all data blocks of the first transaction set.
It should be understood that in the embodiment of the present specification, the consensus object of the RAFT protocol is demonstrated by replacing the conventional transaction set data with the merck tree, but the consensus principle is not changed, so the conventional RAFT protocol logic can be used to complete the consensus.
S110, after the merck tree evidence of all the data blocks of the first transaction set completes consensus, the leader node and the follower node match the corresponding transaction of the merck tree evidence achieving the consensus from the respective first transaction set so as to execute block writing operation on the matched transaction.
Compared with the traditional RAFT protocol, since the consensus object is replaced by the transaction set data to the merck tree proof, what is determined by the RAFT protocol result is the merck tree proof of consensus, and the leader node and the follower node are required to match corresponding transactions from the respective determined transaction sets, and then perform the block writing operation on the matched transactions (also understood as the consensus transactions).
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, whereas the first transaction set on the leader node side is itself derived from the pool of transactions of the target consensus node.
The method of the embodiment of the specification realizes consensus through RBC protocol and RAFT protocol. In the RBC protocol stage, the leader node splits a transaction set serving as proposal data into data blocks corresponding to follower nodes by utilizing an erasure code transmission mechanism of the RBC protocol, the split data blocks are sent to the corresponding follower nodes, and the follower nodes forward the split data blocks to each other so as to allocate the transmission of the proposal data, so that the transmission fault tolerance is realized by the network bandwidth and the storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal by taking the merck tree evidence of the data block of the RBC protocol result as a consensus object, so that the merck tree evidence achieving the consensus is matched back to the corresponding transaction completion writing block operation, and the execution time of the RAFT protocol can be effectively reduced due to the relatively smaller data quantity of the merck tree evidence, so that the consensus efficiency is improved.
The following describes the consensus method of the embodiments of the present specification in detail.
In the method of the embodiment of the specification, the consensus node of the blockchain realizes the consensus uplink of the transaction based on the RBC protocol and the RAFT protocol. Here, the number of consensus nodes of the blockchain is set to N, and the fault-tolerant number of consensus nodes of the bayer is set to f, N > =3f+1.
The RAFT protocol divides consensus nodes into three types, leader, follower, CANDIDATE (candidates) respectively:
the Leader is responsible for synchronously managing logs, processing requests from clients and keeping connection with Follower heartbeat (heartBeat);
follower when the system is started, all the consensus nodes are Follower, respond to the log synchronization request of the Leader, respond to the request of CANDIDATE and forward the transaction from the request to Follower to the Leader;
CANDIDATE, responsible for electing voting, switching from Follower to CANDIDATE by a node when RAFT is started to initiate election, and switching from CANDIDATE to a Leader state after electing a Leader.
Furthermore, the RAFT protocol divides time into tenns (Term) of any different length. Tenns are indicated by consecutive numbers. Each tenure starts with an election (election) and one or more CANDIDATE will attempt to become a Leader. If one CANDIDATE wins the election, it will act as a Leader for the remainder of the tenure.
The corresponding consensus flow is as follows:
RBC protocol phase:
the leader node selects a plurality of transactions to be consensus from a transaction pool of the leader node to form a first transaction set.
The leader node splits the first transaction set into N ordered data blocks corresponding one-to-one to the consensus nodes of the blockchain in the consensus sequence using an erasure coding algorithm. Here, each data block includes at least one transaction in the first transaction set, and corresponds to a merck tree proof (root hash) calculated by the erasure coding algorithm.
For ease of understanding, assuming that the blockchain is provided with 6 consensus nodes (the rest are follower nodes) including the leader node, the transactions in the first transaction set are 20, i.e., tx1 to tx20, then the first transaction set may be split into 6 data blocks, i.e., root hash 1 to root hash 6. Correspondingly, the merck tree demonstrates the following correspondence with the transaction:
root hash 1:{tx1,tx2,tx3,tx4}
root hash 2:{tx5,tx6,tx7}
root hash 3:{tx8,tx9,tx10}
root hash 4:{tx11,tx12,tx13}
root hsh 5:{tx14,tx15,tx16}
root hash 6:{tx17,tx18,tx19,tx20}
Thereafter, the leader node Rval message sends corresponding data blocks to each follower node of the blockchain.
Here, the consensus node 1 is taken as a leader node. If the data block with the merck tree proven to be the root hash 2 corresponds to the consensus node 2, the Rval message sent by the consensus node 1 to the consensus node 2 carries the merck tree proven root hash 2, and if the data block with the merck tree proven to be the root hash 3 corresponds to the consensus node 3, the Rval message sent by the consensus node 1 to the consensus node 3 carries the merck tree proven root hash 3.
After receiving the Rval message of the leader node, the follower node forwards the merck tree proof in the Rval message to other follower nodes through the Echo message.
For example, the consensus node 2 sends Echo messages carrying root hash 2 to the consensus nodes 1, 3, 4, 5, 6, the consensus node 3 sends Echo messages carrying root hash 3 to the consensus nodes 1, 2,4, 5, 6, and the consensus node 6 sends Echo messages carrying root hash 6 to the consensus nodes 1, 2, 3, 4, 5.
After receiving N-2f Echo messages, any follower node attempts to restore the received data blocks (the data blocks in Rval messages sent by the leader node and the data blocks in Echo messages sent by other follower nodes) back to the first transaction set using an erasure coding algorithm, and reconstructs the merck tree of the first transaction set to verify whether the reconstructed merck tree is consistent with the received merck tree proof. If so, a Ready message is broadcast to the blockchain.
In addition, on the basis of the above, if any follower node obtains data blocks from Echo messages and Rval messages, the data blocks in Rval messages received by other follower nodes may be obtained from other follower nodes to attempt to restore the first transaction set.
Then, for each consensus node, when f+1 identical Ready messages from different nodes are received, judging whether the Ready messages are broadcast by the leader node or not, if not, broadcasting the Ready messages, and when 2f+1 Ready messages from different consensus nodes are received, the leader node correctly synchronizes the first transaction set in the own transaction pool to the follower node.
Here, the leader node locally maintains a consensus execution queue for storing the merck tree certificates to be consensus. After splitting the first transaction set into N data blocks, the leader node sequentially adds the N data blocks split by the first transaction set into a consensus execution queue of the leader node.
After the RBC protocol stage is finished, the leader node sequentially selects the merck tree evidence from the consensus execution queue as a consensus object to initiate the consensus proposal of the RAFT protocol. It should be appreciated that if the merck tree evidence in the consensus execution queue exceeds the maximum number of merck tree evidence supported by one consensus proposal, the leader node may choose to initiate at least two rounds of consensus proposals to consensus the merck tree evidence in the consensus execution queue.
RAFT protocol stage:
first, the leader node initiates a consensus proposal using the merck tree evidence of each data block of the first transaction set as proposal data. The consensus process includes:
The leader node copies the merck tree evidence of each data block of the first transaction set in Log form of a distribution attempt to the follower node for storage. In addition, the Log also contains a command, a corresponding terminal time period number and an Index of the Log. The additional information in these Log logs assists the follower in determining the validity of the Log and the subsequent data synchronization security logic.
The Log is copied to the follower node and takes effect without representing the command contained in the Log, and the copied Log also needs to go through a commit (commit) process. When the Leader confirms that the Log has been successfully copied by most consensus nodes, the instruction contained in the Log can be formally submitted to be effective.
When the Leader node considers that the data reliability is guaranteed (provided that replication is completed on the most half of the nodes), the Leader then notifies the other consensus nodes (including itself) to commit (i.e., execute) the instruction in the respective state machine. As long as the state machine switching logic of each consensus node is guaranteed to be consistent, the executed instructions are also consistent (including sequence), the state consistency among all RAFT nodes can be guaranteed, and thus the consensus is realized.
After all the merck tree certificates in the consensus execution queue of the leader node complete the consensus, the leader node and the follower node match the corresponding transactions for which the merck tree certificates of the consensus are reached from the respective first transaction sets, so as to execute the block writing operation on the matched transactions.
For ease of understanding, assuming that the merck tree of root hash 1 and root hash 5 prove to agree, the leader node and follower node perform a write block operation on the transactions { tx1, tx2, tx3, tx4} and root hsh { tx14, tx15, tx16} corresponding to root hash 1, i.e., the transactions { tx1, tx2, tx3, tx4 tx14, tx15, tx16} complete the chaining.
The above is an introduction to a round of RBC protocol + RAFT protocol. It should be appreciated that after the merck tree of all the data blocks of the first transaction set proves that the consensus is completed, if the blockchain does not replace the tenn period of the RAFT protocol (i.e. does not replace the leader node), the leader node may further continue to execute a new round of RBC protocol on the second transaction set in the transaction pool of the leader node (the second transaction set is the transaction set in the transaction pool of the leader node that has not been executed with the RBC protocol by the leader node), and then initiate a proposal for the consensus of the RAFT protocol for the merck tree proof of each data block split by the second transaction set to complete the uplink of the second transaction set.
In addition, on the basis of the above, the leader node can perform data persistence on the consensus execution queue local to the leader node, and if the leader node is down, the consensus execution queue of the leader node can be restored to the state before restarting based on the persistence data of the leader node after restarting.
The above is an introduction to the method of the embodiments of the present specification. It will be appreciated that suitable modifications may be made without departing from the principles set forth herein above, and such modifications are intended to be considered within the scope of the embodiments of the present disclosure.
Corresponding to the above-described consensus method shown in fig. 1, the present embodiment further provides a consensus node of a blockchain.
Fig. 2 is a block diagram of a consensus node 200 according to an embodiment of the present disclosure, comprising:
A first RBC execution module 210, where a leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain using an erasure coding algorithm, and sends corresponding data blocks to each follower node of the blockchain based on Rval messages, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, where N is the number of consensus nodes of the blockchain and f is the fault tolerance number of the consensus nodes of the blockchain, where the data blocks split by the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm;
A first RAFT execution module 220, the leader node performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set after performing the RBC protocol on the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
The first writing block module 230 matches the transaction corresponding to the merck tree evidence reaching the consensus from the first transaction set after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, so as to execute writing block operation on the matched transaction.
The consensus node in the embodiment of the present specification realizes consensus through RBC protocol and RAFT protocol. In the RBC protocol stage, the transaction set serving as the proposal data is split into data blocks corresponding to follower nodes by utilizing an erasure code transmission mechanism of the RBC protocol, the split data blocks are sent to the corresponding follower nodes, and then the follower nodes forward each other so as to allocate the transmission of the proposal data, so that the transmission fault tolerance is realized by the network bandwidth and the storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal by taking the merck tree evidence of the data block of the RBC protocol result as a consensus object, so that the merck tree evidence achieving the consensus is matched back to the corresponding transaction completion writing block operation, and the execution time of the RAFT protocol can be effectively reduced due to the relatively smaller data quantity of the merck tree evidence, so that the consensus efficiency is improved.
Optionally, the consensus node of the embodiments of the present specification further includes:
The queue maintenance module, after the first RBC execution module 210 splits the first transaction set into N data blocks corresponding to the consensus node of the blockchain by using the erasure coding algorithm, sequentially adds the N data blocks split by the first transaction set to the consensus execution queue of the leader node, and correspondingly, the first RAFT execution module 220 may sequentially select the merck tree proof of the data blocks of the first transaction set from the consensus execution queue to initiate at least one round of consensus proposal until the merck tree proof of all the data blocks of the first transaction set completes consensus.
Optionally, the first RBC execution module 210 and the first RAFT execution module 220 are in serial relationship.
After the merkel tree of all the data blocks of the first transaction set proves that the consensus is completed, if the blockchain does not change the period of the RAFT protocol, the first RBC executing module 210 executes a new round of RBC protocol on a second transaction set in the transaction pool of the leader node, wherein the second transaction set is a transaction set in the transaction pool of the leader node, which has not been executed by the leader node.
Optionally, the consensus execution queue of the leader node acts as persistent data for the leader node. If the leader node is restarted, the queue maintenance module may restore the consensus execution queue of the leader node to a state before restarting based on the persistent data of the leader node.
Optionally, when executing the RAFT protocol on the merck tree certificates of all the data blocks of the first transaction set, the leader node sends the merck tree certificates as the current round of consensus objects to other consensus nodes based on a Pre-preparation message of the RAFT protocol.
Obviously, the consensus node in the embodiment of the present disclosure may be used as an execution body of the leader node in the method shown in fig. 1, and may implement a function corresponding to the leader node in the method shown in fig. 1. Since the principle is the same, the description is not repeated here.
Corresponding to the above-described consensus method shown in fig. 1, the present embodiment further provides a consensus node of a blockchain. Fig. 3 is a block diagram of a consensus node 300 according to an embodiment of the present disclosure, comprising:
A receiving module 310, configured to receive a data block corresponding to a follower node sent when a leader node of the blockchain executes an RBC protocol, where the data block corresponding to the follower node is that 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 consensus nodes of the blockchain using an erasure coding algorithm, and send the N data blocks to the follower node based on an Rval message;
A second RBC executing module 320, configured to execute the RBC protocol, forward, through Echo messages, corresponding data blocks received from Rval messages to other follower nodes, and restore, after receiving N-2f Echo messages, the received data blocks to the first transaction set based on an erasure coding algorithm, and restore, based on the erasure coding algorithm, the received data blocks to the first transaction set, where f is a fault tolerance number of the consensus node of the blockchain;
A second RAFT execution module 330 that, after the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
The second writing block module 340 matches the transaction corresponding to the merck tree evidence reaching the consensus from the restored first transaction set after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, so as to execute the writing block operation on the matched transaction.
The consensus node in the embodiment of the present specification realizes consensus through RBC protocol and RAFT protocol. In the RBC protocol stage, the leader node splits a transaction set serving as proposal data into data blocks corresponding to follower nodes by utilizing an erasure code transmission mechanism of the RBC protocol, the split data blocks are sent to the corresponding follower nodes, and the follower nodes forward the split data blocks to each other so as to allocate the transmission of the proposal data, so that the transmission fault tolerance is realized by the network bandwidth and the storage space overhead of the leader node. In the RAFT protocol stage, the leader node initiates a consensus proposal by taking the merck tree evidence of the data block of the RBC protocol result as a consensus object, so that the merck tree evidence achieving the consensus is matched back to the corresponding transaction completion writing block operation, and the execution time of the RAFT protocol can be effectively reduced due to the relatively smaller data quantity of the merck tree evidence, so that the consensus efficiency is improved.
Obviously, the consensus node in the embodiment of the present disclosure may be used as an execution body of the follower node in the method shown in fig. 1, so that the corresponding function of the follower node in the method shown in fig. 1 can be realized. Since the principle is the same, the description is not repeated here.
Fig. 4 is a schematic structural view of an electronic device according to an embodiment of the present specification. Referring to fig. 4, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (PERIPHERAL COMPONENT INTERCONNECT, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 4, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program, and a block chain consensus device is formed on a logic level, wherein the consensus device can be used as a leader node of the block chain and can also belong to a component in a consensus main node. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
Performing a reliable broadcast transmission (RBC) protocol on a first transaction set in a transaction pool of a leader node to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain by using an erasure coding algorithm, sending corresponding data blocks to each follower node of the blockchain based on Rval messages, enabling the follower nodes to perform the RBC protocol, forwarding the corresponding data blocks received from Rval messages to other follower nodes by Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the data blocks split by the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm, N is the number of the consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is performed on the first transaction set, performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set so as to execute block writing operation on the matched transaction.
Or the processor reads the corresponding computer program from the nonvolatile memory to the memory and then runs, and forms a block chain consensus device on a logic level, wherein the consensus device can be used as a follower node of the block chain or can be a component in a consensus backup node. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
And receiving a data block corresponding to a follower node transmitted when a leader node of the blockchain executes the RBC protocol, wherein the data block corresponding to the follower node is obtained by the leader node executing a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, so that the first transaction set is split into N data blocks corresponding to a consensus node of the blockchain by using an erasure coding algorithm, and the N data blocks are transmitted to the follower node based on an Rval message.
Executing the RBC protocol, forwarding corresponding data blocks received from Rval messages to other follower nodes through Echo messages, broadcasting Ready messages to the blockchain after receiving N-f Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving 2f+1 Ready messages, wherein f is the fault tolerance number of the consensus node of the blockchain.
After the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responding to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set.
After the merck tree evidence of all the data blocks of the first transaction set completes the consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set so as to execute the block writing operation on the matched transaction.
The consensus method disclosed in the embodiment shown in fig. 1 of the present specification can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The Processor may be a general-purpose Processor including a central processing unit (Central Processing Unit, CPU), a network Processor (Network Processor, NP), etc., or may be a digital signal Processor (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of this specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present specification may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
It should be understood that the electronic device of the embodiments of the present disclosure may implement the functions of the embodiment shown in fig. 1 of the leader node or follower node, which are not described herein.
Of course, in addition to the software implementation, the electronic device in this specification does not exclude other implementations, such as a logic device or a combination of software and hardware, that is, the execution subject of the following process is not limited to each logic unit, but may also be hardware or a logic device.
Furthermore, the embodiments of the present specification also propose a computer-readable storage medium, the computer-readable storage medium stores one or more programs, the one or more programs including instructions.
The above instructions, when executed by a portable electronic device including a plurality of applications, enable the portable electronic device to perform the method of the embodiment shown in fig. 1, and specifically are configured to perform the following steps corresponding to a leader node:
Performing a reliable broadcast transmission (RBC) protocol on a first transaction set in a transaction pool of a leader node to split the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain by using an erasure coding algorithm, sending corresponding data blocks to each follower node of the blockchain based on Rval messages, enabling the follower nodes to perform the RBC protocol, forwarding the corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the data blocks split into the first transaction set correspond to the number of the consensus nodes of the blockchain calculated based on the erasure coding algorithm, and N is the number of the consensus nodes of the blockchain and f is the fault tolerance number of the consensus nodes of the blockchain.
After the RBC protocol is performed on the first transaction set, performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete the consensus of the merck tree evidence of all data blocks of the first transaction set.
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set so as to execute block writing operation on the matched transaction.
Or the above instructions, when executed by a portable electronic device comprising a plurality of applications, enable the portable electronic device to perform the method of the embodiment shown in fig. 1, and specifically for performing the following steps corresponding to follower nodes:
And receiving a data block corresponding to a follower node transmitted when a leader node of the blockchain executes the RBC protocol, wherein the data block corresponding to the follower node is obtained by the leader node executing a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, so that the first transaction set is split into N data blocks corresponding to a consensus node of the blockchain by using an erasure coding algorithm, and the N data blocks are transmitted to the follower node based on an Rval message.
Executing the RBC protocol, forwarding corresponding data blocks received from Rval messages to other follower nodes through Echo messages, broadcasting Ready messages to the blockchain after receiving N-f Echo messages, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving 2f+1 Ready messages, wherein f is the fault tolerance number of the consensus node of the blockchain.
After the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responding to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set.
After the merck tree evidence of all the data blocks of the first transaction set completes the consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set so as to execute the block writing operation on the matched transaction.
It should be appreciated that the above-described instructions, when executed by a portable electronic device comprising a plurality of applications, enable the leader node or follower node described above to perform the functions of the embodiment shown in fig. 1, and are not described in detail herein.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The foregoing is merely an example of the present specification and is not intended to limit the present specification. Various modifications and alterations to this specification will become apparent to those skilled in the art. Any modifications, equivalent substitutions, improvements, or the like, which are within the spirit and principles of the present description, are intended to be included within the scope of the claims of the present description. Moreover, all other embodiments obtained by those skilled in the art without making any inventive effort shall fall within the scope of protection of this document.

Claims (13)

1. A method of consensus of a blockchain, comprising:
a leader node of a blockchain executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and sends corresponding data blocks to follower nodes of the blockchain based on Rval messages, wherein the data blocks split by the first transaction set correspond to merck tree certificates calculated based on the erasure coding algorithm, and N is the number of the consensus nodes of the blockchain;
The follower node executes the RBC protocol to forward corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and after receiving N-2f Echo messages, restores the received data blocks into the first transaction set based on the erasure coding algorithm, wherein f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is executed on the first transaction set, the leader node executes a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set;
The follower node responding to the consensus proposal based on the RAFT protocol to complete a consensus of merck tree evidence for all data blocks of the first transaction set;
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, the leader node and the follower node match the transaction corresponding to the merck tree evidence achieving consensus from the respective first transaction set so as to execute block writing operation on the matched transaction.
2. The method of claim 1, further comprising:
after the leader node splits the first transaction set into N data blocks corresponding to the consensus nodes of the blockchain by using an erasure code algorithm, the N data blocks split by the first transaction set are added to a consensus execution queue of the leader node in sequence;
After the RBC protocol is performed on the first transaction set, the leader node performs a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, comprising:
The leader node sequentially selects the merck tree evidence 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 merck tree evidence of all the data blocks of the first transaction set completes consensus.
3. The method according to claim 1,
The leader node executing the RBC protocol and the RAFT protocol in series, the method further comprising:
After the merck tree of all the data blocks of the first transaction set proves that the consensus is completed, if the blockchain does not replace any period of the RAFT protocol, the leader node executes the RBC protocol on a second transaction set in a transaction pool of the leader node, wherein the second transaction set is a transaction set in the transaction pool of the leader node, which has not been executed by the leader node.
4. The method according to claim 2,
The common execution queue of the leader node acts as persistent data for the leader node, the method further comprising:
And if the leader node is restarted, recovering the consensus execution queue of the leader node to a state before restarting based on the persistent data of the leader node.
5. The method according to claim 2,
And when the master node executes the RAFT protocol on the merck tree certificates of all the data blocks of the first transaction set, the master node sends the merck tree certificates which are the round of consensus objects to other consensus nodes based on Log logs of the RAFT protocol.
6. A method of consensus of a blockchain, comprising:
The leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, so that the first transaction set is split into N data blocks corresponding to the co-identified nodes of the blockchain by using an erasure code algorithm, corresponding data blocks are sent to each follower node of the blockchain based on Rval messages, the follower node executes the RBC protocol, the corresponding data blocks received from Rval messages are forwarded to other follower nodes through Echo messages, the received data blocks are restored back to the first transaction set based on an erasure code algorithm after receiving N-f Echo messages to reconstruct the merck tree of the first transaction set, a Ready message is broadcast to the blockchain after verifying that the reconstructed merck tree is consistent with the received merck tree, and after receiving 2f+1 Ready messages from different co-identified nodes, the received data blocks are restored to the first transaction set based on the erasure code algorithm, the first transaction set is calculated as the first transaction set, and the number of the first transaction set is calculated as the error-tolerant tree of the co-identified nodes;
After the RBC protocol is executed on the first transaction set, the leader node executes a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence 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 for the merck tree evidence of all data blocks of the first transaction set;
After the merck tree certificates of all the data blocks of the first transaction set are completely agreed, the leader node matches the transaction corresponding to the agreed merck tree certificates from the first transaction set so as to execute the block writing operation on the matched transaction.
7. A method of consensus of a blockchain, comprising:
A follower node of a blockchain receives a data block corresponding to a follower node transmitted when a leader node of the blockchain executes a RBC protocol, wherein the data block corresponding to the follower node is that the leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain using an erasure coding algorithm and transmits to the follower node based on Rval messages;
The follower node executes the RBC protocol, forwards corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein f is the fault tolerance number of the consensus nodes of the blockchain;
after the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, the follower node matches the transaction corresponding to the merck tree evidence achieving consensus from the restored first transaction set so as to execute block writing operation on the matched transaction.
8. A consensus node of a blockchain, comprising:
A first RBC execution module, wherein a leader node executes a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node to split the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and sends corresponding data blocks to each follower node of the blockchain based on Rval messages, so that the follower node executes the RBC protocol, forwards the corresponding data blocks received from Rval messages to other follower nodes through Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the split data blocks of the first transaction set correspond to merck tree certificates calculated based on the erasure coding algorithm, and N is the number of consensus nodes of the blockchain and f is the fault tolerance number of the consensus nodes of the blockchain;
A first RAFT execution module, the leader node performing a copy and fault tolerant RAFT protocol on a merck tree evidence of all data blocks of the first transaction set after performing the RBC protocol on the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
And the first writing block module is used for matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, so as to execute writing block operation on the matched transaction.
9. An electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor:
Performing a reliable broadcast transmission (RBC) protocol on a first transaction set in a transaction pool of a leader node to split the first transaction set into N data blocks corresponding to consensus nodes of a blockchain by using an erasure coding algorithm, sending corresponding data blocks to each follower node of the blockchain based on an Rval message, enabling the follower node to perform the RBC protocol, forwarding the corresponding data blocks received from the Rval message to other follower nodes through an Echo message, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the split data blocks of the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm, N is the number of the consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is performed on the first transaction set, performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set so as to execute block writing operation on the matched transaction.
10. A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Performing a reliable broadcast transmission (RBC) protocol on a first transaction set in a transaction pool of a leader node to split the first transaction set into N data blocks corresponding to consensus nodes of a blockchain by using an erasure coding algorithm, sending corresponding data blocks to each follower node of the blockchain based on an Rval message, enabling the follower node to perform the RBC protocol, forwarding the corresponding data blocks received from the Rval message to other follower nodes through an Echo message, and restoring the received data blocks into the first transaction set based on the erasure coding algorithm after receiving N-2f Echo messages, wherein the split data blocks of the first transaction set correspond to the merck tree evidence calculated based on the erasure coding algorithm, N is the number of the consensus nodes of the blockchain, and f is the fault tolerance number of the consensus nodes of the blockchain;
After the RBC protocol is performed on the first transaction set, performing a copy and fault tolerant RAFT protocol on the merck tree evidence of all data blocks of the first transaction set to initiate a consensus proposal for the merck tree evidence of all data blocks of the first transaction set, such that the follower node responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree evidence of all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the first transaction set so as to execute block writing operation on the matched transaction.
11. A consensus node of a blockchain, comprising:
a receiving module, configured to receive a data block corresponding to a follower node sent when a leader node of the blockchain executes an RBC protocol, where the data block corresponding to the follower node is that 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 a consensus node of the blockchain using an erasure coding algorithm, and send the N data blocks to the follower node based on an Rval message;
The second RBC executing module executes the RBC protocol, forwards corresponding data blocks received from Rval messages to other follower nodes through Echo messages, restores the received data blocks to the first transaction set based on an erasure coding algorithm after receiving N-2f Echo messages, and restores the received data blocks to the first transaction set based on the erasure coding algorithm, wherein f is the fault tolerance number of the consensus node of the blockchain;
A second RAFT execution module that, after the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responds to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
And the second writing block module is used for matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, so as to execute writing block operation on the matched transaction.
12. An electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor:
Receiving a data block corresponding to a follower node transmitted when a leader node of a blockchain executes a RBC protocol, wherein the data block corresponding to the follower node is obtained by the leader node executing a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, splitting the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and transmitting the N data blocks to the follower node based on Rval messages;
Executing the RBC protocol, forwarding corresponding data blocks received from Rval messages to other follower nodes through Echo messages, restoring the received data blocks to a first transaction set based on an erasure coding algorithm after receiving N-2f Echo messages to reconstruct the merck tree of the first transaction set, broadcasting Ready messages to the blockchain after verifying that the reconstructed merck tree is consistent with the received merck tree, and restoring the received data blocks to the first transaction set based on the erasure coding algorithm after receiving 2f+1 Ready messages from different consensus nodes, wherein f is the fault tolerance number of the consensus nodes of the blockchain;
After the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responding to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
after the merck tree evidence of all the data blocks of the first transaction set completes the consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set so as to execute the block writing operation on the matched transaction.
13. A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Receiving a data block corresponding to a follower node transmitted when a leader node of a blockchain executes a RBC protocol, wherein the data block corresponding to the follower node is obtained by the leader node executing a reliable broadcast transmission RBC protocol on a first transaction set in a transaction pool of the leader node, splitting the first transaction set into N data blocks corresponding to consensus nodes of the blockchain by using an erasure coding algorithm, and transmitting the N data blocks to the follower node based on Rval messages;
Executing the RBC protocol, forwarding corresponding data blocks received from Rval messages to other follower nodes through Echo messages, restoring the received data blocks to a first transaction set based on an erasure coding algorithm after receiving N-2f Echo messages to reconstruct the merck tree of the first transaction set, broadcasting Ready messages to the blockchain after verifying that the reconstructed merck tree is consistent with the received merck tree, and restoring the received data blocks to the first transaction set based on the erasure coding algorithm after receiving 2f+1 Ready messages from different consensus nodes, wherein f is the fault tolerance number of the consensus nodes of the blockchain;
After the leader node performs a replication and fault tolerant RAFT protocol on the merck tree certificates for all data blocks of the first transaction set to initiate a consensus proposal for the merck tree certificates for all data blocks of the first transaction set, responding to the consensus proposal based on the RAFT protocol to complete a consensus for the merck tree certificates for all data blocks of the first transaction set;
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, matching the transaction corresponding to the merck tree evidence achieving the consensus from the restored first transaction set so as to execute block writing operation on the matched transaction;
After the merck tree evidence of all the data blocks of the first transaction set completes consensus, the follower node matches the transaction corresponding to the merck tree evidence achieving consensus from the restored first transaction set so as to execute block writing operation on the matched transaction.
CN202111124497.4A 2021-09-24 2021-09-24 A consensus method, consensus node and electronic device for blockchain Active CN113873030B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111124497.4A CN113873030B (en) 2021-09-24 2021-09-24 A consensus method, consensus node and electronic device for blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111124497.4A CN113873030B (en) 2021-09-24 2021-09-24 A consensus method, consensus node and electronic device for blockchain

Publications (2)

Publication Number Publication Date
CN113873030A CN113873030A (en) 2021-12-31
CN113873030B true CN113873030B (en) 2024-12-10

Family

ID=78993977

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111124497.4A Active CN113873030B (en) 2021-09-24 2021-09-24 A consensus method, consensus node and electronic device for blockchain

Country Status (1)

Country Link
CN (1) CN113873030B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338695B (en) * 2022-03-10 2022-05-24 深圳艾灵网络有限公司 Leader election method, device, equipment and storage medium based on multiple copies
CN115208881B (en) * 2022-06-02 2024-03-26 哈尔滨工业大学(深圳) Blockchain consensus methods, equipment and storage media
CN114996027A (en) * 2022-08-02 2022-09-02 深圳百纳维科技有限公司 Algorithm for consensus of Baina sea chain block chains

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109345386A (en) * 2018-08-31 2019-02-15 阿里巴巴集团控股有限公司 Transaction common recognition processing method and processing device, electronic equipment based on block chain
CN111526217A (en) * 2020-07-03 2020-08-11 支付宝(杭州)信息技术有限公司 Consensus method and system in block chain

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108243241B (en) * 2017-11-10 2019-10-15 杭州复杂美科技有限公司 A kind of storage mode of block chain transaction and queueing form
CN109379397B (en) * 2018-08-31 2019-12-06 阿里巴巴集团控股有限公司 Transaction consensus processing method and device based on block chain and electronic equipment
CN110599174B (en) * 2019-09-20 2023-11-24 腾讯科技(深圳)有限公司 Block chain information processing method and related equipment
CN112019599A (en) * 2020-03-16 2020-12-01 支付宝(杭州)信息技术有限公司 Method and device for synchronizing processing messages during block chain consensus processing
CN111522822A (en) * 2020-07-03 2020-08-11 支付宝(杭州)信息技术有限公司 Block chain consensus method and device and electronic equipment
CN111526218B (en) * 2020-07-03 2020-09-22 支付宝(杭州)信息技术有限公司 Consensus method and system in alliance chain
CN111526219B (en) * 2020-07-03 2021-02-09 支付宝(杭州)信息技术有限公司 Alliance chain consensus method and alliance chain system
CN112788137A (en) * 2021-01-06 2021-05-11 平衡机器科技(深圳)有限公司 Alliance chain consensus method based on RAFT algorithm
CN112465515B (en) * 2021-01-28 2022-02-25 支付宝(杭州)信息技术有限公司 Block chain consensus method, consensus node and electronic equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109345386A (en) * 2018-08-31 2019-02-15 阿里巴巴集团控股有限公司 Transaction common recognition processing method and processing device, electronic equipment based on block chain
CN111526217A (en) * 2020-07-03 2020-08-11 支付宝(杭州)信息技术有限公司 Consensus method and system in block chain

Also Published As

Publication number Publication date
CN113873030A (en) 2021-12-31

Similar Documents

Publication Publication Date Title
EP3934165B1 (en) Consensus method of consortium blockchain, and consortium blockchain system
CN113873030B (en) A consensus method, consensus node and electronic device for blockchain
CN113852691B (en) Block chain consensus method, consensus node and electronic equipment
CN113849564B (en) Block chain consensus method, consensus node and electronic equipment
US11614867B2 (en) Distributed storage system-based data processing method and storage device
CA2751358C (en) Distributed storage of recoverable data
WO2020151323A1 (en) Data slicing-based data storage method, device, and medium
CN106776130B (en) A log recovery method, storage device and storage node
US20160006461A1 (en) Method and device for implementation data redundancy
CN109783014B (en) A method and device for storing data
WO2014121593A1 (en) Distributed storage method, device and system
CN112835743A (en) Distributed account book data storage optimization method and device, electronic equipment and medium
CN114900532B (en) Power data disaster recovery method, system, device, computer equipment and storage medium
CN103530206B (en) A kind of method and apparatus of date restoring
CN113761069B (en) A consensus method, system, node and electronic device for blockchain
CN113872961B (en) Block chain consensus method, consensus node and electronic equipment
CN113760519B (en) Distributed transaction processing method, device, system and electronic equipment
WO2024146186A1 (en) Data storage method and apparatus, and computer device and non-volatile readable storage medium
CN112860488B (en) Object recovery method and device, electronic equipment and storage medium
Ren et al. An Improved Raft Protocol Combined with Cauchy Reed-Solomon Codes
CN117271228A (en) Consistency algorithm in rack server environment
KR102835086B1 (en) System, apparatus, and method for storing byzantine fault tolerant block data utilizing external storage
CN119759640A (en) A storage optimization method based on erasure coding for decentralized storage systems
CN118567903A (en) Data processing method and device
CN116248693A (en) Light-weight operation method and device for Raft consensus algorithm of block chain

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant