CN112583908A - Block chain consensus method, system, device and medium applied to block output node - Google Patents

Block chain consensus method, system, device and medium applied to block output node Download PDF

Info

Publication number
CN112583908A
CN112583908A CN202011416874.7A CN202011416874A CN112583908A CN 112583908 A CN112583908 A CN 112583908A CN 202011416874 A CN202011416874 A CN 202011416874A CN 112583908 A CN112583908 A CN 112583908A
Authority
CN
China
Prior art keywords
block
node
nodes
block chain
output
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.)
Granted
Application number
CN202011416874.7A
Other languages
Chinese (zh)
Other versions
CN112583908B (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.)
Hefei DappWorks Technology Co Ltd
Original Assignee
Hefei DappWorks 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 Hefei DappWorks Technology Co Ltd filed Critical Hefei DappWorks Technology Co Ltd
Priority to CN202011416874.7A priority Critical patent/CN112583908B/en
Publication of CN112583908A publication Critical patent/CN112583908A/en
Application granted granted Critical
Publication of CN112583908B publication Critical patent/CN112583908B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Abstract

The invention relates to a block chain consensus method, a block chain consensus system, block chain consensus equipment and a block chain consensus medium, wherein a first node and an Nth node of a second node … are sequentially packaged according to a preset sequence to form blocks: if the current round is that the x-th node goes out the block, the x-th node responds to a block-out verification instruction to execute verification operation, if the block-out verification is passed, the block-out operation is executed, and meanwhile, the latest block is sent to a network communication module; the first node, the second node …, the x-1 st node and the x +1 st node … receive the latest block through a network communication module, execute verification operation in response to a verification instruction for the latest block, and add the latest block to a block chain of a node local database if verification is passed. The invention can partially solve or relieve a series of problems caused by the failure of consensus due to poor network communication, and effectively improves the block output rate of the block chain.

Description

