A consensus method, device, and medium using the hash of the block to be generated as a seed

By collecting random numbers of each node in the blockchain network and comparing with the hash value of the block to be generated, the accounting nodes are determined, and the problem of high node control consensus algorithm is solved, equal competition and participation of each node are achieved, and the healthy development of the blockchain network is promoted.

CN111147229BActive Publication Date: 2025-05-30INSPUR YUNZHOU (SHANDONG) IND INTERNET CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201911401372.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-30
Publication Date
2025-05-30
Estimated Expiration
2039-12-30

AI Technical Summary

Technical Problem

Under the proof of work mechanism, nodes with high computing power are more likely to gain accounting rights than nodes with low computing power, which makes the consensus algorithm in the blockchain easily controlled by nodes with high computing power, which is not conducive to the good development of the blockchain network.

Method used

By collecting random numbers generated by each node in the blockchain and comparing them with these random numbers based on the hash value of the block to be generated, the accounting node of the block to be generated is determined. This method no longer considers the computing power of each node to ensure equality in the acquisition of accounting rights.

Benefits of technology

Under the conditions of greater randomness, it is ensured that all nodes in the blockchain network may become accounting nodes, realizing equality between each node in seizing accounting rights, preventing individual nodes from holding accounting rights, ensuring the participation of each node, which is conducive to the maintenance of the blockchain network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111147229B_ABST
    Figure CN111147229B_ABST
Patent Text Reader

Abstract

The present application discloses a consensus method, device, and medium using the hash of the block to be generated as a seed. This method collects random numbers generated by each node in the blockchain; determines the hash value of the block to be generated; and determines the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node. By comparing the random numbers generated by each node with the hash value of the block to be generated to determine the accounting node, it is possible to ensure that each node in the blockchain network may become the accounting node under relatively large randomness conditions, realizing the equality of each node competing for the accounting right.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of consensus algorithms, and particularly to a consensus method, device, and medium using the hash value of the to-be-generated block as a seed. Background Art

[0002] With the development of technology, the application of blockchain technology is becoming more and more extensive.

[0003] In blockchain technology, each node in the blockchain network, based on the proof-of-work mechanism, relies on its own computing power to compete for the right to record transactions, serves as a recording node, and obtains corresponding rewards.

[0004] However, under the proof-of-work mechanism, nodes with higher computing power obviously have an advantage over nodes with lower computing power and are more likely to grab the right to record transactions. This makes the consensus algorithm in the blockchain easily controlled by nodes with high computing power, which is not conducive to the healthy development of the blockchain network. Summary of the Invention

[0005] Embodiments of this application provide a consensus method, device, and medium using the hash value of the to-be-generated block as a seed to solve the following technical problems in the prior art: Under the proof-of-work mechanism, nodes with higher computing power are more likely to grab the right to record transactions than nodes with lower computing power. This makes the consensus algorithm in the blockchain easily controlled by nodes with high computing power, which is not conducive to the healthy development of the blockchain network.

[0006] Embodiments of this application adopt the following technical solutions:

[0007] A consensus method using the hash value of the to-be-generated block as a seed includes:

[0008] Collecting random numbers generated by each node in the blockchain;

[0009] Determining the hash value of the to-be-generated block;

[0010] Determining the recording node of the to-be-generated block from each node according to the hash value and the random numbers generated by each node.

[0011] Optionally, collecting random numbers generated by each node in the blockchain includes: collecting random numbers generated by each node in the blockchain according to the block generation period for generating new blocks.

[0012] Optionally, the tenure of the recording node is less than twice the block generation period for generating new blocks.

[0013] Optionally, determining the recording node of the to-be-generated block from each node according to the hash value and the random numbers generated by each node includes: determining the random number with the smallest difference from the hash value from the random numbers generated by each node; determining the corresponding node as the recording node of the to-be-generated block according to the determined random number.

[0014] Optionally, among the random numbers generated by each node, determining the random number with the smallest difference from the hash value includes: determining a partial hash value from the hash value; determining that the random number and the partial hash value have the same number of digits; and determining, from each random number, the random number with the smallest difference from the partial hash value.

[0015] Optionally, the method further includes: if the determined random number is not unique, giving up selecting the accounting node for the to-be-generated block.

[0016] Optionally, the method further includes: extending the term of office of the previous accounting node as the accounting node for the to-be-generated block.

