CN114049123B - Block chain consensus method and device, computer equipment and storage medium - Google Patents

Block chain consensus method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114049123B
CN114049123B CN202210029254.0A CN202210029254A CN114049123B CN 114049123 B CN114049123 B CN 114049123B CN 202210029254 A CN202210029254 A CN 202210029254A CN 114049123 B CN114049123 B CN 114049123B
Authority
CN
China
Prior art keywords
consensus
block
target
acyclic graph
directed acyclic
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
CN202210029254.0A
Other languages
Chinese (zh)
Other versions
CN114049123A (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.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology 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 Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202210029254.0A priority Critical patent/CN114049123B/en
Publication of CN114049123A publication Critical patent/CN114049123A/en
Application granted granted Critical
Publication of CN114049123B publication Critical patent/CN114049123B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3821Electronic credentials
    • G06Q20/38215Use of certificates or encrypted proofs of transaction rights
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification

Abstract

The invention discloses a method, a device, equipment and a storage medium for realizing a consensus mechanism; the consensus mechanism implementation method comprises the following steps: receiving transaction information and storing the transaction information in a transaction pool; packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in a directed acyclic graph structure; receiving authentication information of the target node on the common identification blocks, and determining a leader block from all the common identification blocks received by the directed acyclic graph structure according to the authentication information; and processing and submitting the history blocks associated with the leader block for execution. The technical scheme of the invention has the advantages that consensus does not depend on a main node, each consensus node has equal right to generate a new block, the fault tolerance of a consensus mechanism is improved, a view switching mechanism is not depended on, the current round of unfinished work can be continued as long as the network recovers connection in an asynchronous network, and the activity loss caused by frequent overtime view switching is avoided.

Description

Block chain consensus method and device, computer equipment and storage medium
Technical Field
The invention relates to the technical field of consensus mechanisms, in particular to a block chain consensus method and device, computer equipment and a storage medium.
Background
With the development of the block chain technology, the core key technology consensus mechanism has also received much attention. The consensus mechanism is responsible for verifying and adding verification information to the classification account book, ensuring that only real transactions are recorded, i.e. safely updating the data state in the distributed network, so that all honest nodes store consistent data. Specifically, the consensus mechanism should achieve consistency, efficiency, and security. Consistency means that all honest nodes hold exactly the same valid data. Validity means that information released by a certain honest node will eventually be recorded by all other honest nodes. Security refers to ensuring that a system can still operate in the face of a threat or failure. Besides, the efficiency and the expandability of the consensus mechanism need to be considered, so that the consensus mechanism has practical value.
In the existing consensus mechanism, PBFT (called as a Practical Byzantine Fault-tolerant algorithm) adopts a method of setting round number and a timer, and selects a globally unified master node in each round, if the network does not respond for a long time or has an error, the master node is triggered to overtime through the timer, and then enters a new round to select a new master node, so that view switching is performed due to frequent overtime of the timer in an asynchronous network, activity is lost, and a slave node has to wait for overtime if the master node fails due to high dependency on the master node selected in each round.
Disclosure of Invention
The embodiment of the invention provides a consensus method and device of a block chain, computer equipment and a storage medium, aiming at solving the problem of low fault tolerance of a consensus mechanism caused by depending on a master node selected in each round in the prior art.
In one aspect, an embodiment of the present invention provides a block chain consensus method, where the method includes:
receiving transaction information and storing the transaction information in a transaction pool;
packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in a directed acyclic graph structure;
receiving authentication information of the target node on the consensus blocks, and determining a leader block from all the consensus blocks of the directed acyclic graph structure according to the authentication information;
and processing and submitting the history blocks associated with the leader block for execution.
In some embodiments of the present invention, the receiving authentication information of the target node for the consensus blocks, and determining a leader block from the consensus blocks of the directed acyclic graph structure according to the authentication information includes:
receiving authentication information of the target node to the consensus block, and counting the number of the received authentication information;
if the number of the received authentication information reaches a preset number threshold, acquiring a preset random number corresponding to the consensus block;
acquiring a target consensus block in the directed acyclic graph structure and the number of times of the target consensus block to be quoted according to the preset random number;
and if the referenced times of the target consensus block reach a preset time threshold, setting the target consensus block as a leader block.
In some embodiments of the present invention, the obtaining a target consensus block in the directed acyclic graph structure according to the preset random number, and the number of times that the target consensus block is referred to includes:
performing security verification on the preset random number;
if the preset random number passes the safety verification, acquiring a block list in the consensus blocks, wherein the block list is used for recording the consensus blocks broadcasted by the target node;
and selecting a target consensus block in the directed acyclic graph structure from the block list according to the preset random number, and obtaining the number of times of being referred corresponding to the target consensus block in the directed acyclic graph structure.
In some embodiments of the present invention, the obtaining a preset random number corresponding to the consensus block if the number of the received authentication information reaches a preset number threshold includes:
if the number of the received authentication information reaches a preset number threshold, generating certificate information according to the received authentication information;
broadcasting the certificate information to the target node, receiving the target certificate information broadcast by the target node, and acquiring a preset random number corresponding to the consensus block according to the target certificate information.
In some embodiments of the present invention, the broadcasting the certificate information to the target node, receiving the target certificate information broadcast by the target node, and acquiring the preset random number corresponding to the consensus block according to the target certificate information includes:
broadcasting the certificate information to the target node, and receiving the target certificate information broadcast by the target node;
acquiring the number of received target certificate information;
if the number of the target certificate information reaches a preset number threshold, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key.
In some embodiments of the present invention, before the step of packaging the transaction information in the transaction pool into a pre-created consensus block and broadcasting the consensus block to the target node in the directed acyclic graph structure, the method includes:
inquiring whether the created directed acyclic graph exists;
if the created directed acyclic graph exists, acquiring the number of rounds of the created directed acyclic graph;
and acquiring an existing consensus block corresponding to the maximum value in the round number, acquiring existing certificate information of the existing consensus block, referring to the existing certificate, and creating the consensus block.
In some embodiments of the present invention, said processing and submitting for execution the history block associated with the leader block comprises:
obtaining a path of the leader block in the directed acyclic graph structure;
acquiring historical blocks in the path and historical transaction information corresponding to the historical blocks;
and sequencing and de-duplicating the historical transaction information, and submitting for execution.
In some embodiments of the present invention, after packaging the transaction information in the transaction pool into a pre-created consensus block and broadcasting the consensus block to a target node in a directed acyclic graph structure, the method includes:
receiving a consensus block broadcast by the target node, and requesting the target node to acquire target transaction information corresponding to the consensus block;
carrying out validity verification on the common identification block according to the signature information, the target certificate information and the target round number information of the common identification block;
if the legitimacy of the common identification block passes the verification, the target transaction information is stored, and authentication information is replied to the target node.
In another aspect, an embodiment of the present invention provides an apparatus for recognizing a block chain, where the apparatus includes:
the receiving module is used for receiving the transaction information and storing the transaction information to the transaction pool;
the creating module is used for packaging the transaction information in the transaction pool into a pre-created consensus block and broadcasting the consensus block to a target node in a directed acyclic graph structure;
a leading block determining module, configured to receive authentication information of the target node on the consensus blocks, and determine a leading block from the consensus blocks of the directed acyclic graph structure according to the authentication information;
and the processing module is used for processing the history blocks associated with the leader block and submitting for execution.
In another aspect, an embodiment of the present invention provides a computer device, where the computer device includes a memory and a processor; the memory stores an application program, and the processor is configured to execute the application program in the memory to perform the operation of the block chain consensus method.
In another aspect, an embodiment of the present invention provides a storage medium, where the storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to perform the steps in the block chain consensus method.
The embodiment of the invention receives the transaction information and stores the transaction information into a transaction pool; packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in a directed acyclic graph structure; receiving authentication information of the target node on the common identification blocks, and determining a leader block from all the common identification blocks of the directed acyclic graph structure according to the authentication information; processing and submitting for execution the history blocks associated with the leader block; the technical scheme of the invention has the advantages that consensus does not depend on a main node, each consensus node has equal right to generate a new block, the fault tolerance of a consensus mechanism is improved, an attempt switching mechanism is not depended on, the incomplete work of the round can be continuously carried out as long as the network recovers connection in an asynchronous network, and the loss of activity caused by frequent overtime view switching is avoided.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of an embodiment of a block chain consensus method according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a directed acyclic graph provided in an embodiment of the present invention;
fig. 3 is a flowchart illustrating an embodiment of processing history blocks in a block chain consensus method according to the present invention;
fig. 4 is a schematic flowchart of an embodiment of determining a leader block in the consensus method of the block chain according to the embodiment of the present invention;
fig. 5 is a flowchart illustrating an embodiment of generating a random number in a block chain consensus method according to an embodiment of the present invention;
fig. 6 is a flowchart illustrating an embodiment of obtaining a target consensus block in a block chain consensus method according to an embodiment of the present invention;
fig. 7 is a flowchart illustrating an embodiment of creating a consensus block in a block chain consensus method according to an embodiment of the present invention;
fig. 8 is a flowchart illustrating an embodiment of checking a consensus block in a block chain consensus method according to the present invention;
fig. 9 is a schematic structural diagram of an embodiment of a block chain consensus device according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of an embodiment of a computer device provided in an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, 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 obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
The embodiment of the invention provides a block chain consensus method, a block chain consensus device, computer equipment and a storage medium. In accordance with an embodiment of the block chain consensus method provided by the embodiments of the present invention, it should be noted that the steps illustrated in the flow diagrams of the figures may be performed in a computer system such as a set of computer-executable instructions, and that while a logical order is illustrated in the flow diagrams, in some cases, the steps described or illustrated may be performed in an order different than the order of execution presented herein.
As shown in fig. 1, fig. 1 is a schematic flowchart of an embodiment of a block chain consensus method according to an embodiment of the present invention. In some embodiments of the present invention, the illustrated block chain consensus method may be applied to at least one of a computer device and a terminal device, where the computer device may be an independent server, or may be a server network or a server cluster composed of servers, for example, a computer, a network host, a single network server, a plurality of network server sets, or a cloud server composed of a plurality of servers. Among them, the Cloud server is constituted by a large number of computers or web servers based on Cloud Computing (Cloud Computing). The terminal device includes but is not limited to a smart phone, a tablet computer and a PC terminal. In some embodiments of the present invention, when the illustrated method for recognizing a block chain is applied to a computer device and a terminal device, the terminal device and the computer device may implement communication through any communication method, where the communication method includes, but is not limited to, mobile communication based on third Generation Partnership project (3 rd Generation Partnership project,3 gpp), long Term Evolution (LTE), worldwide Interoperability for Microwave Access (WiMAX), or computer network communication based on TCP/IP Protocol Suite (TCP/IP), user Datagram Protocol (UDP), and the like. The block chain consensus method shown in fig. 1 includes steps 101 to 104:
step 101, receiving transaction information and storing the transaction information in a transaction pool.
A transaction refers to an operation that the blockchain generates in an application, such as a transfer operation, creation of a smart contract, smart contract invocation, creation of an account, and the like. The transaction information includes a plurality of information such as an initiator address of the transaction, a contract address of the transaction, a transaction type of the transaction, and the like, and one transaction corresponds to one transaction information.
In some embodiments of the present invention, when a new transaction is generated, the transaction information of the transaction is sent to the selected node, and the node stores the received transaction information in the transaction pool. It should be noted that, in the embodiment of the present application, the manner of selecting a node for a client that generates a transaction is not limited.
In some embodiments of the invention, the transaction amount in the transaction pool may be counted after the transaction information is received and saved to the transaction pool; if the transaction amount reaches the preset transaction amount threshold, step 102 is executed.
In some embodiments of the invention, after the transaction information is received and stored in the transaction pool, time information for storing the transaction information in the transaction pool is recorded, and the storage duration of the transaction information in the transaction pool is counted according to the world time information; if the storage time length reaches the preset time length, executing the step 102; if the storage time does not reach the preset time, counting the transaction number in the transaction pool; if the transaction amount reaches the preset transaction amount threshold, step 102 is executed.
In some embodiments of the present invention, after receiving the transaction information and saving the transaction information to the transaction pool, it may also be queried whether a directed acyclic graph exists; if there is a directed acyclic graph, perform step 102; if the directed acyclic graph does not exist, submitting an initial empty area block, establishing an appearance generation wheel of the directed acyclic graph corresponding to the block chain according to the submitted empty area block, submitting a1 st-round consensus block according to each appearance generation block in the appearance generation wheel of the directed acyclic graph, packaging transaction information into the 1 st-round consensus block, and creating a first round of the directed acyclic graph. Wherein the generative blocks in the generative wheel of the directed acyclic graph are used to place a list of nodes participating in consensus in a blockchain. In some embodiments of the present invention, if there is no directed acyclic graph, each node in the block chain submits an initial empty block corresponding to each node, each node packs the transaction information in the corresponding transaction pool into a corresponding initial empty block, obtains a consensus block corresponding to each node, and creates an initial round of the directed acyclic graph. In some embodiments of the present invention, each node generates only one block in each round of the directed acyclic graph structure, as shown in fig. 2, fig. 2 is a schematic structural diagram of the directed acyclic graph provided in the embodiment of the present invention, and in the illustrated directed acyclic graph structure, a v1 node generates only the consensus block b (v 1, r 1) in the round r1, and the consensus block b (v 1, r 2) created in the round r2 by the v1 node references the consensus blocks b (v 1, r 1), b (v 2, r 1), b (v 3, r 1) in the round r1, where v1, v2, v3, and v4 refer to nodes in a block chain, and r1, r2, r3, r4, and r5 are used to indicate the number of rounds of the directed acyclic graph. It should be noted that, when a node generates more than one block in each round of the directed acyclic graph, other nodes will refuse to authenticate the block generated by the node.
In some embodiments of the present invention, in order to reduce the structural complexity of the directed acyclic graph and increase throughput, transaction information of other nodes may also be acquired, and each transaction information and source node information corresponding to each transaction information are stored in the transaction pool.
And 102, packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in the directed acyclic graph structure.
The target node refers to other nodes participating in consensus besides the local node in the block chain.
In some embodiments of the present invention, step 102 comprises: and acquiring the abstract hash value of the transaction information in the transaction pool, writing the abstract hash value into a pre-established consensus block, and broadcasting the consensus block to a target node in the directed acyclic graph structure.
In some embodiments of the present invention, step 102 further comprises: the method comprises the steps of obtaining a summary hash value of transaction information in a transaction pool, obtaining signature information of a node, obtaining the round number of a pre-created consensus block in a directed acyclic graph structure, writing the summary hash value, the signature information and the round number into the pre-created consensus block, and broadcasting the consensus block to a target node in the directed acyclic graph structure.
In some embodiments of the present invention, step 102 further comprises: acquiring the number of current wheels in a directed acyclic graph structure, and judging whether the number of the current wheels is greater than 1; if the number of rounds is equal to 1, packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in the directed acyclic graph structure; if the number of rounds is larger than 1, inquiring whether certificate information exists in a pre-established consensus block corresponding to the current round; if the certificate information exists in the pre-created consensus blocks corresponding to the current round, packaging the transaction information in the transaction pool into the pre-created consensus blocks, and broadcasting the consensus blocks to target nodes in the directed acyclic graph structure; if the certificate information does not exist in the pre-established common identification block corresponding to the current round, network interruption of a node in a block chain is described, or the node fails, waiting for a preset time length, and inquiring whether the certificate information exists in the pre-established common identification block corresponding to the current round; if after the preset time length, certificate information still does not exist in the pre-established common identification block corresponding to the current round, and the node fails, the node sends node failure information to the client or the background server, so that the client reselects the node or the background server performs failure detection. The certificate information refers to a voting set of a plurality of nodes for the same information, which are voted for reaching consensus in the family fault tolerance algorithm, and is used for indicating whether the consensus blocks corresponding to the nodes are created successfully.
And 103, receiving authentication information of the target node on the common identification blocks, and determining a leader block from all the common identification blocks of the directed acyclic graph structure according to the authentication information.
In some embodiments of the present invention, the node receives authentication information of the target node on the consensus block, counts source nodes of the authentication information according to signatures of the authentication information, and determines whether to submit the leader block according to a current round number corresponding to the consensus block in the directed acyclic graph structure when the number of the source nodes reaches a preset number; if the leader block is submitted, determining the leader block according to the consensus block and the authentication information, and executing step 104; and if the leader block is not submitted, moving the directed acyclic graph structure to the next round and creating a new consensus block. The current round number corresponding to the common identification block in the directed acyclic graph structure may be compared with a preset round number threshold, if the current round number is greater than or equal to the preset round number threshold, the leader block is submitted, and if the current round number is less than the preset round number threshold, the leader block is not submitted. Illustratively, taking an example that the preset round number threshold is 3, when the current round number corresponding to the consensus block in the acyclic graph structure is greater than or equal to 3, submitting the leader block; and if the corresponding current number of rounds of the common identification block in the directed acyclic graph structure is less than 3, the leader block is not submitted.
A leader block refers to a block used to make consensus in a block chain.
And 104, processing the history blocks associated with the leader block and submitting for execution.
The history blocks can be blocks in the directed acyclic graph structure except the common blocks corresponding to the current wheel, and the blocks on the path can also be referred by the leader block. In some embodiments of the present invention, the processing may be ordering and deduplication of transactions in a history block, specifically, as shown in fig. 3, fig. 3 is a flowchart illustrating an embodiment of processing a history block in the consensus method of a block chain provided in the embodiment of the present invention, where the illustrated method of processing a history block includes steps 301 to 303:
step 301, acquiring a path of the leader block in the directed acyclic graph structure.
The path refers to a reference block path of the leader block in the directed acyclic graph structure, and in some embodiments of the present invention, the path of the leader block may be determined from referenced certificate information in the leader block.
In some embodiments of the present invention, the number of starting rounds and the number of ending rounds of the path are determined according to the number of rounds in which the leader block is located and a preset round number interval, for example, when the preset round number interval is 3 and the number of rounds in which the leader block is located is r3, the number of starting rounds of the corresponding path is r1, and the number of ending rounds is r2, that is, the reference path of the leader block in the r1 round and the r2 round is obtained according to the certificate information of reference of the leader block in the r3 round.
Step 302, obtain the historical blocks in the path and the historical transaction information corresponding to the historical blocks.
The history blocks include the leader block, the blocks referenced by the leader block, and the blocks on the referenced block path. For example, when the leader block is b (v 3, r 3) in fig. 2, reference blocks b (v 2, r 2), b (v 3, r 2), b (v 4, r 2) of which b (v 3, r 3) is r2 are obtained, reference blocks b (v 1, r 1), b (v 2, r 1), b (v 3, r 1), b (v 4, r 1) and b (v 4, r 1) of each of b (v 2, r 2), b (v 3, r 2), b (v 4, r 2) of the reference blocks are obtained, and the history blocks are obtained: b (v 3, r 3), b (v 2, r 2), b (v 3, r 2), b (v 4, r 2), b (v 1, r 1), b (v 2, r 1), b (v 3, r 1) and b (v 4, r 1), and acquiring historical transaction information in each historical block.
In some embodiments of the present invention, the digest hash values in the history blocks may be obtained, and the corresponding history transaction information may be obtained according to the digest hash values.
Step 303, sorting and de-duplicating the historical transaction information, and submitting for execution.
In some embodiments of the present invention, historical transaction information may be grouped according to the number of rounds in which the historical blocks are located, and for the historical transaction information in each group, the historical transaction information in each group may be sorted according to any sort method, such as historical transaction information generation time, digest hash value, creation time of the corresponding block, and the like; and sequencing each group of sequenced historical transaction information according to the sequence of the round number from large to small or the round number from small to large, performing deduplication processing on the sequenced historical transaction information according to the digest hash value of each historical transaction information, and submitting and executing the deduplicated historical transaction information.
The consensus of the embodiment of the invention does not depend on the main node, each consensus node has equal right to generate a new block, the fault tolerance of the consensus mechanism is improved, the consensus mechanism does not depend on an attempt switching mechanism, the current round of unfinished work can be continued as long as the network recovers the connection in an asynchronous network, and the activity loss caused by frequent overtime view switching can be avoided.
In some embodiments of the present invention, a target consensus block may be selected according to the authentication information, and whether the target consensus block is a leader block is determined according to a number of times that the target consensus block is referenced in a next round in the directed acyclic graph structure. Specifically, a method for determining a leader block is shown in fig. 4, where fig. 4 is a schematic flow chart of an embodiment of determining a leader block in a block chain consensus method provided by the embodiment of the present invention, and the method for determining a leader block includes steps 401 to 404:
step 401, receiving the authentication information of the target node to the consensus block, and counting the number of the received authentication information.
In step 402, if the number of the received authentication information reaches a preset number threshold, a preset random number corresponding to the consensus block is obtained.
The random number refers to a group of arrays or a value, and in some embodiments of the present invention, the random number may be derived from a private key in a shared key in the blockchain. Specifically, signature information of the consensus block and signature information of other consensus blocks corresponding to the number of rounds in which the consensus block is located are obtained, the signature information is aggregated, and a private key in the shared key is used for encrypting the aggregated signature information to obtain a group of random numbers as preset random numbers corresponding to the consensus block.
In some embodiments of the present invention, when the random number is generated, it is determined whether creation of other consensus blocks in the current round is completed, and when it is detected that creation of other consensus blocks is completed, the random number is generated according to the signature information of the consensus blocks, the signature information of the other consensus blocks corresponding to the current round, and the private key in the shared key. Specifically, a method for generating a random number is shown in fig. 5, where fig. 5 is a flowchart illustrating an embodiment of generating a random number in a block chain consensus method provided in an embodiment of the present invention, and the method for generating a random number includes steps 501 to 502:
step 501, if the number of the received authentication information reaches a preset number threshold, generating certificate information according to the received authentication information.
In some embodiments of the present invention, if the number of received authentication information reaches the preset number threshold, which indicates that the establishment of the consensus node is successful, at least a preset number of authentication information from different target nodes is combined to generate the certificate information, where the preset number may be 2f +1, where f is the maximum number of malicious nodes allowed in the block chain, for example, as in the directed acyclic graph structure shown in fig. 2, f is 1, that is, in the directed acyclic graph structure shown in fig. 2, if the number of received authentication information reaches the preset number threshold, which indicates that the establishment of the consensus node is successful, at least 3 authentication information from different target nodes are combined to generate the certificate information.
Step 502, broadcasting certificate information to a target node, receiving the target certificate information broadcast by the target node, and acquiring a preset random number corresponding to the consensus block according to the target certificate information.
In some embodiments of the present invention, whether other consensus blocks of the current round are completed may be determined according to the number of received target certificate information broadcasted by the target node, specifically, the method includes steps a1 to a3:
step a1, broadcasting certificate information to a target node, and receiving the target certificate information broadcast by the target node.
The target certificate information refers to certificate information corresponding to other common identification nodes in the current round.
And step a2, acquiring the number of the received target certificate information.
And counting the number of the target certificate information which is the same as the number of the rounds of the consensus blocks in the received target certificate information according to the number of the rounds of the consensus blocks.
And a3, if the number of the target certificate information reaches a preset number threshold, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key.
The pre-set key refers to a private key in a consensus key in the blockchain.
In some embodiments of the invention, step a3 comprises: if the number of the target certificate information reaches a preset number threshold value, which indicates that other common identification blocks of the current wheel in the directed acyclic graph structure are established, acquiring the number of the current wheel, and judging whether the number of the current wheel meets preset requirements or not; if the preset requirement is met, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key; if the preset requirement is not met, moving to the next round of the directed acyclic graph, proposing a new consensus block, and executing steps 101-104. In some embodiments of the present invention, the preset requirement may be whether the number of rounds is greater than or equal to a preset number of rounds threshold, obtaining the number of rounds corresponding to the consensus block, and if the number of rounds is less than the preset number of rounds threshold, moving the directed acyclic graph structure to the next round, creating a new consensus block, and performing steps 101 to 104; if the number of rounds is larger than or equal to the preset round number threshold, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key. In some embodiments of the present invention, when determining whether the number of current rounds meets a preset requirement, it may be queried whether a previous leader block exists in a directed acyclic graph structure; if the leader block exists in the previous leader block, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key; and if the previous leader block does not exist, judging whether the number of the wheels corresponding to the consensus block is greater than or equal to a preset wheel number threshold value or not, and determining whether the number of the current wheels meets the preset requirement or not.
The embodiment of the invention does not depend on a view switching mechanism, and the node continuously tries to send the blocks and the certificate information created in the current round until entering the next round. In the asynchronous network, as long as the network recovers the connection, the unfinished work of the current round can be continued, and the activity can not be lost due to frequent overtime view switching.
Step 403, obtaining the target consensus blocks in the directed acyclic graph structure and the number of times of referencing the target consensus blocks according to the preset random number.
The target consensus block refers to an existing consensus block selected by a predetermined random number.
In some embodiments of the present invention, a target consensus block may be selected from existing consensus blocks selected by a preset random number according to the preset random number, and a number of times that the target consensus block is referred to in a directed acyclic graph structure is obtained, specifically as shown in fig. 6, where fig. 6 is a schematic flow diagram of an embodiment of obtaining the target consensus block in the consensus method of the block chain provided in the embodiment of the present invention, and the shown method of obtaining the target consensus block includes steps 601 to 603:
step 601, performing security verification on a preset random number.
In some embodiments of the present invention, the preset random number may be securely verified according to a public key in a shared secret key in the blockchain. For example, decrypting a preset random number through a public key in a shared secret key in a block chain, and comparing the decrypted data with signature information aggregated by all the consensus blocks in the current round; if the decrypted data is consistent with the aggregated signature information, judging that the safety verification of the preset random number is passed; and if the decrypted data is inconsistent with the aggregated signature information, judging that the preset random number security verification fails.
Step 602, if the security verification of the preset random number passes, a block list in the consensus block is obtained.
The block list is used for recording the target consensus blocks broadcasted by the target node.
In some embodiments of the present invention, the node receives the consensus blocks broadcast by the target node in each round number, and sorts each consensus block according to the receiving time or the digest hash value in the consensus block to obtain a block list corresponding to each round number.
In some embodiments of the present invention, a target round number is determined according to a current round number of a common identification block and a preset round number interval, and a block list corresponding to the target round number in the common identification block is obtained, which is exemplarily described by taking 3 as an example at the preset round number interval, when the current round number is r, and when r is greater than or equal to 3, the target round number is determined to be r-2, and a block list corresponding to the target round number r-2 in the common identification block is obtained; and when the current round number is r +1, determining the target round number as r-1, and acquiring a block list corresponding to the target round number r-1 in the consensus blocks. For example, when r is 5, and the current round number of the consensus blocks is 5, and the preset round number interval is 3, it is determined that the target round number is 3, and a block list corresponding to the target round number 3 in the consensus blocks is obtained.
Step 603, selecting a target consensus block in the directed acyclic graph structure from the block list according to a preset random number, and obtaining the number of times of reference corresponding to the target consensus block in the directed acyclic graph structure.
In some embodiments of the present invention, the consensus blocks corresponding to the preset random numbers in the block list may be used as target consensus blocks in the directed acyclic graph structure, and the number of times of reference corresponding to the target consensus blocks in the directed acyclic graph structure is obtained.
In some embodiments of the present invention, each value in the random number may be calculated according to a preset value calculation method to obtain a target value, a consensus block corresponding to the target value in the block list is used as a target consensus block in the directed acyclic graph structure, and the number of times that the target consensus block in the directed acyclic graph structure is referred to is obtained.
In some embodiments of the present invention, an existing round number corresponding to a target consensus block in the directed acyclic graph structure is obtained, an existing consensus block in +1 of the existing round number in the directed acyclic graph structure is obtained, and the number of blocks in the existing consensus blocks that point to the target consensus block is counted as the number of times of being referred to corresponding to the target consensus block, for example, when the target consensus block is b (v 3, r 3), the consensus block b (v 3, r 3) of r3 is referred to by b (v 1, r 4), b (v 2, r 4), and b (v 4, r 4) in r4 round, so that the number of times of being referred to corresponding to the target consensus block in the directed acyclic graph structure is 3.
In step 404, if the referenced times of the target consensus block reach a preset times threshold, the target consensus block is set as a leader block.
In some embodiments of the present invention, the preset time threshold may be f +1, for example, in the directed acyclic graph structure shown in fig. 2, f takes a value of 1, that is, the preset time threshold is 3, when the target consensus block is b (v 4, r 1), the block is referred by the block b (v 4, r 2) in the r2 round, and the reference time does not reach f +1, the target consensus block cannot be set as the leader block; and when the target consensus block is b (v 3, r 3), the target consensus block is referred by 3 blocks in the r4 round, and the referred times of the target consensus block reach a preset time threshold, the target consensus block is set as a leader block. In some embodiments of the present invention, when the target consensus block cannot be used as the leader block, the directed acyclic graph structure is moved to the next round, a new consensus block is created, and steps 101-104 are performed.
According to the embodiment of the invention, the main node is not selected, the target consensus block is selected according to the authentication information, whether the target consensus block is the leader block or not is determined according to the number of times of being quoted of the target consensus block, consensus does not depend on the main node, and the fault tolerance of the consensus method of the block chain is improved.
In some embodiments of the present invention, a consensus block may be created according to the number of turns of a directed acyclic graph, specifically, as shown in fig. 7, fig. 7 is a flowchart illustrating an embodiment of creating a consensus block in a block chain consensus method provided in an embodiment of the present invention, where the illustrated method of creating a consensus block includes steps 701 to 703:
step 701, inquiring whether the created directed acyclic graph exists.
Step 702, if there is a created directed acyclic graph, acquiring the number of rounds of the created directed acyclic graph.
Step 703, obtaining the existing consensus block corresponding to the maximum value in the round number, obtaining the historical certificate information of the existing consensus block, referring to the historical certificate information, and creating the consensus block.
In some embodiments of the invention, the consensus block is created with reference to historical certificate information of 2f +1 existing consensus blocks.
The embodiment of the invention does not depend on an attempted switching mechanism, and the node can put forward the consensus blocks of the current round according to the consensus blocks created in the previous round and the certificate information. In the asynchronous network, as long as the network recovers the connection, the unfinished work of the current round can be continued, and the activity can not be lost due to frequent overtime view switching.
In some embodiments of the present invention, when receiving a consensus block broadcasted by a target node, a node checks the consensus block according to the received signature information of the consensus block, the number of rounds where the consensus block is located, and the quoted certificate information; if the verification is passed, returning authentication information to the target node according to the signature information of the node; specifically, as shown in fig. 8, fig. 8 is a schematic flow chart of an embodiment of checking the consensus block in the block chain consensus method provided in the embodiment of the present invention, where the method of checking the consensus block includes steps 801 to 803:
step 801, receiving the consensus block broadcast by the target node, and requesting the target node to obtain the target transaction information corresponding to the consensus block.
And step 802, performing validity verification on the consensus blocks according to the signature information, the target certificate information and the target round number information of the consensus blocks.
In some embodiments of the present invention, it is checked whether the common identification block has signature information of a target node corresponding to the common identification block, and whether there is wheel number information corresponding to the common identification block, if there is signature information of a target node corresponding to the common identification block and there is wheel number information corresponding to the common identification block, the number of target certificate information in the common identification block is obtained, and if the number of target certificate information reaches a preset number, it is determined that the validity verification of the common identification block passes.
In some embodiments of the present invention, if there is the number-of-rounds information corresponding to the consensus block, it is determined whether the number-of-rounds corresponding to the target number-of-rounds information is r1; if the number of rounds is r1, verifying the legality of the consensus block by inquiring whether the consensus block has signature information of a target node corresponding to the consensus block; if the number of turns is not r1, acquiring the number of target certificate information in the consensus block, and verifying the legitimacy of the consensus block according to the number of the target certificates.
In some embodiments of the present invention, if the number of rounds is r1, the common identification block is queried to determine whether signature information of a target node corresponding to the common identification block exists; if the common identification block has the signature information of the target node corresponding to the common identification block, inquiring whether the common identification block is the first common identification block submitted by the target node corresponding to the common identification block in r1 round; and if the common identification block is the first common identification block submitted by the target node in r1 round corresponding to the common identification block, acquiring the quantity of target certificate information in the common identification block, and carrying out validity verification on the common identification block according to the quantity of the target certificates. Step 803, if the validity of the consensus block passes the verification, the target transaction information is saved, and the authentication information is returned to the target node.
In some embodiments of the present invention, if the validity of the consensus block passes the verification, the target transaction information is saved, the voting information is signed according to the signature information of the node to serve as the authentication information, and the authentication information is replied to the voting information of the target node.
In the embodiment of the invention, when the node receives the consensus block broadcasted by the target node, the node firstly requests original transaction information from the source node of the consensus block and then carries out validity verification and signature voting operation. By using the transaction information shared by the transaction pools, the message delay and bandwidth resource consumption of consensus are reduced.
In order to better implement the block chain consensus method provided in the embodiment of the present invention, based on the block chain consensus method, a block chain consensus device is provided, as shown in fig. 9, where fig. 9 is a schematic structural diagram of an embodiment of the block chain consensus device provided in the embodiment of the present invention, and the block chain consensus device includes:
a receiving module 901, configured to receive transaction information and store the transaction information in a transaction pool;
a creating module 902, configured to pack the transaction information in the transaction pool into a pre-created consensus block, and broadcast the consensus block to a target node in the directed acyclic graph structure;
a leader block determining module 903, configured to receive authentication information of the target node on the common knowledge blocks, and determine the leader block from the common knowledge blocks received by the directed acyclic graph structure according to the authentication information;
and a processing module 904, configured to process and submit execution of the history blocks associated with the leader block.
In some embodiments of the invention, the leader block determination module 903 comprises:
the counting unit is used for receiving the authentication information of the target node on the common identification block and counting the number of the received authentication information;
a random number unit, configured to obtain a preset random number corresponding to the consensus block if the number of the received authentication information reaches a preset number threshold;
the acquisition unit is used for acquiring a target consensus block in the directed acyclic graph structure and the quoted times of the target consensus block according to a preset random number;
and the leader block determining unit is used for setting the target consensus block as the leader block if the referenced times of the target consensus block reach a preset time threshold.
In some embodiments of the invention, the obtaining unit is further configured to: carrying out security verification on a preset random number; if the preset random number passes the safety verification, acquiring a block list in the consensus blocks, wherein the block list is used for recording the consensus blocks broadcasted by the target node; and selecting a target consensus block in the directed acyclic graph structure from the block list according to a preset random number, and acquiring the number of times of being quoted corresponding to the target consensus block in the directed acyclic graph structure.
In some embodiments of the invention, the random number unit comprises:
the certificate generating subunit is used for generating certificate information according to the received authentication information if the number of the received authentication information reaches a preset number threshold;
and the random number subunit is used for broadcasting the certificate information to the target node, receiving the target certificate information broadcast by the target node and acquiring the preset random number corresponding to the consensus block according to the target certificate information.
In some embodiments of the invention, the random number subunit is further configured to: broadcasting certificate information to a target node, and receiving the target certificate information broadcast by the target node; acquiring the number of received target certificate information; if the number of the target certificate information reaches the preset number threshold, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key.
In some embodiments of the present invention, the apparatus for identifying a blockchain further comprises:
a block generation module 905, configured to query whether there is a created directed acyclic graph; if the created directed acyclic graph exists, acquiring the number of rounds of the created directed acyclic graph; and acquiring an existing consensus block corresponding to the maximum value in the round number, acquiring existing certificate information of the existing consensus block, referring to an existing certificate, and creating the consensus block.
In some embodiments of the invention, the processing module 904 is further configured to: acquiring a path of the leader block in a directed acyclic graph structure; acquiring historical blocks in the path and historical transaction information corresponding to the historical blocks; and sequencing and de-duplicating the historical transaction information, and submitting for execution.
In some embodiments of the present invention, the apparatus for identifying a blockchain further comprises:
the verification module 906 is configured to receive the consensus block broadcast by the target node, and request the target node to obtain target transaction information corresponding to the consensus block; carrying out validity verification on the common identification block according to the signature information, the target certificate information and the target round number information of the common identification block; if the legitimacy of the common identification block passes the verification, the target transaction information is stored, and the authentication information is replied to the target node.
The consensus in the embodiment of the invention does not depend on the main node, each consensus node has equal right to generate a new block, the fault tolerance of the consensus mechanism is improved, and the consensus does not depend on an attempted switching mechanism.
An embodiment of the present invention further provides a computer device, as shown in fig. 10, which shows a schematic structural diagram of a computer device according to an embodiment of the present invention, specifically:
the computer device may include components such as a processor 1001 of one or more processing cores, memory 1002 of one or more computer-readable storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 10 is not intended to be limiting of computer devices and may include more or fewer components than those shown, or some of the components may be combined, or a different arrangement of components. Wherein:
the processor 1001 is a control center of the computer device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by running or executing software programs and/or modules stored in the memory 1002 and calling data stored in the memory 1002, thereby monitoring the computer device as a whole. Optionally, processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor, which mainly handles an operating system, a user interface, application programs, etc., and a modem processor, which mainly handles wireless communication. It will be appreciated that the modem processor described above may not be integrated into the processor 1001.
The memory 1002 may be used to store software programs and modules, and the processor 1001 executes various functional applications and data processing by operating the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 1002 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 access to the memory 1002.
The computer device further includes a power source 1003 for supplying power to each component, and preferably, the power source 1003 may be logically connected to the processor 1001 through a power management system, so that functions of managing charging, discharging, power consumption, and the like are implemented through the power management system. The power source 1003 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
The computer device may also include an input unit 1004, and the input unit 1004 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the computer device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 1001 in the computer device loads the executable file corresponding to the process of one or more application programs into the memory 1002 according to the following instructions, and the processor 1001 runs the application programs stored in the memory 1002, so as to implement various functions as follows:
receiving transaction information and storing the transaction information in a transaction pool;
packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in a directed acyclic graph structure;
receiving authentication information of the target node on the consensus blocks, and determining a leader block from all the consensus blocks of the directed acyclic graph structure according to the authentication information;
and processing and submitting the history blocks associated with the leader block for execution.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the present invention provides a storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any block chain consensus method provided by the present invention. For example, the instructions may perform the steps of:
receiving transaction information and storing the transaction information in a transaction pool;
packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in a directed acyclic graph structure;
receiving authentication information of the target node on the consensus blocks, and determining a leader block from all the consensus blocks of the directed acyclic graph structure according to the authentication information;
and processing and submitting the history blocks associated with the leader block for execution.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium may execute the steps in any block chain consensus method provided in the embodiments of the present invention, beneficial effects that can be achieved by any block chain consensus method provided in the embodiments of the present invention can be achieved, for which details are shown in the foregoing embodiments and are not described herein again.
The block chain consensus method, apparatus, computer device and storage medium provided in the embodiments of the present invention are described in detail above, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the description of the embodiments is only used to help understanding the method and its core ideas of the present invention; meanwhile, for those skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for block chain consensus, the method comprising:
receiving transaction information and storing the transaction information in a transaction pool;
packaging the transaction information in the transaction pool into a pre-established consensus block, and broadcasting the consensus block to a target node in a directed acyclic graph structure;
receiving authentication information of the target node on the consensus blocks, determining a preset random number according to the authentication information and the current round number of the directed acyclic graph structure, and determining a leader block from the consensus blocks of the directed acyclic graph structure according to the preset random number; the leader block is obtained by selecting from all the consensus blocks of the directed acyclic graph structure without selecting a main node, and the leader block is used for performing consensus in a block chain;
and processing and submitting the history blocks associated with the leader block for execution.
2. The method of claim 1, wherein the receiving authentication information of the target node for the consensus block, determining a preset random number according to the authentication information and a current round number of the directed acyclic graph structure, and determining a leader block from the consensus blocks of the directed acyclic graph structure according to the preset random number comprises:
receiving authentication information of the target node to the consensus block, and counting the number of the received authentication information;
if the number of the received authentication information reaches a preset number threshold, acquiring a preset random number corresponding to the consensus block according to the current round number of the directed acyclic graph structure;
acquiring a target consensus block in the directed acyclic graph structure and the number of times of the target consensus block to be quoted according to the preset random number;
and if the referenced times of the target consensus block reach a preset time threshold, setting the target consensus block as a leader block.
3. The method of claim 2, wherein the obtaining the target consensus chunk in the directed acyclic graph structure according to the predetermined random number, and the number of times the target consensus chunk is referenced comprises:
performing security verification on the preset random number;
if the preset random number passes the safety verification, acquiring a block list in the consensus blocks, wherein the block list is used for recording the consensus blocks broadcasted by the target node;
and selecting a target consensus block in the directed acyclic graph structure from the block list according to the preset random number, and obtaining the number of times of being referred corresponding to the target consensus block in the directed acyclic graph structure.
4. The method as claimed in claim 2, wherein the obtaining the predetermined random number corresponding to the consensus block according to the current round number of the directed acyclic graph structure if the number of the received authentication information reaches a predetermined number threshold comprises:
if the number of the received authentication information reaches a preset number threshold, generating certificate information according to the received authentication information;
broadcasting the certificate information to the target node, receiving the target certificate information broadcasted by the target node, and acquiring a preset random number corresponding to the consensus block according to the target certificate information and the current round number of the directed acyclic graph structure.
5. The method for block chain consensus as claimed in claim 4, wherein the broadcasting the certificate information to the target node, receiving the target certificate information broadcast by the target node, and obtaining the predetermined random number corresponding to the consensus block according to the target certificate information and the current round number of the directed acyclic graph structure comprises:
broadcasting the certificate information to the target node, and receiving the target certificate information broadcast by the target node;
acquiring the number of received target certificate information;
if the number of the target certificate information reaches a preset number threshold value and the current round number of the directed acyclic graph structure meets a preset requirement, acquiring a preset secret key of the consensus block, and generating a preset random number corresponding to the consensus block according to the preset secret key; the preset requirement indicates that the number of rounds is greater than or equal to a preset round threshold.
6. The block chain consensus method of claim 1, wherein said step of packaging transaction information in said transaction pool into pre-created consensus blocks and broadcasting said consensus blocks to target nodes in a directed acyclic graph structure comprises:
inquiring whether the created directed acyclic graph exists;
if the created directed acyclic graph exists, acquiring the number of rounds of the created directed acyclic graph;
and acquiring an existing consensus block corresponding to the maximum value in the round number, acquiring existing certificate information of the existing consensus block, referring to the existing certificate, and creating the consensus block.
7. A method of consensus of a block chain according to any one of claims 1 to 6, wherein said processing and submitting to execution historical blocks associated with said leader block comprises:
obtaining a path of the leader block in the directed acyclic graph structure;
acquiring historical blocks in the path and historical transaction information corresponding to the historical blocks;
and sequencing and de-duplicating the historical transaction information, and submitting for execution.
8. An apparatus for block chain consensus, the apparatus comprising:
the receiving module is used for receiving the transaction information and storing the transaction information to the transaction pool;
the creating module is used for packaging the transaction information in the transaction pool into a pre-created consensus block and broadcasting the consensus block to a target node in a directed acyclic graph structure;
a leader block determining module, configured to receive authentication information of the target node on the consensus blocks, determine a preset random number according to the authentication information and a current round number of the directed acyclic graph structure, and determine a leader block from the consensus blocks of the directed acyclic graph structure according to the preset random number; the leader block is obtained by selecting from all the consensus blocks of the directed acyclic graph structure without selecting a main node, and the leader block is used for performing consensus in a block chain;
and the processing module is used for processing the history blocks associated with the leader block and submitting for execution.
9. A computer device, wherein the computer device comprises a memory and a processor; the memory stores an application program, and the processor is configured to execute the application program in the memory to perform the operations of the block chain consensus method according to any one of claims 1 to 7.
10. A storage medium storing instructions adapted to be loaded by a processor to perform the steps of the block chain consensus method according to any one of claims 1 to 7.
CN202210029254.0A 2022-01-12 2022-01-12 Block chain consensus method and device, computer equipment and storage medium Active CN114049123B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210029254.0A CN114049123B (en) 2022-01-12 2022-01-12 Block chain consensus method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210029254.0A CN114049123B (en) 2022-01-12 2022-01-12 Block chain consensus method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114049123A CN114049123A (en) 2022-02-15
CN114049123B true CN114049123B (en) 2022-10-04

Family

ID=80196322

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210029254.0A Active CN114049123B (en) 2022-01-12 2022-01-12 Block chain consensus method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114049123B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979166B (en) * 2022-06-09 2023-05-16 中国联合网络通信集团有限公司 Method, device and storage medium for determining consensus node
CN116723200B (en) * 2023-08-11 2023-11-10 武汉趣链数字科技有限公司 Cluster changing method and device, electronic equipment and computer readable storage medium
CN116743771B (en) * 2023-08-11 2023-11-03 武汉趣链数字科技有限公司 Block chain consensus method, apparatus, electronic device and computer readable storage medium
CN116846916B (en) * 2023-09-01 2023-12-08 武汉趣链数字科技有限公司 Data synchronization method, device, electronic equipment and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108182635A (en) * 2017-12-18 2018-06-19 深圳前海微众银行股份有限公司 Block chain common recognition method, system and computer readable storage medium
WO2020042805A1 (en) * 2018-08-31 2020-03-05 阿里巴巴集团控股有限公司 Blockchain-based transaction consensus processing method and apparatus, and electrical device
WO2021238527A1 (en) * 2020-05-26 2021-12-02 腾讯科技(深圳)有限公司 Digital signature generation method and apparatus, computer device, and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11063746B2 (en) * 2018-04-19 2021-07-13 Electronics And Telecommunications Research Institute Method for selecting consensus node using nonce and method and apparatus for generating blockchain using the same
CN109150598B (en) * 2018-08-10 2021-09-03 上交所技术有限责任公司 BFT consensus algorithm bandwidth utilization rate improvement method based on block slice
CN110941859A (en) * 2018-09-21 2020-03-31 上海派链信息科技有限公司 Method, apparatus, computer-readable storage medium, and computer program product for block chain formation consensus
CN110971684B (en) * 2019-11-28 2022-09-09 北京工业大学 PBFT-based block chain network node load balancing method
CN113888164A (en) * 2021-09-30 2022-01-04 上海浦东发展银行股份有限公司 Block chain transaction pool implementation method and device, computer equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108182635A (en) * 2017-12-18 2018-06-19 深圳前海微众银行股份有限公司 Block chain common recognition method, system and computer readable storage medium
WO2020042805A1 (en) * 2018-08-31 2020-03-05 阿里巴巴集团控股有限公司 Blockchain-based transaction consensus processing method and apparatus, and electrical device
WO2021238527A1 (en) * 2020-05-26 2021-12-02 腾讯科技(深圳)有限公司 Digital signature generation method and apparatus, computer device, and storage medium

Also Published As

Publication number Publication date
CN114049123A (en) 2022-02-15

Similar Documents

Publication Publication Date Title
CN114049123B (en) Block chain consensus method and device, computer equipment and storage medium
US20210256016A1 (en) Blockchain system and method
CN108681565B (en) Block chain data parallel processing method, device, equipment and storage medium
CN109831487B (en) Fragmented file verification method and terminal equipment
EP3480686B1 (en) Data processing method, cluster manager, resource manager and data processing system
CN111131209A (en) Improved efficient consensus method, system, computer device and storage medium
CN108509615B (en) Consensus establishing method and device based on drawing mechanism and readable storage medium
CN110995513A (en) Data sending and receiving method in Internet of things system, Internet of things equipment and platform
CN109669822B (en) Electronic device, method for creating backup storage pool, and computer-readable storage medium
CN110334484B (en) Copyright verification method and device, computer equipment and storage medium
CN113742660A (en) Application program permission management system and method
WO2022206431A1 (en) Method and apparatus for querying ledger data of fabric blockchain
US8719622B2 (en) Recording and preventing crash in an appliance
Zhao A byzantine fault tolerant distributed commit protocol
CN109919768B (en) Block generation method, device, medium and computing equipment
CN113364874B (en) Node synchronization method and device based on block chain, storage medium and server
CN113342893B (en) Node synchronization method and device based on block chain, storage medium and server
CN116232893A (en) Consensus method and device of distributed system, electronic equipment and storage medium
CN108984105B (en) Method and device for distributing replication tasks in network storage device
CN117194348B (en) Household file storage system, method, equipment and storage medium
CN113379542B (en) Block chain transaction query method, device, medium and electronic equipment
US20230100485A1 (en) Neural consensus-based blockchain network system for performing random consensus proof using non-random consensus proof-based blockchain network
US11734230B2 (en) Traffic redundancy deduplication for blockchain recovery
Kang et al. Blockchain-based High-reliability Recovery and Verification Mechanism for Power Data Storage Nodes
CN114513307B (en) New client verification method, device, equipment and storage medium

Legal Events

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