Block chain consensus method, system, device and medium applied to block output node
Technical Field
The present invention relates to the field of blockchain technologies and data processing technologies, and in particular, to a method, a system, a device, and a medium for blockchain consensus applied to a block output node.
Background
The blockchain is a novel decentralized protocol, digital currency transactions or data thereof can be safely stored, information cannot be forged and falsified, transaction confirmation on the blockchain is completed by all nodes on the blockchain together, consistency of the transaction confirmation is guaranteed by a consensus algorithm, a public account book is maintained on the blockchain, and the public account book is located at any node on a storage block, so that the digital currency transactions or the data thereof cannot be forged and falsified.
Generally, when multiple hosts in a network cooperate to form a network cluster through asynchronous communication, the asynchronous network is unreliable by default, and a mechanism is needed to copy the state between the unreliable hosts to ensure that the state of each host eventually reaches the same consistency state, so as to achieve consensus. Specifically, in the block chain network, new uncertain factors are introduced in the consensus problem, such as: malicious nodes, network delays, and the system may reach a wrong consensus, resulting in significant errors.
The public blockchain generally adopts a POW consensus algorithm, i.e., a workload certification scheme. POW consensus requires a large number of hash operations, requires power and various computational resources, and finding a suitable hash value has virtually no other effect. Secondly the network performance is also very low. The DPOS consensus algorithm has short block-out time and high efficiency, but has great dependence on a network. For example, when a block is packed out, the block outlet node needs to send the latest block data to other common nodes for confirmation, and the block outlet node can add the latest block data to the block chain and synchronize the latest block data with other nodes after the other common nodes pass the verification. In a real environment, communication between node hosts is temporarily unavailable due to unsmooth network, and at the moment, the block outlet node cannot perform normal block packing work due to the fact that the block outlet node cannot receive confirmation information of other common identification nodes to the block.
For example, the invention patent application with the application number "CN 201910694191.9" discloses a block chain-based consensus method, apparatus, device and storage medium, wherein the method is applied to a first node of the block chain, and the method comprises: entering a first consensus stage of the R1 round of consensus, wherein R1 is a natural number; triggering a timer to start timing when a preset condition is met; if the time length timed by the timer is greater than or equal to the preset time length and is kept in the first consensus stage of the R1 round of consensus, packing a valid voting set; wherein the valid voting set comprises a first valid vote for proving that the first node enters a first consensus phase of an R1 round of consensus; broadcasting the valid voting set; but the patent solution can not overcome the problem that normal packet block operation can not be performed due to network unclogging.
Disclosure of Invention
The invention aims to solve the technical problem that under the condition of network unsmooth, the node hosts can not communicate temporarily, and at the moment, the block outlet node can not carry out normal block packing work because the block outlet node can not receive the confirmation information of other common identification nodes to the block.
The invention solves the technical problems through the following technical means:
a block chain consensus method is applied to a block outlet node and is characterized in that when the block outlet of the block outlet node is currently in turn, the block outlet node responds to a block outlet verification instruction to execute verification operation, if the block outlet verification is passed, the block outlet operation is executed, transactions are packaged into a latest block and stored in a local block chain database, meanwhile, the latest block is sent to other nodes through a network communication module, and if the verification fails, the block outlet operation is not executed.
Whether the current node can execute the block outputting operation or not is judged, if the current node passes the verification, the block outputting operation is executed, the fact that the blocks can still be output under the condition that communication cannot be conducted between the nodes in a short time is achieved, the latest block is sent to all other nodes to be verified, all other nodes are verified and stored in a local block chain database, therefore, even if communication cannot be conducted between node hosts temporarily under the condition that a network is not smooth, a series of problems caused by the fact that common identification cannot be achieved due to poor network communication can be partially solved or relieved, and the block outputting rate of a block chain is effectively improved.
As a further scheme of the invention: the out-block node performing a verify operation in response to an out-block verify instruction comprises:
the block output node judges whether the block output node is in a block output available node list or not, judges whether the block output of the node is due to the current time point or not and judges whether the block output is legal or not, and if the block output node is in the block output available node list, the block output of the node is due to the current time point and the block output is legal, the block output operation is executed; otherwise, the block output operation is forbidden.
As a further scheme of the invention: the judging whether the self is in the list of the names of the nodes capable of outputting the blocks by the node capable of outputting the blocks comprises the following steps:
the out-blocking node matches the content recorded in the list of out-blocking nodes, if the matching is successful, the out-blocking node is located in the list of out-blocking nodes, and if the matching is unsuccessful, the out-blocking node is not located in the list of out-blocking nodes.
As a further scheme of the invention: the node list capable of extracting blocks stores node information of the capable of extracting blocks, node addresses of the capable of extracting blocks, node public keys of the capable of extracting blocks or node certificates of the capable of extracting blocks.
As a further scheme of the invention: the judging whether the current time point is out by the node itself comprises the following steps: the block output node judges whether the current time point is turned to the self node for block output through a consensus rule mechanism, the block output node matches the block output condition of the current time with a preset condition in the node block output rule in turn, if the matching is successful, the block output condition is met, and if the matching is unsuccessful, the block output operation is forbidden.
As a further scheme of the invention: the judging whether the block is legal comprises:
s1301), when the block is taken out from the block outlet node, reading block chain data from a local database of the node, judging that the height of a block chain in the read block chain data is compared with a preset first threshold value, and if the height of the block chain is the same as the first threshold value, indicating that only an initial block exists in the block chain, wherein the block outlet node is legal; if the blockchain height is greater than the first threshold, go to step 1302);
s1302), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is smaller than the minimum node confirmation number, judging whether a block out of the current node exists in the block chain, if the block out of the current node does not exist in the block chain, judging that the block is legal, and if the block out of the current node exists in the block chain, judging that the block is illegal;
if the height of the block chain is larger than or equal to the minimum node confirmation number, reading N1-1 blocks forwards from the maximum height of the block chain, wherein N1 is the total number of nodes of the block capable of being extracted, if the height of the N1-1 block is larger than the maximum height, reading the created blocks till the created blocks are read, judging the nodes of the block capable of being extracted corresponding to each block, and adding the nodes of the block capable of being extracted to form a set;
s1303), judging whether the set has repeated nodes, if so, removing the repeated nodes, and then executing S1304), and if not, directly executing S1304);
s1304), judging the sizes of the node number of the set without the repeated nodes and the minimum confirmation number, and if the set node number is not less than the minimum confirmation number, judging that the block is legal.
As a further scheme of the invention: when the block is judged to be legal, the method also comprises the step of finding out a block which accords with the height of the irreversible block in the local block chain database and marking the block as the irreversible block.
A block chain common identification system comprises a block outlet node verification module, wherein the block outlet node verification module is used for responding to a block outlet verification instruction to execute verification operation when the block outlet of the block outlet node is started, executing the block outlet operation if the block outlet verification is passed, packaging transactions into a latest block and storing the latest block into a local block chain database, and meanwhile, sending the latest block to a network communication module, and not executing the block outlet operation if the verification fails.
An electronic device comprising a memory and a processor; wherein the memory is to store one or more computer instructions, wherein the one or more computer instructions are to be executed by the processor to implement the consensus method as described.
A medium having stored thereon computer instructions which, when executed by a processor, implement the consensus method as described.
The invention has the advantages that:
1. in the invention, whether the current node can execute the block outputting operation or not is judged, if the current node passes the verification, the block outputting operation is executed, so that the block can be still output under the condition that the communication between the nodes can not be carried out within a short time, the latest block is sent to all other nodes for verification, all other nodes are verified and stored in the local block chain database, and therefore, even if the communication between the node hosts can not be carried out temporarily under the condition of unsmooth network, a series of problems caused by the fact that the network communication is poor and the common identification can not be achieved can be partially solved or relieved, and the block outputting rate of the block chain is effectively improved.
2. The invention can effectively provide a solution of low efficiency of the block chain caused by temporary network instability factors, can still output the block under the condition that the communication between the nodes can not be carried out in a short time, and can communicate and synchronize data with other nodes after the network is recovered smoothly by verifying the existing block data, confirming the accounting right and packing the transaction output block, thereby overcoming the conditions of low working efficiency, paralysis and the like of the block chain caused by network reasons.
3. The invention realizes the mechanism that whether the current node can legally generate the block or not under the condition of poor network environment, improves the flexibility and the reliability of the block chain, can partially solve or relieve a series of problems caused by incapability of realizing consensus due to poor network communication by utilizing the technology of the invention, and effectively improves the block generation rate of the block chain.
4. In the invention, when the block height of the received block chain fork needing to be rolled back is found to be smaller than the height of the irreversible block, the block synchronization of the block chain fork is not carried out, but the block chain fork is directly abandoned, thereby saving the network flow and ensuring that the irreversible block is not rewritten due to the block chain fork.
5. In the invention, the node capable of extracting the block reads each block in the block chain stored locally, identifies the production node of each block, and judges whether the extraction of the block by the current node meets the minimum node confirmation number according to the number of the production nodes, thereby effectively realizing that the block can be extracted under the condition that the communication between the nodes can not be carried out in a short time.
Drawings
Fig. 1 is a flowchart illustrating a block chain consensus method according to embodiment 1 of the present invention.
Fig. 2 is a schematic diagram of a workflow of applying the block chain consensus method provided in embodiment 3 of the present invention to a block outlet node.
Fig. 3 is a schematic diagram of a workflow of applying the block chain consensus method provided in embodiment 4 of the present invention to a non-block-out node.
Fig. 4 is a block diagram of a block chain consensus system according to embodiment 2 of the present invention.
Fig. 5 is a block diagram of an electronic device according to an embodiment of the present invention.
Fig. 6 is a schematic structural diagram of a computer system suitable for implementing a blockchain consensus method according to an embodiment of the present disclosure.
FIG. 7 is a block validity verification process according to the present invention.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those skilled in the art, the technical solutions of the exemplary embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the exemplary embodiments of the present disclosure.
In some of the flows described in the specification and claims of this disclosure and in the above-described figures, a number of operations are included that occur in a particular order, but it should be clearly understood that these operations may be performed out of order or in parallel as they occur herein, with the order of the operations being numbered, e.g., S1, S2, etc., merely to distinguish between various operations, and the order of the operations by themselves is not meant to represent any order of performance. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that, the descriptions of "first", "second", etc. in this document are used for distinguishing different messages, devices, modules, etc., and do not represent a sequential order, nor limit the types of "first" and "second" to be different.
Technical solutions in exemplary embodiments of the present disclosure will be described clearly and completely with reference to the accompanying drawings in the exemplary embodiments of the present disclosure, and it is apparent that the described exemplary embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
Example 1
Fig. 1 is a schematic flow diagram of a block chain consensus method according to embodiment 1 of the present invention, and referring to fig. 1, in an embodiment of the present disclosure, a block chain consensus method includes a first node, a second node … N-th node, where the first node and the second node … N-th node sequentially pack blocks according to a preset sequence, N is any positive integer, x is a positive integer between 1 and 2 … N, and specifically includes the following steps:
s1, if the current turn is that the x node goes out of the block (namely a certain block-out node), the x node responds to a block-out verification instruction, if the block-out verification is passed, the block-out operation is executed, the transaction is packaged into the latest block and stored in a local block chain database, meanwhile, the latest block is sent to other nodes through a network communication module, and if the verification fails, the block-out operation is not executed;
specifically, the verification process includes: judging whether the node is in a node list capable of outputting blocks, judging whether the current time point is in turn to output the blocks by the node and whether the output blocks are legal, and executing block output operation if the node is in the node list capable of outputting the blocks, and the current time point is in turn to output the blocks by the node and whether the output blocks are legal; otherwise, the block output operation is forbidden.
For example, for convenience of understanding, the step S1 may be:
s11, the x-th node judges whether the node is in the list of the nodes with the block capable of being out, if yes, the step S12 is executed, and if not, the operation of block out is forbidden;
s12, judging whether the current time point is the time point for the self node to go out of the block, if the current time point is the time point for the self node to go out of the block, executing the step S13, and if the time point is not the time point for the self node to go out of the block, prohibiting the block out operation;
s13, judging whether the current block is legal or not, if so, performing block output operation, packaging the transaction into a latest block, and executing the step S14, otherwise, prohibiting block output operation;
and S14, the xth node adds the latest block to a block chain of the local storage and sends the latest block to the network communication module.
The S2, the first node, the second node …, the x-1 st node, and the x +1 st node … (i.e., all nodes except the x-th node among the N participating nodes, including nodes that can go out of blocks but do not go to their out of blocks, and nodes that do not go out of block right) receive the latest block through the network communication module, respond to the latest block being verified, if the verification is passed, add the latest block to the block chain of the node local database, and if the verification is not passed, discard the latest block.
Wherein the S2 includes: the first node, the second node …, the x-1 st node and the x +1 st node … determine whether the latest block is located on an acceptable block chain fork, determine whether the x-th node (i.e., the node that has already output the block in step S1) exists in the node list of the block-capable node, determine whether the current time point is in turn to the x-th node to output the block, determine the validity of the latest block, if the current time point is in turn to the x-th node to output the block, and the current time point is in turn to the block chain of the local storage, add the latest block to the block chain of the local storage, and if the current time point is not in turn to the block chain fork, is in the list of the block-capable node, is in turn to the x-th node to output the block, and the block-out is legal, discard the latest block.
That is, the first node, the second node …, the x-1 st node, and the x +1 st node … add the newest chunk to the corresponding locally stored chunk chain by confirming that the newest chunk is on an acceptable chunk chain fork, that the x-th node is on a list of outgoing chunks, that it is their turn to go out of chunks by the x-th node, and that the x-th node has an outgoing chunk right (i.e., the outgoing chunk is legal).
Exemplary, include:
s21, the first node, the second node …, the x-1 st node, and the x +1 st node …, the nth node determines whether the current latest chunk is located on an acceptable chunk chain fork, but not on a fork that should be discarded, if so, performs step S22, otherwise, the verification fails;
s22, judging whether the xth node exists in the list of the block-out nodes, if yes, executing the step S23; if the xth node does not exist in the list of the exportable block nodes, the verification is not passed;
s23, judging whether the identity of the xth node is real, if the identity of the xth node is real, executing the step S24, and if not, the verification is not passed;
s24, judging whether the current time point is the xth node block, if so, executing the step S25, and if not, failing to pass the verification;
and S25, judging whether the latest block is legal or not, if so, adding the latest block to a block chain of a node local database, and if not, judging that the latest block is legal.
Specifically, as an aspect of the embodiment of the present disclosure, in step S11, the xth node matches contents recorded in the list of block-capable nodes, and if the matching is successful, whether the xth node is located in the list of block-capable nodes, and if the matching is unsuccessful, the xth node is not located in the list of block-capable nodes.
It should be noted that the list of the out-of-block nodes records information of all out-of-block, and the address of the out-of-block node, the public key of the out-of-block node, or the certificate of the out-of-block node, etc. are used to verify the true identity of the node.
It can be understood that the xth node confirms whether the xth node exists in the list of the block-capable nodes by matching with the information about the block-capable nodes stored in the list of the block-capable nodes, and if so, the xth node has the right to perform block-out.
Compared with the mode that a POW (Proof-of-Work) person can produce blocks, the scheme of the embodiment of the disclosure can effectively avoid adding malicious nodes by adopting the mode of the list of the nodes capable of producing blocks, because only the nodes in the list of the nodes capable of producing blocks have the right of packaging and producing blocks, the nodes capable of producing blocks need to be specified in the list of the nodes capable of producing blocks at the beginning of block chain creation.
Furthermore, after the blockchain is created, the list can be changed by updating the names of the nodes with the blocks that can be out of all the nodes or using a blockchain election function, so as to replace the nodes with the blocks that can be out of the nodes.
In step S12, the xth node determines whether it is time to go out of the block by the node-in-turn block-out rule in the consensus rule mechanism.
The consensus rule mechanism specifies a consensus rule of the block chain, and the consensus rule mechanism can be block chain consensus of any node round outflow block, including but not limited to block chain consensus of various node round outflow blocks such as fixed node outflow block sequences, randomly generated node outflow block sequences in each round, and the like.
Wherein, the fixed node block output sequence refers to that the round of block output is performed according to the preset node sequence, that is to say: the node block output sequence generated randomly in each round refers to random scrambling of the node block output sequence of one time after each N times of block output, and the random scrambling is used as the sequence of the next N nodes for sequentially outputting the blocks, wherein N is the total number of the node blocks, and N times of block output is generally called as one round of block output.
In one aspect of the present disclosure, the consensus rule mechanism specifies a node-alternate block-out rule, a total number of nodes that can generate blocks, a minimum node confirmation number, and a bifurcation selection mechanism;
the node block taking-in-turn rule specifies a legal block-capable node condition in a certain time period, and the x-th node judges whether the self block-capable node condition is legal or not according to the node block taking-in-turn rule, namely, the x-th node matches the condition of block taking at the current time with the condition specified in the node block taking-in-turn rule, if the matching is successful, the condition of block taking is met, and if the matching is unsuccessful, the block taking is not carried out.
It is to be understood that the condition specified in the node rotation block outputting rule may be determined manually, the node rotation rule may not only be a fixed node block outputting sequence, but also be a random scrambling of the node block outputting sequence after y × N times of block outputting, and y may be any value specified manually.
In addition, the node-rotation block-out rule may also be: the node-in-turn block output rule is to perform node election once again after each y-round block output, and the elected nodes can output blocks according to a fixed node block output sequence rule or a randomly generated node block output sequence rule in each round.
The total number of out-blocking nodes specifies the number of nodes that can be out-blocked.
The minimum node confirmation number specifies the minimum number of different nodes that need block confirmation, for example, the PBFT consensus mechanism specifies that a block that needs more than two-thirds of the total node number of nodes to accept can be accepted as a valid block by the entire block chain network, so the minimum node confirmation number in the PBFT is two-thirds of the total node number and the value is rounded up.
Preferably, in this embodiment, the preset minimum node confirmation number is: n-ceiling (2/3N +1), N representing the size of the preset minimum acknowledgement number, N representing the total number of nodes, and ceiling function representing rounding up.
As can be understood from the above, it is necessary to determine the number as two thirds of the total number of nodes plus one and then rounding up.
In addition, the xth node judges the validity of the bifurcation by a method of a bifurcation selection mechanism, which specifically comprises the following steps: when the x-th node receives a plurality of block chain branches, the x-th node selects the branch with the largest block chain height and containing all the irreversible blocks in the local block chain database.
That is, the fork selection mechanism specifies how the xth node determines the validity of the fork when the node receives multiple block chain forks.
In step S13, the xth node determines the block validity by a validity confirmation method, which specifically includes: and the xth node identifies the production nodes of each block by reading each block in the locally stored block chain, and judges whether the block output by the current node meets the minimum node confirmation number or not according to the number of the production nodes.
To illustrate the block validity verification process in more detail, refer to the diagram, wherein when the x-th node goes out of blocks, the blockchain data is read from the local database of the node to make a judgment:
s1301), judging that the height of the block chain in the read block chain data is compared with a preset first threshold value, if the height of the block chain is the same as the first threshold value, indicating that only a starting block exists in the block chain, and enabling the x-th node to meet a block outlet condition; if the blockchain height is greater than the first threshold, go to step 1302);
s1302), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is smaller than the minimum node confirmation number, judging whether a block out of the current node exists in the block chain, if the block out of the current node does not exist in the block chain, judging that the block is legal, and if the block out of the current node exists in the block chain, judging that the block is illegal;
if the height of the blockchain is greater than or equal to the minimum node confirmation number, reading N1-1 blocks (N1 is the total number of nodes of the extractable block) from the maximum height of the blockchain forward, if the height of the N1-1 block is greater than the maximum height, the length of the blockchain is less than N1-1, reading the created blocks until the created blocks are read, judging the nodes of the extractable block corresponding to each block, adding the nodes of the currently extractable blocks (namely the x-th node in the step) to serve as a set, and executing step S1303);
s1303), judging whether the set has repeated nodes, if so, removing the repeated nodes, and then executing S1304), and if not, directly executing S1304);
s1304), judging the sizes of the node number of the set without the repeated nodes and the minimum confirmation number, and if the set node number is not less than the minimum confirmation number, judging that the block is legal.
Wherein the first threshold is 0.
It will be appreciated that the founder block is typically a common ancestor of all blocks within the block chain, meaning that from any block, back down the chain, the founder block will eventually be reached.
In addition, it should be emphasized that the blocking situation can be determined in the above manner, and except the above situation, the blocking situation cannot be performed unless the conditions are satisfied uniformly.
Through the content, the legality of the block can be better determined, and even if a scene that communication between the node hosts is temporarily unavailable due to the fact that a short-time network is obstructed appears, the x-th node can also timely output the block.
The step S1 further includes: s15, find the block with the height of the irreversible block in the local blockchain database, and mark it as the irreversible block.
An irreversible block is a block that is accepted by the blockchain consensus mechanism and is not changed or deleted due to forking, etc., so that the irreversible block is not overwritten due to the forking of the blockchain.
Specifically, when receiving a block chain fork, the x-th node judges whether the block chain fork height is higher than the block chain height in the node database, if so, the x-th node rolls back the block chain in the database to the height when the fork occurs, and adds all blocks in the received block chain fork into the database to finish the irreversible marking; if so, the blockchain split is discarded.
That is, when it is found that the block height of the received block chain fork requiring rollback is smaller than the irreversible block height, block synchronization of block chain fork is not performed, but directly discarded, thereby saving network traffic.
The specific method for determining the height of the irreversible block is that the value obtained by subtracting the minimum node confirmation number from the current blockchain height is the height of the irreversible block, and the blocks at the height and all blocks before the height are irreversible, that is, the contents of the blocks are not changed due to bifurcation and the like.
Through the content, the x-th node completes irreversible marking on the latest block, and the property of preventing tampering of a block chain is realized.
Generally, an irreversible block refers to a block in a blockchain that has been accepted by blockchain consensus and is not changed or deleted due to forking or the like. The function of the irreversible block mechanism is to ensure that the irreversible block is not overwritten due to block chain branching.
As an aspect of the embodiment of the present disclosure, the network communication module is used for communication and data transmission between the respective participating nodes, for example, synchronization of transactions between the nodes, synchronization of latest blocks, transmission of messages, and the like, are all completed by the module.
In step S21, the first node, the second node … x-1 th node, and the x +1 th node … N determine whether the current latest block is located on an acceptable block chain branch by using a branch selection mechanism in the consensus rule module;
the first node, the second node …, the x-1 st node and the x +1 st node …, the nth node, determine the validity of the bifurcation by a bifurcation selection mechanism, specifically: when the first node, the second node …, the x-1 st node, and the x +1 st node … receive a plurality of block chain branches, the first node, the second node …, the x-1 st node, and the x +1 st node … select the branch having the largest block chain height and including all the irreversible blocks in the local block chain database.
In step S22, the first node, the second node …, the x-1 st node, and the x +1 st node … determine whether the x-th node exists in the list of accessible block nodes through the list of accessible block nodes;
the first node, the second node …, the x-1 st node and the x +1 st node … match the x-th node with the contents recorded in the list of the block-capable nodes, if the matching is successful, the x-th node is located in the list of the block-capable nodes, and if the matching is unsuccessful, the x-th node is not located in the list of the block-capable nodes;
the first node, the second node …, the x-1 st node, and the x +1 st node …, the nth node, are configured to identify whether the xth node exists in the list of block-capable nodes by matching the node information of the block-capable stored in the list of block-capable nodes, and if so, the xth node has the right to obtain the block.
In step S23, the first node, the second node … the x-1 st node, the x +1 st node … the nth node determines whether the latest block was generated by the x-th node by verifying the x-th node signature included in the block using the public key. That is, the embodiment scheme of the present disclosure uses public and private key technology to verify the authenticity of the xth node identity;
in step S24, the first node, the second node …, the x-1 st node, and the x +1 st node … determine whether the current time point is the x-th node for block generation by a node-rotation block generation rule in the consensus rule module;
specifically, the first node, the second node …, the x-1 st node, and the x +1 st node … determine whether the conditions of the node capable of outputting the block of the x-th node are legal or not according to a node rotation block outputting rule, that is, the first node, the second node …, the x-1 st node, and the x +1 st node … match the conditions of the node capable of outputting the block at the current time with the conditions specified in the node rotation block outputting rule, and do not output the block if the matching is unsuccessful.
In step S25, the first node, the second node …, the x-1 st node and the x +1 st node … confirm the validity of the latest block by a validity confirmation method.
The first node, the second node …, the x-1 st node and the x +1 st node … determine whether the block output of the x-th node in the current time period meets the minimum node confirmation quantity rule through a block validity confirmation mechanism. Specifically, the first node, the second node …, the x-1 st node and the x +1 st node …, the nth node, the production nodes of each block are identified by reading each block in a locally stored block chain, whether the block output of the current node meets the minimum node confirmation number rule or not is judged according to the number of the production nodes, if yes, the block output of the x-th node is legal, and if not, the block output of the x-th node is illegal, and the block is discarded. The specific process is as follows:
s2501), judging that the height of a block chain in the read block chain data is compared with a preset first threshold, if the height of the block chain is the same as the first threshold, indicating that only a starting block exists in the block chain, and enabling the x-th node to meet a block outlet condition; if the blockchain height is greater than the first threshold, go to step 2502);
s2502), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is smaller than the minimum node confirmation number, judging whether the latest block from the xth node exists in the block chain, if the latest block from the xth node does not exist in the block chain, meeting the block condition, and if the block from the current node exists in the block chain, not meeting the block condition;
if the height of the blockchain is greater than or equal to the minimum node confirmation number, reading N1-1 blocks (N1 is the total number of nodes of the block capable of being extracted) from the maximum height of the blockchain forward, if the height of the N1-1 block is greater than the maximum height, the length of the blockchain is less than N1-1, reading the created blocks until the created blocks are read, adding the nodes of the block capable of being extracted corresponding to each block, and then adding the nodes of the current block capable of being extracted (namely the x-th node in the step S1) to form a set;
s2503), judging whether a set has repeated nodes, if so, performing deduplication, and then executing the step S2504), otherwise, directly executing the step S2504);
s2504), if the number of the nodes in the set after the duplication removal is not less than the minimum node confirmation number, the block output condition is met, and the block output is legal.
Wherein the first threshold is 0.
Further, the step S2 further includes:
s26, the first node, the second node … the x-1 st node, the x +1 st node … the N node marks the block of the block chain that meets the height of the irreversible block rule as irreversible block.
Example 2
Referring to fig. 4, fig. 4 is a block diagram of a block chain consensus system according to embodiment 2 of the present invention, where the block chain consensus system includes a first node and a second node … N-th node that are sequentially packed into blocks according to a preset sequence;
a block output verification module 801, configured to, when it is currently turned that a block is output at an xth node, execute a verification operation in response to a block output verification instruction by the xth node, if the block output verification is passed, execute the block output operation, package a transaction into a latest block and store the latest block in a local block chain database, and simultaneously send the latest block to other nodes through a network communication module, and if the verification fails, not execute the block output operation;
further comprising:
the xth node performing a validation operation in response to the out-of-block validation instruction comprises: judging whether the node is in a node list capable of outputting blocks, judging whether the current time point is in turn to output the blocks by the node and whether the output blocks are legal, and executing block output operation if the node is in the node list capable of outputting the blocks, and the current time point is in turn to output the blocks by the node and whether the output blocks are legal; otherwise, forbidding the block output operation;
the x-th node judging whether the x-th node is in the list of the node names capable of outputting the blocks comprises the following steps: the x-th node matches the contents recorded in the list of the block-capable nodes, if the matching is successful, the x-th node is located in the list of the block-capable nodes, and if the matching is unsuccessful, the x-th node is not located in the list of the block-capable nodes;
the node list capable of extracting the blocks stores node information of the blocks, node addresses of the blocks, node public keys of the blocks or node certificates of the blocks;
the judging whether the current time point is out by the node itself comprises the following steps: the x-th node judges whether the current time point is turned to the self node for block output or not through a consensus rule mechanism, the x-th node matches the condition of block output at the current time with a preset condition in the node block output rule in turn, if the matching is successful, the condition of block output is met, and if the matching is unsuccessful, the block output operation is forbidden;
to describe the block validity confirmation process in more detail, referring to fig. 7, fig. 7 is a schematic flow chart of the block validity confirmation of the present invention, wherein when it is time for the xth node to go out a block, the block chain data is read from the node local database, and the determining whether the block is valid includes:
s1301), when the x-th node goes out of the block, reading block chain data from a local database of the node, judging that the height of a block chain in the read block chain data is compared with a preset first threshold value, and if the height of the block chain is the same as the first threshold value, indicating that only an initial block exists in the block chain, wherein the x-th node goes out of the block to be legal; if the blockchain height is greater than the first threshold, go to step 1302);
s1302), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is smaller than the minimum node confirmation number, judging whether a block out of the current node exists in the block chain, if the block out of the current node does not exist in the block chain, judging that the block is legal, and if the block out of the current node exists in the block chain, judging that the block is illegal;
if the height of the block chain is larger than or equal to the minimum node confirmation number, reading N1-1 blocks forwards from the maximum height of the block chain, wherein N1 is the total number of nodes of the block which can be found out, if the height of the N1-1 block is larger than the maximum height, reading the created blocks till the created blocks are read, judging the nodes of the block which can be found out and corresponding to each block, and adding the Xth node to form a set;
s1303), judging whether the set has repeated nodes, if so, removing the repeated nodes, and then executing S1304), and if not, directly executing S1304);
s1304), judging the sizes of the node number and the minimum confirmation number of the set without the repeated nodes, and if the set node number is not less than the minimum confirmation number, judging that the block is legal;
when the block is judged to be legal, the method also comprises the step of finding out a block which accords with the height of the irreversible block in the local block chain database and marking the block as the irreversible block.
A non-block-out node verification module 802, configured to receive the latest block by the first node, the x-1 st node of the second node …, and the x +1 st node … through the network communication module, perform a verification operation in response to a verification instruction for the latest block, add the latest block to a block chain of the node local database if the verification is passed, and discard the latest block if the verification is not passed, further including:
the performing a verify operation in response to a verify instruction on the most recent block comprises: the first node, the second node …, the x-1 st node and the x +1 st node …, the nth node, determine whether the latest block is located on an acceptable block chain fork, determine whether the x-th node exists in the name list of the node capable of generating the block, determine whether the current time point is the x-th node for generating the block, and determine the validity of the latest block; if the current block is in the acceptable block chain fork, in the list of the nodes capable of outputting the block, when the block is output to the x-th node and the block output is legal, adding the latest block to the block chain stored locally;
if not, the newest block is discarded.
Said determining whether the latest block is located on an acceptable block chain split comprises: when the first node, the second node …, the x-1 st node and the x +1 st node … receive a plurality of block chain branches, the branch with the largest block chain height and including all irreversible blocks in the local block chain database is selected;
the determining whether the xth node exists in the list of exportable block nodes comprises: the first node, the second node …, the x-1 st node and the x +1 st node … match the x-th node with the contents recorded in the list of the block-capable nodes, if the matching is successful, the x-th node is located in the list of the block-capable nodes, and if the matching is unsuccessful, the x-th node is not located in the list of the block-capable nodes;
the judging whether the current time point is turned to the x-th node for block output comprises the following steps: the first node, the second node …, the x-1 st node, the x +1 st node …, the nth node, determining whether the latest block was generated by the x-th node by verifying the x-th node signature included in the block using a public key;
the judging the validity of the latest block comprises: s2501), judging that the height of a block chain in the read block chain data is compared with a preset first threshold, if the height of the block chain is the same as the first threshold, indicating that only a starting block exists in the block chain, and enabling the x-th node to meet a block outlet condition; if the blockchain height is greater than the first threshold, go to step 2502);
s2502), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is smaller than the minimum node confirmation number, judging whether a block out of the xth node exists in the block chain, if the block out of the xth node does not exist in the block chain, meeting a block out condition, and if the block out of the current node exists in the block chain, not meeting the block out condition;
if the height of the block chain is larger than or equal to the minimum node confirmation number, reading N1-1 blocks forwards from the maximum height of the block chain, wherein N1 is the total number of nodes of the block which can be found, if the height of the N1-1 block is larger than the maximum height, reading the blocks which are created till the moment, and adding the x node to the nodes of the block which can be found and corresponds to each block to form a set;
if the set has repeated nodes, performing duplicate removal, then judging the size of the node number and the minimum confirmation number of the set after the duplicate removal, and if the node number after the duplicate removal is not less than the minimum confirmation number, meeting a block output condition, namely, outputting a block to be legal;
s2503), judging whether a set has repeated nodes, if so, performing deduplication, and then executing the step S2504), otherwise, directly executing the step S2504);
s2504), if the number of the nodes in the set after the duplication removal is not less than the minimum node confirmation number, the block is legal;
adding the latest block to a block chain of a local database of the node further comprises: the first node, the second node …, the x-1 st node, and the x +1 st node … mark the block at the height of the block chain that meets the irreversible block rule as an irreversible block.
Example 3
Fig. 2 is a schematic diagram of a block output node workflow of the block chain consensus method provided in embodiment 3 of the present invention, where the block chain consensus method is applied to a block output node, and includes:
s3, when the block discharging of the block discharging node is currently in turn, the block discharging node responds to the block discharging verification instruction to execute verification operation, if the block discharging verification is passed, the block discharging operation is executed, the transaction is packaged into the latest block and stored in the local block chain database, meanwhile, the latest block is sent to the network communication module, and if the verification fails, the block discharging operation is not executed.
Specifically, the verification process includes: the block output node judges whether the block output node is in a block output available node list or not, judges whether the block output of the current time point is in turn to the self node or not and judges whether the block output is legal or not, and if the block output node is in the block output available node list, the block output is in turn to the self node and the block output is legal at the same time, the block output operation is executed; otherwise, the block output operation is forbidden.
For example, for convenience of understanding, the step S3 may be:
s31, the block-out node judges whether the node is in the list of the block-out node, if yes, the step S32 is executed, if not, the block-out operation is forbidden;
s32, judging whether the current time point is the time point for the self node to go out of the block, if the current time point is the time point for the self node to go out of the block, executing the step S33, and if the time point is not the time point for the self node to go out of the block, prohibiting the block out operation;
s33, judging whether the current block is legal or not, if so, performing block output operation, packaging the transaction into a latest block, and executing the step S34, otherwise, prohibiting block output operation;
and S34, the block outlet node adds the latest block to a block chain stored locally and sends the latest block to the network communication module.
In step S31, the block output node matches the content recorded in the list of block output nodes, and if the matching is successful, the block output node is located in the list of block output nodes, and if the matching is unsuccessful, the block output node is not located in the list of block output nodes.
It should be noted that the list of the out-of-block nodes records information of all out-of-block, and the address of the out-of-block node, the public key of the out-of-block node, or the certificate of the out-of-block node, etc. are used to verify the true identity of the node.
It can be understood that the out-blocking node confirms whether itself exists in the list of out-blocking nodes by matching with the information about the out-blocking nodes stored in the list of out-blocking nodes, and if so, the out-blocking node is indicated to have the right to go out blocks.
Compared with the mode that a POW (Proof-of-Work) person can produce blocks, the scheme of the embodiment of the disclosure can effectively avoid adding malicious nodes by adopting the mode of the list of the nodes capable of producing blocks, because only the nodes in the list of the nodes capable of producing blocks have the right of packaging and producing blocks, the nodes capable of producing blocks need to be specified in the list of the nodes capable of producing blocks at the beginning of block chain creation.
Furthermore, after the blockchain is created, the list can be changed by updating the names of the nodes with the blocks that can be out of all the nodes or using a blockchain election function, so as to replace the nodes with the blocks that can be out of the nodes.
In step S32, the block output node determines whether it is time for itself to output a block according to a node block output rule in the consensus rule mechanism.
The consensus rule mechanism specifies a consensus rule of the block chain, and the consensus rule mechanism can be block chain consensus of any node round outflow block, including but not limited to block chain consensus of various node round outflow blocks such as fixed node outflow block sequences, randomly generated node outflow block sequences in each round, and the like.
In one aspect of the present disclosure, the consensus rule mechanism specifies a node-alternate block-out rule, a total number of nodes that can generate blocks, a minimum node confirmation number, and a bifurcation selection mechanism;
the node block taking-in-turn rule specifies a legal block-capable node condition in a certain time period, and the block-out node judges whether the block-capable node condition is legal or not according to the node block taking-in-turn rule, that is, the block-out node matches the condition of block taking at the current time with the condition specified in the node block taking-in-turn rule, if the matching is successful, the block-out condition is met, and if the matching is unsuccessful, the block is not taken out.
The total number of out-blocking nodes specifies the number of nodes that can be out-blocked.
The minimum node confirmation number specifies the minimum number of different nodes that need block confirmation, for example, the PBFT consensus mechanism specifies that a block that needs more than two-thirds of the total node number of nodes to accept can be accepted as a valid block by the entire block chain network, so the minimum node confirmation number in the PBFT is two-thirds of the total node number and the value is rounded up.
Preferably, in this embodiment, the preset minimum node confirmation number is: n-ceiling (2/3N +1), N representing the size of the preset minimum acknowledgement number, N representing the total number of nodes, and ceiling function representing rounding up.
In addition, the block output node judges the validity of the bifurcation by a bifurcation selection mechanism method, which specifically comprises the following steps: when the block output node receives the plurality of block chain branches, the block output node selects the branch with the largest block chain height and containing all the irreversible blocks in the local block chain database.
That is, the forking selection mechanism specifies how the out-block node judges the validity of the forking when the node receives a plurality of block chain forking.
In step S33, the block output node determines the validity of the block by using a validity confirmation method, which specifically includes: and the block output node identifies the production node of each block by reading each block in the locally stored block chain, and judges whether the block output of the current node meets the minimum node confirmation number or not according to the number of the production nodes.
To illustrate the block validity verification process in more detail, refer to the diagram, wherein when the block is output by the block output node, the blockchain data is read from the local database of the node to make a judgment:
s3301), judging that the height of the block chain in the read block chain data is compared with a preset first threshold, if the height of the block chain is the same as the first threshold, indicating that only a starting block exists in the block chain, and enabling a block outlet node to meet a block outlet condition; if the blockchain height is greater than the first threshold, go to step 1302);
s3302), comparing the block chain height with the minimum node confirmation number, if the block chain height is smaller than the minimum node confirmation number, judging whether a block out of the current node exists in the block chain, if the block out of the current node does not exist in the block chain, judging that the block is legal, and if the block out of the current node exists in the block chain, judging that the block is illegal;
if the height of the blockchain is greater than or equal to the minimum node confirmation number, reading N1-1 blocks (N1 is the total number of nodes of the extractable block) from the maximum height of the blockchain forward, if the height of the N1-1 block is greater than the maximum height, the length of the blockchain is less than N1-1, reading the created blocks until the created blocks are read, judging the nodes of the extractable blocks corresponding to each block, adding the nodes of the currently extractable blocks (namely the extracted block nodes in the step) to form a set, and executing the step S3303);
s3303), judging whether the set has repeated nodes, if so, removing the repeated nodes, and then executing S3304), if not, executing step S1304);
s3304), judging the size of the node number of the set without the repeated nodes and the minimum confirmation number, and if the set node number is not less than the minimum confirmation number, the block is legal.
Wherein the first threshold is 0.
It will be appreciated that the founder block is typically a common ancestor of all blocks within the block chain, meaning that from any block, back down the chain, the founder block will eventually be reached.
In addition, it should be emphasized that the blocking situation can be determined in the above manner, and except the above situation, the blocking situation cannot be performed unless the conditions are satisfied uniformly.
Through the content, the legality of the block can be better determined, and even if a scene that communication between the node hosts is temporarily unavailable due to the fact that a short-time network is unsmooth appears, the block can be timely output by the block output node.
The step S3 further includes: s35, find the block with the height of the irreversible block in the local blockchain database, and mark it as the irreversible block.
An irreversible block is a block that is accepted by the blockchain consensus mechanism and is not changed or deleted due to forking, etc., so that the irreversible block is not overwritten due to the forking of the blockchain.
Specifically, when receiving a block chain fork, the out-block node judges whether the block chain fork height is higher than the block chain height in the node database, if so, the out-block node rolls back the block chain in the database to the height when the fork occurs, and adds all blocks in the received block chain fork into the database to finish the irreversible marking; if so, the blockchain split is discarded.
That is, when it is found that the block height of the received block chain fork requiring rollback is smaller than the irreversible block height, block synchronization of block chain fork is not performed, but directly discarded, thereby saving network traffic.
The specific method for determining the height of the irreversible block is that the value obtained by subtracting the minimum node confirmation number from the current blockchain height is the height of the irreversible block, and the blocks at the height and all blocks before the height are irreversible, that is, the contents of the blocks are not changed due to bifurcation and the like.
Through the content, the block-out node completes irreversible marking on the latest block, and the property of preventing the block chain from being tampered is realized.
Generally, an irreversible block refers to a block in a blockchain that has been accepted by blockchain consensus and is not changed or deleted due to forking or the like. The function of the irreversible block mechanism is to ensure that the irreversible block is not overwritten due to block chain branching.
In the solution of the embodiment of the present disclosure, another block chain consensus system is further included, where the system includes a block exit node verification module, and the block exit node verification module is configured to execute step S3.
Example 4
Fig. 3 is a schematic diagram of a workflow of applying the block chain consensus method provided in embodiment 4 of the present invention to a non-block-out node, and referring to fig. 3, a block chain consensus method applied to a non-block-out node includes:
and S4, receiving the latest block through the network communication module, responding to the verification operation of the latest block, if the latest block passes the verification, adding the latest block into a block chain of the node local database, and if the latest block does not pass the verification, discarding the latest block.
The S4 includes: the non-block-out node judges whether the latest block is positioned on an acceptable block chain fork, judges whether the block-out node exists in the list of the block-out nodes, judges whether the current time point is in turn to the block-out node for block-out, judges the legality of the latest block, if the latest block is positioned on the acceptable block chain fork, positioned on the list of the block-out nodes, rotated to the block-out node for block-out and legal for block-out, the latest block is added to a locally stored block chain, and if the latest block is not in turn positioned on the acceptable block chain fork, positioned on the list of the block-out nodes, rotated to the block-out node for block-out and legal for block-out, the latest block is abandoned.
The non-block-out nodes comprise all nodes except the node out of which the block is out at the current time.
That is, the non-out-of-block node adds the latest block to the corresponding locally stored block chain by confirming that the latest block is on an acceptable block chain fork, that the out-of-block node is on an available block list, that it is the out-of-block node that turns out the block, and that the out-of-block node has the right to go out the block (i.e., the out-of-block is legal).
Exemplary, include:
s41, the non-chunking node determines whether the current latest chunk is located on an acceptable chunk chain fork, but not on a fork that should be discarded, if yes, then execute step S22, otherwise, the verification fails;
s42, judging whether the block-out node exists in the list of names of the block-out nodes, if so, executing the step S23; if the out-block node does not exist in the list of out-block nodes, the verification is not passed;
s43, judging whether the identity of the block-out node is real, if so, executing a step S44, and if not, failing to pass the verification;
s44, judging whether the current time point is the time when the block is extracted by the block extraction node, if so, executing the step S25, and if not, passing the verification;
and S45, judging whether the latest block is legal or not, if so, adding the latest block to a block chain of a node local database, and if not, judging that the latest block is legal.
In step S41, the non-chunking node determines whether the current latest chunk is located on an acceptable chunk chain fork by using a fork selection mechanism in the consensus rule module;
the non-block-exiting node judges the validity of the bifurcation by a bifurcation selection mechanism method, which specifically comprises the following steps: when the non-out-block node receives a plurality of block chain branches, the non-out-block node selects the branch with the largest block chain height and containing all the irreversible blocks in the local block chain database.
In step S42, the non-out-block node determines whether the block node exists in the list of out-block nodes through the list of out-block nodes;
the non-out-block node matches the out-block node with the content recorded in the list of out-block nodes, if the matching is successful, the out-block node is located in the list of out-block nodes, and if the matching is unsuccessful, the out-block node is not located in the list of out-block nodes;
the non-block-out node matches and identifies the node information of the block-out node stored in the block-out node list and the block-out node, thereby confirming whether the block node exists in the block-out node list, and if so, indicating that the block node has the block-out right.
In step S43, the non-out-block node determines whether the latest block was generated by the out-block node by verifying the out-block node signature contained in the block using the public key. That is to say, the embodiment scheme of the present disclosure uses public-private key technology to verify the authenticity of the block node identity;
in step S44, the non-block-out node determines whether the current time point is a block-out node for block out according to the node-in-turn block-out rule in the consensus rule module;
specifically, the non-block-out node judges whether the block-out node condition of the block node is legal or not according to the node rotation block-out rule, that is, the non-block-out node matches the block-out condition of the block-out node at the current time with the condition specified in the node rotation block-out rule, and does not perform block-out if the matching is unsuccessful.
In step S45, the non-chunking node confirms the validity of the latest chunk by a validity confirmation method.
The non-out-block node judges whether the out-block of the out-block node in the current time period accords with the minimum node confirmation quantity rule or not through a block validity confirmation mechanism. Specifically, the non-block-out node is to read each block in a block chain stored locally, identify a production node of each block, judge whether the block out of the current node meets the minimum node confirmation number rule or not according to the number of the production nodes, if yes, the block out of the block node is legal, and if not, the block out of the block node is illegal, and discard the block. The specific process is as follows:
s4501), judging that the height of a block chain in the read block chain data is compared with a preset first threshold, and if the height of the block chain is the same as the first threshold, indicating that only a starting block exists in the block chain, wherein a block outlet node meets a block outlet condition; if the blockchain height is greater than the first threshold, go to step 2502);
s4502), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is less than the minimum node confirmation number, judging whether the block chain has the latest block from the block node, if the block chain does not have the latest block from the block node, meeting the block condition, and if the block chain does not have the block from the current node, not meeting the block condition;
if the height of the blockchain is greater than or equal to the minimum node confirmation number, reading N1-1 blocks (N1 is the total number of nodes of the block capable of being extracted) from the maximum height of the blockchain forward, if the height of the N1-1 block is greater than the maximum height, the length of the blockchain is less than N1-1, reading the created blocks until the created blocks are read, adding the nodes of the block capable of being extracted corresponding to each block, and then adding the nodes of the current block capable of being extracted (namely the nodes of the block capable of being extracted in the step S1) to form a set;
s4503), judging whether a set has repeated nodes, if so, performing deduplication, and then executing the step S2504), otherwise, directly executing the step S2504);
s4504), if the number of the nodes in the set after the duplication removal is not less than the minimum node confirmation number, the block outlet condition is met, and the block outlet is legal.
Wherein the first threshold is 0.
Further, the step S2 further includes:
s46, the non-out-of-block node marks the block in the block chain at the height corresponding to the non-reversible block rule as a non-reversible block.
In the solution of the embodiment of the present disclosure, another block chain consensus system is further included, where the system includes a block exit node verification module, and the block exit node verification module is configured to execute step S4.
Fig. 5 shows a block diagram of a device according to an embodiment of the present disclosure.
The foregoing embodiments describe the internal functionality and structure of a block node or non-block node, which in one possible design may be implemented as an electronic device, such as shown in fig. 5, where the electronic device 900 may include a processor 901 and a memory 902.
The memory 902 is used for storing programs for supporting a processor to execute the data processing method or the resource allocation method in any of the above embodiments, and the processor 901 is configured to execute the programs stored in the memory 902.
The memory 902 is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 901 to implement the steps of:
the first node and the Nth node of the second node … are sequentially packaged according to a preset sequence to form blocks;
if the current round is that the x node goes out of the block, the x node responds to a block-out verification instruction to execute verification operation, if the block-out verification is passed, the block-out operation is executed, the transaction is packaged into a latest block and stored in a local block chain database, meanwhile, the latest block is sent to other nodes through a network communication module, and if the verification fails, the block-out operation is not executed;
the first node, the second node …, the x-1 st node and the x +1 st node … receive the latest block through a network communication module, respond to a verification instruction for the latest block to execute verification operation, if the verification is passed, the latest block is added to a block chain of a local database of the node, and if the verification is not passed, the latest block is discarded.
Fig. 6 is a schematic structural diagram of a computer system suitable for implementing a blockchain consensus method according to an embodiment of the present disclosure.
As shown in fig. 6, the computer system 1000 includes a processor (CPU, GPU, FPGA, etc.) 1001 that can perform part or all of the processing in the embodiment shown in the above-described drawings according to a program stored in a Read Only Memory (ROM)1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM1003, various programs and data necessary for the operation of the system 1000 are also stored. The processor 1001, ROM1002, and RAM1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
In particular, according to embodiments of the present disclosure, the methods described above with reference to the figures may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a medium readable thereby, the computer program comprising program code for performing the methods of the figures. In such embodiments, the computer program may be downloaded and installed from a network through the communication section 1009 and/or installed from the removable medium 1011.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams may represent a module, a program segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present disclosure may be implemented by software or hardware. The units or modules described may also be provided in a processor, and the names of the units or modules do not in some cases constitute a limitation of the units or modules themselves.
As another aspect, the present disclosure also provides a medium which is a computer-readable storage medium, and the computer-readable storage medium may be a computer-readable storage medium included in the node in the above embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A block chain consensus method is applied to a block outlet node and is characterized in that when the block outlet of the block outlet node is currently in turn, the block outlet node responds to a block outlet verification instruction to execute verification operation, if the block outlet verification is passed, the block outlet operation is executed, transactions are packaged into a latest block and stored in a local block chain database, meanwhile, the latest block is sent to other nodes through a network communication module, and if the verification fails, the block outlet operation is not executed.
2. The blockchain consensus method of claim 1, wherein the out-of-block node performing a verification operation in response to an out-of-block verification instruction comprises:
the block output node judges whether the block output node is in a block output available node list or not, judges whether the block output of the node is due to the current time point or not and judges whether the block output is legal or not, and if the block output node is in the block output available node list, the block output of the node is due to the current time point and the block output is legal, the block output operation is executed; otherwise, the block output operation is forbidden.
3. The blockchain consensus method of claim 2, wherein the determining by the out-block node whether it is in an out-block-capable-node list comprises:
the out-blocking node matches the content recorded in the list of out-blocking nodes, if the matching is successful, the out-blocking node is located in the list of out-blocking nodes, and if the matching is unsuccessful, the out-blocking node is not located in the list of out-blocking nodes.
4. The blockchain consensus method of claim 3, wherein the list of block-capable nodes stores information of nodes capable of realizing blocks, addresses of nodes capable of realizing blocks, public keys of nodes capable of realizing blocks, or certificates of nodes capable of realizing blocks.
5. The blockchain consensus method of claim 2, wherein the determining whether the current time point is up to itself comprises: the block output node judges whether the current time point is turned to the self node for block output through a consensus rule mechanism, the block output node matches the block output condition of the current time with a preset condition in the node block output rule in turn, if the matching is successful, the block output condition is met, and if the matching is unsuccessful, the block output operation is forbidden.
6. The method of claim 2, wherein said determining whether the block is legal comprises:
s1301), when the block is taken out from the block outlet node, reading block chain data from a local database of the node, judging that the height of a block chain in the read block chain data is compared with a preset first threshold value, and if the height of the block chain is the same as the first threshold value, indicating that only an initial block exists in the block chain, wherein the block outlet node is legal; if the blockchain height is greater than the first threshold, go to step 1302);
s1302), comparing the height of the block chain with the minimum node confirmation number, if the height of the block chain is smaller than the minimum node confirmation number, judging whether a block out of the current node exists in the block chain, if the block out of the current node does not exist in the block chain, judging that the block is legal, and if the block out of the current node exists in the block chain, judging that the block is illegal;
if the height of the block chain is larger than or equal to the minimum node confirmation number, reading N1-1 blocks forwards from the maximum height of the block chain, wherein N1 is the total number of nodes of the block capable of being extracted, if the height of the N1-1 block is larger than the maximum height, reading the created blocks till the created blocks are read, judging the nodes of the block capable of being extracted corresponding to each block, and adding the nodes of the block capable of being extracted to form a set;
s1303), judging whether the set has repeated nodes, if so, removing the repeated nodes, and then executing S1304), and if not, directly executing S1304);
s1304), judging the sizes of the node number of the set without the repeated nodes and the minimum confirmation number, and if the set node number is not less than the minimum confirmation number, judging that the block is legal.
7. The method of claim 2, wherein when determining whether the block is legal, the method further comprises finding a block with a height corresponding to the irreversible block in the local blockchain database, and marking the block as the irreversible block.
8. A blockchain consensus system, comprising:
and the block outlet node verification module is used for responding to a block outlet verification instruction to execute verification operation when the block outlet of the block outlet node is turned, executing the block outlet operation if the block outlet verification is passed, packaging the transaction into a latest block and storing the latest block into a local block chain database, and simultaneously sending the latest block to the network communication module, and not executing the block outlet operation if the verification fails.
9. An electronic device comprising a memory and a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executable by the processor to implement the method of any of claims 1-7.
10. A medium having stored thereon computer instructions which, when executed by a processor, implement the method of any one of claims 1 to 7.
CN202011416874.7A 2020-12-07 2020-12-07 Block chain consensus method, system, equipment and medium applied to block outlet node Active CN112583908B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011416874.7A CN112583908B (en) 2020-12-07 2020-12-07 Block chain consensus method, system, equipment and medium applied to block outlet node

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011416874.7A CN112583908B (en) 2020-12-07 2020-12-07 Block chain consensus method, system, equipment and medium applied to block outlet node