[0017] Optionally, the random number is a hexadecimal number.

[0018] A consensus device using the hash of the to-be-generated block as a seed includes:

[0019] At least one processor; and,

[0020] A memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to:

[0022] Collect random numbers generated by each node in the blockchain;

[0023] Determine the hash value of the to-be-generated block;

[0024] Determine the accounting node for the to-be-generated block from each node according to the hash value and the random numbers generated by each node.

[0025] A non-volatile computer storage medium for consensus using the hash of the to-be-generated block as a seed stores computer-executable instructions, and the computer-executable instructions are configured to:

[0026] Collect random numbers generated by each node in the blockchain;

[0027] Determine the hash value of the to-be-generated block;

[0028] Determine the accounting node for the to-be-generated block from each node according to the hash value and the random numbers generated by each node.

[0029] The above at least one technical solution adopted in the embodiments of the present application can achieve the following beneficial effects:

[0030] The random numbers generated by each node are compared with the hash value of the block to be generated, thereby determining the accounting node. Under relatively large randomness conditions, it can ensure that each node in the blockchain network has the possibility of becoming the accounting node.

[0031] Moreover, this method no longer considers the computing power of each node, enabling each node to have exactly the same competitive conditions, realizing the equality of each node in competing for the right to record transactions. In this way, it can ensure that there is no problem of individual nodes having dominance, prevent individual nodes from monopolizing the right to record transactions, guarantee the participation of each node, and is conducive to the maintenance of the blockchain network. Brief Description of the Drawings

[0032] The drawings described herein are used to provide a further understanding of the present application and form a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:

[0033] Figure 1 It is a flowchart of a consensus method using the hash of the block to be generated as a seed provided by an embodiment of the present application;

[0034] Figure 2 It is for an embodiment of the present application corresponding to Figure 1 a schematic structural diagram of a device for consensus using the hash of the block to be generated as a seed. Detailed Embodiments

[0035] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.

[0036] The following will describe in detail the technical solutions provided by each embodiment of the present application in conjunction with the drawings.

[0037] Figure 1 It is a flowchart of a consensus method using the hash of the block to be generated as a seed provided by an embodiment of the present application. The specific steps include:

[0038] S101: Collect the random numbers generated by each node in the blockchain.

[0039] A blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. Essentially, it is a decentralized database.

[0040] First, a blockchain network can be deployed based on a blockchain framework. Among them, the blockchain framework can be any blockchain framework that can implement the corresponding functions of the embodiments of the present application. For example, Bitcoin, Ethereum, Fabric, Corda, etc.

[0041] The blockchain network includes several nodes. In the process of generating a new block each time, each node may act as a bookkeeping node and be responsible for publishing the content of the new block.

[0042] In the embodiments of the present application, each node in the blockchain network can generate a random number respectively, so as to determine which node will be the bookkeeping node of the block to be generated through the random number subsequently. Among them, the block to be generated refers to the new block to be added to the blockchain.

[0043] The bookkeeping node in the blockchain network is not fixed. According to the term of office of the bookkeeping node, a new bookkeeping node can be determined through the corresponding consensus method when the term of office of the bookkeeping node expires. Among them, the term of office of the bookkeeping node refers to the duration during which a certain node can serve as the bookkeeping node.

[0044] In the embodiments of the present application, the term of office of the bookkeeping node can be determined according to the preset in the consensus method. Specifically, it can be determined that the term of office of the bookkeeping node is not less than the block generation period of generating a new block and less than 2 times the block generation period of generating a new block. For example, the block generation period of generating a new block is 10 minutes, and the term of office of the bookkeeping node is 15 minutes.

[0045] That is to say, each term of office of the bookkeeping node can be responsible for publishing a new block once or twice. Before the term of office of the previous bookkeeping node expires, a new bookkeeping node needs to be determined through the corresponding consensus method. In a possible implementation manner, the term of office of the bookkeeping node can be default set to 1.5 times the block generation period of the new block.

[0046] By setting the term of office of the bookkeeping node and setting it to a shorter term, the bookkeeping power of each term of office of the bookkeeping node can be restricted, so that each node in the blockchain network has the opportunity to become the bookkeeping node, which is beneficial to the maintenance of the blockchain network.

