Blockchain consensus method, apparatus, computer device, and storage medium

CN115422525BActive Publication Date: 2026-08-07INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INDUSTRIAL AND COMMERCIAL BANK OF CHINA
Filing Date
2022-08-31
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

然而,现有技术中的区块链共识方法,多数无法体现公平性,例如在DPoS共识机制中,节点使用各自的选票(权益)来选出代表节点,由前n个代表节点组成未来共识轮次的共识委员会,委员会成员轮流担任区块提出者,其他委员会成员则担任区块验证者,共同完成区块的出块和验证的整个过程,这种方法只有固定数量的节点能够参与共识过程,会使得去中心化程度受到影响,同时“权益”也限定了公平性,使得普通节点无法获得担任区块提出者的机会,这对于需要体现公平性的业务场景是不利的

Benefits of technology

[0041]The aforementioned blockchain consensus method, apparatus, computer equipment, storage medium, and computer program products determine the initial node set in the blockchain, obtain the corresponding value chain for each node in the initial node set (the value chain consists of multiple values), and broadcast the first unbroadcast value in its respective value chain in reverse order by each node. If all nodes have broadcast their corresponding values ​​within a first preset time period, the first values ​​broadcast by each node are integrated to obtain a target random number. Based on the difference between the first values ​​broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set. The process continues until the first block-producing node completes its work. After a block is produced, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces a block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number. This can improve the fairness of selecting block-producing nodes in the blockchain system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115422525B_ABST
    Figure CN115422525B_ABST
Patent Text Reader

Abstract

The application relates to a blockchain consensus method and device, a computer device, a storage medium and a computer program product. The method comprises the following steps: determining an initial node set in a blockchain; broadcasting, by each node, a first value in a respective value chain in a reverse order, and integrating the first values broadcast by each node to obtain a target random number if each node has broadcast the corresponding value within a first preset time length; determining a first block node from all nodes in the initial node set according to the difference between the first value broadcast by each node and the target random number; obtaining a new target random number according to the first block node, determining a next block node according to the new target random number, and stopping until the total number of blocks reaches a preset number. The method can improve the fairness of selecting a block node in a blockchain system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular to a blockchain consensus method, apparatus, computer equipment, and storage medium. Background Technology

[0002] Blockchain consensus methods can be used for activities such as voting and lotteries. However, most existing blockchain consensus methods fail to ensure fairness. For example, in the DPoS consensus mechanism, nodes use their votes (stakes) to elect representative nodes. The top n representative nodes form a consensus committee for future consensus rounds. Committee members take turns being block proposers, while other committee members act as block validators, jointly completing the entire process of block production and verification. This method allows only a fixed number of nodes to participate in the consensus process, affecting decentralization. Furthermore, the "stakes" limit fairness, preventing ordinary nodes from having the opportunity to be block proposers, which is detrimental to business scenarios requiring fairness. Blockchains based on this type of consensus method wield excessive power over block proposers, making data forgery easy and causing incalculable losses to blockchain businesses. Therefore, a new blockchain consensus method is urgently needed. Summary of the Invention

[0003] Therefore, it is necessary to provide a blockchain consensus method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve fairness in response to the above-mentioned technical problems.

[0004] Firstly, this application provides a blockchain consensus method. The method includes:

[0005] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0006] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0007] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0008] In one embodiment, obtaining the corresponding value chain for each node in the initial node set includes:

[0009] For any node in the initial node set, generate an initial random value for that node;

[0010] Iterative hashing is performed based on an initial random value. The results of each iteration are sorted in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for any node.

[0011] In one embodiment, after each node broadcasts the first unbroadcast value in its respective value chain in reverse order, the method further includes:

[0012] If a node fails to broadcast its first value within the first preset time period, then the nodes that have broadcast their first value within the first preset time period will form a set of participating nodes.

[0013] The first value broadcast by each participating node in the participating node set is integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, the target participating node is determined from all participating nodes in the participating node set.

[0014] The target participating node broadcasts the first unbroadcast value in the corresponding value chain, which is sorted in reverse order. If the target participating node has broadcast the corresponding value within the second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number.

[0015] Determine if the count value is equal to a preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to the initial value when the first target participating node is generated.

[0016] In one embodiment, after determining whether the count value is equal to a preset threshold, the method further includes:

[0017] If the count value is less than the preset threshold, the target participating node is removed from the participating node set, and the count value is incremented by 1.

[0018] Jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0019] In one embodiment, after broadcasting the first unbroadcast value in the corresponding value chain in reverse order by the target participating node, the method further includes:

[0020] If the target participating node does not broadcast the corresponding value within the second preset time period, the target participating node will be removed from the participating node set.

[0021] Determine if the count value is equal to the initial value. If the count value is equal to the initial value, jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0022] If the count value is greater than the initial value, the count value is decremented by 1, and the process jumps to the step of broadcasting the first unbroadcasted value in the corresponding value chain in reverse order through the target participating node and continues execution.

