CN115034794B - Node consensus method and device for block chain system - Google Patents

Node consensus method and device for block chain system Download PDF

Info

Publication number
CN115034794B
CN115034794B CN202210947617.9A CN202210947617A CN115034794B CN 115034794 B CN115034794 B CN 115034794B CN 202210947617 A CN202210947617 A CN 202210947617A CN 115034794 B CN115034794 B CN 115034794B
Authority
CN
China
Prior art keywords
target
hash value
node
preset
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210947617.9A
Other languages
Chinese (zh)
Other versions
CN115034794A (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.)
Beijing Aerospace Aoxiang Ventilation Technology Co ltd
Original Assignee
Beijing Aerospace Aoxiang Ventilation 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 Beijing Aerospace Aoxiang Ventilation Technology Co ltd filed Critical Beijing Aerospace Aoxiang Ventilation Technology Co ltd
Priority to CN202210947617.9A priority Critical patent/CN115034794B/en
Publication of CN115034794A publication Critical patent/CN115034794A/en
Application granted granted Critical
Publication of CN115034794B publication Critical patent/CN115034794B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a node consensus method and a node consensus device for a block chain system, relates to the technical field of block chains, and mainly aims to realize node consensus without large computational power. The main technical scheme of the invention is as follows: firstly, calculating a target hash value corresponding to a target node, and then forming a binary group by the target node and the corresponding target hash value; arranging a plurality of binary groups in ascending order according to the hash value to form a first array; calculating to obtain a comparison hash value through a preset hash function according to the target information of the last block of the current block chain; traversing the first array based on the comparison hash value to find a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value, wherein the two tuples are adjacent; and if so, determining that the target node corresponding to the first target hash value is the consensus accounting node. The invention is used for determining the common-identification accounting node in the block chain system.

Description