[0047] Furthermore, each node in the blockchain network can generate corresponding random numbers at the same period as the block generation period of generating a new block, so as to determine a new bookkeeping node according to the random numbers subsequently.

[0048] S102: Determine the hash value of the block to be generated.

[0049] In a blockchain network, each block to be generated includes the hash value of the previous block and the Merkle root hash value of the current block. Among them, the Merkle root hash value of the current block can represent all the transactions included in the current block, which is obtained by operating on the hash values of all the transactions included in the current block through a binary tree structure.

[0050] In an embodiment of the present application, during the process of determining the accounting node, it is necessary to determine the Merkle root hash value of the block to be generated, so as to subsequently determine the accounting node corresponding to the block to be generated through the hash value of the block to be generated.

[0051] It should be noted that the present application does not limit the sequence relationship between step 101 and step 102. In the actual process, the random numbers generated by each node can be collected first, and then the hash value of the block to be generated can be determined. Or the hash value of the block to be generated can be determined first, and then the random numbers generated by each node can be collected. Or the random numbers generated by each node and the determination of the hash value of the block to be generated can be collected simultaneously.

[0052] S103: Determine the accounting node of the block to be generated from each node according to the hash value of the block to be generated and the random numbers generated by each node.

[0053] In an embodiment of the present application, the accounting node of the block to be generated can be determined from each node according to the hash value of the block to be generated and the random numbers generated by each node.

[0054] Specifically, the random numbers generated by each node can be subtracted from the hash value of the block to be generated respectively, and the results can be compared. After comparison, the random number with the smallest difference from the hash value of the block to be generated can be determined from the random numbers generated by each node. Then, the node corresponding to the determined random number can be used as the accounting node of the block to be generated.

[0055] This consensus method compares the random numbers generated by each node with the hash value of the block to be generated, so as to determine the accounting node. It can ensure that each node in the blockchain network may become the accounting node under the condition of greater randomness.

[0056] Moreover, this method no longer considers the computing power of each node, making each node have exactly the same competitive conditions, realizing the equality of each node in competing for the accounting right. In this way, it can be ensured that there is no problem of individual nodes having the dominant right, preventing individual nodes from holding the accounting right, guaranteeing the participation of each node, and being conducive to the maintenance of the blockchain network.

[0057] Further, since the hash value in the block to be generated is relatively long, therefore, a partial hash value can be determined from the hash value of the block to be generated. And ensure that each node generates a random number with the same number of digits as this partial hash value. Then, determine the random number with the smallest difference based on the difference between this partial hash value and the random number with the same number of digits.

[0058] By this method, the complexity of calculating the difference between the hash value and the random number can be reduced, and to a certain extent, part of the calculation amount can be reduced, alleviating the calculation pressure. And it is determined that the number of digits of the random number generated by each node is the same as that of the partial hash value, ensuring the equality of the results obtained by subtracting each random number from this partial hash value, thereby ensuring the equality of each node competing for the accounting right.

[0059] In a possible implementation manner, the last four digits of the hash value of the block to be generated can be determined as the partial hash value to be calculated. Then, the random numbers generated by each node are also four digits and are hexadecimal numbers.

[0060] Further, in the process of calculating the difference between each random number and the partial hash value, if only one random number is determined to have the smallest difference from the hash value of the block to be generated, the node corresponding to this random number can be directly determined as the accounting node.

[0061] However, there may also be a situation where multiple random numbers have the same difference from the hash value of the block to be generated and this difference is the smallest difference. In this case, when the determined random numbers are not unique, since multiple nodes cannot be used as accounting nodes at the same time, the selection of the accounting node for the block to be generated can be abandoned.

[0062] Then, the previous accounting node in the blockchain network can be determined, and the term of office of this accounting node can be extended, and this accounting node continues to be responsible for the release of the content of the block to be generated until a new accounting node is selected next time.

[0063] Based on the same idea, some embodiments of the present application also provide devices and non-volatile computer storage media corresponding to the above method.

[0064] Figure 2 For the Figure 1 a schematic structural diagram of a device for consensus with the hash of the block to be generated as the seed provided by the embodiment of the present application, the blockchain device includes:

[0065] At least one processor; and,

[0066] A memory communicatively connected to the at least one processor; wherein,

[0067] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:

[0068] Collect random numbers generated by each node in the blockchain;