Publications (2)

Publication Number Publication Date
CN112583908A true CN112583908A (en) 2021-03-30
CN112583908B CN112583908B (en) 2024-04-16

Family

ID=75128045

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011416874.7A Active CN112583908B (en) 2020-12-07 2020-12-07 Block chain consensus method, system, equipment and medium applied to block outlet node

Country Status (1)

Country Link
CN (1) CN112583908B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112487496A (en) * 2020-12-07 2021-03-12 合肥达朴汇联科技有限公司 Block chain consensus system

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106878000A (en) * 2017-03-06 2017-06-20 中钞信用卡产业发展有限公司北京智能卡技术研究院 A kind of alliance's chain common recognition method and system
CN109087098A (en) * 2018-07-27 2018-12-25 杭州复杂美科技有限公司 A kind of transaction processing method, system, equipment and storage medium for permitting chain
CN109660545A (en) * 2018-12-27 2019-04-19 北京新唐思创教育科技有限公司 A kind of alliance's chain common recognition method and computer storage medium
CN109743173A (en) * 2018-12-20 2019-05-10 弗洛格(武汉)信息科技有限公司 Go out block node in block chain and determines method, block verification method and block catenary system
CN109785130A (en) * 2018-12-17 2019-05-21 金蝶软件(中国)有限公司 Block chain is known together method, apparatus, computer equipment and storage medium at random
US20190182029A1 (en) * 2017-12-08 2019-06-13 Electronics And Telecommunications Research Institute Method of generating block chain and apparatus and method for generating blocks
CN109949157A (en) * 2019-03-08 2019-06-28 矩阵元技术(深圳)有限公司 A kind of processing method of block chain common recognition, apparatus and system
CN111506656A (en) * 2020-04-20 2020-08-07 腾讯科技(深圳)有限公司 Consensus processing method and device for block chain system, intelligent device and storage medium
CN111930845A (en) * 2020-08-12 2020-11-13 湖南宸瀚信息科技有限责任公司 Block chain consensus method, system, terminal and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106878000A (en) * 2017-03-06 2017-06-20 中钞信用卡产业发展有限公司北京智能卡技术研究院 A kind of alliance's chain common recognition method and system
US20190182029A1 (en) * 2017-12-08 2019-06-13 Electronics And Telecommunications Research Institute Method of generating block chain and apparatus and method for generating blocks
CN109087098A (en) * 2018-07-27 2018-12-25 杭州复杂美科技有限公司 A kind of transaction processing method, system, equipment and storage medium for permitting chain
CN109785130A (en) * 2018-12-17 2019-05-21 金蝶软件(中国)有限公司 Block chain is known together method, apparatus, computer equipment and storage medium at random
CN109743173A (en) * 2018-12-20 2019-05-10 弗洛格(武汉)信息科技有限公司 Go out block node in block chain and determines method, block verification method and block catenary system
CN109660545A (en) * 2018-12-27 2019-04-19 北京新唐思创教育科技有限公司 A kind of alliance's chain common recognition method and computer storage medium
CN109949157A (en) * 2019-03-08 2019-06-28 矩阵元技术(深圳)有限公司 A kind of processing method of block chain common recognition, apparatus and system
CN111506656A (en) * 2020-04-20 2020-08-07 腾讯科技(深圳)有限公司 Consensus processing method and device for block chain system, intelligent device and storage medium
CN111930845A (en) * 2020-08-12 2020-11-13 湖南宸瀚信息科技有限责任公司 Block chain consensus method, system, terminal and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112487496A (en) * 2020-12-07 2021-03-12 合肥达朴汇联科技有限公司 Block chain consensus system
CN112487496B (en) * 2020-12-07 2024-04-16 合肥达朴汇联科技有限公司 Block chain consensus system