Node consensus method and device for block chain system
Technical Field
The present invention relates to the field of blockchain technologies, and in particular, to a node consensus method and apparatus for a blockchain system.
Background
The block chain is composed of a plurality of connected blocks. Each block stores certain information, and each block is connected into a chain according to the time sequence generated by each block. The blockchain is stored in all servers in the blockchain system, and the whole blockchain is safe as long as one server in the whole system can work. These servers, referred to as nodes in the blockchain system, provide storage space and computational support for the entire blockchain system. When a new block is added to the blockchain, the accounting node is determined through a consensus mechanism, the accounting node is a server for creating the new block, and the consensus mechanism is how to achieve consensus among all nodes to determine the effectiveness of a record, which is a determination means and a tamper-proof means. The consensus mechanism of the block chain has the characteristics of 'few obedience majority' and 'human-equal', wherein the 'few obedience majority' does not completely refer to the number of nodes, and can also be the computing power, the number of shares or other characteristic quantities which can be compared by a computer. "equal people" means that when the nodes meet the condition, all the nodes have the right to give priority to the consensus result, and the consensus result is directly recognized by other nodes and finally can become the final consensus result.
The current consensus mechanisms mainly include a workload certification mechanism, a rights and interests certification mechanism, a shares authorization certification mechanism, a Pool verification Pool and a practical byzantine. The consensus mechanism with the highest reliability is a workload proving mechanism, the consensus method of the workload mechanism is that all nodes in the block chain system compete for accounting right by calculating numerical solutions of random hash, and which node can solve a correct numerical solution at the fastest speed determines which node is an accounting node, so that a new block can be created.
However, in the process of determining the billing node by the workload certification mechanism, all nodes in the blockchain system need to perform a large amount of computation to contend for the billing right, which results in a large amount of computer-intensive resource waste, and causes mining actions to be performed by the computer, further resulting in resource waste, and also results in a long period required for achieving node consensus.
Disclosure of Invention
In view of the foregoing, the present invention provides a node consensus method and apparatus for a blockchain system, and a primary objective of the invention is to achieve node consensus without a large amount of computation.
In order to solve the technical problems, the invention provides the following scheme:
in a first aspect, the present invention provides a node consensus method for a blockchain system, where the method includes:
calculating a target hash value corresponding to a target node through a preset hash function according to target information of the target node and target information of the last block of a current block chain, wherein the number of the target nodes is not less than 2;
forming a binary group by the target node and the target hash value corresponding to the target node;
arranging a plurality of binary groups in ascending order according to the hash value to form a first array;
calculating a comparison hash value through the preset hash function according to the target information of the last block of the current block chain;
based on the comparison hash value traversing the target hash values of the binary groups in the first array, judging whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist, wherein the binary groups where the first target hash value and the second target hash value are respectively located are adjacent;
and if so, determining that the target node corresponding to the first target hash value is a consensus accounting node.
Preferably, after obtaining a comparison hash value through the preset hash function according to the target information of the last block of the current block chain, the method includes:
acquiring a preset interception digit;
intercepting the preset interception digit from the lowest order to the highest order of the target hash value in the first array in sequence to form a target hash value of the preset interception digit;
forming a second array by using a new binary group formed by the target nodes corresponding to the preset interception digit target hash value and the preset interception digit target hash value;
arranging the new binary groups of the second array in an ascending order according to the hash value to obtain a third array;
intercepting the preset interception digit from the lowest bit of the comparison hash value to the highest bit to form a comparison hash value of the preset interception digit;
based on the preset interception digit target hash value of the new binary group in the third array traversed by the preset interception digit comparison hash value, judging whether a first preset interception digit target hash value larger than the preset interception digit comparison hash value and a second preset interception digit target hash value not larger than the preset interception digit comparison hash value exist, and the first preset interception digit target hash value and the second preset interception digit target hash value are respectively located in adjacent new binary groups;
and if so, determining that the target node corresponding to the first preset interception digit target hash value is a consensus accounting node.
Preferably, the obtaining of the preset truncation digit includes:
acquiring the total number of nodes of the current block chain system;
and calculating to obtain the preset interception digit through a preset calculation rule based on the total number of the nodes, wherein the preset calculation rule is as follows: j = K/2,2 J < N <=2 K K is the preset interception digit number, and N is the total number of the nodes.
Preferably, the obtaining of the preset truncation digit by calculating according to a preset calculation rule based on the total number of the nodes includes:
judging whether the preset interception digit is smaller than a preset threshold value or not;
and if so, determining that the preset interception digit is equal to the preset threshold value.
Preferably, the forming a second array by the new tuple formed by the target node corresponding to the preset interception bit number target hash value and the preset interception bit number target hash value includes:
sequentially acquiring the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value;
judging whether the same preset interception digit target hash value exists in the second array or not based on the preset interception digit target hash value;
and if the two-tuple does not exist, sequentially adding a new two-tuple consisting of the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value into the second array.
Preferably, after said determining that the target node corresponding to the first target hash value is a consensus accounting node, the method further comprises:
the consensus accounting node creates a target block and synchronizes to the current blockchain network;
receiving the target block by other nodes of the current block chain network, and judging whether the common identification accounting node corresponding to the target block passes the verification according to a preset verification rule;
if the verification is passed, feeding back verification passing information;
determining the number of other nodes in the current block chain network which verify the consensus accounting node based on the number of the verification passing information;
judging whether the proportion of the number of other nodes which pass the verification of the consensus accounting node in the current block chain network to the number of all nodes in the current block chain network is greater than a preset threshold value;
if so, other nodes of the current blockchain network synchronously add the target block to the corresponding local blockchain end.
Preferably, the receiving the target block by another node of the current block link network, and determining whether the node of the common identification accounting corresponding to the target block passes the verification according to a preset verification rule includes:
receiving the target block by other nodes of the current block chain network, and judging whether the common identification accounting node corresponding to the target block is the same as the accounting node which is locally calculated by the other nodes and is required to be accounted at this time;
if the verification information is the same as the verification information, the verification is passed, and verification passing information is fed back.
In a second aspect, the present invention provides an apparatus for node consensus in a blockchain system, the apparatus comprising:
the first calculation unit is used for calculating a target hash value corresponding to a target node through a preset hash function according to target information of the target node and target information of the last block of a current block chain, wherein the number of the target nodes is not less than 2;
a first composing unit, configured to compose the target node and the target hash value corresponding to the target node into a binary group; the first array is formed by arranging a plurality of the binary groups in an ascending order according to the hash value;
the second calculation unit is used for calculating a comparison hash value through the preset hash function according to the target information of the last block of the current block chain;
a judging unit, configured to judge whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist based on the comparison hash value traversing the target hash values of the tuples in the first array, where the first target hash value and the second target hash value are located adjacent to each other;
a determining unit, configured to determine that the target node corresponding to the first target hash value is a consensus accounting node if a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist in the first array, and the first target hash value and the second target hash value are located in adjacent duplets.
Preferably, the apparatus further comprises:
the acquisition unit is used for acquiring a preset interception digit;
a first truncating unit, configured to truncate the preset truncation digit from a lowest bit to a highest bit of the target hash value in the first array in sequence to form a target hash value with the preset truncation digit;
the second composition unit is used for composing a second array by a new binary group composed of the target nodes corresponding to the preset interception digit target hash value and the preset interception digit target hash value; the new binary group of the second array is further arranged in an ascending order according to the hash value to obtain a third array;
the second intercepting unit is used for intercepting the preset intercepting digit from the lowest bit of the comparison hash value to the highest bit of the comparison hash value to form the comparison hash value with the preset intercepting digit;
the judging unit is further configured to, based on the preset capture digit comparison hash value traversing the preset capture digit target hash value of the new binary group in the third array, judge whether a first preset capture digit target hash value larger than the preset capture digit comparison hash value and a second preset capture digit target hash value not larger than the preset capture digit comparison hash value exist, where the first preset capture digit target hash value and the second preset capture digit target hash value are located adjacent to each other;
the determining unit is further configured to determine that the target node corresponding to the first preset interception digit target hash value is a consensus accounting node if a first preset interception digit target hash value larger than the preset interception digit comparison hash value and a second preset interception digit target hash value not larger than the preset interception digit comparison hash value exist in the third array, and new binary groups in which the first preset interception digit target hash value and the second preset interception digit target hash value are located are adjacent to each other.
Preferably, the acquiring unit includes:
an obtaining module, configured to obtain a total number of nodes of the current block chain system;
a calculating module, configured to calculate, based on the total number of nodes, the preset interception bit number through a preset calculation rule, where the preset calculation rule is: j = K/2,2 J < N <=2 K K is the preset interception digit number, and N is the total number of the nodes.
Preferably, the calculation module includes:
the judgment submodule is used for judging whether the preset interception digit is smaller than a preset threshold value or not;
and the determining submodule is used for determining that the preset interception digit number is equal to the preset threshold value if the preset interception digit number is smaller than the preset threshold value.
Preferably, the second constituent unit includes:
the acquisition module is used for sequentially acquiring the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value;
the judging module is used for judging whether the same preset interception digit target hash value exists in the second array or not based on the preset interception digit target hash value;
and the adding module is used for sequentially adding a new binary group consisting of the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value into the second array if the same preset interception digit target hash value does not exist in the second array.
Preferably, the apparatus further comprises:
a creating unit, configured to create a target block and synchronize to the current blockchain network by the consensus accounting node;
a first verifying unit, configured to receive the target block by another node of the current blockchain network, and determine whether the node of the common identification account corresponding to the target block passes verification according to a preset verifying rule; the system is also used for feeding back verification passing information if the verification passes;
a third calculating unit, configured to determine, based on the number of obtained verification passing information, the number of other nodes in the current block chain network that verify the consensus accounting node;
a second verifying unit, configured to determine whether a ratio of the number of other nodes in the current block chain network that pass verification for the consensus accounting node to the number of all nodes in the current block chain network is greater than a preset threshold; and the node is further configured to add the target block to the corresponding local blockchain end synchronously by other nodes of the current blockchain network if the ratio of the number of other nodes in the current blockchain network that pass the verification of the consensus accounting node to the number of all nodes in the current blockchain network is greater than a preset threshold.
Preferably, the first authentication unit includes:
a judging module, configured to receive the target block by another node of the current block link network, and judge whether the node to which the accounting is locally calculated by the other node and the node to which the accounting is locally calculated by the common node corresponding to the target block are the same;
and the verification module is used for passing the verification and feeding back verification passing information if the common identification accounting node corresponding to the target block is the same as the current accounting node calculated locally by other nodes.
In order to achieve the above object, according to a third aspect of the present invention, there is provided a storage medium, where the storage medium includes a stored program, and when the program runs, the apparatus on which the storage medium is located is controlled to execute the node consensus method of the blockchain system according to the first aspect.
In order to achieve the above object, according to a fourth aspect of the present invention, there is provided an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing all or part of the steps of the node consensus apparatus for a blockchain system as described in the first aspect when executing the program.
By means of the technical scheme, the node consensus method and the node consensus device for the block chain system provided by the invention have the advantages that in the process of determining the accounting nodes, the workload proving mechanism needs to carry out a large amount of calculation on all the nodes in the block chain system to compete for the accounting right, so that a large amount of resource waste of computer computing power is caused, the mining action of a computer is caused, the resource waste is further caused, and meanwhile, the period required for achieving the node consensus is longer. Therefore, according to target information of a target node and target information of the last block of a current block chain, calculating by a preset hash function to obtain a target hash value corresponding to the target node, wherein the number of the target nodes is not less than 2; then the target node and the target hash value corresponding to the target node form a binary group; then arranging a plurality of binary groups in ascending order according to the hash value to form a first array; calculating by the preset hash function according to the target information of the last block of the current block chain to obtain a comparison hash value; then, based on the comparison hash value traversing the target hash values of the binary groups in the first array, judging whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist, wherein the binary groups where the first target hash value and the second target hash value are respectively located are adjacent; and if so, determining that the target node corresponding to the first target hash value is a consensus accounting node. The invention can realize the common identification among the nodes only at the algorithm level innovatively by utilizing the high speed of the safe hash function and the indistinguishable property of a tiny change result on the basis of the data storage structure block chain in the block chain system. Because the workload of the node is not proved by a large amount of calculation power, the energy is saved, and the node consensus period is shortened.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
Various additional advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart illustrating a node consensus method of a blockchain system according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a node consensus method of another blockchain system according to an embodiment of the present invention;
fig. 3 is a block diagram illustrating a node consensus apparatus of a blockchain system according to an embodiment of the present invention;
fig. 4 is a block diagram illustrating a node consensus apparatus of another blockchain system according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The block chain is composed of a plurality of connected blocks, which constitute the block chain. The first block that is constructed earliest is referred to as the founder block. Each block holds certain information, which are linked in a chain according to a respective generated time sequence. This chain is maintained in all servers, and as long as one server can work in the entire system, the entire blockchain is secure. These servers, referred to as nodes in the blockchain system, provide storage space and computational support for the entire blockchain system.
The consensus mechanism is how to achieve consensus among all nodes to identify the validity of a record, and is a means for identification and a means for preventing falsification. The consensus mechanism of the block chain has the characteristics of 'few obedience majority' and 'human-equal', wherein the 'few obedience majority' does not completely refer to the number of nodes, and can also be the computing power, the number of shares or other characteristic quantities which can be compared by a computer. "equal people" means that when the nodes meet the condition, all the nodes have the right to give priority to the consensus result, and the consensus result is directly recognized by other nodes and finally can become the final consensus result.
The current consensus mechanism can be classified into 5 types: a workload attestation mechanism (PoW), a equity attestation mechanism (PoS), a stock authorization attestation mechanism (DPoS), pool verification Pool, and a Pragmatistine (PBFT). The node in the workload proof mechanism (PoW) competes for the accounting right by calculating the numerical solution of the random hash, and the ability to obtain the correct numerical solution to generate the block is a concrete representation of the node computing power. Meanwhile, the mining action based on the workload proving mechanism also causes a great deal of resource waste, and the period required for reaching the consensus is also long, so that the mechanism is not suitable for commercial application. The equity proof mechanism (PoS) proportionally reduces the ore digging difficulty of the nodes according to the proportion and time of the token owned by each node and the algorithm, thereby accelerating the speed of searching the random number. This consensus mechanism can reduce the time required to achieve consensus, but still requires nodes in the network to perform the mining operation per se. Therefore, the PoS mechanism does not fundamentally solve the problem that the PoW mechanism is difficult to apply to the commercial field. The stock authorization certification mechanism (DPoS) votes and elects a certain number of node representatives through all nodes, and the representatives proxy all the nodes to confirm a block and maintain the orderly operation of the system, so that the number of nodes participating in verification and accounting can be greatly reduced, and second-level consensus verification is achieved. However, the consensus mechanism still does not perfectly solve the problem of applying a blockchain in commerce, because the consensus mechanism cannot get rid of the dependence on tokens, and the presence of tokens is not required in many commercial applications. The Pool verification Pool is established based on a traditional distributed consistency technology and assisted by a data verification mechanism, can work without depending on tokens, can realize second-level consensus verification on the basis of a mature distributed consistency algorithm (Pasox and Raft), and is more suitable for a multi-center business model with multi-party participation. But the consensus mechanism is much less distributed than the PoW mechanism. A Practical Byzantine (PBFT) is a state machine replication algorithm, i.e. the service is modeled as a state machine that performs replication at different nodes of the distributed system. The copies of each state machine preserve the state of the service and also enable the operation of the service. The extra copies do not improve reliability, except for reduced performance. However, the workload certification mechanism requires a huge number of nodes to contend for the accounting right through a large amount of calculation in the process of node consensus achievement, which causes a large amount of resource waste of computer calculation power, and causes mining behavior of the computer, further causes resource waste, and also causes a long period required for achieving node consensus. In view of the above problem, the inventor thinks that on the basis of a data storage structure blockchain in a blockchain system, by utilizing the fast speed of a secure hash function and the indistinguishable result of a small change, the consensus among nodes is innovatively realized only at an algorithm level. Because the workload of the node is not proved by a large amount of calculation power, the energy is saved, and the node consensus period is shortened.
To this end, an embodiment of the present invention provides a node consensus method for a blockchain system, where the method implements node consensus for the blockchain system, and the specific implementation steps of the method are shown in fig. 1, where the method includes:
101. and the target node of the current block chain system obtains a target hash value corresponding to the target node through calculation by a preset hash function according to the target information of the target node and the target information of the last block of the current block chain.
Wherein the number of the target nodes is not less than 2. The present invention includes a blockchain system, nodes (i.e., servers) and hash functions operating in the blockchain system, which are well known in the art and will not be described herein. The target node is a server in a current blockchain system; the target information of the target node may be public key information of the node, identity ID information of the node, and the like, and this step is not specifically limited; the target information of the last block of the current block chain may be ID information of the block, timestamp information of the block, etc., and this step is not specifically limited; merging the target information of the target node and the target information of the last block of the current block chain to form merged target information, wherein the merged target information is used as an input value of the preset hash function;
the preset hash function is used for calculating a hash value with a fixed length from any input value, and when the input value is slightly changed, the output hash value is also changed. The preset hash function comprises SHA2-256, keccak-256 and the like, which are not described again; SHA2-256 and Keccak-256 may generate 256 binary bit hash values from the input values, and such algorithms are well known to those skilled in the art and will not be described herein.
For example, the following steps are carried out:
using a preset hash function f to calculate the combined information obtained by combining the public key information of all the nodes with the number of N in the current block chain network and the data information stored in the last block M of the current block chain as an input value by using the preset hash function to obtain a hash value; the preset hash function f is SHA2-256 algorithm, and the obtained output value is a hash value of 256 binary bits.
102. And forming a binary group by the target node and the target hash value corresponding to the target node.
According to step 101, a plurality of target nodes exist in the current block chain system, a target hash value corresponding to each target node can be obtained by using the hash function, the target information of each target node and the target information of the last block of the current block chain, and then each target node and the corresponding target hash value form a binary set to prepare an array to be formed later.
For example, the following steps are carried out:
if the target node is marked as P and the hash value is marked as Q, f (P, M) = Q; let P and Q be a doublet (P, Q).
In the current consensus process, the target information of each target node and the target information of the last block of the current block chain are used as input values of a hash function, so that a hash value corresponding to each target node can be obtained, and the hash values corresponding to the target nodes are different, because although the target information of the last block of the current block chain is the same, the target information of each target node is determined differently; therefore, the method adopting the step can distinguish by the different hash values of each target node in the current consensus process; the method can also distinguish the current consensus from the next consensus, because the same target node has the same target information of the node, but the current block chain changes along with the system transaction and the time lapse, namely the target information of the last block of the current block chain is different in the current consensus and the next consensus, so that the hash value corresponding to each target node calculated by the hash function method is different in the previous consensus and the next consensus, and the introduction of the target information of the last block of the current block chain into the input value of the hash function in the step can ensure that the hash value of the target node calculated before each consensus is changed.
103. And arranging the plurality of binary groups into a first array according to the ascending order of the hash values.
According to step 102, a plurality of binary groups composed of each target node in the current block chain system and a target hash value corresponding to each target node can be obtained, and the binary groups are arranged in an ascending order according to the hash values to form a first array.
By way of example:
if the target node is marked as P and the hash value is marked as Q, f (P, M) = Q; marking P and Q as a binary group (P, Q), and storing the binary group of N target nodes into an array A according to the ascending arrangement of the hash value Q, namely: a = [ (P1, Q1), (P2, Q2), (P3, Q3), \ 8230; (PN, QN) ].
104. And calculating by a preset hash function according to the target information of the last block of the current block chain to obtain a comparison hash value.
The preset hash function is the same as the preset hash function in step 101, the only difference is that the input value is different, and the input value in this step is only "the target information of the last block of the current block chain", and does not include the target information of the target node. For example, "f (M) = H", where f is "target information of the last chunk of the current chunk chain" of the preset hash function M, and H is a comparison hash value; the comparison hash value is used to locate the location of the consensus accounting node, as will be explained in more detail in the following steps.
105. And based on the comparison hash value traversing the target hash values of the binary groups in the first array, judging whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist, wherein the first target hash value and the second target hash value are respectively positioned adjacent to the binary groups.
By way of example:
in the examples of steps 103 and 104, if the target node is P and the hash value is Q, f (P, M) = Q; and recording P and Q as a binary group (P, Q), and storing the binary groups of the N target nodes into an array A according to the ascending arrangement of the hash value Q, namely: a = [ (P) 1 ,Q 1 ), (P 2 ,Q 2 ), (P 3 ,Q 3 ),…,(P N ,Q N )]. f (M) = H, where f is the preset hash function M is "target information of the last chunk of the current chunk chain", and H is a comparison hash value; finding two tuples (P) in array A i-1 ,R i-1 ) (Pi, ri) is such that R i-1 <= H < R i Then node P i Namely the selected consensus accounting node. Wherein the first target hash value is R i The second target hash value is R i-1
106. And if so, determining that the target node corresponding to the first target hash value is the consensus accounting node.
As illustrated by the example of step 105, if two tuples (P) are found in array A i-1 ,R i-1 ), (P i ,R i ) So that R i-1 <= H < R i Wherein the first target hash value is R i Then the first target hash value is R i Corresponding target node P i Namely the selected consensus accounting node.
Based on the implementation manner of the embodiment shown in fig. 1, it can be seen that the invention provides a node consensus method for a blockchain system, because a workload certification mechanism needs to perform a large amount of calculations on all nodes in the blockchain system to contend for the accounting right in the process of determining the accounting node, a large amount of computer-powered resource waste is caused, and a mining behavior is caused in a computer, which further causes resource waste, and also causes a long period required for achieving node consensus. Therefore, according to target information of a target node and target information of the last block of a current block chain, calculating by a preset hash function to obtain a target hash value corresponding to the target node, wherein the number of the target nodes is not less than 2; then the target node and the target hash value corresponding to the target node form a binary group; then arranging a plurality of binary groups in ascending order according to the hash value to form a first array; calculating by the preset hash function according to the target information of the last block of the current block chain to obtain a comparison hash value; then, based on the comparison hash value traversing the target hash values of the binary groups in the first array, judging whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist, wherein the binary groups in which the first target hash value and the second target hash value are respectively located are adjacent; and if so, determining that the target node corresponding to the first target hash value is a consensus accounting node. The invention can realize the common identification among the nodes only at the algorithm level innovatively by utilizing the high speed of the safe hash function and the indistinguishable property of a tiny change result on the basis of the data storage structure block chain in the block chain system. Because a large amount of calculation power is not needed to prove the workload of the nodes, the energy is saved, and the node consensus period is shortened.
Further, as a refinement and an extension of the embodiment shown in fig. 1, the embodiment of the present invention further provides another node consensus method for a blockchain system, as shown in fig. 2, which includes the following specific steps:
201. and the target node of the current block chain system obtains a target hash value corresponding to the target node through calculation by a preset hash function according to the target information of the target node and the target information of the last block of the current block chain.
The number of the target nodes is not less than 2;
this step is combined with the description of step 101 in the above method, and the same contents are not described herein again.
202. And forming a binary group by the target node and the target hash value corresponding to the target node.
In this step, the description of step 102 in the above method is combined, and the same contents are not described herein again.
203. And arranging the plurality of duplets into a first array according to the ascending order of the hash values.
This step is combined with the description of step 103 in the above method, and the same contents are not described herein again.
The contents of the above steps 201, 202 and 203 are collectively exemplified:
the preset hash function uses SHA2-256, but other hash algorithms may be used, such as: keccak-256. The process of competing for the accounting right through the consensus mechanism provided by the invention is as follows, and it is assumed that all nodes currently located in the block chain network have 5 nodes, which are respectively: node 1, node 2, node 3, node 4, and node 5, each node having a node ID that uniquely identifies a node in the blockchain network. Each block in the block chain is also provided with a block ID that uniquely identifies a block in the block chain.
Node 1 uses the SHA2-256 algorithm to compute the hash value for each node (node 1, node 2, node 3, node 4, node 5) in the current blockchain system in turn. When calculating the hash value, the input parameters of the hash function are: node ID + end block ID, for example, when calculating the hash value of node 2, the input parameter used is node 2 ID + end block ID. The length of the calculated hash value is 256 binary bits. After node 1 calculates the hash value for each node (node 1, node 2, node 3, node 4, and node 5) in turn, it stores the calculation result in array a, where each element of array a is a binary group (node, hash value), in this example, that is: a = [ (node 1, node 1 hash value), (node 2, node 2 hash value), (node 3, node 3 hash value), (node 4, node 4 hash value), (node 5, node 5 hash value) ]. Node 2, node 3, \ 8230all perform this calculation. After the calculation is completed, each node calculates to obtain an array A. Suppose the computed hash value is binary as follows:
node 1 hash value: 10001010010101010011010 \8230a1101010, 1101010
Node 2 hash value: 01001010101010011010 \8230; 1010100
Node 3 hash value: 10010101001010100111 \8230; 0010110
Node 4 hash value: 10101010101000100010101\823000and 0111101
Node 5 hash value: 10100101010100101010010 \8230a1110111
Then A = [ = ], [ solution ]
(node 1, 10001010010101010011010 \8230; 1101010),
(node 2, 01001010101001010011010 \8230; 1010100),
(node 3, 10010101001001010100111 \8230; 0010110),
(node 4, 10101010101000100010101 \8230; 0111101),
(node 5, 10100101010100101010010 \8230; 1110111)
]。
204. And calculating by a preset hash function according to the target information of the last block of the current block chain to obtain a comparison hash value.
This step is combined with the description of step 104 in the above method, and the same contents are not described herein again.
For example, the following steps are carried out:
the description is made with an example of steps 201, 202 and 203: node 1 calculates the hash value of the last block of the current block chain using the SHA2-256 algorithm (this calculated hash value is referred to as the comparison hash value in this step). When the comparison hash value is calculated, the input parameters of the hash function are as follows: the ID of the last block, the length of the hash value calculated is 256 binary bits. Node 2, node 3, \8230, all do this calculation. After the calculation is completed, each node calculates the same comparison hash value, provided that the calculated comparison hash value is binary as follows:
comparing the hash values: 10001010010101010011010 8230, 1101010.
Further, after obtaining a comparison hash value by calculating according to the target information of the last block of the current block chain by using the preset hash function, the method of the present invention includes:
acquiring a preset interception digit; wherein, the obtaining of the preset interception digit further comprises: acquiring the total number of nodes of the current block chain system; and calculating to obtain the preset interception digit through a preset calculation rule based on the total number of the nodes, wherein the preset calculation rule is as follows: j = K/2,2 J < N <=2 K K is the preset interception digit number, and N is the total number of the nodes; wherein, the calculating based on the total number of the nodes through a preset calculation rule to obtain the preset interception digit further comprises: judging whether the preset interception digit is smallAt a preset threshold value; if yes, determining that the preset interception digit is equal to the preset threshold;
intercepting the preset interception digit from the lowest order to the highest order of the target hash value in the first array in sequence to form a target hash value of the preset interception digit;
forming a second array by using a new binary group formed by the target nodes corresponding to the preset interception digit target hash value and the preset interception digit target hash value;
arranging the new binary groups of the second array in an ascending order according to the hash value to obtain a third array; intercepting the preset interception digit from the lowest bit to the highest bit of the comparison hash value to form the comparison hash value of the preset interception digit;
based on the preset interception digit target hash value of the new binary group in the third array traversed by the preset interception digit comparison hash value, judging whether a first preset interception digit target hash value larger than the preset interception digit comparison hash value and a second preset interception digit target hash value not larger than the preset interception digit comparison hash value exist, wherein the first preset interception digit target hash value and the second preset interception digit target hash value are respectively positioned adjacent to the new binary group;
if yes, determining that the target node corresponding to the first preset interception bit target hash value is a common identification accounting node. The description is made with an example of steps 201, 202 and 203:
the first step is as follows:
since the number of nodes in the block chain system network is 5, the interception digit K needs to be calculated so as to satisfy the formula: j = K/2,2 J < 5 <=2 K Through calculation, the satisfied K is 3, at this time, since K is smaller than 4, in order to ensure the accuracy of the result when the number of nodes is small, it is specified that K is set to 4 when the value of K is smaller than 4, so that the intercept digit K =4 is finally calculated in the present example, wherein 4 is the preset threshold;
the second step is as follows:
the array A obtained by each node for step 203 is:
a = [ (node 1, 10001010010101010011010 \82301101010; 1101010),
(node 2, 01001010101001010011010 \8230; 1010100),
(node 3, 10010101001010100111 \ 8230; 0010110),
(node 4, 10101010101000100010101 \8230; 0111101),
(node 5, 10100101010100101010010 \8230; 1110111)
];
Intercepting 4 bits from the lowest bit to the highest bit of each hash value in the array A (the intercepted bit number calculated in the first step is 4), namely the target hash value of the preset intercepted bit number is 4, and generating a new binary array B as follows:
b = [ (node 1, 1010), (node 2, 0100), (node 3, 0110), (node 4, 1101), (node 5, 0111) ]. The decimal value corresponding to the preset intercepted digit target hash value '1010' of the node 1 is 10; the decimal value corresponding to the preset intercepted digit target hash value '0100' of the node 2 is 4; a decimal numerical value corresponding to a preset interception digit target hash value '0110' of the node 3 is 6; the decimal value corresponding to the preset interception digit target hash value '1101' of the node 4 is 13; the decimal value corresponding to the preset intercepted digit target hash value "0111" of the node 5 is 7. For example, the target hash value of the preset truncated digits "1010" of the node 1 is a binary representation, which is converted into decimal 23+21=10; the method of converting binary values into decimal values is prior art and will not be described herein.
The third step:
each node arranges the corresponding decimal values of the array B obtained by converting the hash value of the element binary group in ascending order from small to large (4, 6, 7, 10 and 13), and obtains a new array C which is:
c = [ (node 2, 0100), (node 3, 0110), (node 5, 0111), (node 1, 1010), (node 4, 1101) ];
the fourth step:
each node reads the ID of the last block in the block chain, and a comparison hash value is calculated by using the preset hash function 201, wherein the input parameter is the ID;
in the first case: assume that the computed comparison hash value is: 10100101010100101010010 \8230, 1111110, then truncates 4 bits from the lowest bit to the highest bit (the number of truncated bits calculated in the first step is 4) to form a 4-bit binary 1110. Since each hash value in array C is also 4 bits, then array C is traversed, assuming that the sequence number of each element of the array is represented by i, such that: hash value with sequence number i-1 < = 1110 < sequence number i node hash value, in this example, there is no i that is satisfied, so we use the 1 st element of array C as the accounting node, i.e.: and (4) a node 2.
In the second case: if the hash value calculated for the ID of the last block is: 10100101010100101010010 \8230, 1110101, then truncates 4 bits from the lowest bit to the highest bit (the number of truncated bits calculated in the first step is 4) to form a 4-bit binary 0101. Since each hash value in array C is also 4 bits, then array C is traversed, assuming that the sequence number of each element of the array is represented by i, such that: hash value with sequence number i-1 < = 0101< sequence number i node hash value, in this example we can calculate i =2, i.e. the 2 nd element of array C is the accounting node, i.e.: and a node 3.
In the third case: if the hash value calculated for the ID of the last block is: 10100101010100101010010 \8230, 1110111, then 4 bits are truncated from the lowest bit to the highest bit (the truncated bit number calculated in step 2 is 4), and a 4-bit binary 0111 is formed. Since each hash value in array C is also 4 bits, then array C is traversed, assuming that the sequence number of each element of the array is represented using i, such that: hash value with sequence number i-1 < = 0111< sequence number inode hash value, in this example we can calculate i =4, i.e. the 4 th element of array C is the accounting node, i.e.: node 1.
Further, the step of forming a second array by using the new binary group formed by the target node corresponding to the preset interception bit number target hash value and the preset interception bit number target hash value includes:
sequentially acquiring the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value;
judging whether the same preset interception digit target hash value exists in the second array or not based on the preset interception digit target hash value;
if the preset interception digit target hash value does not exist, sequentially adding a new binary group consisting of the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value into the second array;
and if so, discarding a new binary group consisting of the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value.
For example, the following steps are carried out:
the array A derived for each node is:
a = [ (node 1, 10001010010101010011010 \ 8230; 1101010),
(node 2, 01001010101001010011010 \8230; 1010100),
(node 3, 10010101001001010100111 \8230; 0010100),
(node 4, 10101010101000100010101 \8230; 0111101),
(node 5, 10100101010100101010010 \8230; 1110111)
];
Intercepting 4 bits from the lowest bit to the highest bit of each hash value in the array A (the intercepted bit number calculated in the first step is 4), that is, the preset intercepted bit target hash value is 4, and obtaining new binary groups, namely (node 1, 1010), (node 2, 0100), (node 3, 0100), (node 4, 1101), (node 5, 0111), wherein the hash values corresponding to the node 2 and the node 3 are both "0100", discarding the new binary group (node 3, 0100) corresponding to the node 3, and generating a new binary group array B as follows:
b = [ (node 1, 1010), (node 2, 0100), (node 4, 1101), (node 5, 0111) ].
205. And based on the comparison hash value traversing the target hash values of the binary groups in the first array, judging whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist, wherein the first target hash value and the second target hash value are respectively positioned adjacent to the binary groups.
This step is combined with the description of step 105 in the above method, and the same contents are not repeated herein.
206. And if so, determining that the target node corresponding to the first target hash value is the consensus accounting node.
This step is combined with the description of step 106 in the above method, and the same contents are not described herein again.
The further technical solutions for steps 205 and 206 are set forth in combination in the extended technical solution and the example of step 204, and are not described herein again.
207. The consensus accounting node creates a target block and synchronizes to the current blockchain network.
Wherein the consensus accounting node is a node with accounting right obtained by the consensus method of steps 201 to 206, the consensus accounting node creates a target block,
the following is illustrated as an example of step 204: the consensus accounting node calculated in the fourth step (including in 3 cases node 2 or node 3 or node 1, respectively) starts creating the target block and synchronizes to the current blockchain network.
208. And other nodes of the current block chain network receive the target block and judge whether the common identification accounting node corresponding to the target block passes the verification according to a preset verification rule.
The preset verification rule is used for judging whether the common identification accounting node corresponding to the target block is the same as the current accounting node locally calculated by other nodes; if the verification information is the same as the verification information, the verification is passed, and verification passing information is fed back.
The method comprises the following specific steps: receiving the target block by other nodes of the current block chain network, and judging whether the common identification accounting node corresponding to the target block is the same as the accounting node which is locally calculated by the other nodes and is required to be accounted at this time; if the verification information is the same as the verification information, the verification is passed, and the verification passing information is fed back.
209. And if the verification is passed, feeding back verification passing information.
The technical solutions for steps 208 and 209 are illustrated in a unified way:
assume that there are 5 nodes currently in the blockchain network, which are: the node 1, the node 2, the node 3, the node 4 and the node 5, wherein the consensus accounting node is the node 2; the consensus accounting node is node 2; the node to be booked locally calculated by the nodes 1, 3 and 4 is the node 2, the node to be booked locally calculated by the node 5 is the node 1, the node 2 creates a target block J, the target block J is synchronized to the current block chain network by the node 2, and the nodes 1, 3, 4 and 5 receive the target block J, wherein the nodes 1, 3 and 4 respectively judge that the ID of the node 2 corresponding to the target block J is the same as the ID of the node to be booked (node 2) calculated by the node 2, so that the nodes 1, 3 and 4 pass verification and feed back verification passing information to the current block chain system, and the nodes of the current block chain system all obtain the fed-back verification passing information; and if the node 5 judges that the ID of the node 2 corresponding to the target block J is different from the ID of the node (node 1) which is calculated and needs accounting at this time, discarding the target block J.
210. And determining the number of other nodes which pass the verification of the consensus accounting node in the current block chain network based on the number of the obtained verification passing information.
The example in step 209 is used to illustrate that:
the node 1, the node 3 and the node 4 pass the verification, and the verification passing information is fed back to the current block chain system, all nodes (and the node 1, the node 2, the node 3, the node 4 and the node 5) of the current block chain system all obtain the verification passing information fed back by the node 1, the node 3 and the node 4, that is, the number of the verification passing information obtained by all nodes is 3, and then the number of other nodes passing the verification of the consensus accounting node 2 in the current block chain network is determined to be 3.
211. And judging whether the proportion of the number of other nodes which pass the verification of the common identification accounting node in the current block chain network to the number of all nodes in the current block chain network is greater than a preset threshold value.
212. If yes, other nodes of the current block chain network synchronously add the target block to the tail end of the corresponding local block chain.
Steps 211 and 212 are illustrated by example in step 210:
when the number of other nodes which pass the verification of the consensus accounting node 2 in the current block-chain network is 3, and the number of all nodes (node 1, node 2, node 3, node 4, node 5) in the current block-chain network is 5, the ratio of the number of other nodes which pass the verification of the consensus accounting node in the current block-chain network to the number of all nodes in the current block-chain network is 3/5=60%; the preset threshold is 51%, and if the ratio (60%) of the number of other nodes in the current blockchain network that pass the verification of the consensus accounting node to the number of all nodes in the current blockchain network is greater than the preset threshold (51%), the other nodes (node 1, node 3, node 4, node 5) in the current blockchain network synchronously add the target block J to the corresponding local blockchain end (i.e., the end of the last block M).
Further, the node consensus performing step (i.e. 201 to 212) of the present invention performs the process every other preset period, where the preset period may be set to 300 seconds, that is, the system generates a block every 300 seconds, the preset period may change with the application scenario of the blockchain system, a smaller time period may be set when the transaction is frequent, and a larger time period may be set when the transaction amount is loose. This step is not particularly limited.
Based on the implementation manner of fig. 2, it can be seen that the present invention provides a node consensus method for a blockchain system, where the consensus method and the system flow of the present invention are as follows: the method comprises the steps of competitively selecting an accounting node, creating a block, verifying the block and synchronizing the block, intercepting a hash value calculated by a preset hash function by adopting an intercepting digit, sequencing the intercepted hash values, and positioning a consensus accounting node by adopting a comparison hash value intercepted by the intercepting digit, wherein the block chain of a data storage structure in a block chain system is taken as a basis, and the consensus among the nodes is innovatively realized only on an algorithm level by utilizing the high speed and indistinguishable property of a small change result of a safe hash function; the workload of the nodes is proved without a large amount of calculation power, so that energy is saved; the expansibility is greatly improved without token, share certification and copy among nodes; the method solves the problems of large resource consumption, long consensus period, token dependence and poor expansibility of the conventional consensus mechanism, and has very important significance for accelerating the landing application of the block chain system.
Further, as an implementation of the method shown in fig. 1, an embodiment of the present invention further provides a node consensus device of a block chain system, which is used for implementing the method shown in fig. 1. The embodiment of the apparatus corresponds to the embodiment of the method, and for convenience of reading, details in the embodiment of the apparatus are not described again one by one, but it should be clear that the apparatus in the embodiment can correspondingly implement all the contents in the embodiment of the method. As shown in fig. 3, the apparatus includes:
the first calculating unit 31 is configured to calculate, according to target information of a target node and target information of a last block of a current block chain, a target hash value corresponding to the target node through a preset hash function, where the number of the target nodes is not less than 2;
a first composing unit 32, configured to compose the target node obtained from the first calculating unit 31 and the target hash value corresponding to the target node into a binary group; the first array is formed by arranging a plurality of the binary groups in an ascending order according to the hash value;
the second calculating unit 33 is configured to calculate a comparison hash value according to the target information of the last block of the current block chain by using the preset hash function;
a judging unit 34, configured to judge whether there are a first target hash value larger than the hash value and a second target hash value not larger than the hash value based on the hash value obtained from the second calculating unit 33 traversing the target hash value of the binary in the first array obtained from the first composing unit 32, and the binary in which the first target hash value and the second target hash value are respectively located are adjacent to each other;
a determining unit 35, configured to determine that the target node corresponding to the first target hash value is a consensus accounting node if the first array obtained by the determining unit 34 has a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value, and the two tuples in which the first target hash value and the second target hash value are located are adjacent to each other.
Further, as an implementation of the method shown in fig. 2, an embodiment of the present invention further provides another node consensus device for a blockchain system, which is used to implement the method shown in fig. 2. The embodiment of the apparatus corresponds to the embodiment of the method, and for convenience of reading, details in the embodiment of the apparatus are not described again one by one, but it should be clear that the apparatus in the embodiment can correspondingly implement all the contents in the embodiment of the method. As shown in fig. 4, the apparatus includes:
the first calculating unit 31 is configured to calculate, according to target information of a target node and target information of a last block of a current block chain, a target hash value corresponding to the target node through a preset hash function, where the number of the target nodes is not less than 2;
a first composing unit 32, configured to compose the target node obtained from the first calculating unit 31 and the target hash value corresponding to the target node into a binary set; the system is also used for arranging a plurality of the binary groups into a first array according to the ascending order of the hash value;
the second calculating unit 33 is configured to calculate, according to the target information of the last block of the current block chain, a comparison hash value through the preset hash function;
a judging unit 34, configured to judge whether there are a first target hash value larger than the hash value and a second target hash value not larger than the hash value based on the hash value obtained from the second calculating unit 33 traversing the target hash value of the binary in the first array obtained from the first composing unit 32, and the binary in which the first target hash value and the second target hash value are respectively located are adjacent to each other;
a determining unit 35, configured to determine that the target node corresponding to the first target hash value is a consensus accounting node if the first array obtained by the determining unit 34 has a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value, and the two tuples in which the first target hash value and the second target hash value are located are adjacent to each other;
an obtaining unit 36, configured to obtain a preset number of bits to be intercepted;
a first truncating unit 37, configured to truncate the preset number of truncates obtained from the obtaining unit 36 from a lowest bit to a highest bit of the target hash value in the first array obtained from the first composing unit 32 in sequence to form the preset number of truncates target hash value;
a second forming unit 38, configured to form a second array from a new binary group formed by the target nodes corresponding to the preset truncating digit target hash value and the preset truncating digit target hash value obtained from the first truncating unit 37; the new binary group of the second array is further arranged in an ascending order according to the hash value to obtain a third array;
a second clipping unit 39 configured to clip the preset clipping bit number obtained from the obtaining unit 36 from the lowest bit to the highest bit of the comparison hash value obtained from the second calculating unit 33 to form the preset clipping bit number comparison hash value;
the determining unit 34 is further configured to determine, based on the preset capture bit number target hash value obtained from the second capturing unit 39 and traversing the preset capture bit number target hash value of the new binary set in the third array obtained from the second composing unit 38, whether there are a first preset capture bit number target hash value larger than the preset capture bit number target hash value and a second preset capture bit number target hash value not larger than the preset capture bit number target hash value, where new binary sets where the first preset capture bit number target hash value and the second preset capture bit number target hash value are located are adjacent to each other;
the determining unit 35 is further configured to determine that the target node corresponding to the first preset interception digit target hash value is a consensus accounting node if the third array obtained by the determining unit 34 has a first preset interception digit target hash value larger than the preset interception digit comparison hash value and a second preset interception digit target hash value not larger than the preset interception digit comparison hash value, and the first preset interception digit target hash value and the second preset interception digit target hash value are located adjacent to each other;
a creating unit 40, configured to create a target block from the consensus accounting node obtained by the determining unit 35 and synchronize to the current blockchain network;
a first verifying unit 41, configured to receive the target block obtained from the creating unit 40 by another node of the current blockchain network, and determine whether the node of the common account corresponding to the target block passes verification according to a preset verification rule; the system is also used for feeding back verification passing information if the verification passes;
a third calculating unit 42, configured to determine the number of other nodes in the current block-chain network that have passed the authentication of the consensus accounting node based on the number of obtained authentication passing information obtained from the first authenticating unit 41;
a second verifying unit 43, configured to determine whether a ratio of the number of other nodes in the current blockchain network that pass verification for the common identification accounting node in the current blockchain network, which is obtained from the third calculating unit 42, to the number of all nodes in the current blockchain network is greater than a preset threshold; and the node is further configured to add the target block to the corresponding local blockchain end synchronously by other nodes of the current blockchain network if the ratio of the number of other nodes in the current blockchain network that pass the verification of the consensus accounting node to the number of all nodes in the current blockchain network is greater than a preset threshold.
Further, the obtaining unit 36 includes:
an obtaining module 361, configured to obtain a total number of nodes of the current blockchain system;
a calculating module 362, configured to calculate the preset interception bit number according to a preset calculation rule based on the total number of nodes obtained from the obtaining module 361, where the preset calculation rule is: j = K/2,2J < N < =2K, K is the preset number of truncated bits, and N is the total number of nodes.
Further, the calculating module 362 includes:
a determining submodule 3621, configured to determine whether the preset number of bits is smaller than a preset threshold;
a determining submodule 3622, configured to determine that the preset number of bits intercepted from the determining submodule 3621 is equal to the preset threshold if the preset number of bits intercepted is smaller than the preset threshold.
Further, the second composition unit 38 includes:
an obtaining module 381, configured to sequentially obtain the preset interception bit number target hash value and the target node corresponding to the preset interception bit number target hash value;
a determining module 382, configured to determine whether the same preset capture bit target hash value exists in the second array based on the preset capture bit target hash value obtained from the obtaining module 381;
an adding module 383, configured to add, if the same preset capture bit target hash value does not exist in the second array obtained from the determining module 382, a new binary group formed by the preset capture bit target hash value and the target node corresponding to the preset capture bit target hash value into the second array in sequence.
Further, the first verification unit 41 includes:
a determining module 411, configured to receive the target block by another node of the current block chain network, and determine whether the co-identified accounting node corresponding to the target block is the same as the accounting node locally calculated by the other node;
the verification module 412 is configured to obtain from the determining module 411, if the common identification accounting node corresponding to the target block is the same as the current accounting node locally calculated by the other nodes, pass the verification, and feed back verification passing information.
Further, an embodiment of the present invention further provides a processor, where the processor is configured to execute a program, where the program executes the node consensus method of the blockchain system described in fig. 1-2.
Further, an embodiment of the present invention further provides a storage medium, where the storage medium is used to store a computer program, where the computer program is run to control an apparatus where the storage medium is located to execute the node consensus method of the blockchain system described in fig. 1-2 above.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another. In addition, "first", "second", and the like in the above embodiments are used to distinguish the embodiments, and do not represent merits of the embodiments. It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system is apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention. In addition, the memory may include volatile memory in a computer readable medium, random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art to which the present application pertains. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for node consensus in a blockchain system, the method comprising:
calculating a target hash value corresponding to a target node through a preset hash function according to target information of the target node and target information of the last block of a current block chain, wherein the number of the target nodes is not less than 2;
forming a binary group by the target node and the target hash value corresponding to the target node;
arranging a plurality of the binary groups into a first array according to the ascending order of the hash values;
calculating a comparison hash value through the preset hash function according to the target information of the last block of the current block chain;
based on the comparison hash value traversing the target hash values of the duplets in the first array, judging whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist, and the duplets in which the first target hash value and the second target hash value are respectively located are adjacent;
if yes, determining that the target node corresponding to the first target hash value is a consensus accounting node.
2. The method as claimed in claim 1, wherein after calculating a comparison hash value according to the target information of the last block of the current blockchain by the preset hash function, the method comprises:
acquiring a preset interception digit;
intercepting the preset interception digits from the lowest bit to the highest bit of the target hash value in the first array in sequence to form a target hash value with the preset interception digits;
forming a second array by using a new binary group formed by the target nodes corresponding to the preset interception digit target hash value and the preset interception digit target hash value;
arranging the new binary groups of the second array according to the ascending order of the hash values to obtain a third array;
intercepting the preset interception digit from the lowest bit to the highest bit of the comparison hash value to form the comparison hash value of the preset interception digit;
based on the preset interception digit target hash value of the new binary group in the third array traversed by the preset interception digit comparison hash value, judging whether a first preset interception digit target hash value larger than the preset interception digit comparison hash value and a second preset interception digit target hash value not larger than the preset interception digit comparison hash value exist, wherein the first preset interception digit target hash value and the second preset interception digit target hash value are respectively positioned adjacent to the new binary group;
and if so, determining that the target node corresponding to the first preset interception digit target hash value is a consensus accounting node.
3. The method of claim 2, wherein the obtaining the preset number of truncation bits comprises:
acquiring the total number of nodes of the current block chain system;
and calculating to obtain the preset interception digit through a preset calculation rule based on the total number of the nodes, wherein the preset calculation rule is as follows: j = K/2,2 J < N <=2 K K is the preset interception digit number, and N is the total number of the nodes.
4. The method according to claim 3, wherein the obtaining the preset number of truncation bits through calculation according to a preset calculation rule based on the total number of nodes comprises:
judging whether the preset interception digit is smaller than a preset threshold value or not;
and if so, determining that the preset interception digit is equal to the preset threshold value.
5. The method according to any one of claims 2-4, wherein the forming a second array of new tuples consisting of the target nodes corresponding to the preset truncated bit target hash value and the preset truncated bit target hash value according to the preset truncated bit target hash value comprises:
sequentially acquiring the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value;
judging whether the same preset interception digit target hash value exists in the second array or not based on the preset interception digit target hash value;
and if the preset interception digit target hash value does not exist, sequentially adding a new binary group consisting of the preset interception digit target hash value and the target node corresponding to the preset interception digit target hash value into the second array.
6. The method of any of claims 1-4, wherein after the determining that the target node to which the first target hash value corresponds is a consensus accounting node, the method further comprises:
the consensus accounting node creates a target block and synchronizes to the current blockchain network;
receiving the target block by other nodes of the current block chain network, and judging whether the node of the consensus accounting corresponding to the target block passes the verification according to a preset verification rule;
if the verification is passed, feeding back verification passing information;
determining the number of other nodes in the current block chain network which pass the verification of the common identification accounting node based on the number of the obtained verification passing information;
judging whether the proportion of the number of other nodes which pass the verification of the consensus accounting node in the current block chain network to the number of all nodes in the current block chain network is greater than a preset threshold value;
if so, other nodes of the current blockchain network synchronously add the target block to the corresponding local blockchain end.
7. The method of claim 6, wherein the other nodes of the current blockchain network receive the target block and determine whether the consensus accounting node corresponding to the target block is verified according to a predetermined verification rule, comprising:
the other nodes of the current block chain network receive the target block and judge whether the common identification accounting node corresponding to the target block is the same as the accounting node locally calculated by the other nodes;
if the verification information is the same as the verification information, the verification is passed, and verification passing information is fed back.
8. An apparatus for node consensus in a blockchain system, the apparatus comprising:
the first calculation unit is used for calculating a target hash value corresponding to a target node through a preset hash function according to target information of the target node and target information of the last block of a current block chain, wherein the number of the target nodes is not less than 2;
a first composing unit, configured to compose the target node and the target hash value corresponding to the target node into a binary set; the system is also used for arranging a plurality of the binary groups into a first array according to the ascending order of the hash value;
the second calculation unit is used for calculating a comparison hash value through the preset hash function according to the target information of the last block of the current block chain;
a judging unit, configured to judge whether a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist based on the comparison hash value traversing the target hash values of the tuples in the first array, where the first target hash value and the second target hash value are located adjacent to each other;
a determining unit, configured to determine that the target node corresponding to the first target hash value is a consensus accounting node if a first target hash value larger than the comparison hash value and a second target hash value not larger than the comparison hash value exist in the first array, and the first target hash value and the second target hash value are located in adjacent duplets.
9. A storage medium comprising a stored program, wherein when the program is executed, an apparatus on which the storage medium is located is controlled to perform a node consensus method of a blockchain system according to any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the program, implements a node consensus method of a blockchain system as claimed in any one of claims 1 to 7.
CN202210947617.9A 2022-08-09 2022-08-09 Node consensus method and device for block chain system Active CN115034794B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210947617.9A CN115034794B (en) 2022-08-09 2022-08-09 Node consensus method and device for block chain system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210947617.9A CN115034794B (en) 2022-08-09 2022-08-09 Node consensus method and device for block chain system

