Data processing method, device, program product, equipment and medium of consensus network
By decomposing a large-scale consensus network into smaller consensus sub-networks for block consensus, the performance degradation caused by excessive communication volume in large-scale consensus networks is solved, achieving more efficient consensus processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-07-08
- Publication Date
- 2026-06-19
AI Technical Summary
In large-scale consensus networks, the amount of communication during the block consensus process is enormous, which leads to a severe decline in the processing performance of the consensus network.
The large-scale consensus network is divided into multiple small-scale consensus sub-networks. Consensus processing of blocks is carried out in each consensus sub-network, and the consensus result is disseminated in the consensus network after the consensus is passed, thereby reducing the amount of communication and improving the consensus efficiency.
It reduces the communication complexity in the block consensus process and improves the consensus performance and efficiency of the consensus network.
Smart Images

Figure CN117411894B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular to a data processing method, apparatus, program product, device, and medium for a consensus network. Background Technology
[0002] Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Blocks in a blockchain network must be agreed upon and approved within the consensus network before they can be added to the chain for processing.
[0003] In existing applications, during the consensus process of a consensus network, the block needs to be broadcast among various consensus nodes in the consensus network before consensus is reached. If the consensus network is large and the number of consensus nodes is large, the communication volume during the broadcast consensus of the block will be extremely large, which will lead to a serious deterioration in the processing performance of the entire consensus network. Summary of the Invention
[0004] This application provides a data processing method, apparatus, program product, device, and medium for consensus networks, which can reduce the amount of communication during the consensus process of blocks in a consensus network and improve the efficiency and performance of the consensus network in reaching consensus on blocks.
[0005] This application provides a data processing method for a consensus network, wherein the consensus network comprises N consensus nodes, where N is a positive integer, and the N consensus nodes include a first master node; the method is executed by the first consensus node, which is any one of the N consensus nodes other than the first master node; the method includes:
[0006] The first block broadcast by the second consensus node in the second consensus subnetwork is received; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first consensus node and the second consensus node belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node;
[0007] Consensus processing of the first block is performed in the second consensus subnetwork. If the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus subnetwork to which the first consensus node belongs, so that the first block can continue to be processed in the first consensus subnetwork. The first consensus subnetwork contains M consensus nodes out of N consensus nodes; M is a positive integer less than N.
[0008] Broadcast the consensus result of the first consensus node for the first block in the consensus network, obtain the first number of consensus results for the first block in the consensus network, and process the first block on the chain according to the first number.
[0009] This application provides a data processing apparatus for a consensus network, wherein the consensus network comprises N consensus nodes, where N is a positive integer, and the N consensus nodes include a first master node; the apparatus is applied to the first consensus node, which is any one of the N consensus nodes other than the first master node; the apparatus includes:
[0010] The receiving module is used to receive the first block broadcast by the second consensus node in the second consensus subnetwork. The second consensus subnetwork contains K consensus nodes out of N consensus nodes. Both the first consensus node and the second consensus node belong to the second consensus subnetwork, and K is a positive integer less than N. The second consensus node is any one of the N consensus nodes except the first consensus node. The consensus process for the first block is initiated by the first master node.
[0011] The consensus module is used to perform consensus processing on the first block in the second consensus subnetwork. If the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus subnetwork to which the first consensus node belongs, so that the first block can continue to be processed in the first consensus subnetwork. The first consensus subnetwork contains M consensus nodes out of N consensus nodes; M is a positive integer less than N.
[0012] The acquisition module is used to broadcast the consensus result of the first consensus node for the first block in the consensus network, obtain the first number of consensus results of the first block in the consensus network, and perform on-chain processing of the first block according to the first number.
[0013] Optionally, among the K consensus nodes, the consensus nodes other than the second consensus node are K-1 consensus nodes selected by the second consensus node from among the N consensus nodes and connected to the second consensus node; among the M consensus nodes, the consensus nodes other than the first consensus node are M-1 consensus nodes selected by the first consensus node from among the N consensus nodes and connected to the first consensus node.
[0014] If the second consensus node is the first master node, then the first block broadcast by the second consensus node is generated by the second consensus node; if the second consensus node is not the first master node, then the first block broadcast by the second consensus node is obtained by any consensus node among the N consensus nodes other than the first and second consensus nodes broadcasting to the second consensus node.
[0015] Optionally, the consensus result of any consensus node for any block in the consensus network refers to the node signature of any consensus node for any block. The first block has an associated set of node signatures, and the set of node signatures contains the node signature of the first consensus node for the first block.
[0016] The acquisition module obtains the first number of consensus results passed by the first block in the consensus network, and the method for processing the first block on the chain based on the first number, including:
[0017] During the consensus processing of the first block in the consensus network, the node signatures for the first block broadcast by the consensus nodes other than the first consensus node among the N consensus nodes are received, and the received node signatures are added to the node signature set.
[0018] Get the first number of node signatures in the node signature set. If the first number is greater than or equal to the number threshold, then process the first block to be added to the chain.
[0019] Optionally, if the second consensus node is the first master node, then the K consensus nodes include the second master node. The second master node refers to the next master node among the N consensus nodes used to rotate the master node from the first master node.
[0020] The second master node is used to initiate the consensus process for the second block in the consensus network after the consensus of the first block broadcast to the second consensus node has been passed. The block height corresponding to the second block is the next block height after the block height corresponding to the first block.
[0021] Optionally, the block height corresponding to the first block is the first block height; the above device is also used for:
[0022] Obtain the third block pending consensus; the third block is a block that needs to be consensused initiated by the third master node when it fails to obtain the first block after a timeout. The block height corresponding to the third block is the height of the first block. The third master node is a consensus node among N consensus nodes that is used for master node rotation after the first master node.
[0023] Perform consensus processing on the third block; if consensus processing on the third block is completed, then cache the third block.
[0024] Optionally, the above-mentioned device is also used for:
[0025] If consensus processing for the first block is completed, then cache the first block;
[0026] The above-mentioned device is also used for:
[0027] If the second number of consensus results for the third block in the consensus network is obtained, and the second number is greater than or equal to the number threshold, then the third block is added to the chain, and the cached first block is deleted.
[0028] Optionally, the method by which the acquisition module processes the first block on the chain based on the first quantity includes:
[0029] If the first quantity is greater than or equal to the quantity threshold, then the first block is added to the chain and the cached third block is deleted.
[0030] Optionally, the above-mentioned device is also used for:
[0031] The block weight of the first block is determined based on the number of sub-blocks of the first block in the cache.
[0032] The block weight of the third block is determined based on the number of sub-blocks of the cached third block;
[0033] The block weights of the first and third blocks are used to determine the parent block of the fourth block. The block height of the fourth block is the height of the second block, which is the next block height after the height of the first block.
[0034] Optionally, the above-mentioned device is also used for:
[0035] Obtain the fourth block pending consensus;
[0036] If the block weight of the first block is greater than the block weight of the third block, then the first block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
[0037] If the block weight of the first block is less than the block weight of the third block, then the third block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
[0038] Optionally, if the number of consensus results of the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the first block, then the first consensus node is used to delete the cached third block and the sibling blocks of the fourth block, and to process the first block and the fourth block on the chain.
[0039] If the number of consensus results passed by the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the third block, then the first consensus node is used to delete the cached first block and the sibling blocks of the fourth block, and is used to process the third block and the fourth block on the chain.
[0040] Among them, a sibling block of any block refers to a block whose corresponding block height is the same as that of any other block. The first block and the third block are sibling blocks of each other.
[0041] Optionally, the above-mentioned device is also used for:
[0042] If consensus processing for the fourth block is completed, then cache the fourth block.
[0043] Based on the cached fourth block and its parent block, update the block weights of the first block, the third block, and the fourth block.
[0044] This application provides a computer device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the method of this application.
[0045] This application provides a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described above.
[0046] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative embodiments described above.
[0047] In this application, the first consensus node can receive the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first and second consensus nodes belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node in the consensus network; consensus processing of the first block is performed in the second consensus subnetwork; if the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus subnetwork to which the first consensus node belongs, so that the first block continues to be processed for consensus in the first consensus subnetwork; the first consensus subnetwork contains M consensus nodes out of N consensus nodes; M is a positive integer less than N; the consensus passing result of the first consensus node for the first block is broadcast in the consensus network, and the first number of consensus passing results of the first block in the consensus network is obtained, and the first block is processed for on-chain processing according to the first number. Therefore, the method proposed in this application allows each consensus node to broadcast the block within a smaller network of the consensus network (such as the first consensus sub-network and the second consensus sub-network), and then perform consensus processing on the block within that smaller network. This can reduce the amount of communication during the consensus process and improve the consensus efficiency and performance of the consensus network for blocks. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is a schematic diagram of the network architecture of a consensus network provided in this application;
[0050] Figure 2 This is a schematic diagram of a block consensus scenario provided in this application;
[0051] Figure 3 This is a flowchart illustrating a data processing method for a consensus network provided in this application;
[0052] Figures 4a-4b This is a schematic diagram illustrating a block broadcast scenario provided in this application;
[0053] Figure 5 This is a schematic diagram of a block consensus scenario provided in this application;
[0054] Figure 6 This is a schematic diagram illustrating a scenario of a block proposal content provided in this application;
[0055] Figure 7 This is a flowchart illustrating a block processing method provided in this application;
[0056] Figure 8 This is a schematic diagram illustrating a scenario for setting block weights provided in this application;
[0057] Figure 9 This is a schematic diagram of a block processing scenario provided in this application;
[0058] Figure 10 This is a schematic diagram of a block consensus process provided in this application;
[0059] Figure 11 This is a flowchart illustrating an additional method provided in this application;
[0060] Figure 12 This is a schematic diagram of the structure of a data processing device for a consensus network provided in this application;
[0061] Figure 13 This is a schematic diagram of the structure of a computer device provided in this application. Detailed Implementation
[0062] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0063] This application relates to blockchain-related technologies. Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer. A blockchain consists of a series of blocks sequentially generated in chronological order. Once a new block is added to the blockchain, it cannot be removed. Each block records the data submitted by nodes in the blockchain system. This application proposes to transform a large-scale consensus network into a series of small-scale consensus sub-networks to achieve consensus on blocks, thereby improving the performance and efficiency of the consensus network in reaching consensus on blocks.
[0064] This application relates to cloud technology. Cloud technology refers to a managed technology that unifies hardware, software, network, and other resources within a wide area network (WAN) or local area network (LAN) to enable data computation, storage, processing, and sharing.
[0065] Cloud technology is a collective term for network technology, information technology, integration technology, management platform technology, and application technology applied to the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0066] The cloud technology mentioned in this application can refer to the ability of blockchain nodes (such as consensus nodes) to communicate with each other via the "cloud".
[0067] First, it should be noted that all data collected in this application (such as blocks and business data within blocks) is collected with the consent and authorization of the object to which the business data belongs (such as a user), and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0068] Please see Figure 1 , Figure 1 This is a schematic diagram of the network architecture of a consensus network provided in this application. Figure 1 As shown, the consensus network can include several consensus nodes, from consensus node 1 to consensus node N, where N is a positive integer, and the specific value of N is determined according to the actual application scenario. Each consensus node can be composed of one or more computer devices, which can be terminal devices or servers, etc.
[0069] If the computer device constituting the consensus node is a server, then the server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. If the computer device constituting the consensus node is a terminal device, then the terminal device can be a smart terminal such as a smartphone, tablet, laptop, desktop computer, smart TV, or in-vehicle terminal.
[0070] Please see also Figure 2 , Figure 2 This is a schematic diagram illustrating a block consensus scenario provided in this application. For example... Figure 2 As shown, the master nodes in the consensus network can rotate, and consensus node 1 can be the current master node initiating a block proposal consensus. Consensus node 1 can first broadcast the block that needs consensus to the corresponding consensus sub-network 1, which can contain consensus node 1, consensus node 2, consensus node 3, and consensus node 4.
[0071] Furthermore, in consensus subnetwork 1, consensus can be reached on the block initiated by consensus node 1. After consensus is achieved, each consensus node in consensus subnetwork 1 can obtain its own consensus result for the block. This consensus result refers to the individual consensus result of each consensus node for the block (such as consensus passed or consensus failed), rather than a final consensus result from all consensus nodes in consensus subnetwork 1 for the block. The consensus results of each consensus node for the block can be the same or different.
[0072] If the block passes consensus at consensus node 2, then consensus node 2 can continue to broadcast the block to the corresponding consensus sub-network 2. This consensus sub-network 2 can include consensus node 2, consensus node 5, consensus node 6 and consensus node 7. In this way, consensus can continue to be reached on the block initiated by the consensus node in consensus sub-network 2. After the consensus is completed, each consensus node in consensus sub-network 2 can also obtain its own consensus result for the block.
[0073] Similarly, if the block passes consensus at consensus node 3, consensus node 3 can continue to broadcast the block to the corresponding consensus sub-network 3. This consensus sub-network 3 can include consensus node 3, consensus node 8, consensus node 9 and consensus node 10. Then, consensus can continue to be reached on the block initiated by the consensus node in the consensus sub-network 3. After the consensus is completed, each consensus node in the consensus sub-network 3 can also obtain its own consensus result for the block.
[0074] Similarly, if the block passes consensus at consensus node 4, then consensus node 4 can continue to broadcast the block to the corresponding consensus sub-network 4. This consensus sub-network 4 can include consensus node 4, consensus node 11, consensus node 12 and consensus node 13. In this consensus sub-network 4, consensus can continue to be reached on the block initiated by the consensus node. After the consensus is completed, each consensus node in the consensus sub-network 4 can also obtain its own consensus result for the block.
[0075] Subsequently, consensus nodes 5, 6, 7, 8, 9, 10, 11, 12, and 13 that have passed consensus on the block can continue to broadcast the block to more consensus nodes in the consensus network (such as broadcasting it to the corresponding consensus sub-network) to continue consensus processing on the block. This allows the block to achieve consensus across the entire consensus network by spreading and broadcasting the block in various consensus sub-networks.
[0076] Furthermore, consensus nodes in the consensus network that have reached consensus on a block can broadcast their consensus results across the entire network. If each consensus node receives a number of consensus results for a block that is greater than or equal to a certain threshold, it indicates that the block has passed network-wide consensus and can be added to the blockchain. For example, the block can be added to the blockchain to which the consensus network belongs. The specific process of reaching consensus on blocks described above can also be found in the following... Figure 3 The description in the corresponding embodiment.
[0077] By using the method provided in this application, consensus on blocks can be achieved in various small networks (such as various consensus sub-networks) instead of in the entire large-scale consensus network. This reduces the communication complexity and the amount of communication during the consensus process, improves the efficiency of consensus on blocks, and enhances the consensus performance of the entire consensus network.
[0078] Please see Figure 3 , Figure 3 This is a flowchart illustrating a data processing method for a consensus network provided in this application. Figure 3 As shown, the method may include:
[0079] Step S101: Receive the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first consensus node and the second consensus node belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node.
[0080] Optionally, the consensus network may include N consensus nodes. These N consensus nodes are blockchain nodes capable of performing consensus processing on blocks that need to be uploaded to the chain. N is a positive integer, and its specific value can be determined based on the actual application scenario. Any consensus node can consist of one or more computer devices, which can be servers or terminal devices, depending on the actual application scenario; there are no restrictions on this.
[0081] The aforementioned N consensus nodes may include a first master node, which is the master node currently proposing a block and is the consensus node currently initiating consensus on the block. Therefore, it can be understood that the executing entity in this embodiment can be the first consensus node, which can be any one of the N consensus nodes other than the first master node.
[0082] Therefore, the first consensus node can receive the first block broadcast by the second consensus node in the second consensus sub-network. This first block is the block that needs to be consensusd. The consensus process of this first block can be initiated by the first master node. The first block can be proposed by the first master node. The first block can be generated by the first master node. This first block can contain any business data that needs to be uploaded to the chain, such as transaction data.
[0083] Optionally, the method provided in this application embodiment can be used to improve the consensus process of TBFT (TendermintBFT, a consensus algorithm). In TBFT, the master nodes in the consensus network are rotated. For example, each consensus node in the consensus network can have a corresponding node number. The master nodes in the consensus network can rotate sequentially according to the node numbers of each consensus node, or the master nodes in the consensus network can rotate according to other strategies. Each consensus node in the consensus network can know the rotation strategy of the master node. Therefore, in the consensus network using TBFT, the consensus nodes do not need to notify each other and can know which consensus node is the master node at each time.
[0084] Therefore, the method provided in this application can be used to transform the large-scale consensus network in TBFT into several smaller networks (such as several consensus sub-networks) to reach consensus on blocks, thereby reducing the amount of data during data broadcasting in the consensus process and reducing the communication complexity during data broadcasting in the consensus process.
[0085] The aforementioned second consensus node can be any one of the N consensus nodes except the first consensus node. The aforementioned second consensus subnetwork can be understood as the consensus subnetwork corresponding to the second consensus node. This second consensus subnetwork is a subnetwork (also called a small network) within the consensus network. This second consensus subnetwork can contain K consensus nodes, where K is a positive integer less than N. The value of K can be smaller than the value of N, and the value of K can be determined based on the actual application scenario. Both the first and second consensus nodes belong to the second consensus subnetwork; that is, the second consensus subnetwork contains both the first and second consensus nodes.
[0086] Of the K consensus nodes mentioned above, the consensus nodes other than the second consensus node can be K-1 consensus nodes selected by the second consensus node from among the N consensus nodes (which can be randomly selected) that are interconnected with the second consensus node. These K-1 consensus nodes can be the consensus nodes to which the second consensus node broadcasts the block that needs consensus when it obtains it. Alternatively, these K-1 consensus nodes can also be consensus nodes that are closer to the second consensus node according to the routing table, or they can be consensus nodes that the second consensus node can broadcast the block that needs consensus to in advance. If these K-1 consensus nodes are pre-set, they can be updated intermittently, such as every certain period of time (e.g., every cycle). When updating, the value of K can also be updated, that is, the number of consensus nodes to which the second consensus node can broadcast the block that needs consensus can also be varied. In other words, the number of consensus nodes to which the second consensus node can broadcast the block that needs consensus can be updated periodically and dynamically. Optionally, the specific method for determining the second consensus node's corresponding second consensus sub-network can be determined based on the actual application scenario, and there are no restrictions on this.
[0087] The aforementioned second consensus subnetwork can be understood as a virtual consensus subnetwork formed when the second consensus node broadcasts the first block, which needs to broadcast the first block. This consensus subnetwork does not have to be a pre-divided independent subnetwork.
[0088] It is understandable that if the second consensus node is the first master node, then the first block broadcast by the second consensus node can be generated by the second consensus node and the consensus process for the first block can be initiated by the second consensus node. If the second consensus node is not the first master node, then the first block broadcast by the second consensus node can be obtained by any of the N consensus nodes other than the first and second consensus nodes broadcasting the first block to the second consensus node. The principle of any of the N consensus nodes other than the first and second consensus nodes broadcasting the first block to the second consensus node is the same as the principle of the second consensus node broadcasting the first block to the first consensus node. For example, it can also be broadcasting the first block to the corresponding consensus subnetwork, which can contain the second consensus node.
[0089] In other words, the first block can initially be generated by the first master node and broadcast to the corresponding consensus sub-network. The first block received by each consensus node in the consensus sub-network corresponding to the first master node can be broadcast by the first master node. The first block received by the consensus nodes among the N consensus nodes other than the consensus nodes included in the consensus sub-network corresponding to the first master node can be broadcast by the consensus nodes among the N consensus nodes other than the first master node.
[0090] Step S102: Perform consensus processing on the first block in the second consensus sub-network; if the first block passes consensus at the first consensus node, broadcast the first block in the first consensus sub-network to which the first consensus node belongs, so that the first block can continue to be processed in the first consensus sub-network; the first consensus sub-network contains M consensus nodes out of N consensus nodes; M is a positive integer less than N.
[0091] Optionally, after receiving the first block broadcast by the second consensus node, the first consensus node can perform consensus processing on the first block within the second consensus sub-network. That is, the consensus nodes in the second consensus sub-network can jointly perform consensus processing on the first block. The consensus nodes in the second consensus sub-network can use the BTFT consensus algorithm to process the first block, which can include three consensus phases: the propose phase, the prevote phase, and the precommit phase. During the prevote and precommit phases, the consensus nodes in the second consensus sub-network need to broadcast data to each other (such as voting data for the first block).
[0092] After all consensus nodes in the second consensus subnetwork reach a consensus on the first block through the aforementioned three consensus stages, each node obtains its own consensus result for the first block. This consensus result can be either a pass or a fail result. Different consensus nodes can obtain the same or different consensus results for the first block. A pass result indicates that the consensus on the first block is successful, and they agree to put the first block on the blockchain. Conversely, a fail result indicates that the consensus on the first block is unsuccessful, and they disagree with putting the first block on the blockchain.
[0093] It is understandable that the first master node mentioned above is the master node of the current entire consensus network, which is used to propose blocks. Regardless of whether the second consensus node is the first master node, the second consensus node can be understood as the "master node" in the second consensus sub-network. That is, it can be understood that in the second consensus sub-network, the second consensus node initiates the consensus proposal for the first block.
[0094] Therefore, if the first block passes consensus at the first consensus node (i.e., the first consensus node obtains its own consensus result for the first block), the first consensus node can continue to broadcast the first block in the corresponding consensus sub-network (which can be called the first consensus sub-network), so that the first block can continue to be processed for consensus in the first consensus sub-network.
[0095] Similarly, the first consensus subnetwork can be a subnetwork (small network) within the consensus network. The first consensus subnetwork can contain M consensus nodes, where M is a positive integer less than N. The value of M can be the same as or different from the value of K mentioned above, depending on the specific application scenario. The consensus nodes other than the first consensus node can be M-1 consensus nodes selected (e.g., randomly selected) from the N consensus nodes that are interconnected with the first consensus node.
[0096] The M-1 consensus nodes can be the consensus nodes to which the first consensus node broadcasts the block requiring consensus (such as the first block) when it obtains it. Alternatively, the M-1 consensus nodes can be consensus nodes selected from the routing table that are closer to the first consensus node by route, or the M-1 consensus nodes can be pre-set consensus nodes to which the first consensus node broadcasts the block requiring consensus. If the M-1 consensus nodes are pre-set, they can be updated intermittently, such as every certain period (e.g., every cycle). During the update, the value of M can also be updated, meaning the number of consensus nodes to which the first consensus node broadcasts the block requiring consensus can also vary. In other words, the number of consensus nodes to which the first consensus node broadcasts the block requiring consensus can be updated periodically and dynamically. Optionally, the specific method for determining the first consensus subnetwork corresponding to the first consensus node can also be determined according to the actual application scenario, and there are no restrictions on this.
[0097] Similarly, the first consensus subnetwork here can also be understood as a virtual consensus subnetwork formed when the first consensus node broadcasts the first block, which needs to broadcast the first block. This consensus subnetwork does not have to be a pre-divided independent subnetwork.
[0098] If consensus on the first block fails at the first consensus node during consensus-building in the second consensus sub-network, then the first consensus node does not need to continue broadcasting the first block to the corresponding first consensus sub-network; it only needs to record the consensus failure result for the first block.
[0099] Similarly, after the first consensus node broadcasts the first block in its first consensus sub-network, each consensus node in the first consensus sub-network can continue to perform the above three-stage consensus processing on the first block. As a result, each consensus node in the first consensus sub-network can also obtain its own consensus result for the first block. This consensus result can be a consensus pass result or a consensus fail result. And so on, the consensus node in the first consensus sub-network that obtains a consensus pass result for the first block can continue to broadcast the first block to the corresponding consensus sub-network, so that the first block can continue to be processed for consensus in that consensus sub-network.
[0100] Similarly, the first master node mentioned above is the master node of the current entire consensus network, which is used to propose blocks; while the first consensus node can be understood as the "master node" in the first consensus sub-network, that is, in the first consensus sub-network, the first consensus node initiates the consensus proposal for the first block.
[0101] Through the above process, it can be understood that the first block is continuously broadcast diffusingly among the consensus sub-networks, allowing for a complete consensus process (including the three consensus stages mentioned above) on the first block in each sub-network. Ultimately, consensus on the first block can be achieved throughout the entire consensus network. Since the latter two consensus stages (prevote and precommit stages) involve broadcasting consensus data (such as voting data) between consensus nodes that need to reach a consensus on the block, the communication complexity is O(N) if data is broadcast across the entire consensus network containing N consensus nodes. 2 ).
[0102] Therefore, using the method provided in this application, when performing consensus processing on blocks in the above three consensus stages, consensus nodes in the latter two consensus stages only need to broadcast consensus data to each other in the corresponding consensus sub-networks, instead of broadcasting consensus data to each other in the entire large-scale consensus network. This reduces the amount of data that needs to be broadcast during the consensus process and lowers the communication complexity during the consensus process.
[0103] The above-mentioned method of broadcasting consensus on the first block in a continuously diffusing manner according to each consensus sub-network can be implemented based on the principle of the gossip protocol (a communication protocol). By transforming the consensus of a large number of nodes into the consensus of several small-scale nodes, the consensus performance of the entire blockchain can be improved.
[0104] Please see Figures 4a-4b , Figures 4a-4b This is a schematic diagram illustrating a block broadcast scenario provided in this application. For example... Figure 4aAs shown, the consensus nodes in the consensus network can include nodes 1 to 14. Node 1 can be the first master node. Node 1 can first broadcast the first block that needs consensus to the corresponding consensus sub-network. The consensus sub-network corresponding to node 1 can include nodes 1, 2, 3, and 4. Then, each consensus node in the consensus sub-network corresponding to node 1 can perform consensus processing on the first block. The consensus node in the consensus sub-network that has passed the consensus on the first block can continue to broadcast the first block to its own corresponding consensus sub-network. Then, each consensus node in the consensus sub-network can continue to perform consensus processing on the first block.
[0105] like Figure 4a As shown, if the first block passes consensus at node 2, node 2 can continue to broadcast the first block to the corresponding consensus subnetwork. This consensus subnetwork can include nodes 2, 5, 6, and 7. Then, each consensus node in the consensus subnetwork corresponding to node 2 can continue to process the consensus on the first block. The consensus nodes in this subnetwork that have passed consensus on the first block can also continue to broadcast the first block to their own corresponding consensus subnetworks, whereby the consensus nodes can continue to process the consensus on the first block.
[0106] like Figure 4b As shown, if the first block passes consensus at node 6, node 6 can then broadcast the first block to its corresponding consensus subnetwork. This consensus subnetwork can include nodes 6, 8, 9, and 14. Similarly, consensus nodes in the consensus subnetwork corresponding to node 6 that have passed consensus on the first block can also broadcast the first block to their respective consensus subnetworks. Furthermore, each consensus node in that subnetwork can continue to process the consensus on the first block, ultimately achieving consensus on the first block throughout the entire consensus network.
[0107] In this consensus network, each consensus node can broadcast the same block only once to the corresponding consensus subnetwork.
[0108] Please see again Figure 5 , Figure 5 This is a schematic diagram illustrating a block consensus scenario provided in this application. For example... Figure 5 As shown, the N consensus nodes in the consensus network can include nodes 0 to 30, with node 0 being the first master node.
[0109] Therefore, node 0 can first broadcast the first block that needs to be consensused in the corresponding consensus subnetwork (including nodes 0 to 4), and then the consensus processing of the first block can be carried out in the consensus subnetwork.
[0110] If consensus on the first block is achieved in the consensus subnetwork corresponding to node 0, and nodes 1 through 4 all pass consensus on the first block, then nodes 1 through 4 can continue to broadcast the first block to their respective consensus subnetworks.
[0111] In this case, the consensus subnetwork corresponding to node 1 can include nodes 1, 5, 6, and 7. Therefore, node 1 can continue to broadcast the first block to nodes 5, 6, and 7. The consensus subnetwork corresponding to node 2 can include nodes 2, 8, 9, and 10. Therefore, node 2 can continue to broadcast the first block to nodes 8, 9, and 10. The consensus subnetwork corresponding to node 3 can include nodes 3, 11, 12, and 13. Therefore, node 3 can continue to broadcast the first block to nodes 11, 12, and 13. The consensus subnetwork corresponding to node 4 can include nodes 4, 14, 15, and 16. Therefore, node 4 can continue to broadcast the first block to nodes 14, 15, and 16.
[0112] Similarly, consensus nodes in each consensus sub-network that pass consensus on the first block can continue to broadcast the first block to the corresponding consensus sub-network for consensus processing. As long as the number of consensus nodes that subsequently pass consensus on the first block in the consensus network is greater than or equal to a certain threshold, the first block can be added to the blockchain. Consensus nodes in each consensus sub-network that fail to pass consensus on the first block do not need to broadcast the first block to more consensus nodes.
[0113] Step S103: Broadcast the consensus result of the first consensus node for the first block in the consensus network, obtain the first number of consensus results of the first block in the consensus network, and perform on-chain processing on the first block according to the first number.
[0114] Optionally, the first consensus node can broadcast its consensus result for the first block throughout the consensus network, allowing other consensus nodes to also know the result. However, if the first block fails to pass consensus at the first consensus node, then the first consensus node does not need to broadcast the failure result.
[0115] Similarly, the first consensus node in the consensus network can also broadcast its consensus on the first block to the corresponding consensus sub-network based on the principle of the gossip protocol. Then, the consensus nodes in the consensus sub-network corresponding to the first consensus node will continue to broadcast the consensus of the first consensus node on the first block to the corresponding consensus sub-network, and so on, until the consensus of the first consensus node on the first block is broadcast throughout the entire consensus network.
[0116] In practice, each consensus node in the consensus network that has reached a consensus on the first block can broadcast its own consensus result for the first block, just as the first consensus node broadcasts its consensus result for the first block within the network. Therefore, each consensus node in the network can obtain the consensus results for the first block from the other consensus nodes.
[0117] Therefore, the first consensus node can also obtain the number of consensus results of the first block in the consensus network (which can be called the first number). This first number is the total number of consensus results of the first block obtained by the first consensus node from all consensus nodes in the entire consensus network.
[0118] Therefore, the first consensus node can process the first block on the blockchain based on this first quantity: if the first quantity is greater than or equal to the quantity threshold, it indicates that the first block has passed consensus in the entire consensus network, and the first consensus node can process the first block on the blockchain, that is, add the first block to the blockchain network. If the first quantity is less than the quantity threshold, it indicates that the first block has not passed consensus in the entire consensus network, and the first consensus node can discard the first block, that is, not process the first block on the blockchain.
[0119] The aforementioned threshold can be 2f+1, where f is the maximum number of malicious nodes supported in the consensus network (i.e., the maximum number of malicious consensus nodes that can be accepted), and N must be greater than or equal to 3f+1.
[0120] Optionally, the consensus result of any consensus node in the consensus network for any block can be the node signature of that consensus node for that block. The first consensus node can cache a set of node signatures associated with the first block. This set of node signatures is used to store the node signatures (i.e., consensus results) of each consensus node in the consensus network for the first block. If the first block passes consensus at the first consensus node, then the set of node signatures can contain the node signature of the first consensus node for the first block.
[0121] Therefore, during the consensus processing of the first block in the consensus network (i.e., the consensus processing of the first block in each consensus subnetwork of the consensus network), the first consensus node can receive node signatures for the first block broadcast by consensus nodes other than the first consensus node among N consensus nodes (the broadcast can be the consensus node's own node signature for the first block, or it can be the node signatures received from other consensus nodes for the first block). The first consensus node can add all the received node signatures for the first block to the node signature set associated with the first block.
[0122] Furthermore, the first consensus node can obtain the number of node signatures in the node signature set associated with the first block. This number is the aforementioned first number. If the first number is greater than or equal to the aforementioned number threshold, the first consensus node can perform on-chain processing (i.e., write to disk, such as adding to the local ledger of the first consensus node).
[0123] Each consensus node in the consensus network can process the first block on the chain according to the principle of the first consensus node. Based on the consensus received for the first block, the first block is processed on the chain through the result.
[0124] Please see Figure 6 , Figure 6 This is a schematic diagram illustrating a scenario of a block proposal provided in this application. For example... Figure 6 As shown, the content of a consensus node's proposal (i.e., the content broadcast) in the corresponding consensus subnetwork can include a Block (such as the first block), the master node's signature on the block (such as the first master node's signature on the first block), a set of node signatures, a set of consensus node IDs (identifiers) for this round (this set can contain the node IDs of all consensus nodes in the current consensus subnetwork), and the current node signature (i.e., the node signature of the "master node" on the block in the current consensus subnetwork).
[0125] The proposal content includes a Block, which can carry the block height and consensus round (i.e., consensus cycle) for that block. This block height and consensus round can be used to uniquely identify the block. The signature of the master node (e.g., the first master node; a master node without quotes represents the master node in the entire consensus network) on the block in the proposal content can be used to confirm the proposal content, that is, to confirm that the current block was initiated by the current master node in the consensus process.
[0126] The node signature set in the proposal can be used to record the node signatures of each consensus node in the consensus network for the first block. The node signature is the consensus result for the first block. It can be understood that when the "master node" (the "master node" in quotes is used to refer to the consensus node that acts as the master node in the corresponding consensus sub-network) first broadcasts the proposal to the corresponding consensus sub-network, the node signature set may initially only contain the node signature of the "master node" for the first block. The node signature set can be continuously updated thereafter.
[0127] The set of consensus node IDs in the proposal can be used to enable each consensus node in the current consensus subnetwork to know clearly which consensus nodes it needs to work with to complete the consensus processing of the block.
[0128] The current node signature is used to confirm that the current proposal content was broadcast by the consensus node that acts as the "master node" in the current consensus subnetwork.
[0129] Furthermore, if the aforementioned second consensus node is the first master node, then the aforementioned K consensus nodes may include the second master node. The second master node refers to the next master node among the N consensus nodes used to rotate the master node from the first master node. That is, the second master node can be the next master node after the first master node used to propose blocks.
[0130] Therefore, after the consensus on the first block broadcast to the second consensus node is completed (e.g., consensus passes), the second master node can initiate a consensus process for the second block within the consensus network. The principle behind the second master node initiating the consensus process for the second block is the same as that of the first master node initiating the consensus process for the first block: both first broadcast to the corresponding consensus sub-network, and then diffusely broadcast the consensus among the various consensus sub-networks of the consensus network. The block height corresponding to the second block can be the next block height after the block height corresponding to the first block.
[0131] It should be noted that the block height corresponding to any block that requires consensus is the block height after the block is uploaded to the blockchain after consensus is reached in the entire consensus network.
[0132] As described above, when the current master node in the consensus network initiates a proposal for a block, it can prioritize broadcasting the block to the next master node (i.e., the consensus sub-network corresponding to the current master node can include the next master node). This allows the next master node to initiate the consensus process for the next block (such as the second block) in advance after completing the consensus on the block broadcast by the current master node. This ensures that the consensus process for the next block can proceed synchronously with the consensus process for the current block, thereby improving the efficiency of block consensus processing.
[0133] In this application, the first consensus node can receive the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first and second consensus nodes belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node in the consensus network; consensus processing of the first block is performed in the second consensus subnetwork; if the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus subnetwork to which the first consensus node belongs, so that the first block continues to be processed for consensus in the first consensus subnetwork; the first consensus subnetwork contains M consensus nodes out of N consensus nodes; M is a positive integer less than N; the consensus passing result of the first consensus node for the first block is broadcast in the consensus network, and the first number of consensus passing results of the first block in the consensus network is obtained, and the first block is processed for on-chain processing according to the first number. Therefore, the method proposed in this application allows each consensus node to broadcast the block within a small area of the consensus network (such as the first consensus sub-network and the second consensus sub-network), and then perform consensus processing on the block within that small area. This can reduce the amount of communication when reaching consensus on the block and improve the consensus efficiency and performance of the consensus network for the block.
[0134] Please see Figure 7 , Figure 7 This is a flowchart illustrating a block processing method provided in this application. Figure 7 As shown, the method includes:
[0135] Step S201: Obtain the third block to be agreed upon; the third block is a block that needs to be agreed upon, initiated by the third master node when it fails to obtain the first block after a timeout. The block height corresponding to the third block is the height of the first block. The third master node is a consensus node among N consensus nodes that is used for master node rotation after the first master node.
[0136] Optionally, the execution entity in this application embodiment can also be the aforementioned first consensus node. The block height corresponding to the aforementioned first block can be the first block height, that is, the first block is the block proposed at the first block height. If the first block passes consensus across the entire network (such as the entire consensus network) (such as the number of consensus results for the first block in the consensus network being greater than or equal to the aforementioned number threshold), then the block height after the first block is on-chain is the first block height.
[0137] The first consensus node can obtain the third block to be agreed upon. This third block can be a block that needs to be agreed upon, initiated by the third master node when it fails to obtain the first block after a timeout. Alternatively, the third block can be a block that needs to be agreed upon, generated by the third master node when it fails to obtain the block proposed at the first block height after a timeout (which could be due to transmission delay or network failure). The block height corresponding to this third block is also the first block height, meaning that the block height corresponding to the first block and the block height corresponding to the third block can be the same.
[0138] At the same block height, one or more rounds of consensus can be initiated for a block. Each round of consensus corresponds to one block that needs to be agreed upon. However, for the same block height, only one block from a single round can be passed by consensus across the entire network. In other words, at the same block height, only one block can be passed by consensus across the entire network. The first and third blocks mentioned above can be blocks that correspond to the same block height but have different consensus rounds.
[0139] The third master node can be one of the N consensus nodes that is used for master node rotation after the first master node. For example, the third master node can be the first master node after the first master node (such as the second master node mentioned above), or the third master node can be the second master node after the first master node, or the third master node can be the third master node after the first master node, and so on.
[0140] The third block obtained by the first consensus node can be broadcast from the third master node, or it can be broadcast by other consensus nodes that have already received the third block initiated by the first consensus node, rather than by the third master node. The principle by which the third master node broadcasts and reaches consensus on the third block in the consensus network can be the same as that of the first master node broadcasting and reaching consensus on the first block, such as through diffusion-based consensus broadcasting between various consensus sub-networks.
[0141] Step S202: Perform consensus processing on the third block; if consensus processing on the third block is completed, then cache the third block.
[0142] Optionally, the first consensus node can process the obtained third block. If it has completed the consensus processing for the second block, it can cache the third block first, and subsequently obtain consensus results from other consensus nodes in the consensus network for the third block. Furthermore, after completing the consensus processing for the third block, the first consensus node can obtain the consensus result for the third block, which can be either a consensus pass or a consensus fail. That is, after completing the consensus processing for the third block, the first consensus node will cache the third block regardless of whether it has reached consensus on it.
[0143] It's important to note that typically, a consensus node can only approve one block at a given block height. This means a node can only vote in favor of a block in any round of consensus within the same block height (i.e., pass the consensus). Furthermore, once a node has voted in favor of a block, it cannot subsequently vote against it (i.e., fail the consensus). However, there's a special exception: if a node votes against a block and obtains a number of passed consensus results for that block in the network, and this number is greater than or equal to a threshold, then the block has passed consensus across the entire network, and the node can change its vote against the block to a vote in favor.
[0144] Similarly, after completing the consensus processing of the first block, regardless of whether the first consensus node obtains a consensus pass result or a consensus failure result for the first block, the first consensus node can also cache the first block so that it can continue to obtain consensus pass results for the first block from other consensus nodes in the consensus network in the future.
[0145] Therefore, the first consensus node can also obtain the number of consensus results for the third block in the consensus network (which can be called the second number). If this second number is greater than or equal to the aforementioned threshold, it indicates that the third block has passed consensus in the entire consensus network. Therefore, the first consensus node can add the third block to the chain and delete the first block. At the same block height, only one block can be passed by consensus. That is, in multiple rounds of consensus at the same block height, only one round of blocks can have a consensus pass count in the consensus network that is greater than or equal to the threshold.
[0146] Therefore, if the second number of consensus results of the third block in the consensus network is greater than or equal to the number threshold, then the first number of consensus results of the first block in the consensus network will inevitably not be greater than or equal to the number threshold. That is, after the third block achieves consensus (i.e., passes consensus) in the entire consensus network, the first block will not achieve consensus in the entire consensus network.
[0147] Similarly, if the first quantity is greater than or equal to the quantity threshold, then the second quantity will not be greater than or equal to the quantity threshold. At this time, the first block passes consensus in the entire consensus network, the first consensus node can process the first block on the chain, and can delete the cached third block.
[0148] Furthermore, in this application, since multiple blocks may be proposed for consensus at the same block height, meaning the first consensus node may have cached multiple blocks at the same block height with the same block height, the following describes how to determine the parent block of the next block height from the cached blocks when the next block height is obtained:
[0149] In this application, block weights can be added to each cached block. The parent block of each block is then selected based on these block weights. The larger the block weight, the more trustworthy the corresponding block is at the current block height. The smaller the block weight, the less trustworthy the corresponding block is at the current block height. The following explanation uses the first and third blocks as examples. If there are more blocks at the same block height, the processing logic between each pair of blocks is similar, as described below.
[0150] The first consensus node can obtain the block weight of the first block based on the number of sub-blocks of the first block cached. The block weight of the first block can then be equal to the number of sub-blocks of the first block cached by the first consensus node.
[0151] Similarly, the first consensus node can also obtain the block weight of the third block based on the number of sub-blocks of the third block cached by the first consensus node. The block weight of the third block can then be equal to the number of sub-blocks of the third block cached by the first consensus node.
[0152] Within any given block, the child blocks can include block a, which is the parent block of the given block; block b, which is the parent block of block a; block c, which is the parent block of block b; block d, which is the parent block of block c; and so on. In other words, the child blocks of any given block can contain all blocks that can be traced back to the given block by continuously going upwards (i.e. backwards) to their parent blocks.
[0153] The sibling blocks of any block refer to all blocks whose corresponding block height is the same as the block height of that block. Since the first block and the third block both correspond to the height of the first block, the first block and the third block can be sibling blocks of each other.
[0154] As can be seen from the above, if the block weight of a certain block is larger, it means that more subsequent blocks will use that block as the basis for consensus. Conversely, if the block weight of a certain block is smaller, it means that fewer subsequent blocks will use that block as the basis for consensus. Therefore, the larger the block weight, the more trustworthy the corresponding block is at the current block height.
[0155] Then, the first node can obtain the fourth block to be agreed upon. The block height corresponding to this fourth block can be called the second block height, which can be the next block height after the first block height. For example, if the first block height is 99, then the second block height can be 100. Optionally, the fourth block can be the aforementioned second block, or it can be a sibling block of the second block.
[0156] Therefore, if the block corresponding to the height of the first block in the cache only contains the first block and the third block, and the block weight of the first block is greater than the block weight of the third block, then the first consensus node can use the first block as the parent block of the fourth block and perform consensus processing on the fourth block.
[0157] If the block corresponding to the height of the first cached block contains only the first block and the third block, and the block weight of the first block is less than the block weight of the third block, then the first consensus node can use the third block as the parent block of the fourth block and perform consensus processing on the fourth block.
[0158] If the block corresponding to the height of the first cached block contains only the first block and the third block, and the block weight of the first block is equal to the block weight of the third block, then the first consensus node can arbitrarily choose one of the first and third blocks as the parent block of the fourth block and perform consensus processing on the fourth block.
[0159] Similarly, if the first consensus node completes the consensus processing of the fourth block and obtains a consensus result for the fourth block (which may be a consensus pass result or a consensus fail result), then the first consensus node can also cache the fourth block.
[0160] The first consensus node can also obtain the number of consensus results for the fourth block in the consensus network. It's understandable that if a block passes consensus in the consensus network, all its parent blocks that can be traced back to it will also pass consensus. Therefore, if the number of consensus results for the fourth block in the consensus network is greater than or equal to the threshold, and the parent block of the fourth block is the first block, it indicates that both the fourth and first blocks will pass consensus in the entire consensus network. The first consensus node can then delete the cached third block and the sibling blocks of the fourth block, and can add the cached first and fourth blocks to the blockchain.
[0161] If, due to network latency, the first consensus node obtains a consensus result in the number of fourth blocks being greater than or equal to the threshold, but has not yet obtained a consensus result in the number of first blocks being greater than or equal to the threshold, then the first consensus node can wait until it obtains a consensus result in the number of first blocks being greater than or equal to the threshold before processing the first and fourth blocks on the chain.
[0162] Similarly, if the number of consensus results for the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the third block, it indicates that the fourth block and the third block will be passed by consensus in the entire consensus network. The first consensus node can delete the cached first block and the sibling blocks of the fourth block, and can put the cached third block and the fourth block on the chain.
[0163] In other words, if a cached block is passed by consensus in the entire consensus network, then the block and all parent blocks that can be traced back to the block (i.e., upwards, such as blocks whose height is less than the height of the block) can be added to the chain. Furthermore, the sibling blocks of the block and all sibling blocks of the parent blocks that can be traced back to the block can be deleted.
[0164] Furthermore, after determining the parent block of the fourth block, completing the consensus processing for the fourth block, and caching the fourth block, the first consensus node can also update the block weight of the first block, the block weight of the third block, and the block weight of the fourth block based on the cached fourth block and its parent block.
[0165] If the parent block of the fourth block is the first block, then updating the block weight of the first block can mean adding 1 to the existing block weight of the first block. If the parent block of the fourth block is the third block, then updating the block weight of the third block can mean adding 1 to the existing block weight of the third block. The block weight added to the latest cached fourth block can be equal to 0.
[0166] Please see Figure 8 , Figure 8 This is a schematic diagram illustrating a scenario for setting block weights provided in this application. For example... Figure 8 As shown, the first consensus node can cache blocks 1, 2, 22, 3, 33, 4, 44 and 444.
[0167] Block 2 and Block 22 are blocks at the same level. The block height of Block 2 is the same as that of Block 22. Block 2 and Block 22 are blocks that have reached consensus through proposals in different rounds at the same block height. Block 2 and Block 22 can be consensus-initiated by different consensus nodes.
[0168] Similarly, blocks 3 and 33 are blocks of the same level. The block height of block 3 is the same as that of block 33. Block 3 and 33 are blocks that have reached consensus through proposals in different rounds at the same block height. Block 3 and 33 can be consensus-initiated by different consensus nodes.
[0169] Furthermore, blocks 4, 44, and 444 are blocks of the same level. The block heights corresponding to blocks 4, 44, and 444 are the same. Blocks 4, 44, and 444 can be blocks that have reached consensus through proposals in different rounds at the same block height. Blocks 4, 44, and 444 can also be blocks that have reached consensus through proposals in different rounds at the same block height.
[0170] The block that any block arrow points to is the parent block of that block. Here, the parent blocks of block 2 and block 22 are both block 1, the parent block of block 3 is block 2, the parent block of block 33 is block 22, and the parent blocks of block 4, block 44 and block 444 are all block 3.
[0171] Here, the block weight can be denoted as β. Block 1's sub-blocks can include 7 sub-blocks: Block 2, Block 22, Block 3, Block 33, Block 4, Block 44, and Block 444. Therefore, Block 1's block weight is 7. Block 2's sub-blocks can include 4 sub-blocks: Block 3, Block 4, Block 44, and Block 444. Therefore, Block 2's block weight is 4. Block 22's sub-blocks include only one sub-block: Block 33. Block 22 has a block weight of 1; Block 3 has three sub-blocks: Block 4, Block 44, and Block 444, so its block weight is 3; Block 33 has no following sub-blocks, so its block weight is 0. Similarly, Block 4, Block 44, and Block 444 have no following sub-blocks, so their block weights are all 0.
[0172] If a block x with the same height as the blocks corresponding to blocks 3 and 33 needs to be added at this time, then block x can take block 2 as its parent block, because the block weight 4 of block 2 is greater than the block weight 1 of block 22 at this time.
[0173] Please see again Figure 9 , Figure 9 This is a schematic diagram illustrating a block processing scenario provided in this application. For example... Figure 9As shown, the first consensus node can currently cache blocks 1, 2, 22, 3, 33, 4, 44, 444, 5, 55, and 555. Blocks 2 and 22 can be siblings, blocks 3 and 33 can be siblings, blocks 4, 44, and 444 can be siblings, and blocks 5, 55, and 555 can be siblings.
[0174] If the number of consensus results obtained by the first consensus node for block 444 in the consensus network is greater than or equal to the threshold (i.e., 2f+1), it indicates that block 444 has passed consensus in the entire consensus network. Therefore, it can be confirmed that all parent blocks traceable back to block 444 (including blocks 3, 2, and 1) will also pass consensus in the consensus network. Thus, the first consensus node can delete all sibling blocks of its parent blocks (including blocks 22 and 33), delete sibling blocks of block 444 (including blocks 4 and 44), and delete child blocks of sibling blocks of block 444 (including blocks 5 and 55). Since the final consensus result for block 555 in the consensus network is currently uncertain, the cached block 555 can be retained, i.e., block 555 can continue to be cached.
[0175] In this application, corresponding block weights can be added to each cached block. Subsequently, by adding block weights to each cached block, the parent block of a newly cached block can be accurately located, thereby improving the consensus accuracy of the entire network on blocks.
[0176] Please see Figure 10 , Figure 10 This is a schematic diagram of a block consensus process provided in this application. For example... Figure 10 As shown, this process can be executed by any consensus node. 1. Enter a new block height (e.g., block height H, where H is a positive integer), and the consensus round is 0 (rounds can be counted from 0 or from 1).
[0177] 2. The consensus node determines whether it is currently the master node. If not, it proceeds to step 3; if so, it proceeds to step 4.
[0178] 3. Consensus nodes can add timers to wait for proposal messages (the block requiring consensus in the proposal message can be initiated by the current master node).
[0179] 4. Consensus nodes can generate the blocks that currently require consensus.
[0180] 5. A consensus node can randomly select surrounding nodes as the consensus node set for this round. This consensus node set includes the consensus nodes in the consensus sub-network corresponding to that consensus node, and generates a proposal (including the generated block).
[0181] 6. Consensus nodes can broadcast the generated proposals to selected surrounding nodes.
[0182] 7. Consensus nodes can work with surrounding nodes to reach a consensus on the current proposed block.
[0183] 8. Consensus nodes can determine whether they agree on the current consensus block. If consensus fails, proceed to step 9; if consensus succeeds, proceed to step 10.
[0184] 9. Consensus nodes can enter a new consensus round at the current block height and then restart the execution of step 2.
[0185] 10. Consensus nodes can cache the current block and update the weight values (i.e., block weights) of the parent blocks (including all tracing back to the previous parent blocks) of this block in memory.
[0186] 11. Consensus nodes can start a timer and broadcast their approval of the block through an additional protocol (a protocol for executing additional processes, namely broadcasting their approval of the block to the entire network), that is, broadcasting their consensus result for the block.
[0187] 12. Consensus nodes can determine whether there are other node signatures for this block in the cache, that is, whether they have obtained the node signatures (i.e. consensus pass results) of other consensus nodes in the consensus network for this block. If there are, then proceed to step 13. If not, it indicates that the current block has failed to achieve consensus across the entire network, then re-execute step 1.
[0188] 13. Consensus nodes can add all the node signatures for a block they have obtained to the block extension data. This block extension data can include the set of node signatures associated with the block. Adding all the node signatures for a block to the block extension data means adding all the node signatures for a block to the set of node signatures associated with the block.
[0189] 14. The consensus node can determine whether the number of node signatures for the block in the block extension data is greater than or equal to 2f+1. If yes, then proceed to step 15. If not, it indicates that the current block has failed to achieve consensus across the entire network, and then step 1 is re-executed.
[0190] Step 15. The consensus node can write the block to disk, that is, write the block to the local ledger, which is to process the block on the blockchain.
[0191] Please see again Figure 11 , Figure 11 This is a flowchart illustrating an additional method provided in this application. For example... Figure 11 As shown, this process can be executed by any consensus node. 1. A consensus node can receive voting messages broadcast by other consensus nodes through an append protocol. This voting message is obtained by serializing the consensus results of other consensus nodes on the current block (such as the first block). Therefore, the consensus node can deserialize the voting message to obtain an append message object. This append message object includes the node signatures of other consensus nodes for the current block (i.e., the consensus result). This append message object can carry the node ID of the corresponding consensus node, indicating that the append message object was obtained by the consensus node to which the node ID belongs after reaching a consensus on the current block.
[0192] 2. The consensus node can determine whether the currently acquired additional message object has been received. If so, proceed to step 3; otherwise, proceed to step 4.
[0193] 3. Consensus nodes can discard any additional message objects they have just acquired.
[0194] 4. Consensus nodes can verify the legitimacy of the currently obtained additional message object, such as verifying whether it was obtained by the corresponding consensus node signing the current block with its private key (which can be verified using the public key of the corresponding consensus node). If the verification is invalid, proceed to step 3; if the verification is valid, proceed to step 5.
[0195] 5. The consensus node can determine whether the block corresponding to the additional message object has been written to disk (e.g., whether it has been uploaded to the chain). If yes, proceed to step 3; otherwise, proceed to step 6.
[0196] 6. The consensus node can also determine whether it has processed the block corresponding to the additional message object (e.g., whether it has been cached after consensus is completed). If it has not been processed, proceed to step 7; if it has been processed, proceed to step 8.
[0197] 7. Consensus nodes can cache the additional message object first, and then use it after the consensus on the block corresponding to the additional message object is completed.
[0198] 8. Consensus nodes can add the node signature in the additional message object to the block extension data of the corresponding block (i.e., add it to the node signature set associated with the corresponding block).
[0199] 9. Consensus nodes can determine whether the number of node signatures for the block in the block extension data is greater than or equal to 2f+1. If yes, proceed to step 10. If not, it indicates that the current block has failed to achieve consensus across the entire network, and the processing of the current block ends.
[0200] Step 10. The consensus node can write the block to disk, that is, write the block to the local ledger, which is to process the block on the blockchain.
[0201] Please see Figure 12 , Figure 12 This is a schematic diagram of the structure of a data processing device for a consensus network provided in this application. The data processing device for the consensus network can be a computer program (including program code) running on a computer device. For example, the data processing device for the consensus network is an application software, and it can be used to execute the corresponding steps in the method provided in the embodiments of this application. The consensus network contains N consensus nodes, where N is a positive integer, and the N consensus nodes include a first master node. The device is applied to the first consensus node, which is any one of the N consensus nodes other than the first master node, such as... Figure 12 As shown, the data processing device 1 of the consensus network may include: a receiving module 11, a consensus module 12, and an acquisition module 13.
[0202] The receiving module 11 is used to receive the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first consensus node and the second consensus node belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node;
[0203] Consensus module 12 is used to perform consensus processing on the first block in the second consensus sub-network. If the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus sub-network to which the first consensus node belongs, so that the first block can continue to be processed in the first consensus sub-network. The first consensus sub-network contains M consensus nodes out of N consensus nodes. M is a positive integer less than N.
[0204] The acquisition module 13 is used to broadcast the consensus passing result of the first consensus node for the first block in the consensus network, obtain the first number of consensus passing results of the first block in the consensus network, and perform on-chain processing of the first block according to the first number.
[0205] Optionally, among the K consensus nodes, the consensus nodes other than the second consensus node are K-1 consensus nodes selected by the second consensus node from among the N consensus nodes and connected to the second consensus node; among the M consensus nodes, the consensus nodes other than the first consensus node are M-1 consensus nodes selected by the first consensus node from among the N consensus nodes and connected to the first consensus node.
[0206] If the second consensus node is the first master node, then the first block broadcast by the second consensus node is generated by the second consensus node; if the second consensus node is not the first master node, then the first block broadcast by the second consensus node is obtained by any consensus node among the N consensus nodes other than the first and second consensus nodes broadcasting to the second consensus node.
[0207] Optionally, the consensus result of any consensus node for any block in the consensus network refers to the node signature of any consensus node for any block. The first block has an associated set of node signatures, and the set of node signatures contains the node signature of the first consensus node for the first block.
[0208] Module 13 obtains the first number of consensus results passed by the first block in the consensus network, and the method for processing the first block on the chain based on the first number, including:
[0209] During the consensus processing of the first block in the consensus network, the node signatures for the first block broadcast by the consensus nodes other than the first consensus node among the N consensus nodes are received, and the received node signatures are added to the node signature set.
[0210] Get the first number of node signatures in the node signature set. If the first number is greater than or equal to the number threshold, then process the first block to be added to the chain.
[0211] Optionally, if the second consensus node is the first master node, then the K consensus nodes include the second master node. The second master node refers to the next master node among the N consensus nodes used to rotate the master node from the first master node.
[0212] The second master node is used to initiate the consensus process for the second block in the consensus network after the consensus of the first block broadcast to the second consensus node has been passed. The block height corresponding to the second block is the next block height after the block height corresponding to the first block.
[0213] Optionally, the block height corresponding to the first block is the first block height; the device 1 described above is also used for:
[0214] Obtain the third block pending consensus; the third block is a block that needs to be consensused initiated by the third master node when it fails to obtain the first block after a timeout. The block height corresponding to the third block is the height of the first block. The third master node is a consensus node among N consensus nodes that is used for master node rotation after the first master node.
[0215] Perform consensus processing on the third block; if consensus processing on the third block is completed, then cache the third block.
[0216] Optionally, the above-mentioned device 1 is also used for:
[0217] If consensus processing for the first block is completed, then cache the first block;
[0218] The aforementioned device 1 is also used for:
[0219] If the second number of consensus results for the third block in the consensus network is obtained, and the second number is greater than or equal to the number threshold, then the third block is added to the chain, and the cached first block is deleted.
[0220] Optionally, the method by which the acquisition module 13 processes the first block onto the chain based on the first quantity includes:
[0221] If the first quantity is greater than or equal to the quantity threshold, then the first block is added to the chain and the cached third block is deleted.
[0222] Optionally, the above-mentioned device 1 is also used for:
[0223] The block weight of the first block is determined based on the number of sub-blocks of the first block in the cache.
[0224] The block weight of the third block is determined based on the number of sub-blocks of the cached third block;
[0225] Among them, a sibling block of any block refers to a block whose corresponding block height is the same as that of any block; the first block and the third block are sibling blocks of each other.
[0226] The block weights of the first and third blocks are used to determine the parent block of the fourth block. The block height corresponding to the fourth block is the height of the second block, which is the next block height after the height of the first block.
[0227] Optionally, the above-mentioned device 1 is also used for:
[0228] Obtain the fourth block pending consensus;
[0229] If the block weight of the first block is greater than the block weight of the third block, then the first block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
[0230] If the block weight of the first block is less than the block weight of the third block, then the third block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
[0231] Optionally, if the number of consensus results of the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the first block, then the first consensus node is used to delete the cached third block and the sibling blocks of the fourth block, and to process the first block and the fourth block on the chain.
[0232] If the number of consensus results passed by the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the third block, then the first consensus node is used to delete the cached first block and the sibling blocks of the fourth block, and is used to process the third block and the fourth block on the chain.
[0233] Among them, a sibling block of any block refers to a block whose corresponding block height is the same as that of any other block. The first block and the third block are sibling blocks of each other.
[0234] Optionally, the above-mentioned device 1 is also used for:
[0235] If consensus processing for the fourth block is completed, then cache the fourth block.
[0236] Based on the cached fourth block and its parent block, update the block weights of the first block, the third block, and the fourth block.
[0237] According to one embodiment of this application, Figure 3 The steps involved in the data processing method of the consensus network shown can be derived from... Figure 12 The consensus network's data processing device 1, as shown, executes this process. For example, Figure 3 Step S101 shown can be performed by Figure 12 The receiving module 11 in the middle is used to perform the operation. Figure 3 Step S102 shown can be performed by Figure 12 The consensus module 12 in the middle is used to execute; Figure 3 Step S103 shown can be performed by Figure 12 The acquisition module 13 in the middle is used to execute.
[0238] In this application, the first consensus node can receive the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first and second consensus nodes belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node in the consensus network; consensus processing of the first block is performed in the second consensus subnetwork; if the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus subnetwork to which the first consensus node belongs, so that the first block continues to be processed for consensus in the first consensus subnetwork; the first consensus subnetwork contains M consensus nodes out of N consensus nodes; M is a positive integer less than N; the consensus passing result of the first consensus node for the first block is broadcast in the consensus network, and the first number of consensus passing results of the first block in the consensus network is obtained, and the first block is processed for on-chain processing according to the first number. Therefore, it can be seen that each consensus node of the device proposed in this application can broadcast the block within a small area of the consensus network (such as the first consensus sub-network and the second consensus sub-network), and then perform consensus processing on the block within the small area. This can reduce the amount of communication when performing consensus on the block, and can improve the consensus efficiency and performance of the consensus network for the block.
[0239] According to one embodiment of this application, Figure 12 The modules in the data processing device 1 of the consensus network shown can be individually or entirely merged into one or more units, or some of these units can be further divided into multiple functionally smaller sub-units to achieve the same operation without affecting the technical effects of the embodiments of this application. The above modules are based on logical functional division. In practical applications, the function of one module can be implemented by multiple units, or the function of multiple modules can be implemented by one unit. In other embodiments of this application, the data processing device 1 of the consensus network may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0240] According to one embodiment of this application, a general-purpose computer device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can perform operations such as... Figure 3 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 12The data processing apparatus 1 for the consensus network shown herein, and the data processing method for implementing the consensus network according to the embodiments of this application, are also described. The aforementioned computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the computer-readable recording medium, and run therein.
[0241] Please see Figure 13 , Figure 13 This is a schematic diagram of the structure of a computer device provided in this application. For example... Figure 13 As shown, the computer device 1000 may include a processor 1001, a network interface 1004, and a memory 1005. Furthermore, the computer device 1000 may also include a user interface 1003 and at least one communication bus 1002. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 13 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.
[0242] exist Figure 13 In the computer device 1000 shown, the network interface 1004 provides network communication functionality; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0243] The first block broadcast by the second consensus node in the second consensus subnetwork is received; the second consensus subnetwork contains K consensus nodes out of N consensus nodes, and both the first consensus node and the second consensus node belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node in the consensus network.
[0244] Consensus processing of the first block is performed in the second consensus subnetwork. If the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus subnetwork to which the first consensus node belongs, so that the first block can continue to be processed in the first consensus subnetwork. The first consensus subnetwork contains M consensus nodes out of N consensus nodes; M is a positive integer less than N.
[0245] Broadcast the consensus result of the first consensus node for the first block in the consensus network, obtain the first number of consensus results for the first block in the consensus network, and process the first block on the chain according to the first number.
[0246] Optionally, among the K consensus nodes, the consensus nodes other than the second consensus node are K-1 consensus nodes selected by the second consensus node from among the N consensus nodes and connected to the second consensus node; among the M consensus nodes, the consensus nodes other than the first consensus node are M-1 consensus nodes selected by the first consensus node from among the N consensus nodes and connected to the first consensus node.
[0247] If the second consensus node is the first master node, then the first block broadcast by the second consensus node is generated by the second consensus node; if the second consensus node is not the first master node, then the first block broadcast by the second consensus node is obtained by any consensus node among the N consensus nodes other than the first and second consensus nodes broadcasting to the second consensus node.
[0248] Optionally, the consensus result of any consensus node for any block in the consensus network refers to the node signature of any consensus node for any block. The first block has an associated set of node signatures, and the set of node signatures contains the node signature of the first consensus node for the first block.
[0249] Processor 1001 can also be used to call device control applications stored in memory 1005 to achieve:
[0250] During the consensus processing of the first block in the consensus network, the node signatures for the first block broadcast by the consensus nodes other than the first consensus node among the N consensus nodes are received, and the received node signatures are added to the node signature set.
[0251] Get the first number of node signatures in the node signature set. If the first number is greater than or equal to the number threshold, then process the first block to be added to the chain.
[0252] Optionally, if the second consensus node is the first master node, then the K consensus nodes include the second master node. The second master node refers to the next master node among the N consensus nodes used to rotate the master node from the first master node.
[0253] The second master node is used to initiate the consensus process for the second block in the consensus network after the consensus of the first block broadcast to the second consensus node has been passed. The block height corresponding to the second block is the next block height after the block height corresponding to the first block.
[0254] Optionally, the block height corresponding to the first block is the first block height; the processor 1001 can also be used to call the device control application stored in the memory 1005 to achieve:
[0255] Obtain the third block pending consensus; the third block is a block that needs to be consensused initiated by the third master node when it fails to obtain the first block after a timeout. The block height corresponding to the third block is the height of the first block. The third master node is a consensus node among N consensus nodes that is used for master node rotation after the first master node.
[0256] Perform consensus processing on the third block; if consensus processing on the third block is completed, then cache the third block.
[0257] Optionally, the processor 1001 can also be used to call the device control application stored in the memory 1005 to achieve:
[0258] If consensus processing for the first block is completed, then cache the first block;
[0259] Processor 1001 can also be used to call device control applications stored in memory 1005 to achieve:
[0260] If the second number of consensus results for the third block in the consensus network is obtained, and the second number is greater than or equal to the number threshold, then the third block is added to the chain, and the cached first block is deleted.
[0261] Optionally, the processor 1001 can also be used to call the device control application stored in the memory 1005 to achieve:
[0262] If the first quantity is greater than or equal to the quantity threshold, then the first block is added to the chain and the cached third block is deleted.
[0263] Optionally, the processor 1001 can also be used to call the device control application stored in the memory 1005 to achieve:
[0264] The block weight of the first block is determined based on the number of sub-blocks of the first block in the cache.
[0265] The block weight of the third block is determined based on the number of sub-blocks of the cached third block;
[0266] The block weights of the first and third blocks are used to determine the parent block of the fourth block. The block height of the fourth block is the height of the second block, which is the next block height after the height of the first block.
[0267] Optionally, the processor 1001 can also be used to call the device control application stored in the memory 1005 to achieve:
[0268] Obtain the fourth block pending consensus;
[0269] If the block weight of the first block is greater than the block weight of the third block, then the first block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
[0270] If the block weight of the first block is less than the block weight of the third block, then the third block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
[0271] Optionally, if the number of consensus results of the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the first block, then the first consensus node is used to delete the cached third block and the sibling blocks of the fourth block, and to process the first block and the fourth block on the chain.
[0272] If the number of consensus results passed by the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the third block, then the first consensus node is used to delete the cached first block and the sibling blocks of the fourth block, and is used to process the third block and the fourth block on the chain.
[0273] Among them, a sibling block of any block refers to a block whose corresponding block height is the same as that of any other block. The first block and the third block are sibling blocks of each other.
[0274] Optionally, the processor 1001 can also be used to call the device control application stored in the memory 1005 to achieve:
[0275] If consensus processing for the fourth block is completed, then cache the fourth block.
[0276] Based on the cached fourth block and its parent block, update the block weights of the first block, the third block, and the fourth block.
[0277] It should be understood that the computer device 1000 described in the embodiments of this application can execute the foregoing text. Figure 3 The description of the data processing method for the consensus network in the corresponding embodiments can also be performed as described above. Figure 12The description of the data processing device 1 of the consensus network in the corresponding embodiments will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.
[0278] Furthermore, it should be noted that this application also provides a computer-readable storage medium storing a computer program executed by the data processing device 1 of the consensus network mentioned above. The computer program includes program instructions, which, when executed by the processor, enable the execution of the aforementioned... Figure 3 The description of the data processing method for the consensus network in the corresponding embodiments is already provided and will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer storage medium embodiments related to this application, please refer to the description of the method embodiments of this application.
[0279] As an example, the above program instructions can be deployed and executed on a single computer device, or deployed and executed on multiple computer devices located in one location, or executed on multiple computer devices distributed across multiple locations and interconnected via a communication network. Multiple computer devices distributed across multiple locations and interconnected via a communication network can form a blockchain network.
[0280] The aforementioned computer-readable storage medium can be the data processing apparatus of the consensus network provided in any of the foregoing embodiments or the internal storage unit of the aforementioned computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device. Furthermore, the computer-readable storage medium can include both internal storage units and external storage devices of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0281] This application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned... Figure 3The data processing method for the consensus network described in the corresponding embodiments will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer-readable storage medium embodiments related to this application, please refer to the description of the method embodiments of this application.
[0282] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0283] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0284] The methods and related apparatuses provided in this application are described with reference to the method flowcharts and / or structural diagrams provided in this application. Specifically, each block of the method flowchart and / or structural diagram, as well as combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to create a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, generate instructions for implementing the process. Figure 1 A schematic diagram of one or more processes and / or structures. Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 A schematic diagram of one or more processes and / or structures. Figure 1The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 A process or multiple processes and / or structures illustrate the steps of the functions specified in one or more boxes.
[0285] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A data processing method for a consensus network, characterized in that, The consensus network is used to reach consensus on blocks based on the TBFT consensus algorithm. The consensus network contains N consensus nodes, where N is a positive integer, and the N consensus nodes include the first master node. The method is executed by a first consensus node, which is any one of the N consensus nodes other than the first master node; the method includes: The system receives the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork contains K consensus nodes out of the N consensus nodes, and both the first consensus node and the second consensus node belong to the second consensus subnetwork, where K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process for the first block is initiated by the first master node; The first block is processed for consensus in the second consensus sub-network; if the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus sub-network to which the first consensus node belongs, so that the first block continues to be processed for consensus in the first consensus sub-network; the first consensus sub-network contains M consensus nodes out of the N consensus nodes; M is a positive integer less than N; the first consensus sub-network and the second consensus sub-network process the first block for consensus based on the TBFT consensus algorithm respectively; The consensus results of the first consensus node for the first block are broadcast in the consensus network, and a first number of consensus results for the first block in the consensus network is obtained, and the first block is processed on the chain according to the first number; the consensus results refer to the consensus results of each consensus node for the first block, and the first number is the total number of consensus results for the first block obtained by the first consensus node in the entire consensus network.
2. The method according to claim 1, characterized in that, The consensus nodes other than the second consensus node among the K consensus nodes are K-1 consensus nodes selected by the second consensus node from the N consensus nodes and connected to the second consensus node; the consensus nodes other than the first consensus node among the M consensus nodes are M-1 consensus nodes selected by the first consensus node from the N consensus nodes and connected to the first consensus node. If the second consensus node is the first master node, then the first block broadcast by the second consensus node is generated by the second consensus node; if the second consensus node is not the first master node, then the first block broadcast by the second consensus node is obtained by any consensus node other than the first consensus node and the second consensus node among the N consensus nodes broadcast to the second consensus node.
3. The method according to claim 1, characterized in that, The consensus result of any consensus node in the consensus network for any block refers to the node signature of any consensus node for any block. The first block has an associated set of node signatures, and the set of node signatures includes the node signature of the first consensus node for the first block. The step of obtaining a first number of consensus pass results for the first block in the consensus network, and performing on-chain processing on the first block based on the first number, includes: During the consensus processing of the first block in the consensus network, node signatures for the first block broadcast by consensus nodes other than the first consensus node among the N consensus nodes are received, and the received node signatures are added to the node signature set. Obtain the first number of node signatures in the node signature set. If the first number is greater than or equal to the number threshold, then process the first block to be added to the chain.
4. The method according to claim 1, characterized in that, If the second consensus node is the first master node, then the K consensus nodes include the second master node, and the second master node refers to the next master node among the N consensus nodes used to rotate the master node of the first master node; The second master node is used to initiate a consensus process for the second block in the consensus network after the consensus of the first block broadcast to the second consensus node has been passed. The block height corresponding to the second block is the next block height after the block height corresponding to the first block.
5. The method according to claim 1, characterized in that, The block height corresponding to the first block is the first block height; the method further includes: Obtain the third block to be agreed upon; the third block is a block that needs to be agreed upon, initiated by the third master node when it fails to obtain the first block within a timeout period. The block height corresponding to the third block is the height of the first block. The third master node is the consensus node among the N consensus nodes that is used for master node rotation after the first master node. Consensus processing is performed on the third block; if consensus processing on the third block is completed, the third block is cached.
6. The method according to claim 5, characterized in that, The method further includes: If consensus processing for the first block is completed, then the first block is cached; The method further includes: If a second number of consensus results for the third block in the consensus network is obtained, and the second number is greater than or equal to a threshold, then the third block is added to the chain, and the cached first block is deleted.
7. The method according to claim 6, characterized in that, The step of uploading the first block to the blockchain according to the first quantity includes: If the first quantity is greater than or equal to the quantity threshold, then the first block is added to the chain, and the cached third block is deleted.
8. The method according to claim 5, characterized in that, The method further includes: The block weight of the first block is determined based on the number of sub-blocks of the first block in the cache. The block weight of the third block is determined based on the number of sub-blocks of the cached third block; The block weights of the first block and the third block are used to determine the parent block of the fourth block. The block height corresponding to the fourth block is the second block height, which is the next block height after the first block height.
9. The method according to claim 8, characterized in that, The method further includes: Obtain the fourth block pending consensus; If the block weight of the first block is greater than the block weight of the third block, then the first block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block. If the block weight of the first block is less than the block weight of the third block, then the third block is used as the parent block of the fourth block, and consensus processing is performed on the fourth block.
10. The method according to claim 9, characterized in that, If the number of consensus results passed by the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the first block, then the first consensus node is used to delete the cached third block and the sibling blocks of the fourth block, and to perform on-chain processing on the first block and the fourth block. If the number of consensus results passed by the fourth block in the consensus network is greater than or equal to the number threshold, and the parent block of the fourth block is the third block, then the first consensus node is used to delete the cached first block and the sibling block of the fourth block, and is used to perform on-chain processing on the third block and the fourth block. Wherein, a sibling block of any block refers to a block whose corresponding block height is the same as that of the block corresponding to any block, and the first block and the third block are sibling blocks of each other.
11. The method according to claim 9, characterized in that, The method further includes: If consensus processing for the fourth block is completed, then the fourth block is cached. Based on the cached fourth block and its parent block, update the block weight of the first block, the block weight of the third block, and the block weight of the fourth block.
12. A data processing apparatus for a consensus network, characterized in that, The consensus network is used to reach consensus on blocks based on the TBFT consensus algorithm. The consensus network contains N consensus nodes, where N is a positive integer, and the N consensus nodes include the first master node. The device is applied to a first consensus node, which is any one of the N consensus nodes other than the first master node; the device includes: The receiving module is used to receive the first block broadcast by the second consensus node in the second consensus subnetwork; the second consensus subnetwork includes K consensus nodes out of the N consensus nodes, both the first consensus node and the second consensus node belong to the second consensus subnetwork, and K is a positive integer less than N; the second consensus node is any one of the N consensus nodes except the first consensus node; the consensus process of the first block is initiated by the first master node; A consensus module is used to perform consensus processing on the first block in the second consensus sub-network. If the first block passes consensus at the first consensus node, the first block is broadcast in the first consensus sub-network to which the first consensus node belongs, so that the first block continues to be processed for consensus in the first consensus sub-network. The first consensus sub-network contains M consensus nodes out of the N consensus nodes, where M is a positive integer less than N. The first consensus sub-network and the second consensus sub-network respectively perform consensus processing on the first block based on the TBFT consensus algorithm. The acquisition module is configured to broadcast the consensus results of the first consensus node for the first block in the consensus network, acquire a first number of consensus results of the first block in the consensus network, and perform on-chain processing on the first block according to the first number; the consensus results refer to the consensus results of each consensus node for the first block, and the first number is the total number of consensus results of each consensus node for the first block acquired by the first consensus node in the entire consensus network.
13. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1-11.
14. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1-11.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed as described in any one of claims 1-11.