[0023] In one embodiment, the first block-producing node is determined from all nodes in the initial node set based on the difference between the first value broadcast by each node and the target random number, including:

[0024] Obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and take the node with the smallest absolute value of the difference as the first block-producing node.

[0025] Secondly, this application also provides a blockchain consensus device. The device includes:

[0026] The first determining module is used to determine the initial set of nodes in the blockchain and obtain the corresponding value chain of each node in the initial set of nodes. The value chain is composed of multiple values.

[0027] The second determining module is used to broadcast the first unbroadcast value in the reverse order of the value chain of each node. If each node has broadcast the corresponding value within the first preset time period, the first value broadcast by each node is integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0028] The third determination module is used to determine the next value after the first block-producing node completes block production. It takes the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value, integrates the next value with the current target random number to obtain a new target random number, determines the next block-producing node from all nodes in the initial node set based on the difference between the new target random number and the latest broadcast value of each node, and returns to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value after the next block-producing node produces a block, and continues to execute until the total number of blocks produced reaches the preset number.

[0029] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0030] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0031] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0032] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0033] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0034] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0035] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0036] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0037] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0038] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0039] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0040] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0041] The aforementioned blockchain consensus method, apparatus, computer equipment, storage medium, and computer program products determine the initial node set in the blockchain, obtain the corresponding value chain for each node in the initial node set (the value chain consists of multiple values), and broadcast the first unbroadcast value in its respective value chain in reverse order by each node. If all nodes have broadcast their corresponding values ​​within a first preset time period, the first values ​​broadcast by each node are integrated to obtain a target random number. Based on the difference between the first values ​​broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set. The process continues until the first block-producing node completes its work. After a block is produced, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces a block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number. This can improve the fairness of selecting block-producing nodes in the blockchain system. Attached Figure Description

[0042] Figure 1 This is a flowchart illustrating a blockchain consensus method in one embodiment;

[0043] Figure 2 This is a flowchart illustrating a blockchain consensus method in another embodiment;

[0044] Figure 3 This is a structural block diagram of a blockchain consensus device in one embodiment;

[0045] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0047] It is understood that the terms "first," "second," etc., used in this application may be used to describe various technical terms, but unless otherwise specified, these technical terms are not limited to these terms. These terms are only used to distinguish one technical term from another. For example, without departing from the scope of this application, the third preset threshold and the fourth preset threshold may be the same or different.

[0048] The existing DPoS consensus mechanism suffers from low decentralization. This invention proposes a blockchain consensus method based on verifiable random numbers, which can solve the fairness problem of block-producing node election in the DPoS consensus mechanism. This application improves upon the DPoS consensus mechanism, making the blockchain consensus method applicable to more fairness-oriented business scenarios and reducing the number of DPoS consensus node elections, thereby accelerating consensus efficiency.

[0049] In one embodiment, such as Figure 1 As shown, a blockchain consensus method is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and further to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0050] 101. Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0051] 102. Each node broadcasts the first unbroadcast value in its respective value chain in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0052] 103. After the first block-producing node completes block production, take the first unbroadcasted value in the reverse-ordered value chain of the current block-producing node as the next value. Integrate the next value with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, determine the next block-producing node from all nodes in the initial node set. After the next block-producing node produces a block, return to the step of taking the first unbroadcasted value in the reverse-ordered value chain of the current block-producing node as the next value and continue to execute until the total number of blocks produced reaches the preset number.

[0053] In a blockchain system, multiple rounds of block production are required, with each round having a preset number of blocks produced. Once the preset number of blocks is reached in any round, the block production for that round ends, and the next round begins. For example, if the preset number of blocks is reached in the first round, the first round ends, and the blockchain system begins the second round of block production.

[0054] In this application, the process of selecting a block-producing node for the first time in each round is called the main consensus process, and each subsequent process of selecting a block-producing node after the first selection in each round is called a secondary consensus process. If the number of blocks produced in each round is a preset number of 5, then the consensus process in each round consists of one main consensus process and four secondary consensus processes.

[0055] At the start of each round, the blockchain system selects a preset number of master nodes based on the DPoS consensus mechanism, while the remaining nodes in the blockchain system will serve as ordinary nodes. In this application, both ordinary nodes and master nodes in each round can participate in the election of block-producing nodes.

[0056] After the master node is determined in each round, each node in the blockchain system generates a corresponding value chain of a preset bit length. For example, after the master node is generated in the Nth round, each node in the blockchain system will generate a t-bit value chain. That is, each node corresponds to one value chain, and the values ​​on each node's value chain are different. After each node generates a value chain, the master node notifies all ordinary nodes to broadcast the last value on their respective value chains and transmit it to all master nodes. Each master node also broadcasts the last value on its own value chain and transmits it to other master nodes. The process of transmitting the last value on a node's value chain to all master nodes is called node registration. Master nodes can verify the corresponding nodes based on the last value on the node's value chain they obtain.