Publications (2)

Publication Number Publication Date
CN115034794A CN115034794A (en) 2022-09-09
CN115034794B true CN115034794B (en) 2023-01-13

Family

ID=83129971

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210947617.9A Active CN115034794B (en) 2022-08-09 2022-08-09 Node consensus method and device for block chain system

Country Status (1)

Country Link
CN (1) CN115034794B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109242299A (en) * 2018-08-31 2019-01-18 深圳付贝科技有限公司 Distribution digs mine method, digs mine machine and block catenary system
CN109542883A (en) * 2018-10-30 2019-03-29 广州斯拜若科技有限公司 A kind of information duplicate checking method based on block chain
CN114598477A (en) * 2022-03-02 2022-06-07 济南量子技术研究院 Consensus system and method based on device-independent quantum random numbers

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11196542B2 (en) * 2018-08-29 2021-12-07 International Business Machines Corporation Checkpointing for increasing efficiency of a blockchain

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109242299A (en) * 2018-08-31 2019-01-18 深圳付贝科技有限公司 Distribution digs mine method, digs mine machine and block catenary system
CN109542883A (en) * 2018-10-30 2019-03-29 广州斯拜若科技有限公司 A kind of information duplicate checking method based on block chain
CN114598477A (en) * 2022-03-02 2022-06-07 济南量子技术研究院 Consensus system and method based on device-independent quantum random numbers

