CN111061769B - Consensus method of block chain system and related equipment - Google Patents

Consensus method of block chain system and related equipment Download PDF

Info

Publication number
CN111061769B
CN111061769B CN201911348339.XA CN201911348339A CN111061769B CN 111061769 B CN111061769 B CN 111061769B CN 201911348339 A CN201911348339 A CN 201911348339A CN 111061769 B CN111061769 B CN 111061769B
Authority
CN
China
Prior art keywords
block
consensus
node device
height
block chain
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
CN201911348339.XA
Other languages
Chinese (zh)
Other versions
CN111061769A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911348339.XA priority Critical patent/CN111061769B/en
Publication of CN111061769A publication Critical patent/CN111061769A/en
Application granted granted Critical
Publication of CN111061769B publication Critical patent/CN111061769B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications

Abstract

An embodiment of the present application provides a consensus method and a related device for a blockchain system, where the blockchain system includes a blockchain and a consensus committee, the consensus committee includes a plurality of node devices participating in consensus, the method is performed by a first node device, and the first node device is any one of the node devices in the consensus committee, and the method includes: in the Nth round of the consensus process of the block height H of the block chain, checking whether a block in a locked state exists in the cache space, wherein H, N is a positive integer; if the block in the locked state exists in the cache space, determining the block in the locked state as a target block to be identified; and carrying out consensus processing on the target block to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain. The embodiment of the application can ensure the consensus accuracy.

Description