[0057] In step 101 above, the initial node set is generated after the master node is determined in each round. The initial node set consists of nodes that broadcast and transmit the last value on the value chain to the master node. Therefore, the initial node set can be a set of nodes including the master node and ordinary nodes. That is to say, the last value on the value chain of each node in the initial node set has been broadcast.

[0058] In step 102 above, the first unbroadcast value in the reverse order of the value chain broadcast by each node means that all values ​​after the first value in the corresponding value chain have been broadcast. For example, if the value chain of node 1 is ordered as A, B, C, D, E, where the value E has been broadcast, while A, B, C, and D have not been broadcast, then the first unbroadcast value in the reverse order of the value chain of node 1 is D.

[0059] The integration method for integrating the first values ​​broadcast by each node is not specifically limited in this embodiment of the invention, but includes, but is not limited to: adding the first values ​​broadcast by each node to obtain the sum, performing a hash operation on the sum to obtain the hash operation result, and using the hash operation result as the integration result; for example, if the nodes are node A, node B, node C, and node D, and the corresponding value broadcast by node A is 1, the corresponding value broadcast by node B is 2, the corresponding value broadcast by node C is 3, and the corresponding value broadcast by node D is 4, then the sum is 1+2+3+4=10, the hash operation result is h(10), and the integration result is h(10), where h(10) represents performing a hash operation on 10. In addition, the first block-producing node in step 102 above refers to the block-producing node determined in the main consensus process.

[0060] In step 103 above, the current block-producing node refers to the latest node that has completed block production. For example, if the latest node that has completed block production is the first block-producing node, then the current block-producing node is the first block-producing node. If the current situation is that after the second consensus process has ended, a third consensus process is needed, then the current block-producing node is the block-producing node determined in the second consensus process.

[0061] The current target random number refers to the target random number for selecting the current block-producing node. For example, if the current block-producing node is K, and the target random number for selecting block-producing node K is 5, then the current target random number is 5.

[0062] The next value refers to the last unpublished value in the value chain of the current block-producing node. For example, if the current block-producing node is k, and its corresponding value chain is ordered as 5, 6, 9, 11, 10, where 11 and 10 have been broadcast, while 5, 6, and 9 have not been broadcast, then the next value is 9.

[0063] The present invention does not specifically limit the integration method for integrating the next value with the current target random number, including but not limited to: adding the next value with the current target random number to obtain the addition result, performing a hash operation on the addition result to obtain the hash operation result, and using the hash operation result as the integration result.

[0064] In one example, the next value is combined with the current target random number to obtain a new target random number. For example, if the next value is 5 and the target random number is 7, the combined result of the next value 5 and the target random number 7 is 12, and the new target random number is 12.

[0065] In one example, the next block-producing node is determined from all nodes in the initial node set based on the difference between the new target random number and the latest broadcast value of each node. This includes: obtaining the absolute value of the difference between the first broadcast value of each node in the reference node set and the new target random number, and selecting the node with the smallest absolute difference as the next block-producing node. The reference node set refers to the set from which the previous block-producing node was selected. For example, if the previous block-producing node was selected from the initial node set, then the reference node set is the initial node set; or if the previous block-producing node was selected from node set A, then the reference node set is node set A; furthermore, the reference node set is a subset of the initial node set.

[0066] It is worth mentioning that in step 103 above, the preset number of times is an integer not less than 2.

[0067] Specifically, it is determined whether each node in the initial node set broadcasts the first unbroadcast value in its respective value chain in reverse order. If each node in the initial node set broadcasts the first unbroadcast value in its respective value chain in reverse order within a first preset time period, the latest broadcast value of each node in the initial node set is integrated to obtain the corresponding integration result, and the integration result is used as the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set. After the first block-producing node completes block production, the first unbroadcast value in the corresponding value chain of the first block-producing node in reverse order is taken as the next value. The next value is integrated with the current target random number, and the integration result obtained after integrating the next value with the current target random number is used as the new target random number.

[0068] In addition, each time a block-producing node completes block production, the master node will verify the block-producing node. The verification methods include: (1) all master nodes verifying whether the block-producing node is consistent with the block-producing node determined according to the target random number; (2) all master nodes verifying the block-producing node's block production information; and (3) all master nodes verifying whether the block-producing node participated in the determination process of the corresponding target random number. When the block-producing node passes the verification of (1), (2), and (3), the block production verification of the block-producing node is successful.