[0069] Determine the hash value of the block to be generated;

[0070] Determine the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node.

[0071] Some embodiments of the present application provide a non-volatile computer storage medium corresponding to Figure 1 a consensus with the hash of the block to be generated as the seed, storing computer-executable instructions, and the computer-executable instructions are set as:

[0072] Collect random numbers generated by each node in the blockchain;

[0073] Determine the hash value of the block to be generated;

[0074] Determine the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node.

[0075] The various embodiments in the present application are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments.

[0076] The device and medium provided by the embodiments of the present application correspond one-to-one with the method. Therefore, the device and medium also have beneficial technical effects similar to those of the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the device and medium are not described here again.

[0077] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

[0078] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices produce means for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 one or more of the blocks.

[0079] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means that implement the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 one or more of the blocks.

[0080] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 one or more of the blocks.

[0081] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0082] The memory may include non-permanent memory in the form of computer-readable media, 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 computer-readable media.

[0083] A computer-readable medium includes permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, 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 technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory media 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 transitory computer-readable media, such as modulated data signals and carrier waves.

[0084] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0085] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A consensus method using the hash of the block to be generated as a seed, characterized in that, it includes: Collecting random numbers generated by each node in the blockchain; Determining the hash value of the block to be generated; Determining the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node; Collecting random numbers generated by each node in the blockchain includes: Collecting random numbers generated by each node in the blockchain according to the block generation period for generating a new block; The tenure of the accounting node is less than twice the block generation period for generating a new block; Determining the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node includes: Determining the random number with the smallest difference from the hash value from the random numbers generated by each node; Determining the corresponding node as the accounting node of the block to be generated according to the determined random number; Determining the random number with the smallest difference from the hash value from the random numbers generated by each node includes: Determining partial hash values from the hash value; Determining that the random number and the partial hash value have the same number of digits; Determining the random number with the smallest difference from the partial hash value from each random number; The method further includes: If the determined random number is not unique, giving up the selection of the accounting node of the block to be generated; The method further includes: Extending the tenure of the previous accounting node as the accounting node of the block to be generated; The random number is a hexadecimal number.

2. A device for consensus using the hash of the block to be generated as a seed, characterized in that, it includes: At least one processor; And, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: Collect random numbers generated by each node in the blockchain; Determine the hash value of the block to be generated; Determine the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node; Collecting random numbers generated by each node in the blockchain includes: Collecting random numbers generated by each node in the blockchain according to the block generation period for generating a new block; The tenure of the accounting node is less than twice the block generation period for generating a new block; Determining the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node includes: Determining the random number with the smallest difference from the hash value from the random numbers generated by each node; Determining the corresponding node as the accounting node of the block to be generated according to the determined random number; Determining the random number with the smallest difference from the hash value from the random numbers generated by each node includes: Determining partial hash values from the hash value; Determining that the random number and the partial hash value have the same number of digits; Determining the random number with the smallest difference from the partial hash value from each random number; If the determined random number is not unique, giving up the selection of the accounting node of the block to be generated; Extending the tenure of the previous accounting node as the accounting node of the block to be generated; The random number is a hexadecimal number.

3. A non-volatile computer storage medium for a consensus with the hash of the block to be generated as a seed, storing computer-executable instructions, characterized in that, the computer-executable instructions are set to: collect random numbers generated by each node in the blockchain; determine the hash value of the block to be generated; determine the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node; collect random numbers generated by each node in the blockchain, including: collect random numbers generated by each node in the blockchain according to the block generation period of generating a new block; the tenure of the accounting node is less than twice the block generation period of generating a new block; determine the accounting node of the block to be generated from each node according to the hash value and the random numbers generated by each node, including: determine the random number with the smallest difference from the hash value from the random numbers generated by each node; determine the corresponding node as the accounting node of the block to be generated according to the determined random number; determine the random number with the smallest difference from the hash value from the random numbers generated by each node, including: determine partial hash values from the hash value; determine that the random number and the partial hash value have the same number of digits; determine the random number with the smallest difference from the partial hash value from each random number; if the determined random number is not unique, abandon the selection of the accounting node of the block to be generated; extend the tenure of the previous accounting node as the accounting node of the block to be generated; the random number is a hexadecimal number.

Citation Information

Patent Citations

  • Proof-of-work method and device

    CN108712486A