CN110517141B - Consensus method and device based on block chain system - Google Patents

Consensus method and device based on block chain system Download PDF

Info

Publication number
CN110517141B
CN110517141B CN201910798196.6A CN201910798196A CN110517141B CN 110517141 B CN110517141 B CN 110517141B CN 201910798196 A CN201910798196 A CN 201910798196A CN 110517141 B CN110517141 B CN 110517141B
Authority
CN
China
Prior art keywords
block
consensus
node
round
information
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
CN201910798196.6A
Other languages
Chinese (zh)
Other versions
CN110517141A (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.)
WeBank Co Ltd
Original Assignee
WeBank 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 WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN201910798196.6A priority Critical patent/CN110517141B/en
Publication of CN110517141A publication Critical patent/CN110517141A/en
Priority to PCT/CN2020/106623 priority patent/WO2021036702A1/en
Application granted granted Critical
Publication of CN110517141B publication Critical patent/CN110517141B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention discloses a consensus method and a consensus device based on a block chain system, wherein the method comprises the following steps: in the block consensus of the I round, a first node receives the consensus information of an M-th block to be consensus sent by a second node, and if the first node is determined to be a main node of the block consensus of the I+1 round, the consensus information of the M+1-th block to be consensus is generated in parallel when the M-th block is consensus according to the consensus information of the M-th block. In the embodiment of the invention, the master node of the I+1st round of block consensus is started in the execution process of the I round of block consensus, so that the master node of the I+1st round of block consensus automatically packages the M+1st block, the parallel execution of the consensus process of the I round of block consensus and the block packaging process of the I+1st round of block consensus is realized, the operation time of the I+1st round of block consensus is shortened, and the consensus efficiency of a block chain system can be improved.

Description