Consensus method of block chain system and related equipment
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a consensus method for a blockchain system, a consensus device for a blockchain system, and a computer storage medium.
Background
The blockchain system is a distributed system, and the consensus mechanism is the basis for ensuring the normal operation of the blockchain system. Consensus means agreement; each node device in the blockchain system stores a distributed ledger (namely, blockchain); the consensus process of the blockchain system is a process for keeping a distributed account book consistent among node devices. The consensus process of the blockchain system is typically implemented based on a consensus algorithm, which may include, but is not limited to: a BFT (Byzantine Fault Tolerance) algorithm, a PBFT (Practical Byzantine Fault Tolerance) algorithm, and the like. In practice, it is found that in the consensus process of the existing blockchain system, consensus errors are easily generated, and the situation that account book data are inconsistent occurs in a distributed account book among node devices in the blockchain system.
Disclosure of Invention
The embodiment of the application provides a consensus method and related equipment for a block chain system, which can ensure the accuracy of consensus.
In one aspect, an embodiment of the present application provides a consensus method for a blockchain system, where the blockchain system includes a blockchain and a consensus committee, where the consensus committee includes a plurality of node devices participating in consensus, and the method is performed by a first node device, where the first node device is any one of the node devices in the consensus committee, and the method includes:
in the Nth round of the consensus process of the block height H of the block chain, checking whether a block in a locked state exists in a cache space, wherein H, N are positive integers;
if the block in the locked state exists in the cache space, determining the block in the locked state as a target block to be identified;
and performing consensus processing on the target block to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
In one aspect, an embodiment of the present application provides a consensus device for a blockchain system, where the blockchain system includes a blockchain and a consensus committee, where the consensus committee includes a plurality of node devices participating in consensus, the consensus device operates in a first node device, and the first node device is any one of the node devices in the consensus committee, and the consensus device includes:
a checking unit, configured to check whether a block in a locked state exists in a cache space in an nth round of consensus of a block height H of the block chain, where H, N are positive integers;
a determining unit, configured to determine, if a block in a locked state exists in the cache space, the block in the locked state as a target block to be identified;
and the processing unit is used for carrying out consensus processing on the target block to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
In one aspect, an embodiment of the present application provides a consensus device for a blockchain system, where the blockchain system includes a blockchain and a consensus committee, where the consensus committee includes a plurality of node devices participating in consensus, and the consensus device is a first node device that is any one of the node devices in the consensus committee, and the consensus device includes:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium having stored thereon one or more instructions adapted to be loaded by the processor and to execute the method of consensus of a blockchain system as described above.
In one aspect, an embodiment of the present application provides a computer storage medium, where one or more instructions are stored, and the one or more instructions are adapted to be loaded by a processor and execute the above-mentioned consensus method of the blockchain system.
In the embodiment of the application, a locking mechanism is set in the consensus process, and in the Nth round of consensus process of the block height H of the block chain, consensus processing is performed on the blocks which are stored in the cache space of the node equipment and are in a locking state; therefore, a new block does not need to be created in each consensus process, the flow of the consensus process is simplified, resources consumed by block creation are saved, meanwhile, the data consistency of the block chain at the same block height can be effectively ensured, and the consensus accuracy is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 illustrates an architecture diagram of a blockchain system provided by an exemplary embodiment of the present application;
FIG. 2 illustrates a block chain structure provided by an exemplary embodiment of the present application;
fig. 3 is a block chain network architecture diagram provided in an exemplary embodiment of the present application;
FIG. 4 illustrates a component architecture diagram of a Committee of consensus provided by an exemplary embodiment of the present application;
FIG. 5 is a flow chart illustrating a consensus method of a blockchain system provided by an exemplary embodiment of the present application;
FIG. 6 is a flow chart illustrating a consensus method of a blockchain system provided by an exemplary embodiment of the present application;
FIG. 7 is a flow chart illustrating a consensus method of a blockchain system provided by an exemplary embodiment of the present application;
fig. 8 is a schematic structural diagram illustrating a consensus device of a blockchain system according to an exemplary embodiment of the present application;
fig. 9 is a schematic structural diagram illustrating a consensus device of a blockchain system according to an exemplary embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Embodiments of the present application relate to blockchain techniques. The block chain is a set of decentralized infrastructure with distributed storage characteristics, and particularly is a data structure formed by data blocks in a linked list-like manner according to a time sequence, so that data which are in a sequential relationship and can be verified in a system can be safely stored, and the data cannot be tampered and counterfeited in a cryptographic manner.
FIG. 1 illustrates an architecture diagram of a blockchain system provided by an exemplary embodiment of the present application; as shown in fig. 1, the block chain system mainly includes 5 hierarchies of 101-105 in bottom-to-top order. Wherein:
(1) the informational data and Merkle (Merkle) tree are located at the bottom level 101. The message data here refers to the original data that is requested to be distributed to the blockchain network but has not yet formed blocks, and may be, for example, loan data, transaction data, and the like. These raw data need further processing (e.g., authentication of each node in the blockchain network, hashing, etc.) to be written into the blocks. The Merkle tree is an important component of the blockchain technology, the blockchain does not directly store the plaintext original data, and the original data needs to be hashed and stored in the form of a hash value. The merkel tree is used for organizing hash values formed by hashing a plurality of original data according to a binary tree structure and storing the hash values in a block of blocks.
(2) The blocks are located at level 102. Blocks, i.e. data blocks, into which the information data of the bottom layer 101 is written after further processing. A block is created and then a consensus process is performed, and the block is allowed to be added to the blockchain only if the block consensus is successful. The block chain comprises a plurality of blocks which are connected into a chain structure according to the sequence of the creation time stamps from small to large. The block chain is a distributed account book, and the information data contained in the blocks on the block chain is the account book data of the distributed account book. FIG. 2 illustrates a block chain structure provided by an exemplary embodiment of the present application; as shown in fig. 2, block 201, block 202, and block 203 are connected in sequence in a chain structure. The block 202 is divided into a block header and a block body, where the block header includes the digest value of the previous block 201, the digest value of the current block 202, and the merkel (Merkle) root of the current block. The block body contains the complete data of this block 202 and is organized together in the form of a Merkle tree.
(3) The protocols and mechanisms followed by the blockchain are located at level 103. These protocols may include: P2P (Peer-to-Peer) protocol; mechanisms may include, but are not limited to: broadcast mechanism, consensus mechanism (including core mechanisms such as PoW (Proof Of Work) mechanism, POS (Proof Of rights) mechanism, etc.).
(4) The blockchain network is located at level 104. The block chain network consists of a plurality of node devices; node devices may include, but are not limited to: a PC (Personal Computer), a server, an ore machine for bitcoin excavation design, a smart phone, a tablet Computer, a mobile Computer, and the like. Fig. 3 is a block chain network architecture diagram provided in an exemplary embodiment of the present application; in the figure, 7 node devices are taken as an example for explanation, each node device in the block chain network is networked in a P2P mode, and the node devices communicate with each other according to a P2P protocol; all the node devices commonly follow a broadcasting mechanism and a common identification mechanism (including core mechanisms such as a PoW mechanism and a POS mechanism), so that the data on the block chain can be ensured to be not tampered and counterfeited, and meanwhile, the characteristics of decentralized center, distrusted trust and the like of the block chain are realized.
(5) The smart contracts are located at upper layer 105. An intelligent contract is a set of scenarios-a countermeasure-type of programmed rules and logic, which is decentralized, information-shareable program code deployed on a blockchain. Each party signing the contract agrees on the contract content, and the contract is deployed in the block chain in the form of an intelligent contract, so that the contract can be automatically executed on behalf of each signing party without any central authority.
Due to the characteristics of decentralized, distributed storage, data non-falsification and non-falsification, more and more business activities (such as loan activities and financial transaction activities) are spread based on the blockchain technology, so as to ensure the fairness and the openness of the business activities by using the characteristics of the blockchain.
The embodiment of the application also relates to a consensus mechanism. The blockchain system is a distributed system, and the consensus mechanism is the basis for ensuring the normal operation of the blockchain system. Consensus means agreement; each node device in the blockchain system stores a distributed ledger (namely, blockchain); the consensus process of the blockchain system is a process for keeping a distributed account book consistent among node devices. All or part of the node devices in the blockchain system can participate in the consensus process of the blockchain system, the node devices participating in the consensus jointly form a consensus committee of the blockchain system, and each node device participating in the consensus serves as a member of the consensus committee; in other words, the consensus committee of the blockchain system includes a plurality of node devices participating in consensus, and the consensus process of the blockchain system is performed by the node devices in the consensus committee, and in particular, the consensus process of the blockchain system is usually implemented based on a consensus algorithm, which may include but is not limited to: BFT algorithm, PBFT algorithm, etc.; each node device in the consensus committee performs a corresponding flow of the consensus process by running a consensus algorithm.
Typically, one or more rounds of consensus are required at a certain block height of the blockchain to achieve agreement between the node devices of the consensus committee. The block height is used to indicate the number of blocks connected on the block chain. The block height is an identifier of the block, which can be used to indicate the position of the block in the block chain; the block height of the starting block in the block chain is default to 0, the block height of the first block after the starting block is 1 (the first block is simply referred to as block 1), the block height of the second block after the starting block is 2 (the second block is simply referred to as block 2), and so on. For example, the block height of the current block of a block chain is 300 (this current block may be referred to as block 300), which means that 300 blocks are already stacked on the starting block, i.e. the number of blocks in the block chain formed from the starting block to block 300 is 301. The common identification process performed at a certain block height of the blockchain refers to a process of common identification of a block to be linked in the blockchain system when the blockchain is at the certain block height, if the common identification of the block to be linked is successful, the block is added to the blockchain, and the block height of the blockchain is + 1; for example: the process of identifying a block at a block height 10 of a block chain refers to a process of identifying a block to be linked in a block chain system when the block chain is at the block height 10, and if the block identification is successful, the block is added to the block chain so that the block height of the block chain is changed from 10 to 11. The round of consensus process can be divided into three consensus stages in sequence according to the execution sequence, wherein the consensus stages comprise a proposal stage, a pre-vote stage and a pre-submission stage. The plurality of node devices participating in the same round of consensus process in the consensus committee comprise two types of proposed nodes and non-proposed nodes. The proposed node is a node device generated by election by a plurality of node devices in the consensus committee, and the node device serving as the proposed node is responsible for generating a block to be identified in the proposal stage of the consensus process of the current round and broadcasting the block to be identified to other node devices in the consensus committee for consensus processing; and is also responsible for carrying out consensus processing on the blocks to be consensus. And the non-proposal node only processes the consensus on the blocks to be treated as consensus. The block to be identified may be a new block created by the proposal node, and in this embodiment, the block to be identified may also be a block in a locked state stored in the cache space of the proposal node. The consensus process includes a pre-voting process and a pre-submission process, the pre-voting process occurring during the pre-voting phase and the pre-submission process occurring during the pre-submission phase. The pre-voting process is whether to agree with the process of pre-voting on the blocks to be identified, and if so, the pre-voting on the blocks to be identified indicates that the blocks are agreed to be added to the block chain. The pre-commit processing refers to whether to approve the pre-commit process of the to-be-consensus blocks, and if the to-be-consensus blocks are approved to be pre-committed, the to-be-consensus blocks are added to the block chain in a confirmation mode. In the multiple rounds of consensus process performed at the same block height, firstly, each time one round of consensus process is replaced, node equipment participating in the consensus may change, namely, members of the consensus committee of each round of consensus process may change; ② the proposed node may change and the block to be identified may also change.
The detailed flow of the N-i round consensus process of the block height H of the block chain according to the embodiment of the present application is described in detail below as an embodiment, where H, N, i is a positive integer and i is smaller than N. Taking i as an example, in the N-1 st round of the block height H of the block chain, the consensus committee includes 4 node devices in total. FIG. 4 illustrates a component architecture diagram of a Committee of consensus provided by an exemplary embodiment of the present application; as shown in fig. 4, the members of the consensus committee of the blockchain system are node device a, node device B, node device C, and node device D, respectively, and in the N-1 st round of consensus process of the blockchain block height H, node device B is a proposed node, and node device a, node device C, and node device D are non-proposed nodes. The specific process of the N-1 round of consensus process at the block height H of the block chain comprises:
firstly, proposing stage:
1-1, node device B (i.e., the proposal node) generates a target Block-X to be agreed upon, which may be a new Block created by node device B.
1-2, the node device B determines Block-X as a target Block to be identified, and broadcasts the Block-X to the node device A, the node device C and the node device D.
II, a pre-voting stage:
2-1, due to a network fault, an equipment fault or other reasons, a situation that some node devices cannot receive the Block-X broadcast by the node device B in the first time may exist, for example, it is assumed that the node device a does not receive the Block-X broadcast by the node device B in the first time, and both the node device C and the node device D receive the Block-X broadcast by the node device B in the first time; in the pre-vote stage, the node device B, the node C and the node device D all use Block-X as a target Block to be identified, and perform pre-voting on Block-X to obtain respective pre-vote information; the pre-vote information contains the block identification of the executed pre-vote processing; for example: the node device C performs pre-voting processing on the Block-X to generate pre-voting information of the node device C, wherein the pre-voting information comprises an identifier of the Block-X, and the pre-voting information indicates that the node device C agrees to perform pre-voting on the Block-X, namely agrees to add the Block-X to a Block chain, and the Block-X obtains the pre-voting of the node device C; it can be understood that if the pre-vote information of the node device C is not generated, it indicates that the node device C does not perform pre-vote processing on Block-X; or if the identifier of the Block-X is not included in the pre-vote information of the node device C, it indicates that the node device C does not agree to pre-vote for the Block-X, that is, does not agree to add the Block-X to the Block chain. And the node device A can determine the empty Block emptyBlock as a target Block to be identified because the node device A is not connected to Block-X in the first time, and pre-vote information of the node device A is obtained by pre-voting the emptyBlock, wherein the pre-vote information of the node device A comprises an identifier of the emptyBlock. The first time can be set according to actual needs, for example, 1 minute, 3 minutes, and the like.
2-2, node device a, node device B, node device C and node device D each broadcast their own pre-vote information. Due to network failure, equipment failure or other reasons, there may be a case that some node devices do not receive the pre-vote information broadcast by other node devices within the second time. When the second time is reached, each node device in the consensus committee respectively counts the number of the pre-votes obtained by the target blocks to be consensus in the pre-voting stage according to the pre-voting information received in the second time, and confirms whether the number of the pre-votes exceeds a number threshold value. The number threshold may be set according to actual conditions, for example, the number threshold may be 50% of the number of node apparatuses in the consensus committee, or 2/3% of the number of node apparatuses in the consensus committee. The second time here can also be set according to actual needs, for example, 1 minute, 3 minutes, and so on; the second time may be the same as the first time or may be different from the first time. For example: setting the quantity threshold value as 2, and because the node device A only carries out the pre-voting processing on the emptyBlock, the pre-voting information of the node device A comprises an emptyBlock identifier; the node device B, the node device C and the node device D are all Block-X and are subjected to pre-voting treatment, and pre-voting information of the node device B, the node device C and the node device D all comprise an identifier of the Block-X; meanwhile, the node device A is only arranged to receive the pre-voting information from the node device B, the number of the pre-votes obtained by Block-X in the pre-voting stage is 1 through statistics of the pre-voting information of the node device A, and the number of the pre-votes obtained by Block-X is confirmed to be not more than the number threshold 2. The node device B is set to receive three pieces of pre-vote information from the node device A, the node device C and the node device D, the number of pre-votes obtained by Blcok-X is obtained by statistics according to the pre-vote information of the node device B, and the number of the pre-votes obtained by Block-X is confirmed to exceed the number threshold value 2. Similarly, the node device C is assumed to receive three pieces of pre-vote information from the node device a, the node device B and the node device D, and then the number of pre-votes obtained by Blcok-X is calculated and obtained to be 3 by combining with the pre-vote information of the node device C, and it is confirmed that the number of pre-votes obtained by Block-X exceeds the number threshold 2. And if the node device D also receives three pieces of pre-vote information from the node device A, the node device B and the node device C, counting the number of the obtained pre-votes by the Blcok-X by combining the pre-vote information of the node device D, wherein the number of the obtained pre-votes by the Block-X is 3, and the number of the obtained pre-votes exceeds a number threshold value 2.
Thirdly, a pre-submission stage:
3-1, node equipment B, node C and node equipment D all determine Block-X as a target Block to be identified, so that the Block-X is subjected to pre-submission processing to obtain respective pre-submission information; the pre-commit information here includes a block identifier to be subjected to the pre-commit processing; for example: the node device C carries out pre-submission processing on the Block-X to generate pre-submission information of the node device C, the pre-submission information comprises an identification of the Block-X, the pre-submission information indicates that the node device C agrees to carry out pre-submission on the Block-X, namely indicates that the node device C agrees to add the Block-X to a Block chain, and the Block-X obtains the pre-submission of the node device C; it can be understood that if the pre-commit information of the node device C is not generated, it indicates that the node device C does not perform pre-commit processing on Block-X; or if the pre-submission information of the node device C does not include the Block-X identifier, it indicates that the node device C does not agree to pre-submit the Block-X, that is, it is confirmed that the Block-X is not agreed to be added to the Block chain. And the node device A determines the empty block emptyBlock as a target block to be identified, so that the node device A carries out pre-submission processing on the emptyBlock to obtain the pre-submission information of the node device A, wherein the pre-submission information of the node device A comprises an identifier of the emptyBlock.
3-2, node device a, node device B, node device C and node device D each broadcast their own pre-submitted information. Due to network failure, equipment failure or other reasons, there may be a case that some node devices do not receive the pre-submission information broadcast by other node devices within the third time. When the third time arrives, each node device in the consensus committee counts the number of pre-submissions obtained by the target blocks to be consensus in the pre-submission stage according to the pre-submission information received in the third time, and confirms whether the number of pre-submissions exceeds a submission threshold. The commit threshold here may be set according to actual circumstances, and for example, the commit threshold may be 50% of the number of node apparatuses in the consensus committee, or 2/3% of the number of node apparatuses in the consensus committee. The third time here can also be set according to actual needs, for example, 1 minute, 3 minutes, and so on; the third time may be the same as the second time or different from the second time; similarly, the third time may be the same as the first time, or may be different from the first time. For example: setting a commit threshold value to be 2, and because the node device A only carries out pre-commit processing on the emptyBlock, the pre-commit information of the node device A comprises an emptyBlock identifier; the node device B, the node device C and the node device D are all subjected to Block-X pre-submission processing, and pre-submission information of the node device B, the node device C and the node device D comprises Block-X identifications; meanwhile, the node device B is set to receive the pre-submission information from the node device A and the node device C, the pre-submission number obtained by Block-X in the pre-submission stage is counted and obtained to be 2 by combining the pre-submission information of the node device B, and the pre-submission number obtained by Block-X is confirmed not to exceed (be not larger than) the submission threshold value 2. The node device C is set to receive the pre-submission information from the node device a and the node device C, then the pre-submission number obtained by Blcok-X is counted and obtained as 2 by combining the pre-submission information of the node device C, and it is confirmed that the pre-submission number obtained by Block-X does not exceed (is not greater than) the submission threshold 2. In a similar way, the node device a is assumed to receive three pieces of pre-submission information from the node device B, the node device C and the node device D, and then the pre-submission number obtained by Blcok-X is counted and obtained to be 3 by combining with the pre-submission information of the node device a itself, and it is confirmed that the pre-submission number obtained by Block-X exceeds the submission threshold 2. The node device D is also configured to receive three pieces of pre-submission information from the node device a, the node device B, and the node device C, count the pre-submission number obtained by Blcok-X by combining with the pre-submission information of the node device D itself to obtain 3, and confirm that the pre-submission number obtained by Block-X exceeds the submission threshold 2.
After the three consensus stages, if the obtained pre-vote number of the target blocks to be consensus exceeds the number threshold and the obtained pre-submission number exceeds the submission threshold, the target blocks to be consensus are successfully consensus and can be added to the block chain; otherwise, the consensus fails and cannot be added to the blockchain. According to the above example, node device a confirms that the number of acquired pre-submissions for Block-X exceeds the submission threshold, but that the number of acquired pre-votes does not exceed the number threshold, and therefore assumes that Block-X consensus failed. Node device B acknowledges that the number of acquired pre-votes for Block-X exceeds the quantity threshold, but the number of acquired pre-commits does not exceed the commit threshold, and therefore assumes that Block-X consensus failed. The node apparatus C confirms that the number of acquired pre-votes by Block-X exceeds the number threshold, but the acquired number of pre-submissions does not exceed the submission threshold, and therefore considers that Block-X consensus failed. The node device D confirms that the obtained pre-vote number of Block-X exceeds the number threshold, and the obtained pre-commit number exceeds the commit threshold, so that the Block-X consensus is considered to be successful, and the node device D adds the Block-X to a Block chain locally stored by the node device D. In summary, in the N-1 round of consensus of the Block height H of the Block chain, the node device a, the node device B, and the node device C do not agree on Block-X, and do not write Block-X into their respective distributed accounts (i.e., add to their locally stored Block chains), but the node device D agrees on Block-X and writes Block-X into their own distributed accounts, so that the Block height of the Block chain locally stored by the node device D becomes H + 1; when node device D is no longer involved in the N-th consensus of the block height H of the block chain, the members of the consensus committee are changed to node device a, node device B and node device C.
It should be noted that, when the N-th round of the block height H of the blockchain is performed, the proposed node may be changed, for example, in the above example, the proposed node in the N-1-th round of the block height H of the blockchain is the node apparatus B, and the N-th round of the block height H of the blockchain may be changed to the node apparatus C; then, the above three consensus phases are performed again to complete the N-th consensus process at the block height H of the blockchain. According to the above example, since the node device D has agreed on Block-X in the N-1 st round of the Block height H of the Block chain, and adds Block-X to the locally stored Block chain, the Block corresponding to the Block height H of the locally stored Block chain for the node device D is Block-X. Then, in the nth round of consensus process of the Block height H of the Block chain and the subsequent rounds of consensus process, Block-X needs to be agreed to the same degree to ensure the consistency of the Block chain at the same Block height, otherwise, consensus errors occur; in order to achieve the purpose, in the embodiment of the present application, a lock mechanism is set in the consensus process, and the lock mechanism requires that a node device of the consensus committee locks and stores the blocks meeting the lock condition in the N-i round of the Block height H of the Block chain into respective cache spaces and keeps a lock state in the cache spaces, so that in the N-th round of the Block height H of the Block chain and the subsequent rounds of the consensus process, the node device only performs consensus processing on the blocks in the lock state; the lock condition here may include the following conditions: is already created in the proposal phase of the N-i th round of consensus process for the block height H of the block chain and with the largest creation timestamp, for example: in the N-i round of the Block height H of the Block chain, two blocks Block-Y and Block-X are created, but the creation timestamp of the Block-X is larger than that of the Block-Y, so that the Block-X meets the condition; the total number of the pre-votes obtained in the pre-vote stage of the N-i round of the consensus process of the block height H of the block chain is larger than a quantity threshold; for example, in the above example, both node device B and node device C confirm that Block-X satisfies the condition that the number of obtained pre-votes is greater than the number threshold; thirdly, the total number of the pre-submissions obtained in the pre-submission stage of the N-i round consensus process of the block height H of the block chain is smaller than a submission threshold value; for example, in the above example, both node device B and node device C confirm that the number of pre-commits obtained by Block-X satisfies the condition is less than the commit threshold. According to a locking mechanism, a node device B and a node device C can lock and store Block-X in respective cache spaces, when the Nth round of consensus process of the Block height H of a Block chain is carried out, the node device B only carries out consensus processing on the Block-X, and the node device C only carries out consensus processing on the Block-X, so that when the node device A, the node device B and the node device C all achieve consensus on the Block-X in the Nth round of consensus process of the Block height H of the Block chain, the node device A, the node device B and the node device C all add the Block-X on the respective locally stored Block chain, the data consistency of the Block chain at the same Block height is guaranteed, and the accuracy of the consensus process is guaranteed.
Based on the above description, in the consensus scheme of the blockchain system proposed in the embodiment of the present application, a lock mechanism is provided in the consensus process, where the lock mechanism requires that the node device of the consensus committee lock and store the block meeting the lock condition in the N-i round of the block height H of the blockchain into the respective cache space of each node device, and maintain the lock state in the cache space, and then in the N round of the block height H of the blockchain and the subsequent rounds of the consensus process, each node device of the consensus committee only performs the consensus processing on the block in the lock state; therefore, the data consistency of the block chains at the same block height can be ensured, the consensus process is not influenced by the factors such as the change of the proposal node and the change of the target block to be consensus, and the consensus accuracy is ensured.
FIG. 5 is a flow chart illustrating a consensus method of a blockchain system provided by an exemplary embodiment of the present application; in this embodiment, the blockchain system includes a blockchain and a consensus committee, where the consensus committee includes a plurality of node devices participating in consensus; the method is executed by a first node device, the first node device being any one of the joint committees, and the method includes the following steps S501-S503:
s501, in the Nth round of the block height H of the block chain, whether a block in a locked state exists in the cache space is checked, wherein H, N is a positive integer.
S502, if there is a block in the locked state in the cache space, determining the block in the locked state as a target block to be identified.
In steps S501-S502, the block in the locked state is the block satisfying the locking condition in the N-i th round of the block height H of the block chain. If the first node device detects that a block meeting the locking condition exists in the N-i round consensus process of the block height H of the block chain, the first node device locks and stores the block into a buffer space of the first node device according to a locking mechanism, the block is used as a target block to be consensus in the N round consensus process of the block height H of the block chain, and the target block is subjected to consensus processing in the N round consensus process of the block height H of the block chain.
S503, performing consensus processing on the target block to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain.
The consensus process may include a pre-vote process and a pre-submission process. The consensus result may be used to indicate that the consensus is successful or failed, and if the consensus result indicates that the consensus is successful, the N-th round of consensus process indicating that the first node device has agreed on the target block at the block height H of the block chain, which is subsequently added by the first node device to the block chain locally stored by the first node device. If the consensus result indicates that the consensus fails, the N-th round of consensus process of the block height H of the block chain indicates that the first node device does not agree on the target block, and the target block is continuously locked and stored in the cache space of the first node device and is continuously subjected to consensus process in the N + j (j is a positive integer) round of consensus process of the block height H.
In the embodiment of the application, a locking mechanism is set in the consensus process, and in the Nth round of consensus process of the block height H of the block chain, consensus processing is performed on the blocks which are stored in the cache space of the node equipment and are in a locking state; therefore, a new block does not need to be created in each consensus process, the flow of the consensus process is simplified, resources consumed by block creation are saved, meanwhile, the data consistency of the block chain at the same block height can be effectively ensured, and the consensus accuracy is ensured.
FIG. 6 is a flow chart illustrating a consensus method of a blockchain system provided by an exemplary embodiment of the present application; in this embodiment, the blockchain system includes a blockchain and a consensus committee, where the consensus committee includes a plurality of node devices participating in consensus; the method is executed by a first node device, the first node device is any node device in a consensus committee, and the first node device is a proposal node in an Nth round of consensus process of a block height H of a block chain. The method comprises the following steps S601-S609:
s601, in the process of the N-i round of consensus of the block height H of the block chain, setting a locking identifier for a block meeting a locking condition, and storing the block with the locking identifier into a cache space; wherein, the block provided with the locking mark is in a locking state.
The consensus process comprises a proposal stage, a pre-vote stage and a pre-submission stage; the lock-out conditions include: creating the proposal stage of the N-i round consensus process of the block height H of the block chain and maximizing the creating time stamp; the total number of the pre-votes obtained in the pre-vote stage of the N-i round of the consensus process of the block height H of the block chain is greater than a quantity threshold value; and the total number of the pre-submissions obtained in the pre-submission stage of the N-i th round of the consensus process of the block height H of the block chain is less than or equal to the submission threshold.
S602, in the nth round of the block height H of the block chain, checking whether a block in a locked state exists in the buffer space. If there is a block in the locked state in the cache space, execute step S603; if there is no block in the locked state in the cache space, go to step S604;
s603, determining the block in the locking state as a target block to be identified; proceed to execution S605.
S604, create a block in the proposal stage of the nth round of consensus process of the block height H of the block chain, and determine the created block as the target block to be consensus.
S605, in the proposal stage of the nth round of the consensus process of the block height H of the block chain, the target block is broadcasted to other node devices in the consensus committee.
In steps S603-S605, the first node device is used as a proposal node in the nth round of the block height H of the block chain, and the target block to be identified is generated in two ways at the proposal stage of the nth round of the block height H of the block chain, one way is to create a new block and determine the created new block as the target block to be identified. Another way is to acquire the block in the locked state from the buffer space as the target block to be identified. According to the locking mechanism of the embodiment of the present application, in order to ensure the consensus accuracy, when a block in a locked state exists in the cache space of the first node device, the block in the locked state is preferentially determined as a target block to be consensus, and the target block is broadcasted to other node devices by the first node device for consensus processing. When the block in the locked state does not exist in the cache space of the first node device, a new block is created as a target block to be identified and broadcasted to other node devices for subsequent identification processing.
S606, acquiring a consensus message generated by each node device in the consensus committee performing consensus on the target block in the nth round of consensus process of the block height H of the block chain. The consensus process comprises a pre-voting process and a pre-submission process, and the consensus message comprises pre-voting information and pre-submission information.
S607, the consensus information is analyzed to obtain the consensus result of the target block in the nth round of consensus process of the block height H of the block chain.
In one embodiment, the consensus message comprises pre-vote information; s607 specifically includes the following steps S11-S12:
s11, determining the total number of pre-votes obtained by the target block in the pre-vote stage of the Nth round of the consensus process of the block height H of the block chain according to the pre-vote information.
s12, if the total number of pre-votes obtained by the target block in the pre-vote phase of the nth round of consensus process of the block height H of the block chain is less than or equal to the number threshold, generating a consensus result indicating that the consensus fails.
The number threshold may be set according to actual needs, for example, the number threshold may be 50% of the number of node apparatuses in the consensus committee, or 2/3% of the number of node apparatuses in the consensus committee.
In another embodiment, the consensus message further comprises pre-commit information; s607 further includes:
s13, if the total number of pre-votes obtained by the target block in the pre-vote phase of the N-th round of consensus process of the block height H of the block chain is greater than the number threshold, determining the total number of pre-commits obtained by the target block in the pre-commit phase of the N-th round of consensus process of the block height H of the block chain according to the pre-commit information;
s14, if the total number of pre-submissions obtained by the target tile in the pre-submission stage of the nth round of consensus process of the tile height H of the tile chain is greater than the submission threshold, generating a consensus result indicating successful consensus;
s15, if the total number of pre-commits obtained by the target tile in the pre-commit stage of the nth round of consensus process for the tile height H of the blockchain is less than or equal to the commit threshold, generating a consensus result indicating that the consensus failed.
In the above steps s11-s15, in the nth round of consensus of the tile height H of the tile chain, the target tile is successfully identified only if the total number of pre-votes obtained for the target tile is greater than the quantity threshold and the total number of pre-submissions obtained for the target tile is also greater than the submission threshold.
S608, if the consensus result indicates that the consensus is successful, adding the target block to the block chain. The first node device adds the target block to a blockchain, where the blockchain refers to a blockchain (i.e., a distributed ledger) that is locally stored by the first node device.
S609, delete the block in the locked state from the buffer space.
Step S609 is an optional step, and if the target block is a block in a locked state in the cache space, after the target block is successfully identified, that is, the first node device achieves the common identification on the target block and adds the target block to the block chain locally stored in the first node device, the block in the locked state corresponding to the target block in the cache space may be deleted. It is understood that if the consensus result indicates a failure, that is, the first node device does not agree on the target block in the current round of consensus process, the target block is continuously locked and stored in the cache space of the first node device. Of course, if the target block is a block to be identified in the current round of identification process created by the first node device, the step S609 is not required to be executed. In addition, in the current round of consensus process (i.e. the nth round of consensus process of the block height H of the block chain), if a new block meeting the locking condition is generated, since the creation timestamp of the new block meeting the locking condition is greater than the creation timestamp between blocks in the locking state in the cache space, the first node device locks and stores the new block meeting the locking condition into the cache space, and replaces the block in the locking state in the original cache space; for example: the method comprises the steps that a Block in a locked state in a cache space of a first node device is set as Block-X, the Block-X is stored in the cache space in a locked mode in an N-i round of a Block height H of a Block chain, a new Block-Y meeting the locked state is generated in an N-i round of a Block height H of the Block chain, and the Block-X in the cache space can be replaced by the Block-Y by the first node device because the creation timestamp of the Block-Y is larger than that of the Block-X.
In the embodiment of the application, a lock mechanism is set in the consensus process, the lock mechanism requires that the node device of the consensus committee locks and stores the blocks meeting the locking condition in the N-i round of consensus process of the block height H of the block chain into the cache space of the node device, and keeps a locked state in the cache space, so that in the N round of consensus process of the block height H of the block chain, the node device only performs consensus processing on the blocks in the locked state; therefore, the data consistency of the block chains at the same block height can be ensured, the consensus process is not influenced by the factors such as the change of the proposal node and the change of the target block to be consensus, and the consensus accuracy is ensured.
FIG. 7 is a flow chart illustrating a consensus method of a blockchain system provided by an exemplary embodiment of the present application; in this embodiment, the blockchain system includes a blockchain and a consensus committee, where the consensus committee includes a plurality of node devices participating in consensus; the method is executed by a first node device, the first node device is any one node device in a consensus committee, the first node device is a non-proposed node in an nth round of consensus process of a block height H of a block chain, the proposed node in the nth round of consensus process of the block height H of the block chain is a second node device, and the second node device is any one node device except the first node device in the consensus committee. The method comprises the following steps S701-S709:
s701, in the process of the N-i round of consensus of the block height H of the block chain, setting a locking identifier for a block meeting a locking condition, and storing the block with the locking identifier into a cache space; the block with the locking mark is in a locking state.
S702, in the Nth round of the block height H of the block chain, checking whether a block in a locked state exists in the cache space. If the block in the locked state exists in the cache space, step S703 is executed; if there is no block in the locked state in the cache space, step S705 is performed.
S703, determining the block in the locked state as the target block to be identified.
S704, when the target block to be identified broadcasted by the second node device is received in the proposal stage of the nth round of the identification process of the block height H of the block chain, discarding the received target block. Proceed to step S706.
S705, receiving the target block to be identified broadcasted by the second node device at the proposal stage of the nth round of the identification process of the block height H of the block chain.
In steps S703-S705, the first node device serves as a non-proposal node in the nth round of the block height H of the block chain, and obtains the target block to be identified in two ways at the proposal stage of the nth round of the block height H of the block chain, where one way is to receive a new block created by the proposal node and determine the created new block as the target block to be identified. Another way is to acquire the block in the locked state from the buffer space as the target block to be identified. According to the locking mechanism of the embodiment of the present application, in order to ensure the consensus accuracy, when a block in a locked state exists in the cache space of the first node device, the block in the locked state is preferentially determined as a target block to be consensus, and at this time, no matter a proposed node broadcasts any block, the first node device discards the received broadcast block, that is, only performs the consensus processing on the block in the locked state in the cache space. When there is no block in the locked state in the cache space of the first node device, the target block to be identified broadcasted by the proposal node is received for subsequent identification processing.
S706, acquiring a consensus message generated by each node device in the consensus committee performing consensus on the target block in the nth round of consensus process of the block height H of the block chain.
And S707, analyzing the consensus information to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
If the consensus result indicates that the consensus is successful, the target block is added to the block chain S708.
S709, delete the block in the locked state from the buffer space.
In the embodiment of the application, a lock mechanism is set in the consensus process, the lock mechanism requires that the node device of the consensus committee locks and stores the blocks meeting the locking condition in the N-i round of consensus process of the block height H of the block chain into the cache space of the node device, and keeps a locked state in the cache space, so that in the N round of consensus process of the block height H of the block chain, the node device only performs consensus processing on the blocks in the locked state; therefore, the data consistency of the block chains at the same block height can be ensured, the consensus process is not influenced by the factors such as the change of the proposal node and the change of the target block to be consensus, and the consensus accuracy is ensured.
Fig. 8 is a schematic structural diagram illustrating a consensus device of a blockchain system according to an exemplary embodiment of the present application; the block chain system comprises a block chain and a consensus committee, wherein the consensus committee comprises a plurality of node devices participating in consensus, and the consensus device operates in a first node device which is any one of the node devices in the consensus committee. In particular, the consensus device may be a computer program (comprising program code) running in the first node apparatus, e.g. the consensus device may be an application software in the first node apparatus; the consensus device may be used to perform the corresponding steps in the methods shown in fig. 5-7. As shown in fig. 8, the consensus apparatus includes:
the checking unit 801 is configured to check whether there is a block in a locked state in the buffer space during the nth round of the block height H of the block chain, where H, N is a positive integer.
The determining unit 802 is configured to determine, if a block in a locked state exists in the cache space, the block in the locked state as a target block to be identified.
The processing unit 803 is configured to perform consensus processing on the target block to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain.
In the process of the N-i round of consensus of the block height H of the block chain, setting a locking identifier for a block meeting a locking condition, and storing the block with the locking identifier into a cache space;
wherein i is a positive integer and i is less than N; the block provided with the locking mark is in a locking state.
In one embodiment, the consensus process includes a proposal phase, a pre-vote phase, and a pre-commit phase;
the lock-out conditions include: creating the proposal stage of the N-i round consensus process of the block height H of the block chain and maximizing the creating time stamp; the total number of the pre-votes obtained in the pre-vote stage of the N-i round of the consensus process of the block height H of the block chain is greater than a quantity threshold value; and the total number of the pre-submissions obtained in the pre-submission stage of the N-i th round of the consensus process of the block height H of the block chain is less than or equal to the submission threshold.
In one embodiment, the processing unit 803 is specifically configured to:
acquiring consensus information generated by consensus processing of each node device in the consensus committee on a target block in the Nth round of consensus process of the block height H of the block chain;
and analyzing the consensus information to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
In one embodiment, the consensus process includes a pre-voting phase, the consensus message containing pre-vote information; the processing unit 803 is specifically configured to:
determining the total number of the pre-votes obtained by the target block in the pre-vote stage of the Nth round of the block height H of the block chain according to the pre-vote information;
and if the total number of the pre-votes obtained by the target block in the pre-vote stage of the Nth round of the consensus process of the block height H of the block chain is less than or equal to the number threshold, generating a consensus result for indicating the consensus failure.
In one embodiment, the consensus process further comprises a pre-commit phase, the consensus message further comprising pre-commit information; the processing unit 803 is further configured to:
if the total number of the pre-votes obtained by the target block in the pre-voting stage of the Nth round of the block height H of the block chain is greater than the quantity threshold, determining the total number of the pre-submissions obtained by the target block in the pre-submission stage of the Nth round of the block height H of the block chain according to the pre-submission information;
if the total number of the pre-submissions of the target block in the pre-submission stage of the Nth round of the block height H of the block chain is greater than the submission threshold, generating a consensus result for indicating successful consensus;
and if the total number of the pre-submissions of the target block obtained in the pre-submission stage of the Nth round of the consensus process of the block height H of the block chain is less than or equal to the submission threshold, generating a consensus result for indicating the consensus failure.
In one embodiment, the processing unit 803 is further configured to:
and if the consensus result indicates that the consensus is successful, adding the target block to the block chain, and deleting the block in the locked state from the buffer space.
In one embodiment, the consensus process includes a proposal phase; the first node device is a proposed node in the nth round of consensus process of the block height H of the block chain, and the processing unit 803 is further configured to:
in the proposal stage of the Nth round of the consensus process of the block height H of the block chain, the target block is broadcasted to other node devices in the consensus committee.
In one embodiment, the processing unit 803 is also used for
If the block in the locking state does not exist in the cache space, creating the block in the proposal stage of the N-th round of the consensus process of the block height H of the block chain;
the created block is determined as a target block to be identified and broadcast to other node devices in the identity committee.
In one embodiment, the consensus process includes a proposal phase; the first node device is a non-proposed node in the nth round of consensus process of the block height H of the block chain, the proposed node in the nth round of consensus process of the block height H of the block chain is a second node device, and the second node device is any node device except the first node device in the consensus committee; the processing unit 803 is further configured to:
when a target block to be identified broadcasted by the second node device is received in the proposal stage of the Nth round of the identification process of the block height H of the block chain, the received target block is discarded.
In one embodiment, the processing unit 803 is further configured to:
if the block in the locked state does not exist in the cache space, the target block to be identified broadcasted by the second node device is received at the proposal stage of the Nth round of the identification process of the block height H of the block chain.
According to an embodiment of the present application, the units in the consensus device shown in fig. 8 may be respectively or entirely combined into one or several other units to form one or several other units, or some unit(s) may be further split into multiple units with smaller functions to form one or several other units, which may achieve the same operation without affecting the achievement of the technical effect of the embodiment of the present application. The units are divided based on logic functions, and in practical application, the functions of one unit can be realized by a plurality of units, or the functions of a plurality of units can be realized by one unit. In other embodiments of the present application, the consensus device may also comprise other units, and in practical applications, these functions may also be facilitated by other units, and may be achieved by a plurality of units in cooperation. According to another embodiment of the present application, the consensus device as shown in fig. 8 may be constructed by running a computer program (including program code) capable of executing the steps involved in the respective methods as shown in fig. 5-7 on a general-purpose computing device, e.g., a computer, comprising a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), and a storage element, and implementing the consensus method of the embodiments of the present application. The computer program may be recorded on a computer-readable recording medium, for example, and loaded and executed in the above-described computing apparatus via the computer-readable recording medium.
In the embodiment of the application, a lock mechanism is set in the consensus process, the lock mechanism requires that the node device of the consensus committee locks and stores the blocks meeting the locking condition in the N-i round of consensus process of the block height H of the block chain into the cache space of the node device, and keeps a locked state in the cache space, so that in the N round of consensus process of the block height H of the block chain, the node device only performs consensus processing on the blocks in the locked state; therefore, the data consistency of the block chains at the same block height can be ensured, the consensus process is not influenced by the factors such as the change of the proposal node and the change of the target block to be consensus, and the consensus accuracy is ensured.
Fig. 9 is a schematic structural diagram illustrating a consensus device of a blockchain system according to an exemplary embodiment of the present application. The blockchain system comprises a blockchain and a consensus committee, wherein the consensus committee comprises a plurality of node devices participating in consensus, the consensus device is a first node device, and the first node device is any one of the node devices in the consensus committee. Referring to fig. 9, the consensus device comprises at least a processor 901, an input device 902, an output device 903, and a computer storage medium 904. The processor 901, the input device 902, the output device 903, and the computer storage medium 904 may be connected by a bus or other means. A computer storage medium 904 may be stored in the memory of the consensus device, the computer storage medium 904 being used for storing a computer program comprising program instructions, the processor 901 being used for executing the program instructions stored by the computer storage medium 904. The processor 901 (or CPU) is a computing core and a control core of a common knowledge device, and is adapted to implement one or more instructions, and in particular, is adapted to load and execute one or more instructions so as to implement a corresponding method flow or a corresponding function.
An embodiment of the present application further provides a computer storage medium (Memory), which is a Memory device in the consensus device and is used to store programs and data. It is understood that the computer storage medium herein may include both a built-in storage medium in the consensus device and, of course, an extended storage medium supported by the consensus device. The computer storage medium provides a storage space that stores an operating system of the consensus device. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), suitable for loading and execution by processor 901. The computer storage medium may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as at least one disk memory; and optionally at least one computer storage medium located remotely from the processor.
In one embodiment, the computer storage medium has one or more instructions stored therein; the processor 901 loads and executes one or more instructions stored in the computer storage medium to implement the corresponding steps in the above-mentioned consensus method embodiment of the consensus status of the blockchain system; in particular implementations, one or more instructions in the computer storage medium are loaded by the processor 901 and perform the following steps:
in the Nth round of the consensus process of the block height H of the block chain, checking whether a block in a locked state exists in the cache space, wherein H, N is a positive integer;
if the block in the locked state exists in the cache space, determining the block in the locked state as a target block to be identified;
and carrying out consensus processing on the target block to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
In one embodiment, one or more instructions in the computer storage medium are loaded by processor 901 and further perform the steps of:
in the process of the N-i round of consensus of the block height H of the block chain, setting a locking identifier for a block meeting a locking condition, and storing the block with the locking identifier into a cache space;
wherein i is a positive integer and i is less than N; the block provided with the locking mark is in a locking state.
In one embodiment, the consensus process includes a proposal phase, a pre-vote phase, and a pre-commit phase;
the lock-out conditions include: creating the proposal stage of the N-i round consensus process of the block height H of the block chain and maximizing the creating time stamp; the total number of the pre-votes obtained in the pre-vote stage of the N-i round of the consensus process of the block height H of the block chain is greater than a quantity threshold value; and the total number of the pre-submissions obtained in the pre-submission stage of the N-i th round of the consensus process of the block height H of the block chain is less than or equal to the submission threshold.
In one embodiment, when one or more instructions in the computer storage medium are loaded by the processor 901 and executed to perform the step of performing consensus processing on the target block to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain, the following steps are specifically performed:
acquiring consensus information generated by consensus processing of each node device in the consensus committee on a target block in the Nth round of consensus process of the block height H of the block chain;
and analyzing the consensus information to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
In one embodiment, the consensus process includes a pre-voting phase, the consensus message containing pre-vote information; when one or more instructions in the computer storage medium are loaded by the processor 901 and perform the step of performing consensus processing on the target block to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain, the specific steps are as follows:
determining the total number of the pre-votes obtained by the target block in the pre-vote stage of the Nth round of the block height H of the block chain according to the pre-vote information;
and if the total number of the pre-votes obtained by the target block in the pre-vote stage of the Nth round of the consensus process of the block height H of the block chain is less than or equal to the number threshold, generating a consensus result for indicating the consensus failure.
In one embodiment, the consensus process further comprises a pre-commit phase, the consensus message further comprising pre-commit information; when one or more instructions in the computer storage medium are loaded by the processor 901 and perform the step of performing consensus processing on the target block to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain, the following steps are further performed:
if the total number of the pre-votes obtained by the target block in the pre-voting stage of the Nth round of the block height H of the block chain is greater than the quantity threshold, determining the total number of the pre-submissions obtained by the target block in the pre-submission stage of the Nth round of the block height H of the block chain according to the pre-submission information;
if the total number of the pre-submissions of the target block in the pre-submission stage of the Nth round of the block height H of the block chain is greater than the submission threshold, generating a consensus result for indicating successful consensus;
and if the total number of the pre-submissions of the target block obtained in the pre-submission stage of the Nth round of the consensus process of the block height H of the block chain is less than or equal to the submission threshold, generating a consensus result for indicating the consensus failure.
In one embodiment, one or more instructions in the computer storage medium are loaded by processor 901 and further perform the steps of:
and if the consensus result indicates that the consensus is successful, adding the target block to the block chain, and deleting the block in the locked state from the buffer space.
In one embodiment, the consensus process includes a proposal phase; the first node device is a proposed node in an nth round of consensus process for a block height H of a block chain, one or more instructions in a computer storage medium loaded by the processor 901 and further performing the steps of:
in the proposal stage of the Nth round of the consensus process of the block height H of the block chain, the target block is broadcasted to other node devices in the consensus committee.
In one embodiment, one or more instructions in the computer storage medium are loaded by processor 901 and further perform the steps of:
if the block in the locking state does not exist in the cache space, creating the block in the proposal stage of the N-th round of the consensus process of the block height H of the block chain;
the created block is determined as a target block to be identified and broadcast to other node devices in the identity committee.
In one embodiment, the consensus process includes a proposal phase; the first node device is a non-proposed node in the nth round of consensus process of the block height H of the block chain, the proposed node in the nth round of consensus process of the block height H of the block chain is a second node device, and the second node device is any node device except the first node device in the consensus committee; one or more instructions in the computer storage medium are loaded by processor 901 and further perform the steps of:
when a target block to be identified broadcasted by the second node device is received in the proposal stage of the Nth round of the identification process of the block height H of the block chain, the received target block is discarded.
In one embodiment, one or more instructions in the computer storage medium are loaded by processor 901 and further perform the steps of:
if the block in the locked state does not exist in the cache space, the target block to be identified broadcasted by the second node device is received at the proposal stage of the Nth round of the identification process of the block height H of the block chain.
In the embodiment of the application, a lock mechanism is set in the consensus process, the lock mechanism requires that the node device of the consensus committee locks and stores the blocks meeting the locking condition in the N-i round of consensus process of the block height H of the block chain into the cache space of the node device, and keeps a locked state in the cache space, so that in the N round of consensus process of the block height H of the block chain, the node device only performs consensus processing on the blocks in the locked state; therefore, the data consistency of the block chains at the same block height can be ensured, the consensus process is not influenced by the factors such as the change of the proposal node and the change of the target block to be consensus, and the consensus accuracy is ensured.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (11)