[0069] Furthermore, in this application, when a regular node in any round suspects the target random number of a block-producing node, the regular node can initiate a verification request to the master node. The master node will then verify, based on the verification request, whether the block-producing node participated in the process of determining the corresponding target random number, whether the block-producing node is consistent with the block-producing node selected in the corresponding master (or slave) consensus process, and the block-producing node's block information. If the master node verifies that the block-producing node did not participate in the process of determining the corresponding target random number, verifies that the block-producing node is inconsistent with the block-producing node selected in the corresponding master (or slave) consensus process, or verifies that the block-producing node's block information fails verification, then the master node confirms that the block produced by that block-producing node is invalid, the block-producing node is set to an empty block, and the master node broadcasts the information that the block produced by that block-producing node is invalid.

[0070] The method provided by this invention involves all nodes in the blockchain system participating in both the master and slave consensus processes. This ensures that the election of block-producing nodes is no longer determined by the size of a node's stake, but by the verifiable numerical values ​​on the blockchain. Furthermore, block-producing nodes lack the ability to forge data, allowing any node in the blockchain system to participate in and verify the block-producing process, thereby improving the fairness of block-producing node selection. Simultaneously, both ordinary nodes and the master node in the blockchain system can verify the block-producing nodes. Moreover, since only one master node election is conducted per round, multiple block productions can be achieved, thus reducing the number of master node elections.

[0071] In conjunction with the above embodiments, in one embodiment, obtaining the corresponding value chain for each node in the initial node set includes:

[0072] For any node in the initial node set, generate an initial random value for that node;

[0073] Iterative hashing is performed based on an initial random value. The results of each iteration are sorted in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for any node.

[0074] Each node generates its own initial random value, and the initial random number of each node is not broadcast.

[0075] Specifically, the process of determining the hash chain of any node is shown in equation (1);

[0076]