Consensus method and device based on block chain system
Technical Field
The invention relates to the technical field of financial science (Fintech), in particular to a consensus method and device based on a blockchain system.
Background
With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changed to the financial technology (Fintech), and the blockchain technology is not exceptional, but because of the requirements of safety and real-time performance of the financial industry, the technology is also required to be higher. In a blockchain system, in order to ensure the accuracy of transaction execution, a plurality of nodes are generally required to be used for consensus on the blocks, and if the number of the nodes for consensus on the blocks exceeds a preset number, the blocks obtained by processing the transaction by most nodes in the blockchain system are consistent; thus, the block can be successfully exported, and the node can update the internal transaction database according to the block.
The PBFT consensus algorithm is a common consensus algorithm in the prior art, in the PBFT consensus algorithm, after the block chain system performs a round of block consensus (that is, the block is successfully obtained by the previous round of block consensus), the PBFT consensus algorithm can select a master node from a plurality of nodes of the block chain system, and the master node is used for acquiring the transaction data to be processed in the block consensus of the current round, packaging the original block according to the transaction data to be processed in the block consensus of the current round, and then sending the packaged original block to other nodes in the block chain system. Accordingly, in the block consensus of the present round, each node (including the master node) in the blockchain system can process the transaction based on the original blocks packed by the master node to obtain the target block, and then the target block is consensus with other nodes in the blockchain system, if the target block consensus is successful, the block is successfully removed, and the block consensus of the present round is completed, so that the PBFT consensus algorithm can select the master node of the next round of block consensus from a plurality of nodes again, and execute the next round of block consensus process. It can be seen that, by adopting the PBFT consensus algorithm, each round of block consensus is performed independently, that is, the next round of block consensus needs to wait for the completion of the execution of the block consensus to start to execute, thereby resulting in lower consensus efficiency of the blockchain system.
In summary, there is a need for a blockchain-based consensus method to solve the technical problem of low consensus efficiency of the blockchain system caused by the fact that the existing blockchain system sequentially executes each round of blockchain consensus.
Disclosure of Invention
The embodiment of the invention provides a block chain system-based consensus method, which is used for solving the technical problem of low consensus efficiency of a block chain system caused by the fact that the existing block chain system sequentially executes each round of block consensus.
In a first aspect, an embodiment of the present invention provides a block chain system-based consensus method, including:
in the block consensus of the I round, a first node receives the consensus information of an M-th block to be consensus sent by a second node, wherein the consensus information of the M-th block comprises first transaction data to be processed in the block consensus of the I round, and the second node is a main node of the block consensus of the I round; further, if the first node determines that the first node is the master node for the block consensus of the (i+1) -th round, when the M-th block is subjected to consensus according to the consensus information of the M-th block, the first node generates the consensus information of the m+1-th block to be subjected to consensus in parallel; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data; wherein I, M is a positive integer.
In the design, the main node of the I+1 round block consensus is started in the execution process of the I round block consensus, so that the main node of the I+1 round block consensus automatically packs blocks, the consensus process of the I round block consensus and the block packing process of the I+1 round block consensus can be executed in parallel, the operation time of the I+1 round block consensus is shortened, and the consensus efficiency of a block chain system is improved.
In one possible design, the first node generates the consensus information of the m+1th block to be consensus in parallel, including: the first node obtains second transaction data except the first transaction data from a transaction pool of the first node, sets the block height of the M+1st block according to the block height of the M th block, and generates consensus information of the M+1st block according to the second transaction data, the block height of the M+1st block and the current timestamp.
In the design, the second transaction data except the first transaction data to be processed in the I-th round of block consensus is obtained from the transaction pool, and the second transaction data is used as the block body of the M+1-th block, so that the repeated processing of the I-th round of block consensus by the I+1-th round of block consensus can be avoided, and the accuracy of transaction processing when the I-th round of block consensus and the I+1-th round of block consensus are executed in parallel is ensured; and, when the block consensus of the ith round and the block consensus of the (i+1) th round are executed in parallel, although the historical maximum block of the second node is the (M-1) th round, by setting the block height of the (m+1) th round of block consensus of the (i+1) th round according to the block height of the (M) th round of block to be consensus in the block consensus of the (I) th round, the second node can accurately generate the block header corresponding to the block consensus process of the (i+1) th round, thereby enabling the block consensus of the (I) th round and the block consensus of the (i+1) th round to be executed in parallel.
In one possible design, after the first node generates the common identification information of the m+1th block to be commonly identified in parallel, if it is determined that the common identification result of the I-th round of block common identification is that the common identification is successful, the hash value of the M-th block is added to the common identification information of the m+1th block, and the common identification information of the m+1th block is sent to other nodes in the blockchain system.
In the design, after the block consensus of the I round is successful, the complete M+1 block can be assembled in the block consensus of the I+1 round by adding the hash value of the M block to be consensus in the block consensus of the I round into the M+1 block to be consensus in the block consensus of the I+1 round, so that the association relation between the M block and the M+1 block is accurately established, and the sequential progress of the block consensus process and the integrity of a block chain are ensured.
In one possible design, after the first node generates the consensus information of the m+1th block to be consensus in parallel, if it is determined that the consensus result of the I-th round of block consensus is that the consensus fails, the first transaction data is obtained from the transaction pool of the first node, and the block height of the M-th block is set according to the block height of the largest historical block; further, the first node generates consensus information of the mth block according to the first transaction data, the block height of the mth block, the hash value of the historical maximum block and the current timestamp, and sends the consensus information of the mth block to other nodes in the blockchain system.
In the design, after the block consensus of the first round fails, the first node is used for reassembling the M-th block to be consensus and executing the consensus process on the M-th block, so that the problem that the block to be consensus in the block consensus of the previous round is omitted due to the failure of the block consensus of the previous round when the two rounds of block consensus processes are processed in parallel can be avoided, and the accuracy of the block chain system consensus is ensured.
In one possible design, the first node determines that the first node is the master node for the i+1st round of block consensus by: and the first node determines the number of the main node which is commonly recognized by the I+1st round of blocks according to the block height of the Mth block and the node number of the blockchain system, and if the identification of the first node is matched with the number of the main node which is commonly recognized by the I+1st round of blocks, the first node is determined to be the main node which is commonly recognized by the I+1st round of blocks.
In the design, for any node in the blockchain system, the number of the main node of the I+1st round of block consensus is automatically matched by using the identification of the node, whether the node is the main node of the I+1st round of block consensus is determined, and when the node is successfully matched, the node can be called to automatically package the M+1st block to be consensus in the I+1st round of block consensus, so that the automatic parallel execution of the I+1st round of block consensus and the I round of block consensus can be ensured, and the accuracy of the blockchain system consensus is improved.
In a second aspect, an embodiment of the present invention provides a block chain system based consensus apparatus, the apparatus comprising:
the receiving and transmitting module is used for receiving the consensus information of the M-th block to be consensus sent by the second node in the I-th block consensus, wherein the consensus information of the M-th block comprises first transaction data to be processed in the I-th block consensus, and the second node is a main node of the I-th block consensus; wherein I, M is a positive integer;
the generating module is used for generating the consensus information of the M+1th block to be consensus in parallel when the M block is consensus according to the consensus information of the M block if the first node is determined to be the main node of the I+1th round block consensus; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data.
In one possible design, the generating module is specifically configured to: and acquiring second transaction data except the first transaction data from a transaction pool of the first node, setting the block height of the M+1st block according to the block height of the M th block, and generating the consensus information of the M+1st block according to the second transaction data, the block height of the M+1st block and the current timestamp.
In one possible design, after the generating module generates the consensus information of the m+1th block to be consensus in parallel, the transceiver module is further configured to: if the common identification result of the block identification of the I round is determined to be successful, adding the hash value of the M block into the common identification information of the M+1st block, and sending the common identification information of the M+1st block to other nodes in the block chain system.
In one possible design, the generating module is further configured to: if the consensus result of the block consensus of the I round is determined to be failure, acquiring the first transaction data from a transaction pool of the first node, and setting the block height of the M-th block according to the block height of the largest historical block; further, generating the consensus information of the Mth block according to the first transaction data, the block height of the Mth block, the hash value of the historical maximum block and the current time stamp, and sending the consensus information of the Mth block to other nodes in the blockchain system.
In one possible design, the generating module is specifically configured to: and determining the number of the primary node of the I+1st round of block consensus according to the block height of the M-th block and the node number of the blockchain system, and if the identification of the first node is matched with the number of the primary node of the I+1st round of block consensus, determining that the first node is the primary node of the I+1st round of block consensus.
In a third aspect, an embodiment of the present invention further provides a computing device, including at least one processing unit and at least one storage unit, where the storage unit stores a computer program, and when the program is executed by the processing unit, causes the processing unit to perform the blockchain system-based consensus method of any of the first aspect above.
In a fourth aspect, embodiments of the present invention also provide a computer readable storage medium storing a computer program executable by a computing device, the program when run on the computing device causing the computing device to perform the blockchain system-based consensus method of any of the first aspects above.
These and other aspects of the invention will be more readily apparent from the following description of the embodiments.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments will be briefly described below, it will be apparent that the drawings in the following description are only some embodiments of the present invention, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a block chain system architecture diagram according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart corresponding to a transaction processing using a PBFT consensus algorithm according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart corresponding to a block chain system-based consensus method according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of performing block consensus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a consensus device based on a blockchain system according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The technical field of financial science (Fintech) generally relates to various transactions, for example, a transaction of a bank may include a card selling transaction, a deposit transaction, a loan transaction, an insurance transaction, a financial transaction, etc., and the daily transaction amount of the bank may reach thousands or even tens of thousands. With the development of blockchain technology, the financial science and technology field can also use blockchain technology to process transactions, for example, if related transactions are related among a plurality of banks, related transactions can be synchronously processed by setting a alliance chain, or courts, clients and the like can be simultaneously and uplink to jointly maintain the security and stability of the alliance chain.
The blockchain system may be a point-To-point (P2P) network consisting of a plurality of nodes. P2P is an application layer protocol that runs on top of the transmission control protocol (Transmission Control Protocol, TCP) protocol, nodes in a blockchain system can peer to each other, there is no central node in the system, and thus each node can randomly connect to other nodes. In the blockchain system, a preset database can be arranged in each node, each node maintains a public account book in the blockchain system through the preset database, and the preset database in the node can store the block data in the blockchain system; the block data comprises a block header and a block body, the block header comprises information such as a hash value of the previous block, a hash value of the current block, a block height of the current block, a time stamp and the like, and the block body comprises transaction data, such as transaction data generated by processing a transaction to be processed in the process of carrying out consensus on the block by a node in a block chain system.
Fig. 1 is a schematic diagram of a block chain system according to an embodiment of the present invention, where, as shown in fig. 1, the block chain system may include one or more nodes, such as a node 101, a node 102, a node 103, and a node 104, and any two of the nodes 101 to 104 may be communicatively connected, so as to jointly maintain the block chain system. Any two nodes may be connected by a wired manner or may also be connected by a wireless manner, which is not particularly limited.
In the embodiment of the invention, the nodes in the blockchain system can have various functions, such as a routing function, a transaction function, a blockchain function, a consensus function and the like. Specifically, the nodes in the blockchain system can transmit the transaction data and other information transmitted by other nodes to more nodes so as to realize the communication between the nodes; alternatively, nodes in the blockchain system may be used to support transactions by users; alternatively, nodes in the blockchain system may be used to record all transactions historically; alternatively, nodes in the blockchain system may generate new blocks in the blockchain by validating and recording transactions. In practice, the routing function is a function that each node in the blockchain system must have, and other functions can be set by those skilled in the art according to actual needs.
It should be noted that a node in the blockchain system may be on a physical machine (server), and a node may specifically refer to a process or a series of processes running in the server. For example, node 101 in the blockchain network may be a process running on a server, or may refer to a server, which is not limited in particular.
As shown in fig. 1, a client device 200 may also be included in the system architecture, and the client device 200 may connect with any node in the blockchain system through an access blockchain network. In implementations, the client device 200 may send a transaction to any node in the blockchain system, and a node in the blockchain system may synchronize the transaction to other nodes in the blockchain system after receiving the transaction. After synchronous transaction, the node can store the transaction in a transaction pool inside the node; accordingly, other nodes may also store transactions in a transaction pool internal to the other nodes after receiving the node synchronized transactions. Thus, if a certain node determines to process a plurality of transactions, the plurality of transactions can be obtained from the internal transaction pool, and further subsequent transaction processing and block consensus can be performed.
Wherein the transactions may be stored in a transaction pool in a stack; thus, if a certain node determines to process a plurality of transactions, the earliest stacked plurality of transactions can be obtained from the internal transaction pool to carry out subsequent processing and consensus process.
Based on the system architecture illustrated in fig. 1, fig. 2 is a schematic flow diagram corresponding to the processing of a transaction by using a PBFT consensus algorithm according to an embodiment of the present invention, and as shown in fig. 2, a process of processing a transaction by using the PBFT consensus algorithm may be divided into three stages: pre-preparation phase, preparation phase and commit phase. The following describes the implementation of the three phases respectively.
pre-preparation stage
After each round of block consensus is successfully executed, a node can be selected from a plurality of nodes of the block chain system to be used as a master node, and other nodes are used as slave nodes by adopting a PBFT consensus algorithm; the successful execution of a round of block consensus may be determined in various manners, for example, if it is detected that a history block is newly added to the memory of the node, it may be considered that a round of block consensus is successfully executed, or if it is detected that the node updates an internal preset database, it may be considered that a round of block consensus is successfully executed, or the like.
The PBFT consensus algorithm can select different nodes from a plurality of nodes of the block chain system in turn to serve as main nodes; specifically, a window value v may be set in each node, if the previous round of block consensus execution succeeds, the window value v in each node may be set to zero, and if the previous round of block consensus execution fails, the window value v in each node is incremented (i.e. added with 1). Correspondingly, if each node detects that a history block is newly added in the memory of the node or detects that the node updates an internal preset database, the number of the master node of the next round of block consensus can be determined according to the following formula:
leader=(h+v)%n
Wherein, leader is the number of the master node of the next round of block consensus, h is the block height of the block to be consensus, v is window value, and n is the number of nodes in the blockchain system.
In one example, each node may send the number of the determined master node to other nodes in the blockchain system, and if the number of nodes passing through the number consensus for a certain master node is greater than a preset number, the node corresponding to the number may be used as the master node for the next round of blocky consensus. In another example, after each node determines the number of the master node, if its own node identifier matches the number of the master node, the node automatically serves as the master node for the next round of block consensus; if the node identification of the node is not matched with the number of the master node, the node can be used as a slave node, and the next round of block consensus is waited to be executed without any processing.
For example, table 1 is a schematic table of the correspondence between node identifiers and numbers of master nodes according to an embodiment of the present invention.
Table 1: schematic representation of correspondence between node identification and number of master node
Numbering of master nodes Node identification
0 Node 101
1 Node 102
2 Node 103
3 Node 104
As shown in table 1, if the number of the master node determined by the node is 0, the node 101 may be used as the master node for the next round of block consensus, and the nodes 102, 103 and 104 may be used as the slave nodes for the next round of block consensus; if the number of the master node determined by the node is 1, the node 102 can be used as the master node for the next round of block consensus, and the node 101, the node 103 and the node 104 can be used as the slave nodes for the next round of block consensus; if the number of the master node determined by the node is 2, using the node 103 as a master node for the next round of block consensus, and using the node 101, the node 102 and the node 104 as slave nodes for the next round of block consensus; if the number of the master node determined by the node is 3, the node 104 is used as the master node of the next round of block consensus, and the nodes 101, 102 and 103 are used as the slave nodes of the next round of block consensus.
For example, if the master node of the previous round of block consensus is node 102 and a new history block 1 is stored in the memory of node 101, window value v is set to zero, and the number of nodes in the blockchain system is 4, so that the number of the master node determined by node 101 (or nodes 102 to 104) using the above formula is 2; based on table 1, it can be seen that the master node of the next round of block consensus can be node 103, and the master node 103 is used to perform the block 2 consensus. Correspondingly, if the node 102 does not respond for a long time, the largest history block in the memory of the node is still 0, and since the previous round of block consensus fails, the window value v is incremented to 1, so that the number of the master node determined by the node 101 (or the nodes 102 to 104) using the above formula is 2, that is, the master node of the next round of block consensus may be the node 103, and the master node 103 is used to execute the block 1 consensus; further, if the node 103 does not respond for a long time, the largest history block in the memory of the node 103 is still 0, and the window value v is incremented to 2 due to failure of the previous round of block consensus, so that the number of the master node determined by the node 101 (or the nodes 102 to 104) using the above formula is 3, i.e. the master node of the next round of block consensus may be the node 104, and the master node 104 is used to perform the block 1 consensus.
In the pre-preparation stage, if a main node of a round of block consensus is node 101 and a maximum block stored in a memory of node 101 is block 1, main node 101 may obtain transaction data to be processed of the round of block consensus from a transaction pool of main node 101, and generate a pre-preparation packet according to a transaction data packing block 2 to be processed of the round of block consensus. Specifically, the master node 101 may assemble the block header of the block 2 using the hash value of the block 1, the block height of the block 2, and the current timestamp, and may assemble the block body of the block 2 using the round of block consensus transaction data to be processed, and may generate the pre-preparation packet according to the block header and the block body of the block 2. Further, master node 101 may send a pre-prepare packet to any node in the blockchain system, namely node 102, node 103, and node 104.
To this end, the pre-preparation phase execution ends.
preparation stage
In the preparation stage, after any node in the blockchain system receives the pre-preparation packet sent by the master node 101, the pre-preparation packet can be parsed to obtain transaction data to be processed by the round of blockjoint consensus; thus, the node can execute the round of block consensus to the transaction data to be processed to obtain a transaction result. Further, the node may generate a first hash value according to the transaction result, generate a second hash value according to receipt information of each transaction, generate a third hash value according to the request message of the transaction, and further assemble the first hash value, the second hash value and the third hash value into the block header of the block 2, and may generate the hash value of the block 2 according to the data in the block header of the block 2. Thus, the node can assemble the hash value of the block 2 and the transaction data processed by the round of block consensus into the block body of the block 2, and generate the signature packet of the node to the block 2 by using the private key of the node, the hash value of the block 2, the block height, the identification of the node and other information, so that the signature packet of the node can be sent to other nodes in the block chain system.
So far, the preparation phase execution ends.
At the commit stage
In the commit phase, public keys of all nodes in the blockchain system can be stored in any node in the blockchain system, so that after determining that signature packets sent by other nodes reach the node, any node can acquire the public keys of other nodes from the inside of the node, and decrypt the signature packets of other nodes by using the public keys of other nodes to obtain hash values of the block 2 determined by processing transactions by other nodes. Further, any node may compare the hash value of the block 2 determined by processing the transaction with the hash value of the block 2 determined by processing the transaction by any other node, if the hash value is the same, the signature packet sent by the other node may be received, and if the hash value is different, the signature packet sent by the other node may be rejected.
For any node in the blockchain system, if that nodeIf the number of signature packets received by the point within the timeout period is smaller than the preset threshold, the node considers that the block consensus of the current round fails, and the node can initiate view switching, i.e. increment the internal window value v (for example, if the original window value is 1, the window value after increment is 2). Correspondingly, if the number of signature packets received by the node within the timeout period is greater than or equal to a preset threshold value, the block 2 obtained by processing the transaction by the node is the same as the block 2 obtained by processing the transaction by other most nodes in the blockchain system, and the block 2 generated by the node is in a state to be submitted; in this way, the node may generate a commit packet for the node to the block 2 using the private key of the node, the hash value of the block 2, the block height, the identifier of the node, and the like, and may send the commit packet to other nodes in the blockchain system, where the commit packet is used to indicate that the node is in a state to be committed. Wherein the preset threshold is calculated according to the total number n of identified nodes in the blockchain system, and the calculation formula is that
Figure BDA0002181548860000111
For example, when n is 8, the preset threshold is 5, if the node receives 4 signature packets in the preparation stage, it is indicated that the node fails in the current round of block consensus, so the node may initiate view switching; if the node receives 6 signature packets in the preparation stage, it is indicated that the block 2 obtained by processing the transaction by the node is the same as the block 2 obtained by processing the transaction by other most of the consensus nodes in the blockchain system, so that the node can generate a commit packet.
Further, after determining that the commit packet sent by other nodes reaches the node, any node in the blockchain system may parse the commit packet of the other nodes to obtain a hash value of the block 2 determined by each other node for processing the transaction; thus, the node can compare the hash value of the block 2 determined by processing the transaction with the hash value of the block 2 determined by processing the transaction by any other node, if the hash value is the same, the node can receive the commit packet sent by the other node, and if the hash value is different, the node can reject the commit packet sent by the other node. Correspondingly, if the number of the commit packets received by the node within the timeout period is smaller than a preset threshold, the node considers that the block consensus of the round fails, and the node can initiate view switching; correspondingly, if the number of commit packets received by the node within the timeout period is greater than or equal to the preset threshold, the block 2 obtained by the node processing the transaction is the same as the block 2 obtained by the transaction processed by most other nodes in the blockchain system, so that the node can acquire the block 2 generated by the node processing the transaction from the memory, and can write the block 2 into the preset database in the node, thereby completing the round of block consensus.
So far, the commit phase execution ends.
In summary, in the process of executing multi-round block consensus, after the PBFT consensus algorithm determines a main node of the block consensus of the round from a plurality of nodes of the block chain system, executing block packing of the block consensus of the round by using the main node of the block consensus of the round, and after each node in the block chain system executes a pre-preparation stage, a preparation stage and a commit node, determining that the block consensus of the round is finished; further, the PBFT consensus algorithm determines a master node of the next round of block consensus from a plurality of nodes of the blockchain system, uses the master node of the next round of block consensus to execute block packing of the next round of block consensus, and determines that the next round of block consensus is finished after each node in the blockchain system executes a pre-preparation stage, a preparation stage and a commit node; the above process is repeatedly performed until no transaction data to be processed exists in the transaction pool.
Therefore, the PBFT consensus algorithm can sequentially execute each round of block consensus, namely, the next round of block consensus is started after the last round of block consensus is finished, and by adopting the mode, the transaction processing can be better performed in a block chain system with smaller transaction amount. However, in the field of financial technology, thousands or even tens of thousands of transactions may be generated per second, resulting in very much transaction data to be processed in a blockchain system in the field of financial technology, if each round of block consensus is performed sequentially using the PBFT consensus algorithm, a lot of time may be required, resulting in very low efficiency of transaction processing, and even blocking of transactions, thereby bringing a huge loss to the financial field.
Based on the above, the embodiment of the invention provides a block chain system-based consensus method, which is used for solving the technical problem that the consensus efficiency and transaction processing efficiency of the block chain system are low due to the fact that the existing block chain system sequentially executes each round of block consensus.
Based on the blockchain system shown in fig. 1 and the PBFT consensus algorithm described in fig. 2, fig. 3 is a schematic flow diagram corresponding to a blockchain system-based consensus method according to an embodiment of the present invention, where the method includes:
step 301, in the round I block consensus, a first node receives the consensus information of the M-th block to be consensus sent by a second node; the common identification information of the Mth block comprises first transaction data to be processed in the I-th round block common identification, and the second node is a master node of the I-th round block common identification.
In the embodiment of the invention, if the M-1 block to be identified in the I-1 round of block identification is successfully written into a preset database of a node in a block chain system, the I-1 round of block identification can be determined to be successful; thus, if the primary node of the first round of block consensus is the second node, the second node may send the consensus information of the mth block to be consensus in the first round of block consensus to other nodes in the blockchain system. The generation manner of the consensus information of the mth block may be various, and two possible implementation manners are respectively described below:
In one possible implementation, the consensus information of the mth block may be generated by the second node after the I-1 round of block consensus is successful; specifically, after the success of the I-1 th round of block consensus is determined, the second node may obtain first transaction data to be processed in the I-th round of block consensus from a memory pool of the second node, and may use the first transaction data to assemble a block body of the M-th block, set a block height of the M-th block according to a block height of the M-th block, and use a block height of the M-th block, a hash value of the M-1 th block and a current timestamp to assemble a block header of the M-th block, so as to generate consensus information of the M-th block according to the block header of the M-th block and a block body of the M-th block.
For example, based on the blockchain system illustrated in fig. 1, if the I-1 round of block consensus is successful and the blockheight of the block with the largest history in the blockchain system at the current time is 1, therefore, the block to be consensus in the I-round of block consensus is block 2, when the I-round of block consensus is started, the window value v=0, the node number n=4, the block height h=2, and the master node of the I-round of block consensus is node 103 based on table 1; in this way, the node 103 may obtain the first transaction data to be processed in the I-th round of block consensus from the transaction pool set inside, and may assemble the block header of the block 2 using the block height of the block 2, the hash value of the block 1, and the current timestamp, assemble the block of the block 2 using the first transaction data, and further generate the pre-preparation packet using the block header of the block 2 and the block body of the block 2.
In another possible implementation manner, the common information of the mth block may be generated by the second node in the process of the mth round of block common identification, for example, after the second node receives the common information of the mth round of block, if the second node is determined to be the master node of the mth round of block common identification, the common information of the mth block may be generated in parallel according to the common information of the mth round of block common identification in the process of participating in the mth round of block common identification. It should be noted that, this implementation may be specifically implemented with reference to the process of generating the common information of the m+1th block in step 301 and step 302, which is not described herein again.
In one example, the common information for the Mth block may include a block height of the Mth block, a hash value of the M-1 th block, a generation time stamp of the Mth block, and first transaction data. The first transaction data may include transaction data of one transaction, or may also include transaction data of a plurality of transactions (i.e. two or more transactions), which is not limited in particular.
Step 302, if the first node determines that the first node is the master node for the block consensus of the i+1st round, the first node generates the consensus information of the m+1st block to be consensus in parallel when the M block is consensus according to the consensus information of the M block; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data.
In the embodiment of the invention, after each node in the block chain system receives the common identification information of the Mth block sent by the second node, the common identification information of the Mth block can be analyzed to obtain the block height of the Mth block, the hash value of the M-1 th block, the generation time stamp of the Mth block and the first transaction data. Further, for each node in the blockchain system, the node may determine, according to the block height of the mth block and the node data in the blockchain system, whether the node is a master node of the i+1st round of block consensus, if not, the node may directly participate in the I-th round of block consensus process, and if so, the node may generate, in parallel, the consensus information of the m+1st block to be consensus in the i+1st round of block consensus when participating in the I-th round of block consensus.
As an example, a node may determine whether the node is the master node for round i+1 block consensus based on the following formula and table 1:
leader I+1 =(h M +1)%n
wherein, leader I+1 Numbering of master node commonly known for the I+1st round of block, h M Block height for the mth block, n is the number of total identified nodes in the blockchain system.
For example, if the mth block is block 2 and the primary node of the I-th round block consensus is node 103, after receiving the pre-preparation packet of block 2 sent by node 103, node 101, node 102 and node 104 may determine the number of the primary node of the i+1-th round block consensus by using the above formula, respectively. For the nodes 101, 102 and 103, since the number of the master node determined by the above formula is 3 and the node corresponding to the master node with the number of 3 is determined to be the node 104 according to table 1, the nodes 101, 102 and 103 can continue to execute the round I block consensus process; accordingly, for the node 104, since the number of the master node determined by the above formula is 3, and the node corresponding to the master node with the number of 3 is determined to be the node 104 according to table 1, the node 104 may generate the pre-preparation packet of the block 3 in parallel in the process of executing the round I block consensus.
In the embodiment of the invention, aiming at any node in the blockchain system, the identification of the node is used for automatically matching the number of the main node of the I+1st round of block consensus, so that whether the node is the main node of the I+1st round of block consensus can be determined, and when the node is successfully matched, the node can be called to automatically package the M+1st block to be consensus in the I+1st round of block consensus, thereby ensuring the automatic parallel execution of the I+1st round of block consensus and the I round of block consensus and improving the accuracy of the blockchain system consensus.
Taking the node 101 as an example, after determining that the primary node is not the i+1st round of block consensus, the node 101 may process the first transaction data to obtain a processing result of the first transaction data, generate a first hash value according to the processing result of the first transaction data, generate a second hash value according to the first transaction data, generate a third hash value according to a receipt of executing each transaction in the first transaction data, and further calculate the first hash value, the second hash value and the third hash value by using a preset hash algorithm to obtain a hash value of the block 2. Further, the node 101 may assemble the first hash value, the second hash value, the third hash value, and the hash value of the block 2 into the block header of the block 2, and may assemble the hash value of the block 2 and the first transaction data into the block of the block 2, generate a signature packet of the node 101 for the block 2 using the private key of the node 101, the hash value of the block 2, the height of the block 2, the identifier of the node 101, and the like, and further send the signature packet of the node 101 for the block 2 to the node 102, the node 103, and the node 104; and, node 101 may wait for signature packets sent by node 102, node 103, and node 104, respectively, and may continue to perform the commit phase in round I block consensus according to the number of received signature packets.
Accordingly, there may be various ways in which the node 104 generates the pre-preparation packet of the block 3 in parallel during the process of executing the round I block consensus, for example, the node 104 may first execute the preparation phase to obtain the signature packet of the node 104 to the block 2, send the signature packet of the node 104 to the block 2 to the node 101, the node 102 and the node 103, and then generate the pre-preparation packet of the block 3 according to the pre-preparation packet of the block 2 while waiting for the signature packets sent by the node 101, the node 102 and the node 103; or after receiving the common identification information of the block 2 sent by the node 103, generating a pre-preparation packet of the block 3 according to the pre-preparation packet of the block 2, and generating a signature packet of the node 104 on the block 2 according to the pre-preparation packet of the block 2 sent by the node 103; or the preparation stage and the commit stage may be performed first to obtain a commit packet of the node 104 to the block 2, and the commit packet of the node 104 to the block 2 may be sent to the node 101, the node 102 and the node 103, and then, when waiting for the commit packet sent by the node 101, the node 102 and the node 103, the pre-preparation packet of the block 3 is generated according to the pre-preparation packet of the block 2; and the like, and is not particularly limited.
In one possible implementation, the node 104 may generate the pre-preparation packet for block 3 as follows: the node 104 may parse the pre-preparation packet of the block 2 to obtain the block height of the block 2 and the first transaction data, and then may set the block height of the block 3 according to the block height of the block 2, and may obtain the second transaction data except the first transaction data from the transaction pool of the node 104; further, the node 104 may use the block height of the block 3 and the current timestamp to assemble a block header of the block 3, and may use the second transaction data to assemble a block body of the block 3, so as to generate a pre-preparation packet of the block 3 according to the block header of the block 3 and the block body of the block 3.
The pre-preparation packet may be a data packet having a preset format, and may be composed of a plurality of storage areas each for storing setting data. For example, the pre-prepare packet of the block 3 may be composed of a first storage field, a second storage field, a third storage field, and a fourth storage field, where the first storage field is used to store the block height of the block 3, the second storage field is used to store the generation timestamp of the block 3, the third storage field is used to store the hash value of the block 2, and the fourth storage field may store the transaction data (i.e., the second transaction data) to be processed in the block 3. Here, the amount of data that can be stored in the first to fourth storage fields may be set empirically by those skilled in the art, and is not limited.
In a specific implementation, after the node 104 assembles to obtain the block header of the block 3 and the block body of the block 3, the block header of the block 3 and the block body of the block 3 may be stored in the memory of the node 104, and then an initial pre-preparation packet (which may be an empty data packet) of the block 3 is generated; further, the node 104 may convert the block height of the block 3 into a preset format (such as binary) and then place the block height in the first storage field of the initial pre-preparation packet, convert the generated timestamp of the block 3 into a preset format and then place the block height in the second storage field of the initial pre-preparation packet, convert the second transaction data into a preset format and then place the block height in the fourth storage field of the initial pre-preparation packet, and since the block 2 does not complete the consensus, the third storage field of the initial pre-preparation packet may be idle; thus, node 104 may obtain the pre-preparation packet for block 3 and may store the pre-preparation packet for block 3 in memory.
In the embodiment of the invention, the second transaction data except the first transaction data to be processed in the I-th round of block consensus is obtained from the transaction pool, and the second transaction data is used as the block body of the M+1th block, so that the repeated processing of the transaction data processed by the I-th round of block consensus by the I+1th round of block consensus can be avoided, and the accuracy of transaction processing when the I-th round of block consensus and the I+1th round of block consensus are executed in parallel is ensured; and, when the block consensus of the ith round and the block consensus of the (i+1) th round are executed in parallel, although the historical maximum block of the second node is the (M-1) th round, by setting the block height of the (m+1) th round of block consensus of the (i+1) th round according to the block height of the (M) th round of block to be consensus in the block consensus of the (I) th round, the second node can accurately generate the block header corresponding to the block consensus process of the (i+1) th round, thereby enabling the block consensus of the (I) th round and the block consensus of the (i+1) th round to be executed in parallel.
Further, the node 104 may continue to perform the block 2 consensus process, such as sequentially performing a preparation phase and a commit phase, and determine whether the block 2 consensus is successful after the completion of the execution of the commit phase, if the node 104 successfully stores the block 2 consensus result in the preset database, it is determined that the block 2 consensus is successful, so the node 104 may send a pre-preparation packet of the block 3 to the node 101, the node 102 and the node 103; if the node 104 fails to store the consensus result of the block 2 in the predetermined database, it determines that the block 2 fails to be consensus, so the node 104 can re-execute the consensus process of the block 2.
In an example, after determining that the block 2 consensus is successful, the node 104 may further obtain the hash value of the block 2 from the consensus result of the block 2, convert the hash value of the block 2 into a preset format, and then add the converted hash value to the third storage field of the pre-preparation packet of the block 3, thereby obtaining the target pre-preparation packet of the block 3, and further send the target pre-preparation packet of the block 3 to the node 101, the node 102 and the node 103.
In the embodiment of the invention, after the block consensus of the I round is successful, the complete M+1 block can be assembled in the block consensus of the I+1 round by adding the hash value of the M block to be consensus in the block consensus of the I round into the M+1 block to be consensus in the block consensus of the I+1 round, so that the association relation between the M block and the M+1 block is accurately established, and the sequential progress of the block consensus process and the integrity of a block chain are ensured.
Accordingly, if node 104 determines that block 2 fails to share, the process of sharing block 2 may be repeated as follows: the node 104 may determine the block height of the largest history block (i.e., block 1) from the memory, and may obtain the first transaction data from the transaction pool of the node 104, so the node 104 may set the block height of the block 2 according to the block height of the block 1, may assemble the block header of the block 2 according to the block height of the block 2, the hash value of the block 1 and the current timestamp, may assemble the block body of the block 2 according to the first transaction data, may further generate the pre-preparation packet of the block 2 according to the block header of the block 2 and the block body of the block 2, and may send the pre-preparation packet of the block 2 to the node 101, the node 102 and the node 103, so that each node in the blockchain system performs the preparation phase and the preparation phase to complete the consensus of the block 2.
In the embodiment of the invention, after the block consensus failure of the I round, the M-th block to be consensus is reassembled by using the first node and the consensus process is executed on the M-th block, so that the problem that the block to be consensus in the block consensus of the previous round is omitted due to the failure of the block consensus of the previous round when the block consensus process of the two rounds is processed in parallel can be avoided, and the accuracy of the block chain system consensus is ensured.
Based on the blockchain system illustrated in fig. 1 and the consensus method illustrated in fig. 3, fig. 4 is a schematic flow chart for performing blockconsensus according to an embodiment of the present invention, where the method includes:
in step 401, in a first round of block consensus, master node 101 wraps block 0.
In the implementation, in the first round of block consensus, since there is no history block in the blockchain system, the block to be consensus is block 0; accordingly, since the number of blocks in the blockchain system is 4 and the window value v is 0, the number of the master node is determined to be 0 using the formula leader= (h+v)/n; the node corresponding to the master node with the number of 0 is determined to be the node 101 based on the table 1, that is, the node 101 is the master node of the first round of block consensus.
Thus, the master node 101 may obtain the transaction data to be processed by the first round of block consensus from the transaction pool of the master node 101, and may assemble the block header of the block 0 according to the block height of the block 0 and the current timestamp, assemble the block body of the block 0 according to the first round of block consensus, and further generate the pre-preparation packet of the block 0 according to the block header of the block 0 and the block body of the block 0, and send the pre-preparation packet of the block 0 to the nodes 102 to 104.
Step 402, the nodes 102-104 receive the pre-preparation packet of block 0 sent by the node 101; in the first round of block consensus, if the node 101, the node 103 and the node 104 determine that the node is not the master node of the second round of block consensus, the node directly participates in the consensus process of the block 0, namely, the preparation phase and the commit phase are sequentially executed; accordingly, node 102 determines that node 102 is the master node for the second round of block consensus, so that node 102 may generate the pre-preparation packet for block 1 in parallel while participating in the block 0 consensus process.
Taking node 102 as an example, since the block height of block 0 in the first round of block consensus is 0 and the number of blocks in the blockchain system is 4, node 102 uses the formula leader I+1 =(h M +1)/n determines the number of the master node to be 1; the node corresponding to the master node with the number of 1 is determined to be the node 102 based on the table 1, namely the node 102 is the master node of the second round of block consensus.
Further, the node 102 may set the block height of the block 1 according to the block height of the block 0, and may obtain transaction data to be processed by the second round of block consensus from the transaction pool, where the transaction data to be processed by the second round of block consensus is different from the transaction data to be processed by the first round of block consensus; node 102 may generate a pre-prepare packet for block 1 based on the block height of block 1, the current timestamp, and the transaction data to be processed for the second round of block consensus.
In step 403, after the first round of block consensus is finished, since the block 0 consensus is successful, the node 102 may update the pre-preparation packet of the block 1 using the hash value of the block 0, and send the updated pre-preparation packet of the block 1 to the node 101, the node 103 and the node 104, and start the second round of block consensus.
Accordingly, when the node 101, the node 103 and the node 104 receive the pre-preparation packet of the block 1 sent by the node 102, and in the second round of block consensus, the node 101, the node 102 and the node 104 determine that the node is not the master node of the third round of block consensus, the node directly participates in the consensus process of the block 1, that is, sequentially executes the preparation phase and the commit phase. Accordingly, the node 103 determines that the node 103 is the master node of the third round of block consensus, so that the node 103 can generate the pre-preparation packet of the block 2 in parallel according to the block height of the block 2, the current time stamp and the transaction data to be processed by the third round of block consensus when participating in the consensus process of the block 1.
In step 404, after the second round of block consensus is finished, since the block 1 consensus is successful, the node 103 may update the pre-preparation packet of the block 2 by using the hash value of the block 1, and send the updated pre-preparation packet of the block 2 to the node 101, the node 102 and the node 104, and start the third round of block consensus.
Accordingly, when the node 101, the node 102 and the node 104 receive the pre-preparation packet of the block 2 sent by the node 103, and in the third round of block consensus, the node 101, the node 102 and the node 103 determine that the node is not the master node of the fourth round of block consensus, the node directly participates in the consensus process of the block 2, that is, sequentially executes the preparation phase and the commit phase. Accordingly, the node 104 determines that the node 104 is the master node of the fourth-round block consensus, so that the node 104 can generate the pre-preparation packet of the block 3 in parallel according to the block height of the block 3, the current time stamp and the transaction data to be processed by the fourth-round block consensus when participating in the consensus process of the block 2.
Step 405, after the third round of block consensus is finished, since block 2 consensus fails, the value of window value v in nodes 101-104 increases to 1, the history maximum block is 1, and the number of the master node is determined to be 3 according to formula leader= (h+v)/n; the node corresponding to the master node with the number of 3 is determined to be the node 104 based on the table 1, that is, the node 104 is the master node of the fourth round of block consensus.
In a specific implementation, the node 104 may delete the block 3 stored in the memory and repackage the block 2, for example, the master node 104 may obtain the transaction data to be processed in the third round of block consensus from the transaction pool of the master node 104, and may assemble the block body of the block 2 according to the block height of the block 2, the hash value of the block 1 and the current timestamp, assemble the block body of the block 2 according to the third round of block consensus, and further may generate the pre-preparation packet of the block 2 according to the block head of the block 2 and the block body of the block 2, and send the pre-preparation packet of the block 2 to the nodes 101 to 103.
In step 406, when the node 101, the node 102 and the node 103 receive the pre-preparation packet of the block 2 sent by the node 104, and in the fourth round of block consensus, the node 102, the node 103 and the node 104 determine that the primary node is not the primary node of the fifth round of block consensus, the process of consensus of the block 2 may be directly participated, that is, the preparation phase and the commit phase are sequentially executed. Accordingly, node 101 determines that node 101 is the master node for the fifth round of block consensus, so node 101 may generate, in parallel, a pre-preparation packet for block 3 according to the block height of block 2, the current timestamp, and the transaction data to be processed for the fifth round of block consensus when participating in the block 2 consensus process.
In step 407, after the fourth round of block consensus is finished, since the block 2 consensus is successful, the node 101 may update the pre-preparation packet of the block 3 using the hash value of the block 2, and send the updated pre-preparation packet of the block 3 to the node 102, the node 103 and the node 104, and start the fifth round of block consensus.
Accordingly, when the node 102, the node 103 and the node 104 receive the pre-preparation packet of the block 3 sent by the node 101, and in the fifth round of block consensus, the node 101, the node 103 and the node 104 determine that the node is not the master node of the sixth round of block consensus, the node directly participates in the consensus process of the block 3, that is, sequentially executes the preparation phase and the commit phase. Accordingly, the node 102 determines that the node 102 is the master node of the sixth round of block consensus, so that the node 102 may generate the pre-preparation packet of the block 4 in parallel according to the block height of the block 4, the current timestamp and the transaction data to be processed by the sixth round of block consensus when participating in the consensus process of the block 3.
Based on the flow illustrated in fig. 4, it can be determined that, compared with the existing blockchain system that directly uses the PBFT consensus algorithm to sequentially execute each round of block consensus process, the block consensus method in the embodiment of the invention can greatly shorten the consensus time and improve the consensus efficiency of the blockchain system.
In the above embodiment of the present invention, in the I-th round of block consensus, a first node receives consensus information of an M-th block to be consensus sent by a second node, where the consensus information of the M-th block includes first transaction data to be processed in the I-th round of block consensus, and the second node is a master node of the I-th round of block consensus; further, if the first node determines that the first node is the master node for the block consensus of the (i+1) -th round, when the M-th block is subjected to consensus according to the consensus information of the M-th block, the first node generates the consensus information of the m+1-th block to be subjected to consensus in parallel; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data. In the embodiment of the invention, the main node of the I+1st round of block consensus is started in the execution process of the I round of block consensus, so that the main node of the I+1st round of block consensus automatically packs blocks, the parallel execution of the consensus process of the I round of block consensus and the block packing process of the I+1st round of block consensus is realized, the operation time of the I+1st round of block consensus is shortened, and the consensus efficiency of a block chain system can be improved.
For the above method flow, the embodiment of the invention also provides a consensus device based on the blockchain system, and the specific content of the device can be implemented by referring to the above method.
Fig. 5 is a schematic structural diagram of a consensus device based on a blockchain system according to an embodiment of the present invention, including:
the transceiver module 501 is configured to receive, in an I-th round of block consensus, consensus information of an M-th block to be consensus sent by a second node, where the consensus information of the M-th block includes first transaction data to be processed in the I-th round of block consensus, and the second node is a master node of the I-th round of block consensus; wherein I, M is a positive integer;
the generating module 502 is configured to, if it is determined that the first node is a master node for sharing the i+1st round of blocks, generate, in parallel, the sharing information of the m+1st round of blocks to be shared when the M is shared according to the sharing information of the M; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data.
Optionally, the generating module 502 is specifically configured to:
acquiring second transaction data except the first transaction data from a transaction pool of the first node, and setting the block height of the M+1th block according to the block height of the M th block;
And generating common identification information of the M+1th block according to the second transaction data, the block height of the M+1th block and the current timestamp.
Optionally, after the generating module 502 generates the consensus information of the m+1th block to be consensus in parallel, the transceiver module 501 is further configured to:
if the common identification result of the block identification of the I round is determined to be successful, adding the hash value of the M block into the common identification information of the M+1st block, and sending the common identification information of the M+1st block to other nodes in the block chain system.
Optionally, the generating module 502 is further configured to:
if the consensus result of the block consensus of the I round is determined to be failure, acquiring the first transaction data from a transaction pool of the first node, and setting the block height of the M-th block according to the block height of the largest historical block;
generating consensus information of the Mth block according to the first transaction data, the block height of the Mth block, the hash value of the historical maximum block and the current timestamp;
and sending the consensus information of the Mth block to other nodes in the blockchain system.
Optionally, the generating module 502 is specifically configured to:
And determining the number of the primary node of the I+1st round of block consensus according to the block height of the M-th block and the node number of the blockchain system, and if the identification of the first node is matched with the number of the primary node of the I+1st round of block consensus, determining that the first node is the primary node of the I+1st round of block consensus.
From the above, it can be seen that: in the above embodiment of the present invention, in the I-th round of block consensus, a first node receives consensus information of an M-th block to be consensus sent by a second node, where the consensus information of the M-th block includes first transaction data to be processed in the I-th round of block consensus, and the second node is a master node of the I-th round of block consensus; further, if the first node determines that the first node is the master node for the block consensus of the (i+1) -th round, when the M-th block is subjected to consensus according to the consensus information of the M-th block, the first node generates the consensus information of the m+1-th block to be subjected to consensus in parallel; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data. In the embodiment of the invention, the main node of the I+1st round of block consensus is started in the execution process of the I round of block consensus, so that the main node of the I+1st round of block consensus automatically packs blocks, the parallel execution of the consensus process of the I round of block consensus and the block packing process of the I+1st round of block consensus is realized, the operation time of the I+1st round of block consensus is shortened, and the consensus efficiency of a block chain system can be improved.
Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, which when executed by the processing unit, causes the processing unit to perform a blockchain system-based consensus method as any of fig. 3 or fig. 4.
Based on the same inventive concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer program executable by a computing device, which when run on the computing device, causes the computing device to perform a blockchain system-based consensus method as any of fig. 3 or 4.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, or as a computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (12)