Also Published As

Publication number Publication date
CN112583908B (en) 2024-04-16

Similar Documents

Publication Publication Date Title
CN109345386B (en) Transaction consensus processing method and device based on block chain and electronic equipment
CN109379397B (en) Transaction consensus processing method and device based on block chain and electronic equipment
CN110868440B (en) Block chain male chain
CN108269090B (en) Consensus method and device for block chain system based on non-negotiation random drawing
CN108648084B (en) Data processing method, device and equipment of block chain network and storage medium
CN107294729B (en) Communication method and device between different nodes in block chain
US20190172026A1 (en) Cross blockchain secure transactions
CN110198233B (en) Block chain consensus method and system based on trusted execution environment and directed acyclic graph
KR20210006934A (en) Blockchain consensus method, accounting nodes and nodes
EP3934161A1 (en) Consensus method and data verification method, apparatus, and system of consortium blockchain
CN111010284B (en) Processing method of block to be identified, related device and block chain system
CN111061769A (en) Consensus method of block chain system and related equipment
CN110659905B (en) Transaction verification method, device, terminal equipment and storage medium
CN112163950A (en) Block chain network construction method and system convenient for expansion and node resource reuse and terminal equipment
CN111159297A (en) Block chain accounting method, device, node and storage medium
CN113841359A (en) Method and apparatus for propagating tiles in a blockchain network
WO2023124364A1 (en) Anti-fraud secret sharing methods and apparatuses
CN110428238A (en) The account cancelling method and system of block chain
CN115797070B (en) Block chain transaction method, device and system based on man-in-the-middle account incentive
CN112583908A (en) Block chain consensus method, system, device and medium applied to block output node
CN112187475A (en) Method and device for performing multi-center accounting based on trusted computing and related products
CN112600698A (en) Block chain consensus method, system, device and medium applied to non-block-out nodes
CN112487496B (en) Block chain consensus system
CN110648234B (en) Block generation method and device
CN109360096B (en) Public chain-based private chain accounting method and system

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