1. A consensus method for a blockchain system, the blockchain system comprising a blockchain and a consensus committee, the consensus committee comprising a plurality of node devices participating in consensus, the method being performed by a first node device, the first node device being any one of the consensus committee, the method comprising:
in the N-i round of consensus process of the block height H of the block chain, setting a locking identifier for a block meeting a locking condition, and storing the block with the locking identifier into a cache space; wherein i is a positive integer and i is less than N; the block provided with the locking mark is in a locking state; the consensus process comprises a proposal stage, a pre-vote stage and a pre-submission stage; the lock-out condition includes: creating a proposal phase of an N-i round consensus process of the block height H of the block chain and the creating time stamp is maximum; the total number of the pre-votes obtained in the pre-vote stage of the N-i round of the consensus process of the block height H of the block chain is greater than a quantity threshold value; and the total number of pre-submissions obtained in the pre-submission stage of the N-i round of consensus process of the block height H of the block chain is less than or equal to a submission threshold;
in the Nth round of the consensus process of the block height H of the block chain, checking whether a block in a locked state exists in a cache space, wherein H, N are positive integers;
if the block in the locked state exists in the cache space, determining the block in the locked state as a target block to be identified;
performing consensus processing on the target block to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain; if the consensus result indicates that the consensus is successful, adding the target block to the block chain, and deleting the block in the locked state from the cache space;
in the Nth round of the consensus process of the block height H of the block chain, if a new block meeting the locking condition is generated, replacing the target block in the cache space with the new block.
2. The method of claim 1, wherein the performing the consensus process on the target block to obtain the consensus result of the target block in an nth round of the consensus process of the block height H of the block chain comprises:
acquiring consensus information generated by consensus processing of each node device in the consensus committee on the target block in the Nth round of consensus process of the block height H of the block chain;
and analyzing the consensus information to obtain a consensus result of the target block in the Nth round of consensus process of the block height H of the block chain.
3. The method of claim 2, wherein the consensus message comprises pre-vote information;
the analyzing the consensus information to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain includes:
determining the total number of pre-votes obtained by the target block in the pre-voting stage of the Nth round of consensus process of the block height H of the block chain according to the pre-voting information;
and if the total number of the pre-votes obtained by the target block in the pre-vote stage of the Nth round of the block height H of the block chain is less than or equal to the number threshold, generating a consensus result for indicating that the consensus fails.
4. The method of claim 3, wherein the consensus message further comprises pre-commit information;
the analyzing the consensus information to obtain a consensus result of the target block in the nth round of consensus process of the block height H of the block chain further includes:
if the total number of the pre-votes obtained by the target block in the pre-vote stage of the Nth round of the block height H of the block chain is greater than the quantity threshold, determining the total number of the pre-submissions obtained by the target block in the pre-submission stage of the Nth round of the block height H of the block chain according to the pre-submission information;
if the total number of the pre-submissions of the target block obtained in the pre-submission stage of the Nth round of the block height H of the block chain is greater than the submission threshold, generating a consensus result for indicating successful consensus;
and if the total number of the pre-submissions of the target block obtained in the pre-submission stage of the Nth round of the block height H of the block chain is less than or equal to a submission threshold, generating a consensus result for indicating that the consensus fails.
5. The method of claim 1, wherein the first node device is a proposal node in an nth round of consensus process for a block height H of the block chain, the method further comprising:
broadcasting the target block to other node devices in the consensus committee at a proposal stage of an Nth round of consensus process of a block height H of the block chain.
6. The method of claim 5, wherein the method further comprises:
if the block in the locked state does not exist in the cache space, creating the block at the proposal stage of the N round of the consensus process of the block height H of the block chain;
and determining the created block as a target block to be identified and broadcasting the target block to other node equipment in the identity committee.
7. The method of claim 1, wherein the first node device is a non-proposed node in an nth round of consensus of block height H of the blockchain, the proposed node in the nth round of consensus of block height H of the blockchain is a second node device, and the second node device is any node device of the consensus committee other than the first node device; the method further comprises the following steps:
when a target block to be identified broadcasted by the second node equipment is received in the proposal stage of the Nth round of the identification process of the block height H of the block chain, the received target block is discarded.
8. The method of claim 7, wherein the method further comprises:
if the block in the locked state does not exist in the cache space, receiving the target block to be identified broadcasted by the second node device at the proposal stage of the N round of the identification process of the block height H of the block chain.
9. A consensus apparatus of a blockchain system, wherein the blockchain system comprises a blockchain and a consensus committee, wherein the consensus committee comprises a plurality of node devices participating in consensus, and wherein the consensus apparatus operates in a first node device, and wherein the first node device is any one of the node devices in the consensus committee, and wherein the consensus apparatus comprises:
the processing unit is used for setting a locking identifier for the block meeting the locking condition in the N-i round of consensus process of the block height H of the block chain and storing the block with the locking identifier into a cache space; wherein i is a positive integer and i is less than N; the block provided with the locking mark is in a locking state; the consensus process comprises a proposal stage, a pre-vote stage and a pre-submission stage; the lock-out condition includes: creating a proposal phase of an N-i round consensus process of the block height H of the block chain and the creating time stamp is maximum; the total number of the pre-votes obtained in the pre-vote stage of the N-i round of the consensus process of the block height H of the block chain is greater than a quantity threshold value; and the total number of pre-submissions obtained in the pre-submission stage of the N-i round of consensus process of the block height H of the block chain is less than or equal to a submission threshold;
a checking unit, configured to check whether a block in a locked state exists in a cache space in an nth round of consensus of a block height H of the block chain, where H, N are positive integers;
a determining unit, configured to determine, if a block in a locked state exists in the cache space, the block in the locked state as a target block to be identified;
the processing unit is configured to perform consensus processing on the target block to obtain a consensus result of the target block in an nth round of consensus process of the block height H of the block chain; if the consensus result indicates that the consensus is successful, adding the target block to the block chain, and deleting the block in the locked state from the cache space;
the processing unit is further configured to, in an nth round of the process of identifying the block height H of the block chain, replace the target block in the cache space with a new block if the new block meeting the locking condition is generated.
10. A consensus device of a blockchain system, the blockchain system comprising a blockchain and a consensus committee, the consensus committee comprising a plurality of node devices participating in consensus, the consensus device being a first node device, the first node device being any one of the consensus committee, the consensus device comprising:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium having stored thereon one or more instructions adapted to be loaded by the processor and to execute the method of consensus of a blockchain system according to any of claims 1-8.
11. A computer storage medium having stored thereon one or more instructions adapted to be loaded by a processor and to perform the method of consensus of a blockchain system according to any one of claims 1-8.
CN201911348339.XA 2019-12-24 2019-12-24 Consensus method of block chain system and related equipment Active CN111061769B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911348339.XA CN111061769B (en) 2019-12-24 2019-12-24 Consensus method of block chain system and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911348339.XA CN111061769B (en) 2019-12-24 2019-12-24 Consensus method of block chain system and related equipment