[0077] Where n is the length of the hash chain, H n (x i Let h be the hash chain of node i. t (xi Let t be the hash value of node i in the hash chain, and h be the hash value of node i. t-1 (x i Let x be the (t-1)th hash value on the hash chain of node i. i Let n be the initial random value of node i, and n be an integer not less than 2.

[0078] It is worth mentioning that the values ​​on the hash chain of any node in this embodiment of the invention are not the same.

[0079] The method provided in this embodiment of the invention can generate a hash number chain for each node by using an initial random value for each node.

[0080] In conjunction with the above embodiments, in one embodiment, after each node broadcasts the first unbroadcast value in its respective value chain in reverse order, the method further includes:

[0081] If a node fails to broadcast its first value within the first preset time period, then the nodes that have broadcast their first value within the first preset time period will form a set of participating nodes.

[0082] The first value broadcast by each participating node in the participating node set is integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, the target participating node is determined from all participating nodes in the participating node set.

[0083] The target participating node broadcasts the first unbroadcast value in the corresponding value chain, which is sorted in reverse order. If the target participating node has broadcast the corresponding value within the second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number.

[0084] Determine if the count value is equal to a preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to the initial value when the first target participating node is generated.

[0085] Here, the first value broadcast by each participating node in the participating node set refers to the second-to-last value in the value chain of that node. The first preset duration and the second preset duration can be the same or different. Both the count value and the preset threshold are integers not less than 0.

[0086] The present invention does not specifically limit the integration method for integrating the first value broadcast by each participating node in the set of participating nodes, including but not limited to: summing the first value broadcast by each participating node in the set of participating nodes to obtain the summation result, performing a hash operation on the summation result to obtain the hash result, and using the hash result as the integration result.

[0087] The process of integrating the first values ​​broadcast by each participating node in the participating node set to obtain a reference random number involves: integrating the first values ​​broadcast by each participating node in the participating node set to obtain an integration result, and using this integration result as a reference random number.

[0088] The process of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number includes: determining the absolute value of the difference between the first value broadcast by each participating node and the latest reference random number, and taking the node with the smallest absolute value of the difference as the target participating node.

[0089] The target participating node broadcasts the first unbroadcast value in the corresponding value chain, sorted in reverse order. If the target participating node has already broadcast the corresponding value within a second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number. This includes: if the target participating node has broadcast the corresponding value J within the second preset time period and the latest reference random number is K, then J and K are integrated to obtain an integration result, which is used as the new reference random number. The embodiment of this invention does not specifically limit the integration method for integrating the latest broadcast value of the target participating node with the latest reference random number, and includes, but is not limited to: summing the latest broadcast value of the target participating node with the latest reference random number to obtain a summation result, which is used as the integration result.

[0090] Based on the difference between the latest value broadcast by each participating node and the latest reference random number, the first block-producing node is determined from all participating nodes in the participating node set. This includes determining the absolute value of the difference between the latest value broadcast by each participating node and the latest reference random number, and selecting the node with the smallest absolute value of the difference as the first block-producing node.

[0091] The method provided in this embodiment of the invention can determine the set of participating nodes by judging whether any node has not broadcast the first value within a first preset time period. Then, the target participating node can be determined based on the set of participating nodes, and the first block producing node can be determined based on the target participating node.

[0092] In conjunction with the above embodiments, in one embodiment, after determining whether the count value is equal to a preset threshold, the method further includes:

[0093] If the count value is less than the preset threshold, delete the target participating node from the set of participating nodes and increment the count value by 1;

[0094] Jump to the step of determining the target participating node from all the participating nodes in the set of participating nodes according to the difference between the first value broadcast by each participating node and the latest reference random number and continue to execute.

[0095] Among them, the size of the preset threshold is related to the computing power of the computer where the blockchain system is located and the number of nodes in the initial node set. In one example, the computing power of the computer where the blockchain system is located is 2 N , the number of nodes in the initial node set is m, the preset threshold is q. If m < N, then q = m / 2 + 1. If m > N, then q = N.

[0096] Specifically, if the count value is less than the preset threshold, delete the target participating node from the set of participating nodes and increment the count value by 1, including: the count value is J, the preset threshold is K, the count value is i. If J < K, then delete the target participating node from the set of participating nodes, increment the count value i by 1, and the new count value obtained is i + 1.

[0097] The method provided by the embodiment of the present invention can re-determine the target participating node by judging whether the count value is equal to the preset threshold and when the count value is less than the preset threshold.

[0098] Combined with the content of the above embodiments, in one embodiment, after the target participating node broadcasts the first unbroadcast value in the corresponding numerical chain in reverse order, it further includes:

[0099] If the target participating node does not broadcast the corresponding value within the second preset time period, delete the target participating node from the set of participating nodes;

[0100] Judge whether the count value is equal to the initial value. If the count value is equal to the initial value, jump to the step of determining the target participating node from all the participating nodes in the set of participating nodes according to the difference between the first value broadcast by each participating node and the latest reference random number and continue to execute;

[0101] If the count value is greater than the initial value, decrement the count value by 1 and jump to the step of broadcasting the first unbroadcast value in the corresponding numerical chain in reverse order by the target participating node and continue to execute.

[0102] Among them, both the count value and the initial value are integers not less than 0.

[0103] If the target participating node does not broadcast the corresponding value within the second preset time period, delete the target participating node, and the number of nodes in the set of participating nodes after deleting the target participating node is reduced by 1.

[0104] In one example, if the initial value is 1 and the count value is 2, then the count value is greater than the initial value. In this case, the process jumps to the step of determining the target participating node from all participating nodes in the set of participating nodes based on the difference between the first value broadcast by each participating node and the latest reference random number, and continues execution.

[0105] In one example, if the initial value is 1 and the count value is 2 (i.e., the count value is greater than the initial value), then the count value is decremented by 1, and the first unbroadcast value in the corresponding numerical chain, sorted in reverse order, is broadcast through the target participating node, and execution continues. If the initial value is 1 and the count value is 1 (i.e., the count value is equal to the initial value), then the process jumps to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and execution continues.

[0106] The method provided in this embodiment of the invention can determine whether a target participating node needs to be deleted from the set of participating nodes by judging whether the target participating node broadcasts the corresponding value within a second preset time period.

[0107] In conjunction with the above embodiments, in one embodiment, the first block-producing node is determined from all nodes in the initial node set based on the difference between the first value broadcast by each node and the target random number, including:

[0108] Obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and take the node with the smallest absolute value of the difference as the first block-producing node.

[0109] The first block-producing node refers to the node that produces blocks during the main consensus process. Specifically, the target random number is r, and the first value broadcast by each node in the initial node set is {x1, x2, ..., x...}. m The value corresponding to the absolute value of the smallest difference is x. j And |rx j |≤|rx i Let | , i∈{1,2,...,m}, j≤m, then the value x j The corresponding node becomes the first block-producing node.

[0110] The method provided in this embodiment of the invention can determine the first block-producing node from all nodes in the initial node set by the difference between the first value broadcast by each node and the target random number.

[0111] In conjunction with the above embodiments, in one embodiment, such as Figure 2 As shown, a blockchain consensus method includes:

[0112] 201. Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0113] 202. Each node broadcasts the first unbroadcast value in its respective value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first values ​​broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0114] 203. If any node has not broadcast its first value within the first preset time period, then the nodes that have broadcast their first value within the first preset time period will form a participating node set. The first values ​​broadcast by each participating node in the participating node set will be integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, a target participating node will be determined from all participating nodes in the participating node set. The target participating node will broadcast the first unbroadcast value in the corresponding value chain, sorted in reverse order. If the target participating node has already broadcast the corresponding value within the second preset time period, then the latest broadcast value of the target participating node will be compared with the latest reference random number. The new reference random number is integrated to obtain a new reference random number; if the target participating node does not broadcast the corresponding value within the second preset time period, the target participating node is deleted from the participating node set; it is determined whether the count value is equal to the initial value. If the count value is equal to the initial value, the process jumps to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continues execution; if the count value is greater than the initial value, the count value is decremented by 1, and the process jumps to the step of broadcasting the first unbroadcast value in the corresponding value chain in reverse order through the target participating node, and continues execution.

[0115] 204. Determine if the count value is equal to the preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to the initial value when the first target participating node is generated. If the count value is less than the preset threshold, delete the target participating node from the participating node set and increment the count value by 1. Proceed to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0116] 205. After the first block-producing node completes block production, take the first unbroadcasted value in the reverse-ordered value chain of the current block-producing node as the next value. Integrate the next value with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, determine the next block-producing node from all nodes in the initial node set. After the next block-producing node produces a block, return to the step of taking the first unbroadcasted value in the reverse-ordered value chain of the current block-producing node as the next value and continue to execute until the total number of blocks produced reaches the preset number.