1. A method of consensus based on a blockchain system, the method comprising:
In the block consensus of the I round, a first node receives the consensus information of an M-th block to be consensus sent by a second node, wherein the consensus information of the M-th block comprises first transaction data to be processed in the block consensus of the I round, and the second node is a main node of the block consensus of the I round;
if the first node determines that the first node is a main node for the I+1st round of block consensus, generating the consensus information of the M+1st round of block to be consensus in parallel when the M is consensus according to the consensus information of the M, and if the consensus result of the I round of block consensus is determined to be successful, transmitting the consensus information of the M+1st round of block to other nodes in the block chain system; if the consensus result of the I-th round of block consensus is determined to be a consensus failure, generating the consensus information of the M-th block in parallel, and transmitting the consensus information of the M-th block to other nodes in the block chain system; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data;
wherein I, M is a positive integer.
2. The method of claim 1, wherein the first node generates the consensus information of the m+1th block to be consensus in parallel, comprising:
the first node obtains second transaction data except the first transaction data from a transaction pool of the first node, and sets the block height of the M+1th block according to the block height of the M th block;
the first node generates consensus information of the M+1th block according to the second transaction data, the block height of the M+1th block and the current timestamp.
3. The method of claim 2, wherein after the first node generates the consensus information of the m+1th block to be consensus in parallel, further comprising:
the first node adds the hash value of the mth block to the common information of the m+1th block.
4. The method of claim 1, wherein the first node generating the consensus information for the mth block in parallel comprises:
the first node acquires the first transaction data from a transaction pool of the first node, and sets the block height of the Mth block according to the block height of the history maximum block;
the first node generates consensus information of the Mth block according to the first transaction data, the block height of the Mth block, the hash value of the historical maximum block and the current time stamp.
5. The method according to any of claims 1 to 4, wherein the first node determines that the first node is the master node of the i+1st round of block consensus by:
and the first node determines the number of the main node which is commonly recognized by the I+1st round of blocks according to the block height of the Mth block and the node number of the blockchain system, and if the identification of the first node is matched with the number of the main node which is commonly recognized by the I+1st round of blocks, the first node is determined to be the main node which is commonly recognized by the I+1st round of blocks.
6. A blockchain system-based consensus device, the device comprising:
the receiving and transmitting module is used for receiving the consensus information of the M-th block to be consensus sent by the second node in the I-th block consensus, wherein the consensus information of the M-th block comprises first transaction data to be processed in the I-th block consensus, and the second node is a main node of the I-th block consensus; wherein I, M is a positive integer;
the generating module is used for generating the consensus information of the (M+1) -th block to be consensus in parallel when the (M) -th block is consensus according to the consensus information of the (M) -th block if the first node is determined to be the main node of the (I+1) -th block consensus, and transmitting the consensus information of the (M+1) -th block to other nodes in the block chain system if the consensus result of the (I) -th block consensus is determined to be successful; if the consensus result of the I-th round of block consensus is determined to be a consensus failure, generating the consensus information of the M-th block in parallel, and transmitting the consensus information of the M-th block to other nodes in the block chain system; the common information of the M+1st block comprises second transaction data to be processed in the I+1st round of block common information; the second transaction data is different from the first transaction data.
7. The apparatus of claim 6, wherein the generating module is specifically configured to:
acquiring second transaction data except the first transaction data from a transaction pool of the first node, and setting the block height of the M+1th block according to the block height of the M th block;
and generating common identification information of the M+1th block according to the second transaction data, the block height of the M+1th block and the current timestamp.
8. The apparatus of claim 7, wherein after the generating module generates the consensus information of the m+1th block to be consensus in parallel, the transceiving module is further configured to:
and adding the hash value of the Mth block into the consensus information of the Mth+1th block.
9. The apparatus of claim 8, wherein the generating module is further configured to:
acquiring the first transaction data from a transaction pool of the first node, and setting the block height of the Mth block according to the block height of the history maximum block;
and generating the consensus information of the Mth block according to the first transaction data, the block height of the Mth block, the hash value of the historical maximum block and the current timestamp.
10. The apparatus according to any one of claims 6 to 9, wherein the generating module is specifically configured to:
And determining the number of the primary node of the I+1st round of block consensus according to the block height of the M-th block and the node number of the blockchain system, and if the identification of the first node is matched with the number of the primary node of the I+1st round of block consensus, determining that the first node is the primary node of the I+1st round of block consensus.
11. A computing device comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program that, when executed by the processing unit, causes the processing unit to perform the method of any of claims 1-5.
12. A computer readable storage medium, characterized in that it stores a computer program executable by a computing device, which when run on the computing device, causes the computing device to perform the method of any of claims 1-5.
CN201910798196.6A 2019-08-27 2019-08-27 Consensus method and device based on block chain system Active CN110517141B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910798196.6A CN110517141B (en) 2019-08-27 2019-08-27 Consensus method and device based on block chain system
PCT/CN2020/106623 WO2021036702A1 (en) 2019-08-27 2020-08-03 Consensus method and device employing blockchain system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910798196.6A CN110517141B (en) 2019-08-27 2019-08-27 Consensus method and device based on block chain system

