Blockchain consensus method, system, device and computer readable storage medium
By forming a multi-level interconnected consortium blockchain among blockchain node groups, the problems of high transaction latency, low TPS, and high energy consumption in existing blockchain consensus systems in large-scale Internet transaction systems are solved, achieving efficient consensus processing and security assurance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2026-04-14
AI Technical Summary
Existing blockchain consensus systems suffer from high transaction latency, low TPS, and high energy consumption in large-scale internet transaction systems. Furthermore, private blockchain algorithms have poor security in scenarios with malicious nodes.
By adding the master node of the next level node group to the current level node group when the number of nodes in the current level node group does not exceed a preset threshold, and taking the next level node group as the current level node group when the number of nodes exceeds the threshold, a multi-level connected node group consortium chain is formed step by step, thus forming a blockchain consensus system suitable for large-scale Internet transaction systems.
A credit-based blockchain consensus system suitable for large-scale internet transaction systems was constructed, supporting millions of nodes and achieving consensus requirements of tens of millions per second, while avoiding high energy consumption and security and fairness issues.
Smart Images

Figure CN115766742B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, specifically to a blockchain consensus method, a blockchain consensus system, a computer device, and a computer-readable storage medium. Background Technology
[0002] Blockchain technology is a distributed internet database technology, also known as distributed ledger technology. It features decentralization, transparency, immutability, trustworthiness, collective maintenance, and traceability.
[0003] However, during the implementation of the embodiments of this invention, the inventors discovered that existing blockchain consensus systems, commonly used algorithms in public chains such as PoW, PoS, and DPoS, are characterized by a large number of nodes participating in the consensus, but also high transaction latency, low TPS, and high energy consumption. Algorithms commonly used in private chains, such as Raft and Paxos, have poor security, are centralized algorithms, and are unsuitable for scenarios with malicious nodes. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention provide a blockchain consensus method, a blockchain consensus system, a computer device, and a computer-readable storage medium to solve the technical problem that existing blockchain consensus systems are not suitable for large-scale Internet transaction systems.
[0005] According to one aspect of the present invention, a blockchain consensus method is provided, the method comprising:
[0006] When the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next level node group is added to the current level node group according to the node join request sent by the master node of the next level node group.
[0007] When the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group.
[0008] Continue executing the above steps until all nodes have joined their respective node groups, thus obtaining the consensus system of the blockchain;
[0009] The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
[0010] In one alternative approach, before adding the master node to the current level node group based on a node join request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold, the method further includes: each node in the next level node group communicating with each other to select the master node of the next level node group from among the nodes in the next level node group; and receiving a node join request sent by the master node of the next level node group.
[0011] In one optional approach, when the number of nodes in the current level node group does not exceed a preset threshold, adding the master node of the next-level node group to the current level node group according to the node join request sent by the master node of the next-level node group includes: when the number of nodes in the current level node group does not exceed the preset threshold, the current level node group initiates a node join vote within the current level node group according to the node join request sent by the master node of the next-level node group; when the vote passes, the master node of the next-level node group is added to the current level node group as a newly added node in the current level node group.
[0012] In one alternative approach, the step of using the newly started node groups as the next-level node groups includes: forming at least one node group from the newly started nodes within the first time window according to the principle of proximity; using the node groups formed by the newly started nodes as the next-level node groups respectively; and selecting the master node of the next-level node group from each node in the next-level node group.
[0013] In an optional manner, the method further includes: each node in the current level node group records two sets of node information, the two sets of node information including sibling node information and parent node information.
[0014] In one alternative approach, the permanent consensus node is a node that participates in consensus voting for an extended period, and the master node in the secondary node group is a rotating consensus node with a term limit within the consensus node group.
[0015] In an optional embodiment, the method further includes: a transaction node receiving a transaction request from a client, and after verifying the client's transaction, executing the transaction request and submitting the transaction data to a transaction pool; the transaction node being any one of all nodes in the consensus system; a consensus master node obtaining the transaction data from the transaction pool and executing a smart contract locally to generate a candidate block; the consensus master node being any one of the consensus nodes and each of the rotating consensus nodes; the consensus master node sending the candidate block to other consensus nodes in the consensus node group; after each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block in the ledger and synchronizes it with other nodes.
[0016] According to another aspect of the present invention, a blockchain consensus system is provided, the system comprising a plurality of node groups cascaded in sequence, the plurality of node groups cascaded in sequence including a first-level node group and a second-level node group;
[0017] The first-level node group is a consensus node group, and the nodes in the consensus node group are consensus nodes. The consensus nodes include pre-selected permanent consensus nodes and master nodes in the second-level node group.
[0018] The secondary node group includes the master node and multiple non-consensus nodes;
[0019] Each node in each node group is a transaction node.
[0020] According to another aspect of the present invention, a blockchain consensus device is provided, the device comprising:
[0021] The first addition module is used to add the master node of the next level node group to the current level node group according to the node addition request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold.
[0022] The second addition module is used to, when the number of nodes in the current level node group exceeds a preset threshold, take the next level node group as the current level node group and take the node group composed of newly started nodes as the next level node group.
[0023] The determination module is used to obtain the consensus system of the blockchain after all nodes have joined their respective node groups;
[0024] The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
[0025] 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;
[0026] The memory is used to store at least one executable instruction that causes the processor to perform the operation of the blockchain consensus method.
[0027] According to another aspect of the present invention, a computer-readable storage medium is provided, the storage medium storing 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.
[0028] In this embodiment of the invention, when the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next-level node group is added to the current level node group according to a node join request sent by the master node of the next-level node group. When the number of nodes in the current level node group exceeds a preset threshold, the next-level node group is adopted as the current level node group, and the newly started node group is also adopted as the next-level node group. The process continues, continuing to add the master node of the next-level node group to the current level node group according to a node join request sent by the master node of the next-level node group when the number of nodes in the current level node group does not exceed a preset threshold, and when the number of nodes in the current level node group exceeds a preset threshold... When the number of nodes in a previous-level node group exceeds a preset threshold, the next-level node group is taken as the current-level node group, and the newly started node group is taken as the next-level node group. This process continues until all nodes have joined, resulting in the consensus system of the blockchain. This system can build a credit-based blockchain consensus system suitable for large-scale internet transaction systems. By applying blockchain technology to large-scale internet transaction scenarios, it can achieve the scalability required by large-scale internet transaction systems, supporting millions of nodes and reaching consensus requirements of tens of millions per second. At the same time, it does not require the energy consumption of Bitcoin and avoids the security and fairness issues of using the Proof-of-Stake (PoS) mechanism.
[0029] 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
[0030] 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:
[0031] Figure 1 A flowchart illustrating the blockchain consensus method provided in an embodiment of the present invention is shown;
[0032] Figure 2 A schematic diagram of the structure of the blockchain consensus system provided in an embodiment of the present invention is shown;
[0033] Figure 3 A schematic diagram of the structure of the blockchain consensus device provided in an embodiment of the present invention is shown;
[0034] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation
[0035] 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.
[0036] Figure 1 A flowchart of a blockchain consensus method provided in an embodiment of the present invention is shown, which is executed by the blockchain. Figure 1 As shown, the method includes the following steps:
[0037] Step 110: When the number of nodes in the current level node group does not exceed the preset threshold, add the master node of the next level node group to the current level node group according to the node join request sent by the master node of the next level node group.
[0038] In this embodiment of the invention, the current-level node group can be any node group currently building connections with each next-level node group. Multiple newly started nodes form multiple next-level node groups according to the principle of proximity. Specifically, for each next-level node group, nodes newly started simultaneously within a first time window can be grouped into at least one node group according to the principle of proximity. Each node group formed by the newly started nodes is designated as a next-level node group, and a master node is selected from each node in the next-level node group. By having the master nodes from multiple next-level node groups join the current-level node group, communication connections are established between the current-level node group and the next-level node groups, ultimately forming a multi-level connected node group consortium chain.
[0039] In this embodiment of the invention, before step 110, the nodes in the next-level node group communicate with each other and select the master node of the next-level node group from the nodes in the next-level node group; and receive the node joining request sent by the master node in the next-level node group.
[0040] Specifically, when the number of nodes in the current level node group does not exceed a preset threshold, the current level node group initiates a node joining vote within the group based on the node joining request sent by the master node of the next level node group; when the vote passes, the master node of the next level node group is added to the current level node group as a newly added node in the current level node group.
[0041] Taking the current level node group as the first-level node group and the next level node group as the second-level node group as an example: For the first-level node group, several T0-level nodes are first deployed to form an initial consensus node group (i.e., the first-level node group). The first-level node group is the consensus node group, and the other level node groups are non-consensus node groups. The T0-level nodes are pre-selected permanent consensus nodes that can participate in consensus voting for a long time and have veto power. They are set by the blockchain's consortium organization and are the initial consensus nodes, usually deployed in the highest-security intranet environment among the consortium members, behind a firewall. Next, the next level of nodes is built. Nodes started within the first preset time window automatically form multiple second-level node groups according to the proximity principle. Nodes in these second-level node groups are non-consensus nodes. The nodes in these second-level node groups elect a master node through voting. Each master node in a second-level node group sends a node joining request to the first-level node group.
[0042] The primary node group receives the node joining request and determines that the number of nodes within the primary node group does not exceed a preset threshold. Since the number of permanent consensus nodes is fixed, this can be checked by checking if the number of rotating consensus nodes already in the primary node group exceeds a preset limit. If not, the primary node group initiates a node joining vote based on the node joining request sent by the master node of the secondary node group. When the vote passes, the master node of the secondary node group is added to the primary node group as a newly added node. The master node in the secondary node group is a rotating consensus node with a term limit within the primary node group. In other words, the permanent consensus nodes and rotating consensus nodes in the primary node group participate in consensus together. The rotating consensus node, as the master node of the secondary node group, facilitates communication between the primary and secondary node groups, thus establishing communication between them.
[0043] Step 120: When the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of the newly started nodes is taken as the next level node group.
[0044] When the number of nodes in the current level node group exceeds a preset threshold, the nodes that are newly started within the first time window will be grouped into at least one node group according to the principle of proximity; the node groups formed by the newly started nodes will be used as the next level node groups, and the master node of the next level node group will be selected from each node in the next level node group.
[0045] Continuing with the example of the current level node group as the first-level node group and the next level node group as the second-level node group: As the number of nodes in the blockchain increases, more and more rotating consensus nodes join the first-level node group. When the number of rotating consensus nodes exceeds the preset number, newly started nodes will default to organizing a lower-level node group, namely the third-level node group. The third-level node group also elects a master node through the protocol and initiates a node join request to a nearby second-level node group according to the proximity principle. At this time, the second-level node group becomes the current level node group, and the third-level node group becomes the next level node group, continuing to execute the above steps for processing node join requests.
[0046] Step 130: Continue to execute the above steps until all nodes have joined their respective node groups, thus obtaining the consensus system of the blockchain.
[0047] The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
[0048] Specifically, the process continues to execute the following steps: when the number of nodes in the current level node group does not exceed a preset threshold, add the master node of the next level node group to the current level node group according to the node join request sent by the master node of the next level node group; and when the number of nodes in the current level node group exceeds the preset threshold, use the next level node group as the current level node group and use the node group composed of the newly started nodes as the next level node group, until all nodes have joined, thus obtaining the consensus system of the blockchain.
[0049] In this embodiment of the invention, several permanent consensus nodes are determined to form a consensus node group; the permanent consensus nodes are nodes that participate in consensus voting for a long time; ordinary nodes added within a first time window are formed into multiple secondary node groups; the master node in each of the secondary node groups sends a request to join the consensus node group; the consensus node group initiates a vote within the group based on the consensus node joining request, and when the vote passes, the master node is added to the consensus node group as a rotating consensus node; when the number of rotating consensus nodes reaches a preset threshold, ordinary nodes newly added within a second time window form multiple tertiary node groups, and the master node of each tertiary node group initiates a node joining request to the secondary node group; the secondary node group initiates a vote within the group based on the node joining request, and when the vote passes, the master node of the tertiary node group is added to the secondary node group as a rotating node in the secondary node group... and so on, with all nodes joining the corresponding node group, and connections between different levels of node groups are established through the lower-level master node. Specifically, when the number of rotating consensus nodes exceeds a preset number, newly launched nodes will default to organizing a lower-level node group (i.e., a third-level node group). The third-level node group also elects a master node through a protocol and initiates a node joining request to a nearby second-level node group based on the principle of proximity. At this time, the second-level node group becomes the current level node group, and the third-level node group becomes the next level node group, continuing to execute the above steps for processing node joining requests. This process continues iteratively until each launched node joins the corresponding level node group. The node groups at different levels establish connections with the higher-level node group through the master node of the next-level node group, thus constructing the consensus system of the blockchain. The first-level node group is the consensus node group, which includes pre-selected permanent consensus nodes and the master node from the second-level node group. The permanent consensus nodes are nodes that participate in consensus voting for a long time, and the master node in the second-level node group is a rotating consensus node with a term limit. Except for the consensus nodes in the first-level node group, other levels of node groups do not have consensus capabilities.
[0050] In this embodiment of the invention, each node in the current level node group and the next level node group records two sets of node information, including peer node information and superior node information. After the blockchain network is successfully established, each node internally records two sets of node information, namely list1 [peer nodes] and list2 [superior nodes]. For T0 nodes (permanent consensus nodes), list2 is empty. The primary node in the same group will exist in both lists simultaneously.
[0051] In this embodiment of the invention, after the consensus system for the blockchain is constructed, consensus processing is performed through the consensus system, specifically including:
[0052] A transaction node receives a transaction request from a client, executes the transaction request after verifying the client's identity, and submits the transaction data to the transaction pool; the transaction node can be any one of all nodes in the consensus system.
[0053] The consensus master node obtains the transaction data from the transaction pool and executes the smart contract locally to generate candidate blocks; the consensus master node is any one of the consensus nodes and each of the rotating consensus nodes;
[0054] The consensus master node sends the candidate block to other consensus nodes in the consensus node group;
[0055] After each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block into the ledger and synchronizes it with the other nodes.
[0056] like Figure 2 As shown, the following describes the blockchain consensus method in one embodiment of the invention using a three-level structure as an example:
[0057] First, the composition and functions of the nodes in this embodiment of the invention are explained. Each node is assigned a hierarchical identity: T0, T1, T2, T3... and so on, which can be progressively increased as the node scale expands. The functions of each level of node are as follows: T0 level is a permanent consensus node, which can participate in consensus voting for a long time and has veto power. It is set by the consortium organization to which the blockchain belongs and is the initial consensus node. It is usually deployed in the internal network environment with the highest security level among the consortium members and is located behind a firewall. T1 is a rotating consensus node, which is elected by the lower-level consensus nodes and approved by the consensus nodes of the same level. T1 level and T0 level consensus nodes form a consensus node group through a P2P network protocol (that is, Figure 2 In a consensus alliance, T1-level consensus nodes have term limits; after their term ends, they are demoted to T2 nodes and re-elected. T2 nodes cannot participate in consensus voting; they are only responsible for electing T1 consensus nodes. 2n+1 T2 consensus nodes form a second-level node group through a p2p network, such as... Figure 2 As shown, four secondary node groups, G1, G2, G3, and G4, are formed. T2-level nodes within a group can propose a consensus vote to a T1-level node within the group. The T1 consensus node then initiates the vote within its group and broadcasts the result to the T2 nodes within the group. This process continues, with 2n+1 T3 nodes forming a tertiary node group. Figure 2 As shown in G5 and G6, T2-level nodes are elected. As the system scales up, the node hierarchy can be continuously expanded, thus forming a structure like... Figure 2The consensus alliance system shown in this embodiment of the invention has the advantage of hierarchical grouping and step-by-step submission: when the system node scale grows significantly, it avoids message delays and message duplication caused by P2P communication between nodes.
[0058] 1. First, deploy several T0-level nodes to form a preliminary consensus node group (first-level node group). Nodes communicate with each other using encryption technology and authenticate identities using digital signature technology.
[0059] 2. Deploy several non-T0 level nodes one by one. Nodes that start within a time window will automatically form one or more secondary node groups consisting of 2n+1 (n>=0) ordinary nodes according to the principle of proximity. The groups communicate with each other through the p2p protocol and select the master node in the group through the Raft protocol.
[0060] 3. The master node of the newly formed secondary node group will proactively report to any node in the T0 node group and request to join the consensus node group.
[0061] 4. Upon receiving the report and consensus joining request, the T0 node broadcasts it within the consensus node group and initiates a vote. When it receives more than 2 / 3 of the nodes' votes in favor, it sends the voting result to the initiator. At this point, the node is upgraded to a T1 level node, i.e., a rotating consensus node.
[0062] 5. Node T1 broadcasts the voting results to the other nodes in its group. The other nodes are then T1+1=T2 nodes.
[0063] 6. Similarly, as the number of nodes in the blockchain increases, the number of T1 nodes will reach a threshold. Newly added nodes will default to organizing a lower-level node group, the third-level node group, which includes multiple T3-level nodes. The T3-level nodes also elect a master node through the Raft protocol. The master node applies to join a nearby T2 node group according to the principle of proximity. Due to the addition of new members, the T2 will re-initiate an election to elect a new master node, which will then request to join the consensus node group. The steps are the same as steps 3-5.
[0064] 7. After the blockchain network is successfully established, each node records two sets of node information: list1 [sibling nodes] and list2 [parent nodes]. For node T0, list2 is empty. The primary node in the same group will exist in both lists simultaneously.
[0065] After the blockchain network is successfully established, transactions are executed and the block production process begins, specifically:
[0066] 1) Nodes T0, T1, and T2 through Tn all act as transaction nodes, receiving transaction requests from clients and authenticating the clients. If authentication is successful, the transaction request is executed, and the transaction is submitted to the transaction pool.
[0067] 2) T0 and T1 level nodes participate in consensus, and the consensus master node periodically obtains transaction data from the transaction pool in batches.
[0068] 3) After the consensus master node obtains the transaction data, it first pre-executes the smart contract locally to generate candidate blocks.
[0069] 4) The consensus master node sends the generated candidate blocks to other consensus nodes through a peer-to-peer network to initiate a consensus vote.
[0070] 5) Consensus nodes verify candidate blocks to reach consensus.
[0071] 6) After the consensus is reached, each node will record the block into the ledger.
[0072] 7) The consensus node synchronizes the block to its subordinate non-consensus nodes, and so on, until all nodes have completed the accounting.
[0073] In this embodiment of the invention, when the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next-level node group is added to the current level node group according to a node join request sent by the master node of the next-level node group. When the number of nodes in the current level node group exceeds a preset threshold, the next-level node group is adopted as the current level node group, and the newly started node group is also adopted as the next-level node group. The process continues, continuing to add the master node of the next-level node group to the current level node group according to a node join request sent by the master node of the next-level node group when the number of nodes in the current level node group does not exceed a preset threshold, and when the number of nodes in the current level node group exceeds a preset threshold... When the number of nodes in a previous-level node group exceeds a preset threshold, the next-level node group is taken as the current-level node group, and the newly started node group is taken as the next-level node group. This process continues until all nodes have joined, resulting in the consensus system of the blockchain. This system can build a credit-based blockchain consensus system suitable for large-scale internet transaction systems. By applying blockchain technology to large-scale internet transaction scenarios, it can achieve the scalability required by large-scale internet transaction systems, supporting millions of nodes and reaching consensus requirements of tens of millions per second. At the same time, it does not require the energy consumption of Bitcoin and avoids the security and fairness issues of using the Proof-of-Stake (PoS) mechanism.
[0074] This invention also provides a blockchain consensus system, the system comprising multiple cascaded node groups, the cascaded node groups including a first-level node group and a second-level node group;
[0075] The first-level node group is a consensus node group, and the nodes in the consensus node group are consensus nodes. The consensus nodes include pre-selected permanent consensus nodes and master nodes in the second-level node group.
[0076] The secondary node group includes the master node and multiple non-consensus nodes;
[0077] Each node in each node group is a transaction node.
[0078] The blockchain consensus system is constructed based on the blockchain consensus method described in the above embodiments, and will not be repeated here. The consensus process of this blockchain consensus system is as follows:
[0079] A transaction node receives a transaction request from a client, executes the transaction request after verifying the client's identity, and submits the transaction data to the transaction pool; the transaction node can be any one of all nodes in the consensus system.
[0080] The consensus master node obtains the transaction data from the transaction pool and executes the smart contract locally to generate candidate blocks; the consensus master node is any one of the consensus nodes and each of the rotating consensus nodes;
[0081] The consensus master node sends the candidate block to other consensus nodes in the consensus node group;
[0082] After each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block into the ledger and synchronizes it with the other nodes.
[0083] 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:
[0084] The first addition module 310 is used to add the master node of the next level node group to the current level node group according to the node addition request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold.
[0085] The second addition module 320 is used to, when the number of nodes in the current level node group exceeds a preset threshold, take the next level node group as the current level node group and take the node group composed of newly started nodes as the next level node group.
[0086] The module 330 is used to determine the consensus system of the blockchain after all nodes have joined their respective node groups;
[0087] The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
[0088] In one alternative approach, before adding the master node to the current level node group based on a node join request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold, the method further includes: each node in the next level node group communicating with each other to select the master node of the next level node group from among the nodes in the next level node group; and receiving a node join request sent by the master node of the next level node group.
[0089] In one optional approach, when the number of nodes in the current level node group does not exceed a preset threshold, adding the master node of the next-level node group to the current level node group according to the node join request sent by the master node of the next-level node group includes: when the number of nodes in the current level node group does not exceed the preset threshold, the current level node group initiates a node join vote within the group according to the node join request sent by the master node of the next-level node group; when the vote passes, the master node of the next-level node group is added to the current level node group as a newly added node in the current level node group.
[0090] In one optional approach, when the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group. This includes: forming at least one node group from the nodes that are newly started simultaneously within the first time window according to the principle of proximity; taking the node group composed of the newly started nodes as the next level node group respectively; and selecting the master node of the next level node group from each node in the next level node group.
[0091] In an optional manner, the method further includes: each node in the current level node group records two sets of node information, the two sets of node information including sibling node information and parent node information.
[0092] In one alternative approach, the permanent consensus node is a node that participates in consensus voting for an extended period, and the master node in the secondary node group is a rotating consensus node with a term limit within the consensus node group.
[0093] In an optional embodiment, the method further includes: a transaction node receiving a transaction request from a client, and after verifying the client's transaction, executing the transaction request and submitting the transaction data to a transaction pool; the transaction node being any one of all nodes in the consensus system; a consensus master node obtaining the transaction data from the transaction pool and executing a smart contract locally to generate a candidate block; the consensus master node being any one of the consensus nodes and each of the rotating consensus nodes; the consensus master node sending the candidate block to other consensus nodes in the consensus node group; after each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block in the ledger and synchronizes it with other nodes.
[0094] The specific working process of the blockchain consensus device in this embodiment of the invention is largely the same as that in the above method embodiment, and will not be repeated here.
[0095] In this embodiment of the invention, when the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next-level node group is added to the current level node group according to a node join request sent by the master node of the next-level node group. When the number of nodes in the current level node group exceeds a preset threshold, the next-level node group is adopted as the current level node group, and the newly started node group is also adopted as the next-level node group. The process continues, continuing to add the master node of the next-level node group to the current level node group according to a node join request sent by the master node of the next-level node group when the number of nodes in the current level node group does not exceed a preset threshold, and when the number of nodes in the current level node group exceeds a preset threshold... When the number of nodes in a previous-level node group exceeds a preset threshold, the next-level node group is taken as the current-level node group, and the newly started node group is taken as the next-level node group. This process continues until all nodes have joined, resulting in the consensus system of the blockchain. This system can build a credit-based blockchain consensus system suitable for large-scale internet transaction systems. By applying blockchain technology to large-scale internet transaction scenarios, it can achieve the scalability required by large-scale internet transaction systems, supporting millions of nodes and reaching consensus requirements of tens of millions per second. At the same time, it does not require the energy consumption of Bitcoin and avoids the security and fairness issues of using the Proof-of-Stake (PoS) mechanism.
[0096] 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.
[0097] like Figure 4As shown, the computer device may include: a processor 402, a communications interface 404, a memory 406, and a communications bus 408.
[0098] 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 described above in the blockchain consensus method embodiment.
[0099] Specifically, program 410 may include program code, which includes computer-executable instructions.
[0100] 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.
[0101] 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.
[0102] Specifically, program 410 can be called by processor 402 to cause the computer device to perform the following operations:
[0103] When the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next level node group is added to the current level node group according to the node join request sent by the master node of the next level node group.
[0104] When the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group.
[0105] Continue executing the above steps until all nodes have joined their respective node groups, thus obtaining the consensus system of the blockchain;
[0106] The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
[0107] In one alternative approach, before adding the master node to the current level node group based on a node join request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold, the method further includes: each node in the next level node group communicating with each other to select the master node of the next level node group from among the nodes in the next level node group; and receiving a node join request sent by the master node of the next level node group.
[0108] In one optional approach, when the number of nodes in the current level node group does not exceed a preset threshold, adding the master node of the next-level node group to the current level node group according to the node join request sent by the master node of the next-level node group includes: when the number of nodes in the current level node group does not exceed the preset threshold, the current level node group initiates a node join vote within the group according to the node join request sent by the master node of the next-level node group; when the vote passes, the master node of the next-level node group is added to the current level node group as a newly added node in the current level node group.
[0109] In one optional approach, when the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group. This includes: forming at least one node group from the nodes that are newly started simultaneously within the first time window according to the principle of proximity; taking the node group composed of the newly started nodes as the next level node group respectively; and selecting the master node of the next level node group from each node in the next level node group.
[0110] In an optional manner, the method further includes: each node in the current level node group records two sets of node information, the two sets of node information including sibling node information and parent node information.
[0111] In one alternative approach, the permanent consensus node is a node that participates in consensus voting for an extended period, and the master node in the secondary node group is a rotating consensus node with a term limit within the consensus node group.
[0112] In an optional embodiment, the method further includes: a transaction node receiving a transaction request from a client, and after verifying the client's transaction, executing the transaction request and submitting the transaction data to a transaction pool; the transaction node being any one of all nodes in the consensus system; a consensus master node obtaining the transaction data from the transaction pool and executing a smart contract locally to generate a candidate block; the consensus master node being any one of the consensus nodes and each of the rotating consensus nodes; the consensus master node sending the candidate block to other consensus nodes in the consensus node group; after each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block in the ledger and synchronizes it with other nodes.
[0113] In this embodiment of the invention, when the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next-level node group is added to the current level node group according to a node join request sent by the master node of the next-level node group. When the number of nodes in the current level node group exceeds a preset threshold, the next-level node group is adopted as the current level node group, and the newly started node group is also adopted as the next-level node group. The process continues, continuing to add the master node of the next-level node group to the current level node group according to a node join request sent by the master node of the next-level node group when the number of nodes in the current level node group does not exceed a preset threshold, and when the number of nodes in the current level node group exceeds a preset threshold... When the number of nodes in a previous-level node group exceeds a preset threshold, the next-level node group is taken as the current-level node group, and the newly started node group is taken as the next-level node group. This process continues until all nodes have joined, resulting in the consensus system of the blockchain. This system can build a credit-based blockchain consensus system suitable for large-scale internet transaction systems. By applying blockchain technology to large-scale internet transaction scenarios, it can achieve the scalability required by large-scale internet transaction systems, supporting millions of nodes and reaching consensus requirements of tens of millions per second. At the same time, it does not require the energy consumption of Bitcoin and avoids the security and fairness issues of using the Proof-of-Stake (PoS) mechanism.
[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] When the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next level node group is added to the current level node group according to the node join request sent by the master node of the next level node group.
[0117] When the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group.
[0118] Continue executing the above steps until all nodes have joined their respective node groups, thus obtaining the consensus system of the blockchain;
[0119] The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
[0120] In one alternative approach, before adding the master node to the current level node group based on a node join request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold, the method further includes: each node in the next level node group communicating with each other to select the master node of the next level node group from among the nodes in the next level node group; and receiving a node join request sent by the master node of the next level node group.
[0121] In one optional approach, when the number of nodes in the current level node group does not exceed a preset threshold, adding the master node of the next-level node group to the current level node group according to the node join request sent by the master node of the next-level node group includes: when the number of nodes in the current level node group does not exceed the preset threshold, the current level node group initiates a node join vote within the group according to the node join request sent by the master node of the next-level node group; when the vote passes, the master node of the next-level node group is added to the current level node group as a newly added node in the current level node group.
[0122] In one optional approach, when the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group. This includes: forming at least one node group from the nodes that are newly started simultaneously within the first time window according to the principle of proximity; taking the node group composed of the newly started nodes as the next level node group respectively; and selecting the master node of the next level node group from each node in the next level node group.
[0123] In an optional manner, the method further includes: each node in the current level node group records two sets of node information, the two sets of node information including sibling node information and parent node information.
[0124] In one alternative approach, the permanent consensus node is a node that participates in consensus voting for an extended period, and the master node in the secondary node group is a rotating consensus node with a term limit within the consensus node group.
[0125] In an optional embodiment, the method further includes: a transaction node receiving a transaction request from a client, and after verifying the client's transaction, executing the transaction request and submitting the transaction data to a transaction pool; the transaction node being any one of all nodes in the consensus system; a consensus master node obtaining the transaction data from the transaction pool and executing a smart contract locally to generate a candidate block; the consensus master node being any one of the consensus nodes and each of the rotating consensus nodes; the consensus master node sending the candidate block to other consensus nodes in the consensus node group; after each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block in the ledger and synchronizes it with other nodes.
[0126] In this embodiment of the invention, when the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next-level node group is added to the current level node group according to a node join request sent by the master node of the next-level node group. When the number of nodes in the current level node group exceeds a preset threshold, the next-level node group is adopted as the current level node group, and the newly started node group is also adopted as the next-level node group. The process continues, continuing to add the master node of the next-level node group to the current level node group according to a node join request sent by the master node of the next-level node group when the number of nodes in the current level node group does not exceed a preset threshold, and when the number of nodes in the current level node group exceeds a preset threshold... When the number of nodes in a previous-level node group exceeds a preset threshold, the next-level node group is taken as the current-level node group, and the newly started node group is taken as the next-level node group. This process continues until all nodes have joined, resulting in the consensus system of the blockchain. This system can build a credit-based blockchain consensus system suitable for large-scale internet transaction systems. By applying blockchain technology to large-scale internet transaction scenarios, it can achieve the scalability required by large-scale internet transaction systems, supporting millions of nodes and reaching consensus requirements of tens of millions per second. At the same time, it does not require the energy consumption of Bitcoin and avoids the security and fairness issues of using the Proof-of-Stake (PoS) mechanism.
[0127] This invention provides a blockchain consensus device for executing the above-described blockchain consensus method.
[0128] 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.
[0129] 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, which, when executed on a computer, cause the computer to perform the blockchain consensus method in any of the above method embodiments.
[0130] 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.
[0131] 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.
[0132] 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.
[0133] 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.
[0134] 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 blockchain consensus method, characterized in that, The method includes: When the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next level node group is added to the current level node group according to the node join request sent by the master node of the next level node group; wherein, nodes that are newly started at the same time within the first time window are formed into at least one node group according to the principle of proximity, and the node group formed by the newly started nodes is the next level node group. When the number of nodes in the current level node group exceeds a preset threshold, the next level node group is taken as the current level node group, and the node group composed of newly started nodes is taken as the next level node group. Continue executing the above steps until all nodes have joined their respective node groups, thus obtaining the consensus system of the blockchain; The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
2. The method according to claim 1, characterized in that, Before adding the master node to the current level node group according to the node join request sent by the master node of the next level node group when the number of nodes in the current level node group does not exceed a preset threshold, the method further includes: The nodes in the next-level node group communicate with each other, and the master node of the next-level node group is selected from the nodes of the next-level node group; Receive node join requests sent by the master node in the next level node group.
3. The method according to claim 1, characterized in that, When the number of nodes in the current level node group does not exceed a preset threshold, the master node of the next-level node group is added to the current level node group according to the node join request sent by the master node of the next-level node group, including: When the number of nodes in the current level node group does not exceed a preset threshold, the current level node group initiates a node joining vote within the current level node group based on the node joining request sent by the master node of the next level node group. When the vote passes, the master node of the next-level node group is added to the current-level node group as a newly added node in the current-level node group.
4. The method according to claim 1, characterized in that, The step of designating a node group composed of newly started nodes as the next-level node group includes: Nodes that are newly started within the first time window will be grouped into at least one node group according to the principle of proximity. Each newly started node group is designated as the next-level node group, and the master node of the next-level node group is selected from each node in the next-level node group.
5. The method according to any one of claims 1-4, characterized in that, The permanent consensus node is a node that participates in consensus voting for a long period of time, and the master node in the secondary node group is a rotating consensus node with a term limit in the consensus node group.
6. The method according to any one of claims 1-4, characterized in that, The method further includes: A transaction node receives a transaction request from a client, executes the transaction request after verifying the client's identity, and submits the transaction data to the transaction pool; the transaction node can be any one of all nodes in the consensus system. The consensus master node obtains the transaction data from the transaction pool and executes the smart contract locally to generate candidate blocks; the consensus master node is any one of the consensus nodes and the rotating consensus nodes; The consensus master node sends the candidate block to other consensus nodes in the consensus node group; After each consensus node in the consensus node group verifies the candidate block and reaches a consensus, each node records the candidate block into the ledger and synchronizes it with other nodes.
7. A blockchain consensus device, characterized in that, The device includes: The first addition module is used to add the master node of the next level node group to the current level node group when the number of nodes in the current level node group does not exceed a preset threshold. The module is used to add the master node of the next level node group to the current level node group according to the node addition request sent by the master node of the next level node group. The nodes that are newly started at the same time within the first time window are formed into at least one node group according to the principle of proximity, and the node group formed by the newly started nodes is the next level node group. The second addition module is used to, when the number of nodes in the current level node group exceeds a preset threshold, take the next level node group as the current level node group and take the node group composed of newly started nodes as the next level node group. The determination module is used to obtain the consensus system of the blockchain after all nodes have joined their respective node groups; The primary node group is the consensus node group, which includes pre-selected permanent consensus nodes and master nodes in the secondary node group.
8. A blockchain consensus system, characterized in that, The system is constructed according to any one of claims 1-6, and the system includes a plurality of cascaded node groups, the plurality of cascaded node groups including a first-level node group and a second-level node group; The first-level node group is a consensus node group, and the nodes in the consensus node group are consensus nodes. The consensus nodes include pre-selected permanent consensus nodes and master nodes in the second-level node group. The secondary node group includes the master node and multiple non-consensus nodes; Each node in each node group is a transaction node.
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 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
Consensus method, device and system based on blockchain system
CN110474986A