[0117] The method provided in this invention improves the fairness of selecting block-producing nodes in the blockchain system by having all nodes participate in the main consensus process and the slave consensus process.

[0118] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0119] Based on the same inventive concept, this application also provides a blockchain consensus device for implementing the blockchain consensus method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more blockchain consensus device embodiments provided below can be found in the limitations of the blockchain consensus method described above, and will not be repeated here.

[0120] In one embodiment, such as Figure 3 As shown, a blockchain consensus device is provided, comprising: a first determining module 301, a second determining module 302, and a third determining module 303, wherein:

[0121] The first determining module 301 is used to determine the initial node set in the blockchain and obtain the corresponding value chain of each node in the initial node set. The value chain is composed of multiple values.

[0122] The second determining module 302 is used to broadcast the first unbroadcast value in the reverse order of the value chain of each node. If each node has broadcast the corresponding value within the first preset time period, the first value broadcast by each node is integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0123] The third determining module 303 is used to, after the first block-producing node completes block production, take the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value, integrate the next value with the current target random number to obtain a new target random number, determine the next block-producing node from all nodes in the initial node set based on the difference between the new target random number and the latest broadcast value of each node, and after the next block-producing node produces a block, return to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value and continue to execute until the total number of block productions reaches the preset number.

[0124] In one embodiment, the first determining module 301 includes:

[0125] The first generation submodule is used to generate an initial random value for any node in the initial node set.

[0126] The second generation submodule is used to perform iterative hash operations based on the initial random value. The generated iteration results are sorted according to the generation order to form the corresponding hash number chain, which serves as the corresponding number chain for any node.

[0127] In one embodiment, the second determining module 301 includes:

[0128] The sub-module is used to form a set of participating nodes if there are nodes that have not broadcast the first value within the first preset time period.

[0129] The first determining submodule is used to integrate the first value broadcast by each participating node in the participating node set to obtain a reference random number, and to determine the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number.

[0130] The integration submodule is used to broadcast the first unbroadcast value in the corresponding value chain in reverse order through the target participating node. If the target participating node has broadcast the corresponding value within the second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number.

[0131] The judgment submodule is used to determine whether the count value is equal to the preset threshold. If the count value is equal to the preset threshold, the first block-producing node is determined from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, the process jumps to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value and continues to execute. The count value is set to the initial value when the first target participating node is generated.

[0132] In one embodiment, determining the submodule includes:

[0133] The first deletion unit is used to delete the target participating node from the participating node set if the count value is less than a preset threshold, and to increment the count value by 1.

[0134] The first jump unit is used to jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0135] In one embodiment, the integration submodule includes:

[0136] The second deletion unit is used to delete the target participating node from the participating node set if the target participating node does not broadcast the corresponding value within a second preset time period.

[0137] The judgment unit is used to determine whether the count value is equal to the initial value. If the count value is equal to the initial value, the process jumps to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continues execution.

[0138] The second jump unit is used to decrement the count value by 1 if the count value is greater than the initial value, and then jump to the step of broadcasting the first unbroadcast value in the corresponding value chain in reverse order through the target participating node and continue execution.

[0139] In one embodiment, the second determining module includes:

[0140] The acquisition submodule is used to obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and to take the node with the smallest absolute value of the difference as the first block-producing node.

[0141] The modules in the aforementioned blockchain consensus device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0142] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, and a communication interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a blockchain consensus method.

[0143] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0144] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0145] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0146] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0147] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0148] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0149] For any node in the initial node set, generate an initial random value for that node;

[0150] Iterative hashing is performed based on an initial random value. The results of each iteration are sorted in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for any node.

[0151] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0152] If a node fails to broadcast its first value within the first preset time period, then the nodes that have broadcast their first value within the first preset time period will form a set of participating nodes.

[0153] The first value broadcast by each participating node in the participating node set is integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, the target participating node is determined from all participating nodes in the participating node set.