Publications (2)

Publication Number Publication Date
CN111061769A CN111061769A (en) 2020-04-24
CN111061769B true CN111061769B (en) 2021-09-10

Family

ID=70303152

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911348339.XA Active CN111061769B (en) 2019-12-24 2019-12-24 Consensus method of block chain system and related equipment

Country Status (1)

Country Link
CN (1) CN111061769B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111683118B (en) * 2020-05-16 2023-07-11 中信银行股份有限公司 Block chain-based consensus method and device, master node equipment and slave node equipment
CN111368008B (en) 2020-05-27 2020-08-25 腾讯科技(深圳)有限公司 Data processing method, device and equipment based on block chain and readable storage medium
CN111654395B (en) * 2020-06-01 2021-10-26 腾讯科技(深圳)有限公司 Voting information processing method, device, equipment and storage medium
CN111382456B (en) 2020-06-01 2020-10-23 腾讯科技(深圳)有限公司 Proposal message processing method, device, equipment and storage medium
CN111931220B (en) * 2020-09-24 2021-01-01 腾讯科技(深圳)有限公司 Consensus processing method, device, medium and electronic equipment for block chain network
CN112182113A (en) * 2020-10-23 2021-01-05 网易(杭州)网络有限公司 Block chain consensus method, system, electronic device and storage medium
CN112202933B (en) * 2020-12-08 2021-03-05 腾讯科技(深圳)有限公司 Information processing method and device of block chain network and node equipment
CN112671761B (en) * 2020-12-22 2022-08-05 网易(杭州)网络有限公司 Node processing method and device for block chain, node equipment and storage medium
CN113094753B (en) * 2021-05-08 2023-02-24 重庆银行股份有限公司 Big data platform hive data modification method and system based on block chain
CN113094754B (en) * 2021-05-08 2022-11-01 重庆银行股份有限公司 Big data platform data modification system and modification, response, cache and verification method
CN114466034B (en) * 2022-03-21 2022-09-02 北京航空航天大学 Block chain consensus method based on anonymous main node
CN117478301B (en) * 2023-12-27 2024-04-09 湖南天河国云科技有限公司 Block chain consensus achieving method and device based on directed acyclic graph

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106060036A (en) * 2016-05-26 2016-10-26 布比(北京)网络技术有限公司 Decentralized consenting method and apparatus
CN109964446A (en) * 2018-06-08 2019-07-02 北京大学深圳研究生院 A kind of common recognition method based on ballot

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108648078B (en) * 2018-05-02 2021-03-23 杭州溪塔科技有限公司 Transaction preprocessing method and device and electronic equipment
CN110012100B (en) * 2019-04-09 2021-04-27 杭州秘猿科技有限公司 Bandwidth-optimized block chain consensus method and device and electronic equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106060036A (en) * 2016-05-26 2016-10-26 布比(北京)网络技术有限公司 Decentralized consenting method and apparatus
CN109964446A (en) * 2018-06-08 2019-07-02 北京大学深圳研究生院 A kind of common recognition method based on ballot