Publications (2)

Publication Number Publication Date
CN110517141A CN110517141A (en) 2019-11-29
CN110517141B true CN110517141B (en) 2023-06-13

Family

ID=68628154

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910798196.6A Active CN110517141B (en) 2019-08-27 2019-08-27 Consensus method and device based on block chain system

Country Status (2)

Country Link
CN (1) CN110517141B (en)
WO (1) WO2021036702A1 (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110517141B (en) * 2019-08-27 2023-06-13 深圳前海微众银行股份有限公司 Consensus method and device based on block chain system
CN110708171B (en) * 2019-12-13 2020-06-12 腾讯科技(深圳)有限公司 Block chain consensus voting method, device, equipment and storage medium
CN111369358B (en) * 2020-02-10 2023-09-12 杭州溪塔科技有限公司 Block chain consensus method and device and electronic equipment
CN111556120B (en) * 2020-04-23 2023-04-07 财付通支付科技有限公司 Data processing method and device based on block chain, storage medium and equipment
CN111768288B (en) * 2020-06-02 2023-12-08 北京同邦卓益科技有限公司 Service processing method, device, electronic equipment and storage medium
CN111698094B (en) * 2020-06-12 2023-06-09 深圳前海微众银行股份有限公司 Common identification method based on block chain system and block chain system
CN111711526B (en) * 2020-06-16 2024-03-26 深圳前海微众银行股份有限公司 Method and system for consensus of block chain nodes
CN111522648B (en) * 2020-07-03 2020-10-09 支付宝(杭州)信息技术有限公司 Transaction processing method and device for block chain and electronic equipment
CN112256476B (en) * 2020-09-27 2024-04-16 陕西医链区块链集团有限公司 Data operation method, device, equipment and medium based on block chain
CN112511312B (en) * 2020-11-23 2023-10-17 北京微芯区块链与边缘计算研究院 Assembled consensus method and system
CN113204432A (en) * 2021-02-03 2021-08-03 支付宝(杭州)信息技术有限公司 Transaction processing method and device in block chain and electronic equipment
CN113379542B (en) * 2021-05-28 2024-01-09 中邮信息科技(北京)有限公司 Block chain transaction query method, device, medium and electronic equipment
CN113486118B (en) * 2021-07-21 2023-09-22 银清科技有限公司 Consensus node selection method and device
CN116737810A (en) * 2023-05-06 2023-09-12 清华大学 Consensus service interface for distributed time sequence database

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109064328A (en) * 2018-07-09 2018-12-21 夸克链科技(深圳)有限公司 A kind of construction and its common recognition algorithm of novel block chain
CN109831425A (en) * 2019-01-25 2019-05-31 中国联合网络通信集团有限公司 Block chain common recognition method, apparatus, equipment and computer readable storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10839379B2 (en) * 2017-07-20 2020-11-17 Chicago Mercantile Exchange Inc. Blockchain including linked digital assets
KR102417067B1 (en) * 2017-12-08 2022-07-05 한국전자통신연구원 Method and apparatus for generating blocks in node on a block-chain network
CN109978516A (en) * 2019-03-06 2019-07-05 西安电子科技大学 The manufacture of block and synchronous method, information data processing terminal in block chain network
CN109993647B (en) * 2019-03-08 2023-12-22 西安电子科技大学 Tax collection system based on blockchain and processing method
CN109889397B (en) * 2019-03-31 2021-08-31 杭州复杂美科技有限公司 Lottery method, block generation method, equipment and storage medium
CN110517141B (en) * 2019-08-27 2023-06-13 深圳前海微众银行股份有限公司 Consensus method and device based on block chain system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109064328A (en) * 2018-07-09 2018-12-21 夸克链科技(深圳)有限公司 A kind of construction and its common recognition algorithm of novel block chain
CN109831425A (en) * 2019-01-25 2019-05-31 中国联合网络通信集团有限公司 Block chain common recognition method, apparatus, equipment and computer readable storage medium

Also Published As

Publication number Publication date
WO2021036702A1 (en) 2021-03-04
CN110517141A (en) 2019-11-29

Similar Documents

Publication Publication Date Title
CN110517141B (en) Consensus method and device based on block chain system
CN110503558B (en) Processing method and device based on block chain system
CN110474986B (en) Consensus method, device and system based on block chain system
CN113329031B (en) Method and device for generating state tree of block
WO2020258848A1 (en) Method and apparatus for cross-chain transmission of resources
CN114944932B (en) Method and system for adding blocks to licensed blockchains
US20230109969A1 (en) Data processing method and apparatus based on node internal memory, device and medium
CN111698094B (en) Common identification method based on block chain system and block chain system
TW202016817A (en) Block chain based transaction processing method and device and electronic equipment
WO2020258847A1 (en) Method and apparatus for cross-chain transmission of authenticable message based on processing module
CN110737664A (en) block link point synchronization method and device
CN113570466B (en) Transaction data processing method and device and readable storage medium
CN111163148B (en) Synchronization method and related equipment for consensus state of block chain system
CN111144883A (en) Processing performance analysis method and device for block chain network
US20230275771A1 (en) Pre-execution of block chain transaction in parallel during block consensus
CN113064764B (en) Method and apparatus for executing blocks in a blockchain system
CN111161078A (en) One-to-many block chain transfer realization method
CN110874351A (en) Workload certification cooperative work method, block chain node and block chain system
WO2023011019A1 (en) Blockchain-based data processing method and apparatus, device, readable storage medium and computer program product
CN113409047B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN113157450B (en) Method and apparatus for executing blocks in a blockchain system
CN111080296A (en) Verification method and device based on block chain system
CN111339089B (en) Data storage and acquisition method and device applied to blockchain
CN117010889A (en) Data processing method, device, equipment, medium and product
WO2021134470A1 (en) Blockchain system, data processing method, computing device and medium

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