[0154] The target participating node broadcasts the first unbroadcast value in the corresponding value chain, which is sorted in reverse order. If the target participating node has broadcast the corresponding value within the second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number.

[0155] Determine if the count value is equal to a preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to the initial value when the first target participating node is generated.

[0156] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0157] If the count value is less than the preset threshold, the target participating node is removed from the participating node set, and the count value is incremented by 1.

[0158] Jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0159] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0160] If the target participating node does not broadcast the corresponding value within the second preset time period, the target participating node will be removed from the participating node set.

[0161] Determine if the count value is equal to the initial value. If the count value is equal to the initial value, jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0162] If the count value is greater than the initial value, the count value is decremented by 1, and the process jumps to the step of broadcasting the first unbroadcasted value in the corresponding value chain in reverse order through the target participating node and continues execution.

[0163] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0164] Obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and take the node with the smallest absolute value of the difference as the first block-producing node.

[0165] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0166] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0167] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0168] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0169] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0170] For any node in the initial node set, generate an initial random value for that node;

[0171] Iterative hashing is performed based on an initial random value. The results of each iteration are sorted in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for any node.

[0172] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0173] If a node fails to broadcast its first value within the first preset time period, then the nodes that have broadcast their first value within the first preset time period will form a set of participating nodes.

[0174] The first value broadcast by each participating node in the participating node set is integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, the target participating node is determined from all participating nodes in the participating node set.

[0175] The target participating node broadcasts the first unbroadcast value in the corresponding value chain, which is sorted in reverse order. If the target participating node has broadcast the corresponding value within the second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number.

[0176] Determine if the count value is equal to a preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to the initial value when the first target participating node is generated.

[0177] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0178] If the count value is less than the preset threshold, the target participating node is removed from the participating node set, and the count value is incremented by 1.

[0179] Jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0180] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0181] If the target participating node does not broadcast the corresponding value within the second preset time period, the target participating node will be removed from the participating node set.

[0182] Determine if the count value is equal to the initial value. If the count value is equal to the initial value, jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0183] If the count value is greater than the initial value, the count value is decremented by 1, and the process jumps to the step of broadcasting the first unbroadcasted value in the corresponding value chain in reverse order through the target participating node and continues execution.

[0184] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0185] Obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and take the node with the smallest absolute value of the difference as the first block-producing node.

[0186] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0187] Determine the initial set of nodes in the blockchain, and obtain the corresponding value chain for each node in the initial set of nodes. The value chain is composed of multiple values.

[0188] Each node broadcasts the first unbroadcast value in its own value chain, sorted in reverse order. If each node has broadcast the corresponding value within the first preset time period, the first values ​​broadcast by each node are integrated to obtain the target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set.

[0189] After the first block-producing node completes its block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is then integrated with the current target random number to obtain a new target random number. Based on the difference between the new target random number and the latest broadcast value of each node, the next block-producing node is determined from all nodes in the initial node set. After the next block-producing node produces its block, the process of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and continued until the total number of blocks produced reaches the preset number.

[0190] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0191] For any node in the initial node set, generate an initial random value for that node;

[0192] Iterative hashing is performed based on an initial random value. The results of each iteration are sorted in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for any node.

[0193] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0194] If a node fails to broadcast its first value within the first preset time period, then the nodes that have broadcast their first value within the first preset time period will form a set of participating nodes.

[0195] The first value broadcast by each participating node in the participating node set is integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, the target participating node is determined from all participating nodes in the participating node set.

[0196] The target participating node broadcasts the first unbroadcast value in the corresponding value chain, which is sorted in reverse order. If the target participating node has broadcast the corresponding value within the second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number.

[0197] Determine if the count value is equal to a preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to the initial value when the first target participating node is generated.

[0198] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0199] If the count value is less than the preset threshold, the target participating node is removed from the participating node set, and the count value is incremented by 1.

[0200] Jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0201] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0202] If the target participating node does not broadcast the corresponding value within the second preset time period, the target participating node will be removed from the participating node set.

[0203] Determine if the count value is equal to the initial value. If the count value is equal to the initial value, jump to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

[0204] If the count value is greater than the initial value, the count value is decremented by 1, and the process jumps to the step of broadcasting the first unbroadcasted value in the corresponding value chain in reverse order through the target participating node and continues execution.

[0205] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0206] Obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and take the node with the smallest absolute value of the difference as the first block-producing node.

[0207] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0208] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0209] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0210] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A blockchain consensus method, characterized in that, The method includes: Determine the initial set of nodes in the blockchain; for any node in the initial set of nodes, generate an initial random value for that node, perform iterative hash operations based on the initial random value, and sort the generated iteration results in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for that node; the number chain is composed of multiple values; Each node broadcasts the first unbroadcast value in its respective value chain, sorted in reverse order. If each node has broadcast the corresponding value within a first preset time period, the first values ​​broadcast by each node are integrated to obtain a target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set. After the first block-producing node completes block production, the first unbroadcast value in the reverse-ordered value chain of the current block-producing node is taken as the next value. The next value is integrated with the current target random number to obtain a new target random number. The absolute value of the difference between the first value broadcast by each node in the reference node set and the new target random number is obtained. The node with the smallest absolute value of the difference is taken as the next block-producing node. After the next block-producing node produces a block, the step of taking the first unbroadcast value in the reverse-ordered value chain of the current block-producing node as the next value is returned and the process continues until the total number of blocks produced reaches the preset number. Wherein, the current block-producing node refers to the latest node that has completed block production; the current target random number refers to the target random number used to select the current block-producing node; and the reference node set refers to the set used to select the previous block-producing node.

2. The method according to claim 1, characterized in that, After broadcasting the first unbroadcast value in its respective value chain in reverse order through each node, the process also includes: If there are nodes that have not broadcast the first value within the first preset time period, then the nodes that have broadcast the first value within the first preset time period will form a set of participating nodes; The first value broadcast by each participating node in the participating node set is integrated to obtain a reference random number. Based on the difference between the first value broadcast by each participating node and the latest reference random number, the target participating node is determined from all participating nodes in the participating node set. The target participating node broadcasts the first unbroadcast value in the corresponding value chain, which is sorted in reverse order. If the target participating node has broadcast the corresponding value within a second preset time period, the latest broadcast value of the target participating node is integrated with the latest reference random number to obtain a new reference random number. Determine whether the count value is equal to a preset threshold. If the count value is equal to the preset threshold, determine the first block-producing node from all participating nodes in the participating node set based on the difference between the latest broadcast value of each participating node and the latest reference random number. After the first block-producing node completes block production, proceed to the step of taking the first unbroadcast value in the reverse order of the corresponding value chain of the current block-producing node as the next value. The count value is set to an initial value when the first target participating node is generated.

3. The method according to claim 2, characterized in that, After determining whether the count value is equal to the preset threshold, the method further includes: If the count value is less than the preset threshold, the target participating node is deleted from the participating node set, and the count value is incremented by 1. Jump to the step of determining the target participating node from all participating nodes in the set of participating nodes based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution.

4. The method according to claim 2, characterized in that, After broadcasting the first unbroadcasted value in the corresponding value chain in reverse order through the target participating node, the method further includes: If the target participating node does not broadcast the corresponding value within the second preset time period, then the target participating node is deleted from the set of participating nodes; Determine whether the count value is equal to the initial value. If the count value is equal to the initial value, proceed to the step of determining the target participating node from all participating nodes in the participating node set based on the difference between the first value broadcast by each participating node and the latest reference random number, and continue execution. If the count value is greater than the initial value, then the count value is decremented by 1, and the process jumps to the step of broadcasting the first unbroadcasted value in the corresponding value chain in reverse order through the target participating node and continues execution.

5. The method according to claim 1, characterized in that, The step of determining the first block-producing node from all nodes in the initial node set based on the difference between the first value broadcast by each node and the target random number includes: Obtain the absolute value of the difference between the first value broadcast by each node in the initial node set and the target random number, and take the node with the smallest absolute value of the difference as the first block-producing node.

6. A blockchain consensus device, characterized in that, The device includes: The first determining module is used to determine the initial set of nodes in the blockchain; for any node in the initial set of nodes, an initial random value is generated for the node, an iterative hash operation is performed based on the initial random value, and the results of each iteration are sorted in the order of generation to form a corresponding hash number chain, which serves as the corresponding number chain for the node; the number chain is composed of multiple values. The second determining module is used to broadcast the first unbroadcast value in the reverse order of the value chain of each node. If each node has broadcast the corresponding value within the first preset time period, the first value broadcast by each node is integrated to obtain a target random number. Based on the difference between the first value broadcast by each node and the target random number, the first block-producing node is determined from all nodes in the initial node set. The third determining module is used to, after the first block-producing node completes block production, take the first unbroadcasted value in the reverse-ordered value chain of the current block-producing node as the next value, integrate the next value with the current target random number to obtain a new target random number, obtain the absolute value of the difference between the first value broadcast by each node in the reference node set and the new target random number, take the node with the smallest absolute value of the difference as the next block-producing node, and after the next block-producing node produces a block, return to the step of taking the first unbroadcasted value in the reverse-ordered value chain of the current block-producing node as the next value and continue to execute until the total number of block productions reaches the preset number; Wherein, the current block-producing node refers to the latest node that has completed block production; the current target random number refers to the target random number used to select the current block-producing node; and the reference node set refers to the set used to select the previous block-producing node.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • A lottery method, a consensus method, an apparatus, and a storage medium

    CN109067516A

  • Service response method and information reading method

    CN112070494A