Block chain consensus method based on'proposing-endorsing 'and related device
By introducing a two-stage asynchronous consensus protocol of 'proposal-endorsement' in the blockchain system, the problem of difficult to take into account in the existing technology is solved, and efficient transaction processing and security is achieved, suitable for mobile devices. .
Patent Information
- Application Number
- CN202411175182.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-26
AI Technical Summary
The existing blockchain consensus protocol cannot take into account high throughput and high security, and there are problems such as large computing volume, high energy consumption, limited transaction processing capabilities, high consensus latency and difficulty in running on mobile devices.
Adopt a two-stage asynchronous consensus protocol based on 'proposed-endorsement', and introduces asynchronous block generation and endorsement mechanism, allowing multiple nodes to generate blocks in parallel asynchronously, reduces communication overhead, and prevents malicious attacks through endorsement mechanisms, improving the scalability of the system and security.
Improve transaction processing speed, balance scalability and security, reduce energy consumption, reduce consensus latency, and support running on mobile devices, achieving more efficient network bandwidth utilization and transaction throughput.
Smart Images

Figure CN119051833A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain consensus method and related devices based on "proposal-endorsement". Background Art
[0002] Blockchain technology is the foundation of decentralized networks, ensuring the transparency, non-tampering, distribution and anonymity of the network. The blockchain system includes multiple nodes distributed in different geographical locations, and multiple nodes do not trust each other. Each node may have different versions of blockchain data due to network delays, system failures or malicious attacks. The consensus protocol, as one of the core mechanisms of blockchain technology, can allow each node to reach a consensus without a central agency through a series of algorithmic rules, so that all nodes can reach a consensus with each other, ensuring that all honest nodes can reach an agreement on the accuracy and order of the data, and maintaining the integrity and security of the blockchain. It can be seen that the consensus protocol is one of the foundations for achieving trust in distributed networks.
[0003] At present, the existing consensus protocols include proof of work, proof of stake, delegated proof of stake and Byzantine fault tolerance. Among the existing consensus protocols, although proof of work and proof of stake provide strong security, they have the disadvantages of large computational complexity and high energy consumption, which reduces the throughput of the blockchain system and sacrifices scalability. In order to improve scalability, the existing technology has proposed solutions such as proxy POS, sharding protocol, DAG mechanism and weak consensus protocol. These solutions all improve throughput by compromising decentralization, increase the risk of blockchain system being attacked, and thus reduce security.
[0004] In summary, existing technologies cannot achieve both high throughput and high security. Summary of the invention
[0005] The purpose of this application is to solve at least one of the above-mentioned technical deficiencies, especially the technical defect that the prior art cannot take into account both high throughput and high security.
[0006] In a first aspect, an embodiment of the present application provides a blockchain consensus method based on "propose-endorsement", which is applied to each node of the blockchain system, and the method includes:
[0007] Determine whether the node is the proposer node corresponding to the h+1th block; where h is the latest block height of the local chain, and the proposer node corresponding to the h+1th block includes at least one node in the blockchain system;
[0008] If the current node is the proposer node corresponding to the h+1th block, an original block with a block height of h+1 is generated and saved, and the original block is broadcasted in the blockchain system as the first block to be endorsed;
[0009] When receiving a second block to be endorsed generated by another node, save the second block to be endorsed, and determine whether the current node is an endorser node corresponding to the second block to be endorsed;
[0010] If the local node is the endorser node corresponding to the second block to be endorsed, verify the second block to be endorsed, and if the verification passes, generate and broadcast the first endorsement certificate of the second block to be endorsed;
[0011] Receive a second endorsement certificate generated by another node, and determine the verified block corresponding to the second endorsement certificate;
[0012] In the case where the blockchain update rule is met, each target endorsed block with a block height of h+1 is determined from each block stored in the local node, and a valid block is determined from each target endorsed block; wherein the local node obtains at least k endorsement certificates of the target endorsed block, where k is a preset positive integer;
[0013] The local chain is updated according to the valid block.
[0014] In a second aspect, an embodiment of the present application provides a blockchain consensus device based on "propose-endorsement", which is applied to each node of the blockchain system, and the device includes:
[0015] A first judgment module is used to judge whether the node is a proposer node corresponding to the h+1th block; wherein h is the latest block height of the local chain, and the proposer node corresponding to the h+1th block includes at least one node in the blockchain system;
[0016] A block generation module, configured to generate and save an original block with a block height of h+1 if the current node is the proposer node corresponding to the h+1th block, and broadcast the original block as the first block to be endorsed in the blockchain system;
[0017] A second determination module is configured to, upon receiving a second block to be endorsed generated by another node, save the second block to be endorsed, and determine whether the current node is an endorser node corresponding to the second block to be endorsed;
[0018] an endorsement module, configured to verify the second block to be endorsed if the current node is an endorser node corresponding to the second block to be endorsed, and if the verification passes, generate and broadcast a first endorsement certificate of the second block to be endorsed;
[0019] An endorsement certificate receiving module, configured to receive a second endorsement certificate generated by another node, and determine a verified block corresponding to the second endorsement certificate;
[0020] A valid block determination module, configured to determine each target endorsed block with a block height of h+1 from each block stored in the node, and determine a valid block from each target endorsed block, when a blockchain update rule is satisfied; wherein the node obtains at least k endorsement certificates of the target endorsed block, where k is a preset positive integer;
[0021] An updating module is used to update the local chain according to the valid block.
[0022] In a third aspect, an embodiment of the present application provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the blockchain consensus method based on "proposal-endorsement" described in any of the above embodiments.
[0023] In a fourth aspect, an embodiment of the present application provides a computer device, the computer device comprising: one or more processors, and a memory;
[0024] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the blockchain consensus method based on "proposal-endorsement" described in any of the above embodiments are performed.
[0025] This application is designed with a unique "proposal-endorsement" two-stage asynchronous consensus protocol, which introduces asynchronous block generation and endorsement mechanisms. Among them, the asynchronous block generation mechanism allows multiple nodes to generate blocks asynchronously and in parallel, while avoiding high power consumption and low throughput, ensuring the decentralized and asynchronous characteristics of the block generation process, thereby speeding up the block generation speed of the blockchain system and improving throughput. The endorsement mechanism can prevent the blockchain system from being attacked by malicious nodes, thereby improving the security of the blockchain system. Through a unique two-stage proposer-endorser consensus protocol, this application can improve the scalability and throughput of the system without sacrificing the principle of decentralization, and maintain good security to prevent attacks and data tampering. At the same time, it can also reduce the cost of the consensus process. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0027] Figure 1 One of the flowcharts of the blockchain consensus method of "propose-endorsement" in one embodiment;
[0028] Figure 2 The second flowchart of the blockchain consensus method of "propose-endorsement" in one embodiment;
[0029] Figure 3 The third flowchart of the blockchain consensus method of "propose-endorsement" in one embodiment;
[0030] Figure 4 4 is a flowchart of a blockchain consensus method of "propose-endorsement" in one embodiment;
[0031] Figure 5 Schematic diagram of the fifth process of the blockchain consensus method of "propose-endorsement" in one embodiment;
[0032] Figure 6 6 is a flowchart of a blockchain consensus method of "propose-endorsement" in one embodiment;
[0033] Figure 7 A schematic diagram of the structure of a blockchain consensus device of "propose-endorsement" in one embodiment;
[0034] Figure 8 FIG. 1 is a diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0036] The terms involved in this application are explained below.
[0037] Scalability: If the throughput of the entire blockchain system increases as the number of consensus nodes increases, the blockchain system is scalable.
[0038] Lightweight Blockchain: A simplified version of the traditional blockchain that addresses some of the limitations of the traditional blockchain, making the blockchain more suitable for resource-constrained scenarios, such as IoT devices or mobile applications. Lightweight blockchains typically use simplified consensus protocols or verification processes, so that blockchain clients require less computing resources.
[0039] Sharding: A database partitioning technology that is applied to blockchain to improve the scalability of the network. By dividing the network and data into multiple smaller parts, each node only needs to process a part of the data to improve the scalability and performance of the blockchain.
[0040] Directed Acyclic Graph (DAG): A data structure used by some blockchain projects as an alternative method of recording transactions. DAG allows transactions to be processed in parallel, which can theoretically greatly increase transaction speed.
[0041] Proof of Work (PoW): Requires nodes to solve a complex mathematical problem to prove that they have invested a certain amount of work.
[0042] Proof of Stake (PoS): Nodes get the opportunity to create the next block based on the stake they hold.
[0043] Delegated Proof of Stake (DPoS): Nodes that are stakeholders vote to elect a small number of representative nodes (or witness nodes), which are responsible for verifying and creating new blocks.
[0044] Byzantine Fault Tolerance (BFT): A mechanism that allows consensus to be reached even if a certain percentage of nodes fail or behave maliciously, given a certain node size. BFT and its variants (e.g., PBFT, Practical Byzantine Fault Tolerance) are used in some blockchain systems to improve efficiency and security.
[0045] As mentioned in the background technology, the existing blockchain consensus protocol has the problem of not being able to balance high throughput and high security. In addition, the existing technology also has the following shortcomings:
[0046] (1) Limited transaction processing capacity: Traditional blockchain technologies such as Ethereum process transactions relatively slowly, at about 15-30 transactions per second. This greatly limits the feasibility of blockchain technology in a wider range of applications, compared to traditional payment systems that can process tens of thousands of transactions.
[0047] (2) High energy consumption: In particular, the Proof of Work (PoW) protocol is not only computationally intensive but also energy intensive, which puts a lot of pressure on the environment and increases the costs for participants.
[0048] (3) High consensus latency and high network communication overhead: In designs such as the Byzantine Fault Tolerance (BFT) protocol, although they can provide fast consensus and low energy consumption, BFT algorithms require a deterministic node scale. As the number of nodes participating in the consensus increases, the network communication overhead increases. The above disadvantages will lead to high latency in reaching consensus and high network communication overhead.
[0049] (4) Difficult to run on convenient mobile devices: Existing consensus protocols have high requirements on the performance of the running devices, such as storage requirements, computing power, etc. In addition, mobile devices often rely on wireless communication to connect to the network, which leads to poor stability of the network environment of mobile devices. Existing consensus protocols often rely on continuous network communication to ensure the correctness of the consensus results.
[0050] The present application discloses a two-stage lightweight and asynchronous consensus protocol based on "propose-endorsement", which distinguishes the present application's solution from traditional blockchains and new solutions focused on scalability. Unlike the Byzantine Fault Tolerant (BFT) protocol, which provides fast consensus but is difficult to scale in public blockchains due to the increased complexity of communication. The present application introduces a two-stage consensus protocol based on "propose-endorsement". This unique mechanism allows a portion of nodes to generate blocks asynchronously and in parallel, significantly reducing communication overhead and eliminating state synchronization delays in the BFT protocol. At the same time, the present application can also solve the problems of insufficient scalability, low throughput, and conflicts between scalability and system security that are common in existing mainstream blockchain consensus protocols.
[0051] Specifically, the solution provided by this application has at least one of the following advantages:
[0052] (1) Improving transaction processing speed: By introducing a lightweight and asynchronous consensus protocol, this application aims to significantly improve transaction processing speed and achieve high throughput compared to traditional payment systems, enabling it to support a wider range of application scenarios.
[0053] (2) Balancing scalability and security: Through its unique two-stage proposer-endorser consensus protocol, this application is able to improve the scalability of the system without sacrificing the principle of decentralization, while maintaining good security to prevent attacks and data tampering.
[0054] (3) Reduced energy consumption: This application avoids the high energy consumption problem of the traditional PoW protocol. By reducing the amount of calculation and optimizing the consensus process, it reduces the energy consumption of the system operation, making it more environmentally friendly and cost-effective, and can run on mobile phone devices.
[0055] (4) Reduce consensus latency: By reducing communication overhead and achieving fast local consensus, this application reduces the time required to reach consensus, and can quickly and efficiently process transactions and maintain chain stability even when the number of nodes is large.
[0056] (5) Support for running the proposed lightweight consensus protocol on mobile devices: This application has lower device operation requirements because it occupies less network bandwidth, computing resources, etc., and can therefore run on mobile devices.
[0057] In summary, the design of this application aims to overcome the limitations of existing blockchain technology in terms of processing speed, scalability, energy consumption and consensus delay, and to provide a blockchain consensus protocol with more efficient network bandwidth utilization, higher transaction throughput, and can be run on lightweight mobile devices.
[0058] In one embodiment, the blockchain consensus method based on "proposal-endorsement" proposed in the present application can be applied to a blockchain system. The blockchain system may include multiple nodes, and each node may be set at a different geographical location. Each node can receive and forward blocks, and each node maintains the blockchain data corresponding to the node. The blockchain data maintained by a node can be called the local chain of the node. For example, nodes A and B in the blockchain system each maintain their corresponding blockchain data, and at the same time, the blockchain data maintained by node A and the blockchain data maintained by node B may be the same or different. In this example, the blockchain data maintained by node A can be called the local chain of node A, and the blockchain data maintained by node B can be called the local chain of node B.
[0059] In this application, the roles played by nodes can be divided into the following two types:
[0060] (1) Proposer: A node that packages transactions at each block height to generate a new block. In this application, there can be multiple proposer nodes at the same block height, and these proposer nodes can asynchronously generate new blocks based on the current state of the local chain. For example, multiple nodes can asynchronously generate multiple blocks with a block height of 1000.
[0061] (2) Endorser: A node that verifies the data recorded in a block to determine the validity of the block and endorses the block if the verification passes. In some examples, each block can have multiple endorser nodes distributed in the blockchain system.
[0062] It can be understood that for a node in the blockchain system, the role played by the node can be one of the following four situations:
[0063] (1) The node is neither a proposer node nor an endorser node;
[0064] (2) The node is a proposer node but not an endorser node;
[0065] (3) The node is an endorser node but not a proposer node;
[0066] (4) This node is both the proposer node and the endorser node.
[0067] In some embodiments, each node may maintain a block pool respectively. The block pool maintained by each node is used to store generated / received blocks and endorsement certificates corresponding to each generated / received block. For example, the block pool maintained by a node stores block A, block B, and block C, where block A is generated by the node, and block B and block C may be generated by other nodes and received through broadcast. The block pool may store endorsement certificates corresponding to each of the three blocks respectively, and each endorsement certificate stored in the block pool may be obtained by the node endorsing the block as an endorser node, and / or generated by endorsements of other nodes and received through broadcast.
[0068] In some embodiments, the block in the present application may include three states, namely: original block, endorsed block and valid block. Among them, the original block refers to a block generated by the proposer node and has not collected at least k endorsement certificates. The endorsed block may be a block that has collected at least k endorsement certificates to prove the validity of the block. Further, in one example, after the endorsement certificates are collected, an aggregated endorsement certificate can be generated.
[0069] A valid block may be an endorsed block that can be put on the chain. Further, in some embodiments of the present application, each node may locally execute a lightweight consensus protocol after determining the endorsed block, and the consensus protocol confirms the valid block that can be put on the chain by quantifying the score of the endorsed block. For example, a valid block may be an endorsed block with the highest score at the same height.
[0070] In one embodiment, the present application proposes a blockchain consensus method based on "propose-endorsement", which can be applied to each node of the blockchain system (i.e., applied to Figure 1 In each node shown). Figure 1 As shown, the blockchain consensus method based on "proposal-endorsement" may include the following steps:
[0071] S102: Determine whether this node is the proposer node corresponding to the h+1th block.
[0072] Wherein, h is the latest block height of the local chain, that is, the length of the local chain of this node. The proposer node corresponding to the h+1th block includes at least one node in the blockchain system.
[0073] In this step, each node maintains a local chain. Each node can determine whether it is the proposer node corresponding to the h+1th block based on the latest block height h of the local chain. It should be noted that in the same blockchain system, the latest block heights of the local chains corresponding to any two nodes can be the same or different, and each node can asynchronously and in parallel determine whether it is the proposer node of the next block in the local chain based on its corresponding latest block height.
[0074] For example, there are nodes A and B in the blockchain system, the latest block height of the local chain of node A is h1, and the latest block height of the local chain of node B is h2. Node A can determine whether it is the proposer node corresponding to the h1+1th block locally at node A, and node B can determine whether it is the proposer node corresponding to the h2+1th block locally at node B.
[0075] In some examples, the node may execute S102 when the preset trigger rules are met. The specific content of the preset trigger rules may be determined according to the actual situation, and this document does not impose any specific restrictions on this. In one example, the node may determine whether the node is the proposer node corresponding to the h+1th block when the local chain updates the block length. For example, after a valid block with a block height of h is submitted to the local chain, the node may perform local verification to determine whether it is the proposer node of the block height h+1.
[0076] S104: If this node is the proposer node corresponding to the h+1th block, an original block with a block height of h+1 is generated and saved, and the original block is broadcasted in the blockchain system as the first block to be endorsed.
[0077] In this step, when it is determined that this node is the proposer node corresponding to the h+1th block, this node can process the received transaction data and package the transaction data to generate an original block with a block height of h+1. It can be understood that in this application, all nodes in the blockchain system can asynchronously and in parallel perform the judgment and selection of the proposer node and the generation of the original block. For example, in the above example, when h1=h2, if node A determines that node A is the proposer node corresponding to the h1+1th block, and node B determines that node B is the proposer node corresponding to the h2+1th block, then node A and node B can asynchronously and in parallel generate the original block corresponding to the same block height.
[0078] After generating an original block with a block height of h+1, this node can save the generated original block and broadcast the original block in the blockchain system, so that other nodes in the blockchain system can receive the original block and verify and endorse it.
[0079] In one example, when saving the generated original block, the present application may save all block information of the original block in the block pool of the node. In another example, limited by the limited resources of the node, the node may save the block header information in the block pool of the node.
[0080] S106: When receiving the second block to be endorsed generated by other nodes, save the second block to be endorsed, and determine whether the current node is the endorser node corresponding to the second block to be endorsed.
[0081] The second block to be endorsed refers to the original block generated by other nodes.
[0082] In this step, each node in the blockchain system can broadcast the original block generated by the node to other nodes, so that other nodes can verify and endorse the original block generated by the node. At the same time, each node in the blockchain system can also receive the original block generated and broadcasted by other nodes, and verify and endorse the original block generated by other nodes.
[0083] The node may receive the second block to be endorsed generated by other nodes through broadcasting, and save the second block to be endorsed when receiving the second block to be endorsed. In one example, the node may save all block information of the second block to be endorsed in the block pool of the node. In another example, limited by the limited resources of the node, the node may save the block header information of the second block to be endorsed in the block pool of the node.
[0084] When receiving the second block to be endorsed, the node can determine whether it is the endorser node of the second block to be endorsed. That is, whether the node can verify the validity of the block to be endorsed. It can be understood that the specific judgment rule for judging whether the node is the endorser node of the second block to be endorsed can be determined according to the actual situation.
[0085] S108: If this node is the endorser node corresponding to the second block to be endorsed, the second block to be endorsed is verified, and if the verification passes, a first endorsement certificate of the second block to be endorsed is generated and broadcasted.
[0086] In this step, if the node determines that it is the endorser node corresponding to the second block to be endorsed, it can verify the second block to be endorsed to determine the validity of the second block to be endorsed. If the verification is passed, the node can generate a first endorsement certificate for the second block to be endorsed, and broadcast the first endorsement certificate in the blockchain system, so that other nodes can receive and collect the first endorsement certificate generated by the node.
[0087] S110: Receive a second endorsement certificate generated by other nodes, and determine the verified block corresponding to the second endorsement certificate.
[0088] In this step, each node in the blockchain system can broadcast the first endorsement certificate generated by the node to other nodes, and can also receive the second endorsement certificate generated and broadcasted by other nodes. This node can collect the second endorsement certificate generated by other nodes through the blockchain system broadcast mechanism, and determine the verified block corresponding to the second endorsement certificate. Among them, the verified block refers to the block that has passed the validity verification corresponding to the second endorsement certificate. That is, the second endorsement certificate is an endorsement certificate generated by other nodes to verify and endorse the verified block.
[0089] In one example, upon receiving the second endorsement certificate, the node may save the second endorsement certificate to collect endorsement certificates. For example, the node may save the second endorsement certificate in the block pool of the node.
[0090] S112: When the blockchain update rules are met, each target endorsed block with a block height of h+1 is determined in each block saved by this node, and a valid block is determined in each target endorsed block.
[0091] Among them, this node obtains at least k endorsement certificates of the target endorsed block, where k is a preset positive integer. The blockchain update rule refers to the judgment rule used to trigger this node to update the local chain. The specific content of the rule can be determined according to the actual situation, and this article does not make specific restrictions on this.
[0092] In this step, this node can save the blocks generated by itself, blocks generated by other nodes, endorsement certificates generated by itself, and endorsement certificates generated by other nodes. Each block has a group of endorsers, which improves the robustness of the endorsement process to tolerate unexpected problems that may occur in the endorser nodes (for example, offline, crash). In order to prevent collusion between the proposer node and the endorser node and ensure that the endorsement process can be completed quickly, this application sets a lower limit on the number of valid endorsement certificates collected, that is, only after collecting at least k (k ≥ 1) endorsement certificates, the block is considered to have been endorsed and can participate in the consensus process of the block with a block height of h+1.
[0093] Specifically, if the blockchain update rules are met, this node can determine each target endorsed block in each block saved by this node based on each first endorsement certificate and second endorsement certificate saved by this node. Among them, the target endorsed block refers to a block with a block height of h+1 and at least k endorsement certificates collected by this node. This machine can use a target endorsed block as a valid block that can be put on the chain.
[0094] S114: Update the local chain according to the valid block.
[0095] In this step, after determining the valid blocks that can be put on the chain, the node can update the local chain according to the valid blocks. For example, the node can add the valid blocks to the blockchain data maintained by the node, so that the latest block height of the local chain increases by 1.
[0096] In this application, a unique "proposal-endorsement" two-stage asynchronous consensus protocol is designed, which introduces asynchronous block generation and endorsement mechanisms. Among them, the asynchronous block generation mechanism allows multiple nodes to generate blocks asynchronously and in parallel, while avoiding high power consumption and low throughput, ensuring the decentralized and asynchronous characteristics of the block generation process, thereby speeding up the block generation speed of the blockchain system and improving throughput. The endorsement mechanism can prevent the blockchain system from being attacked by malicious nodes, thereby improving the security of the blockchain system. Through a unique two-stage proposer-endorser consensus protocol, this application can improve the scalability and throughput of the system without sacrificing the principle of decentralization, and maintain good security to prevent attacks and data tampering. At the same time, it can also reduce the cost of the consensus process.
[0097] In one embodiment, determining whether the current node is the proposer node corresponding to the h+1th block includes:
[0098] Obtain the first block hash value and the node public key of this node; wherein the first block hash value is the block hash value of the hth block in the local chain;
[0099] Generate a random number, and calculate the sum of the random number and the hash value of the first block to obtain a first sum value;
[0100] Based on the comparison result between the node public key and the first sum value, determine whether this node is the proposer node corresponding to the h+1th block.
[0101] Specifically, in the two-stage consensus protocol proposed in this application, the selection of the proposer node may satisfy at least one of the following conditions:
[0102] (1) Independence. Unlike DPoS, nodes in this application can independently determine whether to act as a proposer node through local data. This independence gives each node greater flexibility because it operates independently of the information of other nodes in the network. The strong robustness of the network comes from its reduced dependence on the online status of individual nodes.
[0103] (2) Randomness. The selection of the proposer node is completely random, ensuring that each node has an equal opportunity to participate in the transaction packaging process and obtain block rewards. This randomization not only promotes fairness, but also reduces the probability of malicious nodes manipulating the block generation process, thereby enhancing the security of the system.
[0104] (3) Verifiability. The selected proposer node must be verifiable by other nodes as a valid block generation node, in order to prevent potential malicious nodes from interfering with the block generation process.
[0105] In order to ensure that the selection of the proposer node meets the above-mentioned independence and randomness requirements, in this embodiment, the selection of the proposer node for each block height can be associated with the following parameters: (1) the block hash value corresponding to the block with a block height of h in the local chain, that is, the first block hash value; (2) the node public key, which can be a key based on asymmetric encryption for identity authentication; (3) a random number to ensure randomness. It can be understood that in this application, the node public key can be any unique information that can authenticate the node, such as the network address of the node. The random number can be a public random seed generated based on a verifiable random function (VRF).
[0106] Specifically, the node can sum the random number with the hash value of the first block, and compare the node public key with the first sum value obtained by summing, to determine whether the node has the right to produce the h+1th block, that is, to determine whether the node is the proposer node corresponding to the h+1th block. Each block height can correspond to multiple proposer nodes.
[0107] It can be understood that the specific comparison method of comparing the node public key with the first sum value can be determined according to the actual situation, and this document does not impose specific restrictions on this. In one example, the 4 bits of the node public key can be compared with the last 4 bits of the first sum value to determine whether the 4 bits of the node public key are equal to the last 4 bits of the first sum value. If the 4 bits of the node public key are equal to the last 4 bits of the first sum value, it can be determined that the current node is the proposer node corresponding to the h+1th block, otherwise, it can be determined that the current node is not the proposer node corresponding to the h+1th block.
[0108] In one embodiment, the random number includes a public random seed and a Nonce value.
[0109] In the present application, generating a random number and calculating the sum of the random number and the first block hash value to obtain a first sum value includes:
[0110] Generate a public random seed and a verification certificate based on a verifiable random function, and broadcast the verification certificate in the blockchain system; the verification certificate is used to verify the validity of the node;
[0111] Generate Nonce value based on proof-of-work function;
[0112] The public random seed, the Nonce value, and the first block hash value are summed to obtain a first sum value.
[0113] Specifically, the Nonce value can be an arbitrary non-repetitive random number output by the proof-of-work function, which is used to prevent Sybil attacks. The public random seed can be a random seed generated by a random beacon protocol based on a verifiable random function, which can change with the change of the latest block height of the local chain. The verifiable random function can also generate a verification certificate. By broadcasting the verification certificate in the blockchain system, other nodes can verify the node based on the verification certificate, ensuring the verifiability of the proposer's node, thereby preventing potential malicious nodes from interfering with the block generation process.
[0114] In this embodiment, the first block hash value, the public random seed and the Nonce value may be summed to obtain a first sum value, thereby ensuring the verifiability of the verifiable node and improving system security.
[0115] In one embodiment, determining whether the current node is an endorser node corresponding to the second block to be endorsed includes:
[0116] Obtain the second block hash value and the node public key of the current node respectively; wherein the second block hash value is the block hash value of the second block to be endorsed;
[0117] According to the comparison result of the second block hash value and the node public key, determine whether this node is the endorser node corresponding to the second block to be endorsed.
[0118] Specifically, in order to solve the problems of block verification and network coverage, the present application introduces a node that can be called an endorser node. The selection of the endorser node can be carried out using the block hash value of the block to be endorsed, rather than using the endorsed block and random beacon. If a block fails to collect enough endorsement proofs, it means that it does not meet the expected coverage, and the system will regard it as an invalid block. The endorser nodes are randomly distributed in the network, which can verify the authenticity of the transactions in the proposed block and attach their own endorsement proofs to it. After the endorsed block is judged to be a valid block, the proposer node at the next height is allowed to mine the block that follows it. Because the network runs asynchronously, the current valid block may not be the final block on the chain. For example, there may be other blocks with higher scores in the network, which may replace the low-scoring blocks on the current chain.
[0119] In this embodiment, the node can compare the block hash value of the second block to be endorsed with the node public key of the node, and determine whether the node is the endorser node corresponding to the second block to be endorsed based on the comparison result. In this way, the selection rule of the endorser node can be simplified to further improve the throughput.
[0120] It can be understood that the specific comparison method of comparing the node public key with the second block hash value can be determined according to the actual situation, and this article does not impose specific restrictions on this. In one example, the 4 bits of the node public key can be compared with the last 4 bits of the second block hash value to determine whether the 4 bits of the node public key are equal to the last 4 bits of the second block hash value. If the 4 bits of the node public key are equal to the last 4 bits of the second block hash value, it can be determined that this node is the endorser node corresponding to the h+1th block, otherwise, it can be determined that this node is not the endorser node corresponding to the h+1th block.
[0121] In one embodiment, determining a valid block in each target endorsed block includes:
[0122] Determine at least one candidate block in each target endorsed block;
[0123] Based on the expression f=H(b) mod w, the score of each candidate block is calculated respectively; where f is the score, H( ) is the preset hash function, b is the block data of the candidate block, and w is a preset constant;
[0124] The maximum value is determined among the scores, and the candidate block corresponding to the maximum value is taken as the valid block.
[0125] Among them, each candidate block can be part or all of each target endorsed block, and the valid block can be determined from each candidate block.
[0126] Specifically, existing consensus algorithms require information from other nodes to determine block consistency. For example, equal-length forks in a PoW-based blockchain system can cause confusion for block-producing nodes. However, in the proposed consensus protocol, the block consistency authentication scheme can determine the only definite main chain locally, thus avoiding this confusion problem.
[0127] One of the purposes of the present application is to quickly and directly confirm a unique block as a valid block. Therefore, the protocol design of the present application is related to the properties of the block, and a hash compression function f=H(b) mod w is introduced to quantify the candidate block b. Function f returns a short hash value, which is used to represent the score of the candidate block. Endorsements from the same endorser for the same block at different times are considered equivalent. For endorsed blocks, the order of endorsement by the endorser will not affect the consensus process. The present application can directly use the candidate block corresponding to the maximum score as a valid block. In this way, the present application can propose a blockchain solution with higher throughput and lower consensus process cost on the basis of ensuring security and decentralization through a unique lightweight consensus protocol.
[0128] It should be noted that each node in the consensus protocol designed in this application performs consensus locally. The local chain status and block generation process between nodes are asynchronous.
[0129] In one embodiment, determining at least one candidate block in each target endorsed block includes:
[0130] Get the first block hash value, which is the block hash value of the hth block in the local chain;
[0131] Extract the third block hash value corresponding to each target endorsed block respectively, where the third block hash value is the block hash value of the previous block pointed to by the target endorsed block;
[0132] At least one candidate block is determined in each target endorsed block; wherein the third block hash value corresponding to the candidate block is the same as the first block hash value.
[0133] In this embodiment, considering that the h+1th block in the blockchain data needs to point to the hth block, the candidate blocks can be determined in each target endorsed block according to the block hash value corresponding to the latest block height in the local chain (i.e., the first block hash value), so that the final determined valid block can point to the hth block of the local chain.
[0134] Specifically, when each node generates an original block with a block height of h+1, it will put the block information of the hth block in the local chain into the original block, so that the newly generated original block points to the hth block in the local chain. When screening candidate nodes, this node can extract the block hash value of the previous block pointed to by each target endorsed block to obtain the third block hash value corresponding to each target endorsed block. This node can use the target endorsed block with the same third block hash value as the first block hash value as a candidate block, so that all candidate blocks are blocks pointing to the hth block of the local chain, and finally ensure that the valid block determined from the candidate block also points to the block of the hth block of the local chain. In this way, the consistency and integrity of the local chain data can be ensured.
[0135] In one embodiment, Figure 2 The blockchain consensus method based on "propose-endorsement" shown includes the following steps:
[0136] Step ①: After a valid block at block height h is submitted to the local chain, the nodes that receive the block can perform local verification to determine whether they are the proposer nodes of block height h+1;
[0137] Step ②: The selection of the proposer node is done asynchronously;
[0138] Step 3: The proposer node packages the transaction and generates an original block with a block height of h+1;
[0139] Step ④: The proposer node broadcasts the original block with a block height of h+1 to the network;
[0140] Step ⑤: The endorser node of each block provides an endorsement certificate (endorser signature) and broadcasts it. For each original block, there is at least one corresponding endorser node in the network that endorses it. Once the original block is endorsed by at least k endorsers, the block will be considered an endorsed block and can participate in the consensus process of the block at height h+1.
[0141] Step ⑥: After receiving the endorsed block at height h+1, any node in the network can use the lightweight consensus mechanism to verify the validity of the block locally. Once the block is valid, the node will update the local chain.
[0142] In one embodiment, the broadcast mechanism of the present application may be: Under the constraint of limited bandwidth, efficient block broadcasting is a necessary condition for improving throughput. The goal of the present application is to propagate blocks to the entire network in the shortest possible time. Therefore, the present application designs a block broadcast mechanism based on asynchronous verifiable information dissemination (AVID) technology, in which each block-producing node in the blockchain network preferentially broadcasts a block summary message of the block, which includes a block header and a block hash, as well as the corresponding brief AVID information. The node that receives the block summary message can calculate the score of the block by the score calculation method described in any of the above embodiments, and use the message content from different senders to retrieve blocks with higher scores in the network. Once a node retrieves the block, the retrieved block can be added to the node's block pool. Nodes with limited resources may choose to keep only the block header. In order to prevent broadcast storms, nodes will not rebroadcast received duplicate blocks. In order to ensure that the information is transmitted to the farthest node in the network, the present application uses the gossip protocol for block diffusion and propagation. The disadvantage of this method is that the block propagation speed is slow. In order to achieve a balance, this application uses AVID technology to speed up message propagation and reduce redundant block propagation.
[0143] In one embodiment, the present application may also include a reward mechanism. Typically, the proposer node, which is the node responsible for block generation, receives a bookkeeping reward. In addition, in order to encourage endorser nodes to sign blocks, it is also important to provide incentives. The present application allocates most of the rewards of block revenue to the proposer node, and uses the remaining part of the block revenue for endorsement incentives. This incentive mechanism is a function that decreases over time. The endorser node can receive an endorsement reward that is inversely proportional to the time the original block was published.
[0144] In some embodiments, the present application proposes a passive "main chain fork elimination" solution to eliminate the main chain fork of the blockchain. Figure 3 As shown in the figure, in each round of the main chain fork elimination mechanism, each node in the blockchain system randomly selects another node to form a node pair and exchange the information of each other's local chain. The nodes in the node pair receive the main chain information of each other and use the block with the highest score to replace the block with the lower score at the corresponding height of the local blockchain, so as to ensure that the local chain state of the node pair is consistent and eliminate forks.
[0145] In the present application, a node pair may include two nodes, namely a first node and a second node. The first node may be used to determine the node of the block to be synchronized between the blockchain maintained by the first node and the blockchain maintained by the second node, and synchronize the blockchain of the first node and the blockchain of the second node accordingly, thereby completing the elimination of the main chain fork. The second node may respond to the request / instruction / data sent by the first node, and thereby complete the elimination of the main chain fork.
[0146] It can be understood that each node in the blockchain system can act as the first node or the second node. When the node is the first node, the paired node of the node is the second node; when the node is the second node, the paired node of the node is the first node.
[0147] When the node is the first node, the steps for eliminating the main chain fork can refer to the following embodiments.
[0148] In one embodiment, Figure 4 As shown, this application proposes a blockchain consensus method based on "propose-endorsement" which also includes the following steps:
[0149] S302: Receive pre-synchronization information sent by a paired node; the paired node is a node other than the current node in the blockchain system.
[0150] The paired node can be another node in the node pair except the current node. The pre-synchronization information includes the block header and score of each block to be compared. Each block to be compared is a block maintained by the paired node with a block height in the interval [TN, T], where T is the discontinuity height and N is the preset length.
[0151] For ease of description and distinction, the following embodiments refer to the blocks maintained by the paired node as paired blocks, and the blocks maintained by the current node as current node blocks.
[0152] For example, the pre-synchronization information may include block data of paired blocks with a block height of [TN, T] in the blockchain maintained by the paired node, and the block data of each paired block includes the block header and score of the block, and the score can be calculated based on the expression f=H(b) mod w.
[0153] In this step, due to the limitation of the actual network bandwidth during the transmission process, this application sets a fixed length N for the information interaction in the main chain fork elimination mechanism. It can be understood that the specific value of N can be determined based on actual factors, and this article does not make specific restrictions on this.
[0154] S304: In order of block height from small to large, compare the block header of the block to be compared with the block header corresponding to the same block height in the local chain to see if they are the same, until the block headers are different and the fork height is determined, or until the comparison of all blocks to be compared is completed.
[0155] Among them, the fork height is the minimum block height with different block headers. If the paired block and the current node block corresponding to the same block height are regarded as a block pair, and the two blocks of the block pair have different block headers, the block pair becomes a forked block pair, then the fork height can be the minimum value of the block heights corresponding to each forked block pair. For example, if the paired block with a block height of 10 has a different block header from the current node block, and the paired block with a block height of 15 also has a different block header from the current node block, then the fork height can be 10.
[0156] In this step, after obtaining the paired block with a block height of [TN, T], the node can compare the block header of the paired block with the block header of the node block at the same block height in ascending order until one of the following conditions is met:
[0157] (1) The block header of the paired block is different from the block header of this node at the same block height;
[0158] (2) Complete the comparison of all blocks to be compared.
[0159] When the above condition (1) is met, this application may use the block height currently being compared as the fork height to determine the main chain fork height between this node and the paired node.
[0160] S306: If the fork height m falls within the interval [TN, T], then when the local score is greater than the remote score, the m-th to h-th blocks in the local chain are sent to the paired node, so that the paired node synchronizes the local chain of the paired node.
[0161] Among them, the local score refers to the block score calculated by the current node, and the remote score refers to the block score calculated by the paired node. Further, in one example, the local score may be the score corresponding to the mth block in the blockchain of the current node, and the remote score may be the score corresponding to the mth block in the blockchain of the paired node.
[0162] In this step, if the fork height falls within the interval [TN, T], it means that there is at least one pair of forked blocks within the block height [TN, T], and the blockchain of this node and the blockchain of the paired node have a fork within the interval of block height [TN, T]. In this case, this node can compare the score corresponding to the mth block in the blockchain of this node (i.e., the local score) with the score corresponding to the mth block in the blockchain of the maintenance node (i.e., the remote score).
[0163] If the local score is greater than the remote score, it indicates that the blockchain of the paired node needs to be synchronized to the blockchain of this node. Therefore, this node can send the m-th to h-th blocks (a total of h - m + 1 blocks) in the local chain to the paired node, so that the paired node can receive the aforementioned m-th to h-th blocks and update and maintain the blockchain of the node accordingly, achieving the elimination of the main chain fork.
[0164] S308: If the fork height m falls within the interval [T - N, T], send the fork height to the paired node when the local score is less than the remote score, to instruct the paired node to send the m-th to h'-th blocks maintained by the paired node, where h' is the latest block height of the paired node.
[0165] In this step, if the local score is less than the remote score, it indicates that this node needs to update the data of the local chain according to the blockchain of the paired node. Therefore, this node can send the fork height to the paired node, so that the paired node returns each paired block with block heights from m to h' (a total of h' - m + 1 blocks) to this node.
[0166] S310: Receive the m-th to h'-th blocks and update the local chain according to the m-th to h'-th blocks.
[0167] In this step, this node can receive each paired block with block heights from m to h' returned by the paired node and update each paired block with block heights from m to h' to the local chain to achieve the elimination of the main chain fork.
[0168] In an example, if h' < h, this node can discard the m-th to h-th blocks of this node in the local chain and update the received m-th to h'-th paired blocks to the local chain, so that the latest block height of the local chain is updated to h'.
[0169] The lightweight consensus protocol designed in this application can quickly reach local consensus and effectively eliminate forks. While expanding the performance of the blockchain, it ensures the security of the blockchain. This solution reduces blockchain forks, guarantees the stable operation of the system, avoids waste of computing resources, and improves the accounting efficiency of the blockchain.
[0170] In an example, to ensure the consistency of the blockchain state after the mechanism runs, the starting heights of the local chain information exchange for each pair of nodes must be the same. The selection of the starting and ending heights of these messages is determined based on the shortest chain in the network. That is, the discontinuous height can be the smaller value of h and h'.
[0171] In one embodiment, as Figure 4 shown, the blockchain consensus method based on "propose - endorse" proposed in this application further includes the following steps:
[0172] S312: If the forking height m does not fall within the interval [T - N, T], then when T < h, send the (T + 1)-th to h-th blocks in the local chain to the paired node, so that the paired node synchronizes the local chain of the paired node.
[0173] In this step, if the forking height does not fall within the interval [T - N, T], it indicates that there is no forking block pair within the block height range of [T - N, T]. Therefore, the main chain forking can be eliminated according to the latest block heights of this node and the paired node. Generally, the node with the larger latest block height has better performance (such as faster communication efficiency and / or faster data processing efficiency). Therefore, the long-chain blockchain can be synchronized to the short-chain blockchain, so that after synchronization, both this node and the paired node maintain the long-chain blockchain.
[0174] Since the discontinuous height is the smaller value of the latest block height h of this node and the latest block height h' of the paired node, when T < h, it indicates that h' < h, and this node maintains the long-chain data chain. Therefore, this node can directly send the (T + 1)-th to h-th blocks in the local chain to the paired node, so that the paired node can update the blockchain accordingly.
[0175] S314: If the forking height m does not fall within the interval [T - N, T], then when T = h, send a block acquisition request to the paired node to instruct the paired node to send the (T + 1)-th to h'-th blocks maintained by the paired node, where h' is the latest block height of the paired node.
[0176] In this step, when T = h, it indicates that h < h', and the paired node maintains the long-chain data chain. Therefore, this node can send a block acquisition request to the paired node, so that the paired node responds to this block acquisition request and returns the paired blocks with block heights from T + 1 to h' to this node.
[0177] S316: Receive the (T + 1)-th to h'-th blocks and update the local chain according to the (T + 1)-th to h'-th blocks.
[0178] In this step, this node can update the paired blocks with block heights from T + 1 to h' sent by the paired node to the local chain, so that the latest block height of the local chain reaches h'.
[0179] In this way, local consensus can be quickly reached and forking can be effectively eliminated. While expanding the performance of the blockchain, the security of the blockchain is ensured. This solution reduces blockchain forking, guarantees the stable operation of the system, avoids waste of computing resources, and improves the accounting efficiency of the blockchain.
[0180] In one embodiment, receive the pre-synchronization information sent by the paired node, including:
[0181] Send a main chain synchronization request to the paired node;
[0182] Upon receiving the synchronization response message returned by the paired node in response to the main chain synchronization request, send the latest block height of the node to the paired node;
[0183] Receive the pre-synchronization information returned by the paired node in response to the latest block height of the current node.
[0184] In this embodiment, the node can send a main chain synchronization request to the paired node and wait for the paired node's confirmation. Once the synchronization response message returned by the paired node is received, the node can send a message to the paired node to notify the paired node of the latest block height of the node. The paired node can determine the discontinuity height based on the received latest block height of the node and return the corresponding pre-synchronization information.
[0185] When the node is the aforementioned second node, the relevant steps of eliminating the main chain fork can refer to the following embodiment.
[0186] In one embodiment, Figure 5 As shown, this application proposes a blockchain consensus method based on "propose-endorsement" which also includes the following steps:
[0187] S502: In response to the main chain synchronization request sent by the paired node, a synchronization response message is returned to the paired node.
[0188] The synchronization response message is used to instruct the paired node to send the latest block height h' of the paired node, and the paired node is a node other than the current node in the blockchain system. The relevant description of the paired node can be found in the above embodiment, and will not be repeated here.
[0189] In this step, when this node receives the main chain synchronization request sent by the paired node, it can return a synchronization response message to the paired node, so that the paired node can respond to the synchronization response message and return the latest block height h' of the paired node to this node.
[0190] S504: Determine the discontinuity height T according to the magnitude relationship between h' and h.
[0191] In this step, the node can determine the discontinuity height T according to the latest block height h' of the paired node and the latest block height h of the node.
[0192] In one example, to ensure the consistency of the blockchain state after the mechanism runs, the starting height of the local chain information exchange of each pair of nodes must be the same. The selection of the starting and ending heights of these messages is based on the shortest chain in the network. That is, the discontinuity height can be the smaller value of h and h'.
[0193] S506: Determine each block to be compared in the local chain according to the discontinuity height T, and generate pre-synchronization information according to each block to be compared.
[0194] The pre-synchronization information includes the block header and score of each block to be compared. Each block to be compared is a block in the local chain whose block height is in the interval [TN, T], and N is a preset length.
[0195] In this step, when the discontinuity height T is determined, the node can use the node blocks with a block height of [TN, T] in the local chain as the blocks to be compared, and generate and synchronize information based on the block header and local score of each block to be compared.
[0196] S508: Send pre-synchronization information to the paired node, and receive the synchronization comparison result returned by the paired node in response to the pre-synchronization information.
[0197] In this step, the node can send pre-synchronization information to the paired node, so that the paired node can obtain the block information of each node block with a block height of [TN, T] in the local chain, and determine the main chain fork accordingly. The paired node can return the synchronization comparison result to the node based on the main chain fork.
[0198] The steps for the paired node to determine the main chain fork situation can refer to the steps performed when this node acts as the first node, which will not be repeated in this article.
[0199] S510: If the synchronization comparison result is a block, update the local chain according to the received block.
[0200] In this step, if the node receives a block sent by the paired node, it means that the node needs to update the blockchain of the paired node to the local chain. In this case, the node can update the local chain based on the received block to eliminate the main chain fork.
[0201] S512: If the synchronization comparison result is a block height or a block acquisition request, some blocks in the local chain are returned to the paired node.
[0202] In this step, if the node receives a block height or block acquisition request from the partner node, it indicates that the partner node needs to update the blockchain of the node to the blockchain of the partner node. In this case, the node can return some blocks in the local chain to the partner node, so that the partner node can update its blockchain based on the received blocks.
[0203] This embodiment can quickly reach local consensus and effectively eliminate forks, while expanding blockchain performance and ensuring the security of the blockchain. This solution reduces blockchain forks, ensures the stable operation of the system, avoids waste of computing resources, and improves the accounting efficiency of the blockchain.
[0204] In one embodiment, if the synchronization comparison result is a block height or a block acquisition request, some blocks in the local chain are returned to the paired node, including:
[0205] If the synchronization comparison result is fork height m, the m~hth block in the local chain is sent to the paired node;
[0206] If the synchronization comparison result is a block acquisition request, the T+1~hth block in the local chain is sent to the paired node.
[0207] In this embodiment, if the current node receives the fork height m returned by the paired node, it indicates that there is at least one fork block pair within the block height [TN, T], and the local score of the current node is greater than the remote score of the paired node. In this case, the paired node can send the mth to hth blocks in the local chain of the current node, so that the paired node can receive the aforementioned mth to hth blocks, and update the blockchain of the maintenance node accordingly, so as to eliminate the main chain fork.
[0208] If this node receives a block acquisition request sent by the paired node, it means that there is no forked block pair within the block height [TN, T], and compared with the paired node, this node maintains longer chain data. In this case, the T+1~hth block in the local chain can be sent to the paired node, so that the paired node can update the blockchain accordingly. After the paired node is updated, the latest block heights of this node and the paired node are both h.
[0209] In one example, the main chain fork elimination mechanism of the present application can be as follows: Figure 6 shown.
[0210] First, the first node (i.e. Figure 6 Node 1) sends a main chain information synchronization request and waits for the second node (i.e. Figure 6 Once the response is received, the first node sends a message to inform the second node of the current block height. The second node obtains this height and compares it with the current block height of the second node's local chain, and then regards the lower height as the discontinuity height T, which is used as the reference point for preparing pre-synchronization information. The pre-synchronization information includes the block headers and corresponding scores of a series of blocks within the range of 30 block heights before T on the second node's local chain. If T is less than 30, the block headers and corresponding scores of all blocks on the current local chain are taken.
[0211] After the first node receives the pre-sync information from the second node, the first node matches the corresponding information on the local chain to find the discontinuity height. The bifurcation point of the chain is determined by comparing the scores of the blocks at the next height of the discontinuity height: if the score of the block from the second node is less than the score of the block at the same height on the first node, it means that the second node is on the fork. In this case, the first node sets the update signal to "remote update" and sends a message to the second node about some subsequent blocks on the local chain starting from the fork height m. The second node receives this message and uses it for the local blockchain update, and then replies to the first node that the main chain synchronization is complete.
[0212] On the contrary, if the score of the block from the second node is greater than the score of the block at the same height on the first node, it means that the first node is on a fork, and the first node sets the update signal to "local update" and sends a message to notify the second node of the height of the blockchain fork. The block information on the local chain prepared by the second node is sent to the first node. Finally, the first node updates the local chain to complete the main chain state synchronization between the node pairs.
[0213] The following is a description of a blockchain consensus device based on “proposal-endorsement” provided in an embodiment of the present application. The blockchain consensus device based on “proposal-endorsement” described below and the blockchain consensus method based on “proposal-endorsement” described above can refer to each other.
[0214] In one embodiment, the present application provides a blockchain consensus device 700 based on "propose-endorsement", which is applied to each node of the blockchain system. Figure 7 As shown, the device 700 includes:
[0215] The first judgment module 710 is used to judge whether the node is the proposer node corresponding to the h+1th block; wherein h is the latest block height of the local chain, and the proposer node corresponding to the h+1th block includes at least one node in the blockchain system;
[0216] The block generation module 720 is configured to generate and save an original block with a block height of h+1 if the current node is the proposer node corresponding to the h+1th block, and broadcast the original block as the first block to be endorsed in the blockchain system;
[0217] A second determination module 730 is configured to, upon receiving a second block to be endorsed generated by another node, save the second block to be endorsed, and determine whether the current node is an endorser node corresponding to the second block to be endorsed;
[0218] The endorsement module 740 is configured to verify the second block to be endorsed if the node is an endorser node corresponding to the second block to be endorsed, and if the verification passes, generate and broadcast a first endorsement certificate of the second block to be endorsed;
[0219] The endorsement certificate receiving module 750 is used to receive a second endorsement certificate generated by another node, and determine the verified block corresponding to the second endorsement certificate;
[0220] The valid block determination module 760 is used to determine each target endorsed block with a block height of h+1 from each block stored in the node, and determine a valid block from each target endorsed block, when the blockchain update rule is satisfied; wherein the node obtains at least k endorsement certificates of the target endorsed block, where k is a preset positive integer;
[0221] The updating module 770 is used to update the local chain according to the valid block.
[0222] In one embodiment, the first determination module 710 of the present application includes:
[0223] A first data acquisition unit, configured to acquire a first block hash value and a node public key of the local node; wherein the first block hash value is a block hash value of the hth block in the local chain;
[0224] A first summing unit, used to generate a random number, and calculate the sum of the random number and the first block hash value to obtain a first sum value;
[0225] A proposer node determination unit is used to determine whether the node is the proposer node corresponding to the h+1th block based on a comparison result between the node public key and the first sum value.
[0226] In one embodiment, the random number includes a public random seed and a Nonce value. The first summing unit of the present application includes:
[0227] A verifiable information generation unit, configured to generate the public random seed and the verification certificate based on a verifiable random function, and broadcast the verification certificate in the blockchain system; wherein the verification certificate is used to verify the validity of the node;
[0228] A Nonce value generating unit, configured to generate the Nonce value based on a proof-of-work function;
[0229] A summation calculation unit is used to sum the public random seed, the Nonce value and the first block hash value to obtain the first summation value.
[0230] In one embodiment, the second determination module 730 of the present application includes:
[0231] A second data acquisition unit, configured to respectively acquire a second block hash value and a node public key of the local node; wherein the second block hash value is a block hash value of the second block to be endorsed;
[0232] The endorser node determination unit is used to determine whether the node is the endorser node corresponding to the second block to be endorsed according to the comparison result between the second block hash value and the node public key.
[0233] In one embodiment, the valid block determination module 760 of the present application includes:
[0234] A candidate block determining unit, configured to determine at least one candidate block from each of the target endorsed blocks;
[0235] A score calculation unit, used to calculate the score of each candidate block based on the expression f=H(b) mod w; wherein f is the score, H( ) is a preset hash function, b is the candidate block, and w is a preset constant;
[0236] The valid block selection unit is used to determine a maximum value among the scores and use the candidate block corresponding to the maximum value as the valid block.
[0237] In one embodiment, the candidate block determination unit of the present application includes:
[0238] A first block hash value obtaining unit, configured to obtain a first block hash value, where the first block hash value is a block hash value of an h-th block in the local chain;
[0239] A third block hash value acquisition unit, configured to respectively extract a third block hash value corresponding to each of the target endorsed blocks, wherein the third block hash value is a block hash value of a previous block pointed to by the target endorsed block;
[0240] A candidate block selection unit is used to determine at least one candidate block in each of the target endorsed blocks; wherein the third block hash value corresponding to the candidate block is the same as the first block hash value.
[0241] In one embodiment, the blockchain consensus device 700 based on "propose-endorsement" of the present application further includes:
[0242] A pre-synchronization information receiving module, configured to receive pre-synchronization information sent by a paired node; the paired node is a node in the blockchain system other than the present node; the pre-synchronization information includes the block headers and scores of each block to be compared, and each block to be compared is a block whose block height maintained by the paired node is within the interval [T - N, T], where T is the discontinuous height and N is a preset length;
[0243] A block comparison module, configured to sequentially compare whether the block headers of the blocks to be compared are the same as the block headers corresponding to the same block height in the local chain in ascending order of block height until the block headers are different and the fork height is determined, or until all the blocks to be compared are completed; wherein, the fork height is the smallest block height at which the block headers are different;
[0244] A first block sending module, configured to, if the fork height m falls within the interval [T - N, T], send the m-th to h-th blocks in the local chain to the paired node when the local score is greater than the remote score, so that the paired node synchronizes the local chain of the paired node;
[0245] A fork height sending module, configured to, if the fork height m falls within the interval [T - N, T], send the fork height to the paired node when the local score is less than the remote score, to instruct the paired node to send the m-th to h'-th blocks maintained by the paired node, where h' is the latest block height of the paired node;
[0246] A first block receiving module, configured to receive the m-th to h'-th blocks and update the local chain according to the m-th to h'-th blocks.
[0247] In one embodiment, the discontinuous height is the smaller value of h and h'.
[0248] In one embodiment, the blockchain consensus device 700 based on "propose - endorse" of the present application further includes:
[0249] A second block sending module, configured to, if the fork height m does not fall within the interval [T - N, T], send the (T + 1)-th to h-th blocks in the local chain to the paired node when T < h, so that the paired node synchronizes the local chain of the paired node;
[0250] A block acquisition request sending module, configured to, if the fork height m does not fall within the interval [T - N, T], send a block acquisition request to the paired node when T = h, to instruct the paired node to send the (T + 1)-th to h'-th blocks maintained by the paired node, where h' is the latest block height of the paired node;
[0251] The second block receiving module is used to receive the T+1~h'th block and update the local chain according to the T+1~h'th block.
[0252] In one embodiment, the first block receiving module of the present application includes:
[0253] A main chain synchronization request sending unit, used to send a main chain synchronization request to the paired node;
[0254] A latest block height sending unit, configured to send the latest block height of the node to the paired node upon receiving a synchronization response message returned by the paired node in response to the main chain synchronization request;
[0255] The return information receiving unit is used to receive the pre-synchronization information returned by the paired node in response to the latest block height of the local node.
[0256] In one embodiment, the blockchain consensus device 700 based on "propose-endorsement" of the present application further includes:
[0257] A synchronization response message sending module, used to respond to the main chain synchronization request sent by the paired node and return a synchronization response message to the paired node; the synchronization response message is used to instruct the paired node to send the latest block height h' of the paired node, and the paired node is a node in the blockchain system other than the current node;
[0258] A discontinuity height determination module, used to determine the discontinuity height T according to the magnitude relationship between h' and h;
[0259] A pre-synchronization information generation module, used to determine each block to be compared in the local chain according to the discontinuity height T, and generate pre-synchronization information according to each block to be compared; wherein the pre-synchronization information includes a block header and a score of each block to be compared, each block to be compared is a block in the local chain whose block height is within the interval [TN, T], and N is a preset length;
[0260] A pre-synchronization information sending module, used to send the pre-synchronization information to the paired node, and receive the synchronization comparison result returned by the paired node in response to the pre-synchronization information;
[0261] A first local chain synchronization module, configured to update the local chain according to the received block if the synchronization comparison result is a block;
[0262] The second local chain synchronization module is used to return some blocks in the local chain to the paired node if the synchronization comparison result is a block height or a block acquisition request.
[0263] In one embodiment, the second local chain synchronization module includes:
[0264] A first block sending unit, configured to send the m-th to h-th blocks in the local chain to the paired node if the synchronization comparison result is the fork height m;
[0265] The second block sending unit is used to send the T+1~hth block in the local chain to the paired node if the synchronization comparison result is the block acquisition request.
[0266] In one embodiment, the discontinuity height is the smaller value of h and h'.
[0267] In one embodiment, the present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the blockchain consensus method based on "proposal-endorsement" in any embodiment.
[0268] In one embodiment, the present application further provides a computer device for acting as a node in a blockchain system. The computer device stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the blockchain consensus method based on "propose-endorsement" in any embodiment.
[0269] Indicatively, Figure 8 The internal structure diagram of a computer device provided in an embodiment of the present application is shown in FIG. 1 . In one example, the computer device may be a server. Figure 8 , the computer device 900 includes a processing component 902, which further includes one or more processors, and a memory resource represented by a memory 901 for storing instructions executable by the processing component 902, such as an application. The application stored in the memory 901 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 902 is configured to execute instructions to perform the steps of the blockchain consensus method based on "propose-endorsement" described in any of the above embodiments.
[0270] The computer device 900 may further include a power supply component 903 configured to perform power management of the computer device 900, a wired or wireless network interface 904 configured to connect the computer device 900 to a network, and an input / output (I / O) interface 905. The computer device 900 may operate based on an operating system stored in the memory 901, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0271] Those skilled in the art will understand that the internal structure of the computer device shown in the present application is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0272] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements. Herein, "one", "one", "said", "the" and "it" may also include plural forms, unless the context clearly indicates another way. A plurality refers to at least two cases, such as 2, 3, 5 or 8, etc. "And / or" includes any and all combinations of the relevant listed items.
[0273] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0274] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A blockchain consensus method based on "proposal-endorsement", characterized in that: Applied to each node of the blockchain system, the method includes: Determine whether the node is the proposer node corresponding to the h+1th block; where h is the latest block height of the local chain, and the proposer node corresponding to the h+1th block includes at least one node in the blockchain system; If the current node is the proposer node corresponding to the h+1th block, an original block with a block height of h+1 is generated and saved, and the original block is broadcasted in the blockchain system as the first block to be endorsed; When receiving a second block to be endorsed generated by another node, save the second block to be endorsed, and determine whether the current node is an endorser node corresponding to the second block to be endorsed; If the local node is the endorser node corresponding to the second block to be endorsed, verify the second block to be endorsed, and if the verification passes, generate and broadcast the first endorsement certificate of the second block to be endorsed; Receive a second endorsement certificate generated by another node, and determine the verified block corresponding to the second endorsement certificate; In the case where the blockchain update rule is met, each target endorsed block with a block height of h+1 is determined from each block stored in the local node, and a valid block is determined from each target endorsed block; wherein the local node obtains at least k endorsement certificates of the target endorsed block, where k is a preset positive integer; The local chain is updated according to the valid block.
2. The method according to claim 1, characterized in that The determining whether the current node is the proposer node corresponding to the h+1th block includes: Obtain a first block hash value and a node public key of the local node; wherein the first block hash value is a block hash value of the hth block in the local chain; Generate a random number, and calculate the sum of the random number and the first block hash value to obtain a first sum value; Based on the comparison result between the node public key and the first sum value, determine whether the current node is the proposer node corresponding to the h+1th block.
3. The method according to claim 2, characterized in that The random number includes a public random seed and a Nonce value; The generating a random number and calculating the sum of the random number and the first block hash value to obtain a first sum value includes: Generate the public random seed and the verification certificate respectively based on the verifiable random function, and broadcast the verification certificate in the blockchain system; wherein the verification certificate is used to verify the validity of the node; Generate the Nonce value based on the proof-of-work function; The public random seed, the Nonce value, and the first block hash value are summed to obtain the first sum value.
4. The method according to claim 1, characterized in that The determining whether the current node is an endorser node corresponding to the second block to be endorsed includes: Obtaining a second block hash value and a node public key of the local node respectively; wherein the second block hash value is a block hash value of the second block to be endorsed; According to the comparison result of the second block hash value and the node public key, it is determined whether the current node is the endorser node corresponding to the second block to be endorsed.
5. The method according to any one of claims 1 to 4, characterized in that: Determining a valid block in each of the target endorsed blocks includes: Determine at least one candidate block in each of the target endorsed blocks; Calculate the score of each candidate block respectively based on the expression f = H(b) mod w; where f is the score, H( ) is a preset hash function, b is the candidate block, and w is a preset constant; Determine the maximum value among the scores, and use the candidate block corresponding to the maximum value as the valid block.
6. The method according to claim 5, characterized in that The determining at least one candidate block in each of the target endorsed blocks includes: Obtain a first block hash value, which is the block hash value of the h-th block in the local chain; Extract the third block hash value corresponding to each target endorsed block respectively, where the third block hash value is the block hash value of the previous block pointed to by the target endorsed block; Determine at least one of the candidate blocks in each of the target endorsed blocks; where the third block hash value corresponding to the candidate block is the same as the first block hash value.
7. The method according to claim 5, characterized in that The method further includes: Receive pre-synchronization information sent by a paired node; the paired node is a node other than the present node in the blockchain system; the pre-synchronization information includes the block headers and scores of each block to be compared, and each block to be compared is a block maintained by the paired node with a block height in the interval [T - N, T], T is the discontinuous height, and N is a preset length; Compare whether the block headers of the blocks to be compared are the same as the block headers corresponding to the same block height in the local chain in ascending order of block height until the block headers are different and the fork height is determined, or until all the blocks to be compared are completed; where the fork height is the smallest block height at which the block headers are different; If the fork height m falls within the interval [T - N, T], send the (m to h)-th blocks in the local chain to the paired node when the local score is greater than the remote score, so that the paired node synchronizes its local chain; If the fork height m falls within the interval [T - N, T], send the fork height to the paired node when the local score is less than the remote score, to instruct the paired node to send the (m to h')-th blocks maintained by the paired node, where h' is the latest block height of the paired node; Receive the (m to h')-th blocks and update the local chain according to the (m to h')-th blocks.
8. The method according to claim 7, characterized in that The discontinuous height is the smaller value of h and h'.
9. The method according to claim 8, characterized in that The method further includes: If the fork height m does not fall within the interval [T - N, T], send the (T + 1 to h)-th blocks in the local chain to the paired node when T < h, so that the paired node synchronizes its local chain; If the fork height m does not fall within the interval [T - N, T], send a block acquisition request to the paired node when T = h, to instruct the paired node to send the (T + 1 to h')-th blocks maintained by the paired node, where h' is the latest block height of the paired node; Receive the T+1~h'th block, and update the local chain according to the T+1~h'th block.
10. The method according to claim 7, characterized in that The receiving of pre-synchronization information sent by the paired node comprises: Sending a main chain synchronization request to the paired node; Upon receiving a synchronization response message returned by the paired node in response to the main chain synchronization request, sending the latest block height of the node to the paired node; Receive the pre-synchronization information returned by the paired node in response to the latest block height of the local node.
11. The method according to claim 5, characterized in that The method further comprises: In response to the main chain synchronization request sent by the paired node, return a synchronization response message to the paired node; the synchronization response message is used to instruct the paired node to send the latest block height h' of the paired node, and the paired node is a node in the blockchain system other than the current node; According to the size relationship between h' and h, determine the discontinuity height T; According to the discontinuity height T, each block to be compared is determined in the local chain, and pre-synchronization information is generated according to each block to be compared; wherein the pre-synchronization information includes a block header and a score of each block to be compared, and each block to be compared is a block in the local chain whose block height is within the interval [TN, T], and N is a preset length; Sending the pre-synchronization information to the paired node, and receiving a synchronization comparison result returned by the paired node in response to the pre-synchronization information; If the synchronization comparison result is a block, updating the local chain according to the received block; If the synchronization comparison result is a block height or a block acquisition request, some blocks in the local chain are returned to the paired node.
12. The method according to claim 11, characterized in that If the synchronous comparison result is a block height or a block acquisition request, returning some blocks in the local chain to the paired node, including: If the synchronization comparison result is the fork height m, sending the mth to hth blocks in the local chain to the paired node; If the synchronization comparison result is the block acquisition request, the T+1~hth block in the local chain is sent to the paired node.
13. The method according to claim 11, characterized in that The discontinuity height is the smaller value of h and h'.
14. A blockchain consensus device based on "propose-endorsement", characterized in that: Applied to each node of the blockchain system, the device includes: A first judgment module is used to judge whether the node is a proposer node corresponding to the h+1th block; wherein h is the latest block height of the local chain, and the proposer node corresponding to the h+1th block includes at least one node in the blockchain system; A block generation module, configured to generate and save an original block with a block height of h+1 if the current node is the proposer node corresponding to the h+1th block, and broadcast the original block as the first block to be endorsed in the blockchain system; A second determination module is configured to, upon receiving a second block to be endorsed generated by another node, save the second block to be endorsed, and determine whether the current node is an endorser node corresponding to the second block to be endorsed; an endorsement module, configured to verify the second block to be endorsed if the current node is an endorser node corresponding to the second block to be endorsed, and if the verification passes, generate and broadcast a first endorsement certificate of the second block to be endorsed; An endorsement certificate receiving module, used to receive a second endorsement certificate generated by another node, and determine a verified block corresponding to the second endorsement certificate; A valid block determination module, configured to determine each target endorsed block with a block height of h+1 from each block stored in the node, and determine a valid block from each target endorsed block, when a blockchain update rule is satisfied; wherein the node obtains at least k endorsement certificates of the target endorsed block, where k is a preset positive integer; An updating module is used to update the local chain according to the valid block.
15. A storage medium, characterized in that: The storage medium stores computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the "proposal-endorsement"-based blockchain consensus method as described in any one of claims 1 to 13.
16. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the "proposal-endorsement"-based blockchain consensus method as described in any one of claims 1 to 13.
Citation Information
Patent Citations
Block generation method and device, block chain node and storage medium
CN110399424A
Block chain network consensus preloading method and device, equipment and storage medium
CN114254050A
Consensus method and device, terminal and storage medium
CN115622713A
Zero-knowledge proof for blockchain endorsement
US20200322128A1