Also Published As

Publication number Publication date
CN115034794A (en) 2022-09-09

Similar Documents

Publication Publication Date Title
TWI721699B (en) System and method for parallel-processing blockchain transactions
US11522706B2 (en) Method and system for publicly verifiable proofs of retrievability in blockchains
US11165589B2 (en) Trusted agent blockchain oracle
KR102561726B1 (en) Method for selecting consensus node using nonse, method and apparatus for generating blockchain using the same
Shrimali et al. Blockchain state-of-the-art: architecture, use cases, consensus, challenges and opportunities
Bano et al. The road to scalable blockchain designs
CN108171601B (en) Block chain source tracing method, device and system
JP2019511151A (en) Cryptographic method and system for secure extraction of data from blockchain
US11170374B2 (en) Method, apparatus and electronic device for blockchain transactions
KR102537774B1 (en) Systems and methods that provide specialized proof of confidential knowledge
Mauri et al. A Comparative Analysis of Current Cryptocurrencies.
Gräbe et al. Do not be fooled: Toward a holistic comparison of distributed ledger technology designs
Plevris et al. Blockchain in civil engineering, architecture and construction industry: state of the art, evolution, challenges and opportunities
CN112613601A (en) Neural network model updating method, device and computer storage medium
Rubel No need to ask: Creating permissionless blockchains of metadata records
Heo et al. Design of blockchain system for protection of personal information in digital content trading environment
CN110119947B (en) Method and apparatus for shared workload proof computing power generation of symbiotic blockchains
CN109829076B (en) Method and equipment for generating block chain
Arjomandi-Nezhad et al. Proof of humanity: A tax-aware society-centric consensus algorithm for Blockchains
CN113994324B (en) Block chain system with efficient world state data structure
CN115034794B (en) Node consensus method and device for block chain system
Hoopes et al. Sciledger: A blockchain-based scientific workflow provenance and data sharing platform
Khacef et al. Trade-off between security and scalability in blockchain design: A dynamic sharding approach
Galletta et al. Resilience of Hybrid Casper under varying values of parameters
Alam The Current State of Blockchain Consensus Mechanism: Issues and Future Works

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