Also Published As

Publication number Publication date
CN111061769A (en) 2020-04-24

Similar Documents

Publication Publication Date Title
CN111061769B (en) Consensus method of block chain system and related equipment
CN107193490B (en) Distributed data storage system and method based on block chain
US20200143366A1 (en) Methods for decentralized digital asset transfer and smart contract state transition
JP7012879B2 (en) Consensus on storage of shared blockchain data based on error correction code
CN111400112B (en) Writing method and device of storage system of distributed cluster and readable storage medium
KR102412024B1 (en) Indexing and recovery of encoded blockchain data
CN111630507A (en) Distributed blockchain data storage under account model
CN111163148B (en) Synchronization method and related equipment for consensus state of block chain system
CN111630830A (en) Distributed blockchain data storage under account model
JP7004423B2 (en) Data security of storage of shared blockchain data based on error correction code
CN111095218B (en) Method, system and device for storing shared block chain data based on error correction coding
CN110941676B (en) Configuration method, device, equipment and medium
CN111095210A (en) Storing shared blockchain data based on error correction coding
CN111417930A (en) Prioritizing shared blockchain data storage
CN110570311B (en) Block chain consensus method, device and equipment
WO2021190179A1 (en) Synchronous processing method and related apparatus
CN110706113A (en) Cross-block-chain data processing method, device, equipment and medium
CN111444204B (en) Synchronous processing method, device, equipment and medium
CN111033491A (en) Storing shared blockchain data based on error correction coding
CN111226206A (en) Taking snapshots of blockchain data
CN111386519A (en) Dynamic blockchain data storage based on error correction codes
CN111316256A (en) Taking snapshots of blockchain data
CN115988001A (en) Consensus voting processing method, device, equipment and medium for block chain system
CN111444206B (en) Synchronous processing method, device, equipment and medium
CN111131329A (en) Data consensus method and device for block chain system and hardware equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40022315

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant