Consensus method and device of blockchain, blockchain and computer device
By randomly generating nodes with accounting rights in the blockchain based on their asset status and freezing the random number generation, combined with the PoS mechanism, the problems of node consensus time and uneven power are solved, achieving more efficient transaction confirmation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MIGU CO LTD
- Filing Date
- 2023-01-05
- Publication Date
- 2026-04-14
AI Technical Summary
Existing blockchain technologies suffer from issues such as the long time it takes for nodes to reach consensus and the excessive power of nodes holding large amounts of cryptocurrency.
By randomly generating a list of random numbers based on the mixed asset situation of the nodes, the nodes with accounting rights are determined, and the generation of random numbers is frozen within a preset period. Combined with the PoS mechanism, this reduces computing power consumption and transaction confirmation time.
It reduces the computing power consumption of the consensus algorithm, shortens the transaction confirmation time, and solves the problem of excessive power for nodes holding a large number of coins.
Smart Images

Figure CN116248272B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, specifically to a consensus method, apparatus, blockchain, computer device, and computer-readable storage medium for blockchain. Background Technology
[0002] Blockchain technology is a distributed ledger technology in which multiple computing devices jointly participate to maintain a complete distributed intelligent database. Due to its decentralized, transparent, and database-driven characteristics, allowing each computing device to participate in recording data and enabling rapid data synchronization and consistent execution between devices, blockchain technology has been widely adopted. However, core consensus algorithms such as PoW, PoS, and DPoS suffer from problems such as excessive computing power consumption, long consensus times for nodes, and excessive power for nodes holding large amounts of cryptocurrency. Summary of the Invention
[0003] In view of the above problems, embodiments of the present invention provide a consensus method, apparatus, blockchain, computer device and computer-readable storage medium for blockchain, to solve the problems of long consensus time for node devices and excessive power of nodes holding a large number of currencies in the prior art.
[0004] According to one aspect of the present invention, a consensus method for blockchain is provided, the method comprising:
[0005] Based on the mixed asset situation of each node at the time of this round of accounting right selection, a random number list for this round is generated for each node; the mixed asset situation includes the number of assets and the number of nodes; the random number list for this round includes one or more random numbers;
[0006] Based on the range of random number generation in this round, generate the target random number for this round.
[0007] The target random number for this round is matched with the random number list for each node in this round to determine the node with the right to record transactions in this round.
[0008] This round of accounting is performed through the accounting right node mentioned above.
[0009] In one alternative approach, after the current round of accounting is performed through the accounting authority node, the method further includes:
[0010] After completing this round of accounting, the generation of random numbers corresponding to the accounting nodes of this round is frozen for a preset number of times within the preset accounting right selection period.
[0011] In one alternative approach, the method of generating a random number list for each node based on the mixed asset situation of each node in this round of accounting right selection further includes:
[0012] Based on the number of assets and nodes at each node, determine the number of random numbers for each node in this round;
[0013] Based on the number of random numbers for each node in this round, generate a list of random numbers for each node in this round.
[0014] In one alternative approach, generating a target random number for the current round based on the current round's random number generation range includes:
[0015] When the current round of accounting rights selection is the first round of accounting rights selection, the range of random number generation for this round is determined based on the number of random numbers at each node in this round;
[0016] Within the range of random number generation in this round, the target random number for this round is generated randomly.
[0017] In one alternative approach, after performing the current round of accounting through the current accounting authority node, the method further includes:
[0018] When selecting the accounting right in the next round, the random number generation range for the next round is randomly generated through the current accounting right node, and a random number generation request is initiated at the same time;
[0019] Based on the random number generation request, generate the next round of random numbers for each node, and obtain the next round of random number list for each node;
[0020] Based on the next round of random numbers, generate the next round of target random numbers from the given range.
[0021] In one alternative approach, after generating a random number list for each node based on the mixed asset situation of each node at the time of the selection of the accounting right in this round, the method further includes:
[0022] Each node records the current round's random number list for all nodes and the correspondence between each node and the current round's random number list.
[0023] According to another aspect of the present invention, a consensus device for a blockchain is provided, comprising:
[0024] The random number generation module is used to generate a random number list for each node in this round based on the mixed asset situation of each node when the accounting right is selected; the mixed asset situation includes the number of assets and the number of nodes; the random number list in this round includes one or more random numbers;
[0025] The random number generation module is also used to generate the target random number for this round based on the range of random numbers for this round;
[0026] The random number determination module is used to match the target random number for this round with the random number list for each node in this round to determine the node with the right to record transactions in this round.
[0027] The accounting module is used to perform the current accounting through the current accounting right node.
[0028] According to another aspect of the present invention, a blockchain is provided, the blockchain including a consensus device for the blockchain.
[0029] According to another aspect of the present invention, a computer device is provided, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus;
[0030] The memory is used to store at least one executable instruction that causes the processor to perform the operation of the consensus method of the blockchain.
[0031] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein at least one executable instruction is stored therein, which, when executed on a computer device, causes the computer device to perform the operation of the consensus method of the blockchain.
[0032] This invention generates a random number list for each node based on the mixed asset situation of each node at the time of selection of the right to record transactions in this round. The mixed asset situation includes the number of assets and the number of nodes. The random number list includes one or more random numbers. A target random number is generated for this round based on the random number generation range. The target random number is matched with the random number list of each node to determine the node with the right to record transactions in this round. The recording of transactions in this round is performed by the node with the right to record transactions in this round. By introducing a random number generation module to generate one or more random numbers for each node in the blockchain each round according to the asset situation, and a random number confirmation module to match the random number generated in each round with the random number list of each node to confirm the ownership of the right to record transactions in each round, this invention combines PoS (Proof-of-Stake, a consensus mechanism) and a random number mechanism. It does not completely depend on the node's asset situation, nor does it completely depend on the generation of random numbers. It achieves an organic combination of the two, thereby greatly reducing the computing power consumption of the consensus algorithm and reducing the transaction confirmation time. Furthermore, it will not rely entirely on random mechanisms, and by introducing the concept of freeze time, it can effectively solve the problem of excessive power of nodes holding a large number of coins.
[0033] The above description is merely an overview of the technical solutions of the embodiments of the present invention. In order to better understand the technical means of the embodiments of the present invention and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0034] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0035] Figure 1 A flowchart illustrating the consensus method for blockchain provided in an embodiment of the present invention is shown.
[0036] Figure 2 A schematic diagram illustrating the application environment of the blockchain consensus method provided in an embodiment of the present invention is shown.
[0037] Figure 3 A schematic diagram of the structure of a blockchain consensus device provided in an embodiment of the present invention is shown;
[0038] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation
[0039] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0040] Figure 1 A flowchart of a blockchain consensus method provided in an embodiment of the present invention is shown. This method is executed by a computer device. Specifically, the computer device can be a distributed device, such as a blockchain, etc., and the embodiments of the present invention do not impose specific limitations. Specifically, in conjunction with... Figure 2 The diagram illustrates an application environment of an embodiment of the present invention. As can be seen from the diagram, the system includes a random number generation module, multiple nodes, and a random number verification module. Figure 1 As shown, the method includes the following steps:
[0041] Step 110: Based on the mixed asset situation of each node when the accounting right is selected in this round, generate a random number list for each node in this round.
[0042] The mixed asset situation includes the number of assets and the number of nodes, and the random number list for this round includes one or more random numbers. In this embodiment of the invention, the number of random numbers for each node in this round is determined based on the number of assets and the number of nodes for each node; based on the number of random numbers for each node in this round, a random number list for this round is randomly generated for each node. Specifically, the sum of the number of assets and the number of nodes for each node can be determined as the number of random numbers for that node. For example, as shown in the figure, node 1 has 5 Bitcoin assets and 2 nodes (since in a distributed system, one node corresponds to multiple machine nodes, and multiple machine nodes are connected in parallel, all of which are part of that node), and can obtain 7 random numbers accordingly. Node 2 has 5 Bitcoin assets, and node N has 0 Bitcoin assets. The total number of nodes and assets corresponding to each node is calculated. Based on the calculated total number of nodes and assets, the number of random numbers generated for each node can be determined.
[0043] Step 120: Generate the target random number for this round based on the random number generation range of this round.
[0044] The random number generation range for this round is the numerical range of the random numbers corresponding to each node in this round. When the accounting right selection for this round is the first round of accounting right selection, the random number generation range for this round is determined based on the number of random numbers for each node in this round; within the random number generation range for this round, the target random number for this round is generated randomly. Specifically, the sum of the number of random numbers for each node in this round can be determined as the maximum value of the random number generation range for this round, and the upper limit of the maximum value in the random number list is also this. For example, if the total number of random numbers for all nodes is 14, then this is the upper limit of the maximum value in the random number generation list.
[0045] Step 130: Match the target random number for this round with the random number list for each node in this round to determine the node with the right to record transactions in this round.
[0046] In this embodiment of the invention, each random number in the current round random number list of each node is matched with the current round target random number. When the current round random list that matches the current round random number is determined, the node corresponding to the matched current round random list is determined to be the current round accounting right node.
[0047] Each node records the current round's random number list for all nodes and the correspondence between each node and the current round's random number list.
[0048] Step 140: Perform this round of accounting through the current accounting right node.
[0049] Once the current accounting node is determined, the current accounting node will perform the current accounting.
[0050] In this invention, after completing the current round of accounting, the generation of random numbers corresponding to the current accounting node is frozen a preset number of times within a preset accounting right selection period. Freezing the generation of random numbers corresponding to the current accounting node a preset number of times within the preset accounting right selection period means reducing the chance of generating a random number for that current accounting node within the preset accounting right selection period. In one embodiment of the invention, the number of random numbers generated by the current accounting node may be reduced by 1 within the preset accounting selection period. For example, if node 1 originally had 7 random numbers, after node 1 becomes the current accounting node, the random number generation of node 1 is frozen once within a period, resulting in 6 random numbers generated by node 1 within that period.
[0051] In the next round of accounting right selection, the current accounting right node randomly generates a range of random numbers for the next round and simultaneously initiates a random number generation request. Based on the random number generation request, random numbers for the next round are generated for each node, resulting in a list of random numbers for each node. A target random number for the next round is generated from the range of the target random number, and this target random number is matched with the current random number lists of each node to determine the next accounting right node. The next round of accounting is then performed through the next accounting right node to complete the next round of accounting. In other words, when selecting the next round of accounting right, the current accounting right node generates a range of random numbers for the next round and simultaneously initiates a random number generation request, making the randomness stronger. The upper limit of this next round random number generation range should be less than or equal to the number of random numbers corresponding to all nodes.
[0052] The following is a detailed description of its operation using a system module in its application environment as an example:
[0053] First, starting at midnight, the random number generation module allocates the number of times each node can obtain random numbers based on the asset situation of each node.
[0054]
[0055] Table 1
[0056] As shown in Table 1, for example, node 1 has 5 Bitcoin assets and 2 nodes, corresponding to 7 random numbers. Node 2 has 5 Bitcoin assets, and node N has 0 Bitcoin assets. Calculate the total number of nodes and assets for each node. Based on the calculated total number of nodes and assets, the number of random numbers generated for each node can be determined. The random number generation module generates a random number list for each node based on the total number of random numbers and the number of nodes. The total number of random numbers, 14, is the upper limit of the maximum value of the random number generation list.
[0057] Subsequently, the random number recording module exists on each node, recording the correspondence between each node and the random number list. This correspondence is synchronized to all nodes to ensure that all nodes obtain the node and generate the random number relationship data consistently. The random number list and its correspondence are shown in Table 2.
[0058] node Random number list Node 1 ['1','5','8','13'] Node 1 ['3','4','9'] Node 2 ['7','11','12','14','6','2'] Node N ['10']
[0059] Table 2
[0060] The random number confirmation module for the first round of node election on that day defaults to a maximum random number limit of 14 and a minimum random number limit of 1. It generates a random number within the range [1-14] to determine which node has the right to record transactions in this round. For example, if the generated random number is 9, each node confirms that the right to record transactions in this round belongs to node 1 based on the correspondence between the node and the random number list recorded by the random number recording module.
[0061] Node 1 acquires the right to record transactions in the first round. After completing the first round, Node 1 freezes the random number generation for one day (one day is a cycle) once. After freezing, Node 1 has 6 random numbers, and there are 2 nodes. Node 2 still has 6 random numbers, and Node N still has 1 random number. Node 1 triggers the random number generation module to regenerate a random number list for each node. At the same time as triggering the random number generation module, Node 1 provides the random number generation range to the random number confirmation module. The random number confirmation module generates a second round of random numbers based on the random number generation range. For example, if the second round random number generation range is [1-9], and the random number confirmation module generates a second round random number of 3 based on the random number generation range, then Node 2 acquires the right to record transactions in the second round. Because Node 1 generates the random number range and the second round random number list simultaneously, there is no issue of Node 1 manipulating the allocation of the right to record transactions in the next round by generating a random number range.
[0062] Serial Number node assets Nodes + Assets Number of freezes Number of random numbers Random number list 1 Node 1 3 4 1 3 ['14','6','2'] 2 Node 1 2 3 0 3 ['1','5','13'] 3 Node 2 5 6 0 6 ['7','11','12','3','4','10'] N Node N 0 1 0 1 ['9'] total 4 10 14 1 13
[0063] Table 3
[0064] As shown in Table 3, by introducing a freeze mechanism, the chances of node N (a node without assets) acquiring the right to record transactions can be increased. The probability of node N acquiring the right to record transactions in the first round is 1 / 14, and the probability in the second round is 1 / 13. The Bitcoin reward received by node 1 after completing the transaction recording in the first round is not included in the random number count for that day (frozen for 1 day). After the freeze period ends, the acquired Bitcoin assets are included in the random number count.
[0065] Assuming the freeze period is configured to be 1 day, then starting at 0:00 every day, the random numbers will be recalculated, generated, recorded and confirmed according to the above process to confirm the ownership of the accounting rights for each round of the node that day.
[0066] This invention generates a random number list for each node based on the mixed asset situation of each node at the time of selection of the right to record transactions in this round. The mixed asset situation includes the number of assets and the number of nodes. The random number list includes one or more random numbers. A target random number is generated for this round based on the random number generation range. The target random number is matched with the random number list of each node to determine the node with the right to record transactions in this round. The recording of transactions in this round is performed by the node with the right to record transactions in this round. By introducing a random number generation module to generate one or more random numbers for each node in the blockchain each round according to the asset situation, and a random number confirmation module to match the random number generated in each round with the random number list of each node to confirm the ownership of the right to record transactions in each round, this invention combines PoS (Proof-of-Stake, a consensus mechanism) and a random number mechanism. It does not completely depend on the node's asset situation, nor does it completely depend on the generation of random numbers. It achieves an organic combination of the two, thereby greatly reducing the computing power consumption of the consensus algorithm and reducing the transaction confirmation time. Furthermore, it will not rely entirely on random mechanisms, and by introducing the concept of freeze time, it can effectively solve the problem of excessive power of nodes holding a large number of coins.
[0067] Figure 3 A schematic diagram of the structure of a blockchain consensus device provided in an embodiment of the present invention is shown. Figure 3 As shown, the device 300 includes:
[0068] The random number generation module 310 is used to generate a random number list for each node in this round based on the mixed asset situation of each node when the accounting right is selected in this round; the mixed asset situation includes the number of assets and the number of nodes; the random number list in this round includes one or more random numbers;
[0069] The random number generation module 310 is also used to randomly generate the target random number for this round based on the random number range of this round;
[0070] The random number determination module 320 is used to match the target random number of this round with the random number list of each node in this round to determine the accounting right node in this round;
[0071] The accounting module 330 is used to perform the current accounting through the current accounting right node.
[0072] In one alternative approach, after the current round of accounting is performed through the accounting authority node, the method further includes:
[0073] After completing this round of accounting, the generation of random numbers corresponding to the accounting nodes of this round is frozen for a preset number of times within the preset accounting right selection period.
[0074] In one alternative approach, the method of generating a random number list for each node based on the mixed asset situation of each node in this round of accounting right selection further includes:
[0075] Based on the number of assets and nodes at each node, determine the number of random numbers for each node in this round;
[0076] Based on the number of random numbers for each node in this round, generate a list of random numbers for each node in this round.
[0077] In one alternative approach, generating a target random number for the current round based on the current round's random number generation range includes:
[0078] When the current round of accounting rights selection is the first round of accounting rights selection, the range of random number generation for this round is determined based on the number of random numbers at each node in this round;
[0079] Within the range of random number generation in this round, the target random number for this round is generated randomly.
[0080] In one alternative approach, after performing the current round of accounting through the current accounting authority node, the method further includes:
[0081] When selecting the accounting right in the next round, the random number generation range for the next round is randomly generated through the current accounting right node, and a random number generation request is initiated at the same time;
[0082] Based on the random number generation request, generate the next round of random numbers for each node, and obtain the next round of random number list for each node;
[0083] Based on the next round of random numbers, generate the next round of target random numbers from the given range.
[0084] In one alternative approach, after generating a random number list for each node based on the mixed asset situation of each node at the time of the selection of the accounting right in this round, the method further includes:
[0085] Each node records the current round's random number list for all nodes and the correspondence between each node and the current round's random number list.
[0086] This invention generates a random number list for each node based on the mixed asset situation of each node at the time of selection of the right to record transactions in this round. The mixed asset situation includes the number of assets and the number of nodes. The random number list includes one or more random numbers. A target random number is generated for this round based on the random number generation range. The target random number is matched with the random number list of each node to determine the node with the right to record transactions in this round. The recording of transactions in this round is performed by the node with the right to record transactions in this round. By introducing a random number generation module to generate one or more random numbers for each node in the blockchain each round according to the asset situation, and a random number confirmation module to match the random number generated in each round with the random number list of each node to confirm the ownership of the right to record transactions in each round, this invention combines PoS (Proof-of-Stake, a consensus mechanism) and a random number mechanism. It does not completely depend on the node's asset situation, nor does it completely depend on the generation of random numbers. It achieves an organic combination of the two, thereby greatly reducing the computing power consumption of the consensus algorithm and reducing the transaction confirmation time. Furthermore, it will not rely entirely on random mechanisms, and by introducing the concept of freeze time, it can effectively solve the problem of excessive power of nodes holding a large number of coins.
[0087] According to another aspect of the present invention, a blockchain is provided, the blockchain including a consensus device. The working process of this blockchain in performing consensus is largely the same as that of the method embodiments described above, and will not be repeated here.
[0088] Figure 4 The diagram shows a structural schematic of a computer device provided in an embodiment of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the computer device.
[0089] like Figure 4 As shown, the computer device may include: a processor 402, a communications interface 404, a memory 406, and a communications bus 408.
[0090] The processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408. Communication interface 404 is used to communicate with other network elements such as clients or other servers. The processor 402 executes program 410, specifically performing the relevant steps in the above-described consensus method embodiment for blockchain.
[0091] Specifically, program 410 may include program code, which includes computer-executable instructions.
[0092] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The computer device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0093] Memory 406 is used to store program 410. Memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0094] Specifically, program 410 can be called by processor 402 to cause the computer device to perform the following operations:
[0095] Based on the mixed asset situation of each node at the time of this round of accounting right selection, a random number list for this round is generated for each node; the mixed asset situation includes the number of assets and the number of nodes; the random number list for this round includes one or more random numbers;
[0096] Based on the range of random number generation in this round, generate the target random number for this round.
[0097] The target random number for this round is matched with the random number list for each node in this round to determine the node with the right to record transactions in this round.
[0098] This round of accounting is performed through the accounting right node mentioned above.
[0099] In one alternative approach, after the current round of accounting is performed through the accounting authority node, the method further includes:
[0100] After completing this round of accounting, the generation of random numbers corresponding to the accounting nodes of this round is frozen for a preset number of times within the preset accounting right selection period.
[0101] In one alternative approach, the method of generating a random number list for each node based on the mixed asset situation of each node in this round of accounting right selection further includes:
[0102] Based on the number of assets and nodes at each node, determine the number of random numbers for each node in this round;
[0103] Based on the number of random numbers for each node in this round, generate a list of random numbers for each node in this round.
[0104] In one alternative approach, generating a target random number for the current round based on the current round's random number generation range includes:
[0105] When the current round of accounting rights selection is the first round of accounting rights selection, the range of random number generation for this round is determined based on the number of random numbers at each node in this round;
[0106] Within the range of random number generation in this round, the target random number for this round is generated randomly.
[0107] In one alternative approach, after performing the current round of accounting through the current accounting authority node, the method further includes:
[0108] When selecting the accounting right in the next round, the random number generation range for the next round is randomly generated through the current accounting right node, and a random number generation request is initiated at the same time;
[0109] Based on the random number generation request, generate the next round of random numbers for each node, and obtain the next round of random number list for each node;
[0110] Based on the next round of random numbers, generate the next round of target random numbers from the given range.
[0111] In one alternative approach, after generating a random number list for each node based on the mixed asset situation of each node at the time of the selection of the accounting right in this round, the method further includes:
[0112] Each node records the current round's random number list for all nodes and the correspondence between each node and the current round's random number list.
[0113] This invention generates a random number list for each node based on the mixed asset situation of each node at the time of selection of the right to record transactions in this round. The mixed asset situation includes the number of assets and the number of nodes. The random number list includes one or more random numbers. A target random number is generated for this round based on the random number generation range. The target random number is matched with the random number list of each node to determine the node with the right to record transactions in this round. The recording of transactions in this round is performed by the node with the right to record transactions in this round. By introducing a random number generation module to generate one or more random numbers for each node in the blockchain each round according to the asset situation, and a random number confirmation module to match the random number generated in each round with the random number list of each node to confirm the ownership of the right to record transactions in each round, this invention combines PoS (Proof-of-Stake, a consensus mechanism) and a random number mechanism. It does not completely depend on the node's asset situation, nor does it completely depend on the generation of random numbers. It achieves an organic combination of the two, thereby greatly reducing the computing power consumption of the consensus algorithm and reducing the transaction confirmation time. Furthermore, it will not rely entirely on random mechanisms, and by introducing the concept of freeze time, it can effectively solve the problem of excessive power of nodes holding a large number of coins.
[0114] This invention provides a computer-readable storage medium storing at least one executable instruction that, when executed on a computer device, causes the computer device to perform the blockchain consensus method in any of the above method embodiments.
[0115] Executable instructions can be used to cause computer devices to perform the following operations:
[0116] Based on the mixed asset situation of each node at the time of this round of accounting right selection, a random number list for this round is generated for each node; the mixed asset situation includes the number of assets and the number of nodes; the random number list for this round includes one or more random numbers;
[0117] Based on the range of random number generation in this round, generate the target random number for this round.
[0118] The target random number for this round is matched with the random number list for each node in this round to determine the node with the right to record transactions in this round.
[0119] This round of accounting is performed through the accounting right node mentioned above.
[0120] In one alternative approach, after the current round of accounting is performed through the accounting authority node, the method further includes:
[0121] After completing this round of accounting, the generation of random numbers corresponding to the accounting nodes of this round is frozen for a preset number of times within the preset accounting right selection period.
[0122] In one alternative approach, the method of generating a random number list for each node based on the mixed asset situation of each node in this round of accounting right selection further includes:
[0123] Based on the number of assets and nodes at each node, determine the number of random numbers for each node in this round;
[0124] Based on the number of random numbers for each node in this round, generate a list of random numbers for each node in this round.
[0125] In one alternative approach, generating a target random number for the current round based on the current round's random number generation range includes:
[0126] When the current round of accounting rights selection is the first round of accounting rights selection, the range of random number generation for this round is determined based on the number of random numbers at each node in this round;
[0127] Within the range of random number generation in this round, the target random number for this round is generated randomly.
[0128] In one alternative approach, after performing the current round of accounting through the current accounting authority node, the method further includes:
[0129] When selecting the accounting right in the next round, the random number generation range for the next round is randomly generated through the current accounting right node, and a random number generation request is initiated at the same time;
[0130] Based on the random number generation request, generate the next round of random numbers for each node, and obtain the next round of random number list for each node;
[0131] Based on the next round of random numbers, generate the next round of target random numbers from the given range.
[0132] In one alternative approach, after generating a random number list for each node based on the mixed asset situation of each node at the time of the selection of the accounting right in this round, the method further includes:
[0133] Each node records the current round's random number list for all nodes and the correspondence between each node and the current round's random number list.
[0134] This invention generates a random number list for each node based on the mixed asset situation of each node at the time of selection of the right to record transactions in this round. The mixed asset situation includes the number of assets and the number of nodes. The random number list includes one or more random numbers. A target random number is generated for this round based on the random number generation range. The target random number is matched with the random number list of each node to determine the node with the right to record transactions in this round. The recording of transactions in this round is performed by the node with the right to record transactions in this round. By introducing a random number generation module to generate one or more random numbers for each node in the blockchain each round according to the asset situation, and a random number confirmation module to match the random number generated in each round with the random number list of each node to confirm the ownership of the right to record transactions in each round, this invention combines PoS (Proof-of-Stake, a consensus mechanism) and a random number mechanism. It does not completely depend on the node's asset situation, nor does it completely depend on the generation of random numbers. It achieves an organic combination of the two, thereby greatly reducing the computing power consumption of the consensus algorithm and reducing the transaction confirmation time. Furthermore, it will not rely entirely on random mechanisms, and by introducing the concept of freeze time, it can effectively solve the problem of excessive power of nodes holding a large number of coins.
[0135] This invention provides a consensus device for blockchain, used to execute the aforementioned blockchain consensus method.
[0136] This invention provides a computer program that can be invoked by a processor to cause a computer device to execute the blockchain consensus method in any of the above method embodiments.
[0137] This invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions that, when executed on a computer, cause the computer to perform the blockchain consensus method in any of the above method embodiments.
[0138] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0139] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0140] Similarly, it should be understood that, in order to streamline the invention and aid in understanding one or more of the various aspects of the invention, features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.
[0141] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0142] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.
Claims
1. A consensus method for blockchain, characterized in that, The method includes: Based on the mixed asset situation of each node at the time of this round of accounting right selection, a random number list for this round is generated for each node; the mixed asset situation includes the number of assets and the number of nodes; the random number list for this round includes one or more random numbers; Based on the range of random number generation in this round, generate the target random number for this round. The target random number for this round is matched with the random number list for each node in this round to determine the node with the right to record transactions in this round. This round of accounting is performed through the aforementioned accounting right node; When selecting the accounting right in the next round, the random number generation range for the next round is randomly generated through the current accounting right node, and a random number generation request is initiated at the same time.
2. The method according to claim 1, characterized in that, After the current round of accounting is performed through the accounting authority node, the method further includes: After completing this round of accounting, the generation of random numbers corresponding to the accounting right nodes of this round is frozen for a preset number of times within the preset accounting right selection period.
3. The method according to claim 1, characterized in that, The method further includes generating a random number list for each node in this round of accounting right selection based on the mixed asset situation of each node. Based on the number of assets and nodes at each node, determine the number of random numbers for each node in this round; Based on the number of random numbers for each node in this round, generate a list of random numbers for each node in this round.
4. The method according to any one of claims 1-3, characterized in that, The process of generating the target random number for this round based on the range of random number generation includes: When the current round of accounting rights selection is the first round of accounting rights selection, the range of random number generation for this round is determined based on the number of random numbers at each node in this round; Within the range of random number generation in this round, the target random number for this round is generated randomly.
5. The method according to any one of claims 1-3, characterized in that, After performing the current round of accounting through the current accounting right node, the method further includes: Based on the random number generation request, generate the next round of random numbers for each node, and obtain the next round of random number list for each node; Based on the next round of random numbers, generate the next round of target random numbers from the given range.
6. The method according to any one of claims 1-3, characterized in that, After generating a random number list for each node based on the mixed asset situation of each node at the time of selection of the accounting right in this round, the method further includes: Each node records the current round's random number list for all nodes and the correspondence between each node and the current round's random number list.
7. A consensus device for blockchain, characterized in that, The device includes: The random number generation module is used to generate a random number list for each node in this round based on the mixed asset situation of each node when the accounting right is selected; the mixed asset situation includes the number of assets and the number of nodes; the random number list in this round includes one or more random numbers; The random number generation module is also used to generate the target random number for this round based on the range of random numbers for this round; The random number determination module is used to match the target random number for this round with the random number list for each node in this round to determine the node with the right to record transactions in this round. The accounting module is used to perform accounting for this round through the accounting right node of this round; This module is used to randomly generate the next round of random number generation range through the current round of accounting right nodes when selecting the next round of accounting right, and at the same time initiate a random number generation request.
8. A blockchain, characterized in that, The blockchain includes the consensus mechanism of the blockchain as described in claim 7.
9. A computer device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the operation of the blockchain consensus method as described in any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one executable instruction, which, when executed on a computer device, causes the computer device to perform the operation of the blockchain consensus method as described in any one of claims 1-6.
Citation Information
Patent Citations
Lucky draw method and device capable of customizing winning probabilities
CN108876486A
Method for generating bookkeeper through difference probability consensus algorithm of block chain
CN114666043A