Block finalization method and system
By setting checkpoints at certain blocks in the blockchain system and using IBFT consensus for voting, it solves the problems of low transaction throughput and difficulty in determining forks in traditional PoW-type blockchains, achieving high throughput and security. The blockchain system ensures the security of the blockchain system and the continuity of transactions.
Patent Information
- Application Number
- CN202210646534.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-06-09
AI Technical Summary
The transaction throughput of the traditional PoW-type blockchain consensus system is low, and it is difficult to quickly determine the final chain when forking, resulting in a long waiting time for finalization.
Set checkpoints every preset number of blocks in the consensus system, and vote on the directions between checkpoints through IBFT consensus. When the checkpoints reach the justified and finalized states, they are finalized to ensure system security and high throughput. , and at the same time, the chain with the largest number of consensus votes is selected as the main chain when the network is partitioned.
It improves transaction throughput, reduces block finalization time, ensures system security and no forks, solves the problem of traditional PoW-type forks being difficult to determine the final chain, and prevents conflicts through the cheating penalty module.
Smart Images

Figure CN114900529B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular, to a block finalization method and system, and more particularly, to a block finalization method and system based on IBFT. Background Art
[0002] The traditional PoW-based blockchain consensus system uses a highly difficult competitive block generation mechanism to ensure the security of the system, that is, it will not be easily forked. However, based on this highly difficult competitive block generation mechanism, such as the difficulty of the PoW consensus system based on Satoshi Nakamoto, only one block is generated every 10 minutes, and the transaction throughput is very low.
[0003] Patent document CN107864198B (application number: 201711084448.6) discloses a blockchain consensus method based on deep learning training tasks, including that all blockchain participating nodes jointly maintain a ledger record, any node can publish transactions, and distribute them to each node through a P2P consensus network. There will be deep learning task nodes in the P2P consensus network, which will distribute deep learning tasks to all participating nodes. The accounting nodes combine the deep learning tasks through an inter-node consensus mechanism to reach a consensus and complete the transaction confirmation. Summary of the invention
[0004] In view of the defects in the prior art, an object of the present invention is to provide a block finalization method and system.
[0005] A block finalization method provided according to the present invention includes:
[0006] Step S1: Set checkpoints every preset number of blocks in the consensus system;
[0007] Step S2: Node S sets the direction between checkpoint A and checkpoint B that meets the preset rules;
[0008] Step S3: Other nodes in the consensus system perform consensus voting on the directions between the checkpoints set by node S; when the directions between the checkpoints obtain the consensus votes of a preset number of nodes, and checkpoint A is in the justified state, the currently pointed checkpoint B reaches the finalized state, and the checkpoint is finalized; when there is a network partition, it means that the checkpoint is forked, waiting for the network to recover, and the chain with the most consensus votes is selected as the main chain to continue finalization;
[0009] The justified state indicates that there are blocks following the checkpoint, and there are blocks following the previous checkpoint of the current checkpoint.
[0010] Preferably, the node S sets the pointing between the checkpoints that meet the preset rules including: the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint, and the signature of <hash value of the source checkpoint, hash value of the target checkpoint, block height of the source checkpoint, block height of the target checkpoint>.
[0011] Preferably, the node S is set to satisfy the predetermined rule that the directions between the checkpoints are: the node S is set to satisfy the following conditions: the directions between the checkpoints cannot be set repeatedly and the directions between the checkpoints cannot be set cyclically;
[0012] The inability to repeatedly set the direction between checkpoints means that the target checkpoint heights of the pointing proposals between checkpoints published by the same node cannot be the same;
[0013] The inability to set the pointing between checkpoints cyclically means that the height of the pointing proposal between checkpoints released by the same node cannot be included in the height of the pointing proposal between previously released checkpoints.
[0014] Preferably, the step S3 adopts: other nodes in the consensus system vote on the directions between the checkpoints set by the node S through IBFT consensus or BFT consensus.
[0015] Preferably, it also includes: when the directions between the checkpoints set by the node S do not meet the preset rules, the funds pledged by the node S on the chain will be recovered.
[0016] A block finalization system provided according to the present invention includes:
[0017] Module M1: Set checkpoints every preset number of blocks in the consensus system;
[0018] Module M2: Node S sets the direction between checkpoint A and checkpoint B that meets the preset rules;
[0019] Module M3: Other nodes in the consensus system perform consensus voting on the directions between checkpoints set by node S; when the directions between checkpoints obtain the consensus votes of a preset number of nodes and checkpoint A is in the justified state, the currently pointed checkpoint B reaches the finalized state and the checkpoint is finalized; when there is a network partition, it means that the checkpoint is forked, waiting for the network to recover, and the chain with the most consensus votes is selected as the main chain to continue finalization;
[0020] The justified state indicates that there are blocks following the checkpoint, and there are blocks following the previous checkpoint of the current checkpoint.
[0021] Preferably, the node S sets the pointing between the checkpoints that meet the preset rules including: the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint, and the signature of <hash value of the source checkpoint, hash value of the target checkpoint, block height of the source checkpoint, block height of the target checkpoint>.
[0022] Preferably, the node S is set to satisfy the predetermined rule that the directions between the checkpoints are: the node S is set to satisfy the following conditions: the directions between the checkpoints cannot be set repeatedly and the directions between the checkpoints cannot be set cyclically;
[0023] The inability to repeatedly set the direction between checkpoints means that the target checkpoint heights of the pointing proposals between checkpoints published by the same node cannot be the same;
[0024] The inability to set the pointing between checkpoints cyclically means that the height of the pointing proposal between checkpoints released by the same node cannot be included in the height of the pointing proposal between previously released checkpoints.
[0025] Preferably, the module M3 adopts: other nodes in the consensus system vote on the directions between the checkpoints set by the node S through IBFT consensus or BFT consensus.
[0026] Preferably, it also includes: when the directions between the checkpoints set by the node S do not meet the preset rules, the funds pledged by the node S on the chain will be recovered.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] 1. The present invention improves transaction throughput by reducing the difficulty of PoW block generation;
[0029] 2. The present invention sets checkpoints every 50 blocks through the proposed block finalization scheme and finalizes the checkpoints, maintaining the longest main chain that reaches the IBFT consensus while maintaining high throughput, thus ensuring the security of the system to a certain extent and preventing it from being forked;
[0030] 3. Using IBFT consensus checkpoints can also reduce the time it takes to finalize a block, and can reduce the time it takes to finalize a PoW blockchain block from the traditional 10 minutes to a smaller time unit;
[0031] 4. The present invention decouples the consensus process and the block finalization process, thereby improving the transaction throughput of the blockchain system and ensuring the security of transactions that will not be forked;
[0032] 5. The present invention improves the transaction throughput of the blockchain system using the traditional PoW consensus algorithm as a whole. When a fork occurs, the IBFT algorithm can be used to quickly determine which fork to use as the final chain, and can solve the problem that the traditional PoW type fork is difficult to determine and the waiting time is too long;
[0033] 6. The justified and finalized states are defined through the voting module to ensure the continuity of finalization, so that the nodes performing PoW calculations can always perform calculations on the same main chain;
[0034] 7. The cheating penalty module can ensure that the finalized state does not conflict. If the rules defined by the cheating penalty module are violated, the assets will be confiscated. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0036] Figure 1 Finalize the system framework diagram for IBFT-based blocks.
[0037] Figure 2 This is a schematic diagram of the voting framework.
[0038] Figure 3 The state of the chain after the finalization checkpoint. DETAILED DESCRIPTION
[0039] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0040] Example 1
[0041] A block finalization method provided according to the present invention includes:
[0042] Step S1: Set checkpoints every preset number of blocks in the consensus system;
[0043] Step S2: Node S sets the direction between checkpoint A and checkpoint B that meets the preset rules;
[0044] Specifically, the node S sets the directions between the checkpoints that meet the preset rules, including: the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint, and the signature of <hash value of the source checkpoint, hash value of the target checkpoint, block height of the source checkpoint, block height of the target checkpoint>.
[0045] Specifically, the node S is set to satisfy the predetermined rule that the directions between the checkpoints are: the node S is set to satisfy the following conditions: the directions between the checkpoints cannot be set repeatedly and the directions between the checkpoints cannot be set cyclically;
[0046] The inability to repeatedly set the direction between checkpoints means that the target checkpoint heights of the pointing proposals between checkpoints published by the same node cannot be the same;
[0047] The inability to set the pointing between checkpoints cyclically means that the height of the pointing proposal between checkpoints released by the same node cannot be included in the height of the pointing proposal between previously released checkpoints.
[0048] Step S3: Other nodes in the consensus system perform consensus voting on the directions between the checkpoints set by node S; when the directions between the checkpoints obtain the consensus votes of a preset number of nodes, and checkpoint A is in the justified state, the currently pointed checkpoint B reaches the finalized state, and the checkpoint is finalized; when there is a network partition, it means that the checkpoint is forked, waiting for the network to recover, and the chain with the most consensus votes is selected as the main chain to continue finalization;
[0049] Specifically, the step S3 adopts: other nodes in the consensus system vote on the directions between the checkpoints set by the node S through IBFT consensus or BFT consensus.
[0050] The justified state indicates that there are blocks following the checkpoint, and there are blocks following the previous checkpoint of the current checkpoint;
[0051] The finalized state is that all nodes in the consensus system cannot fork the currently pointed block.
[0052] Specifically, it also includes: when the directions between the checkpoints set by node S do not meet the preset rules, the funds pledged by node S on the chain will be recovered.
[0053] A block finalization system provided according to the present invention includes:
[0054] Module M1: Set checkpoints every preset number of blocks in the consensus system;
[0055] Module M2: Node S sets the direction between checkpoint A and checkpoint B that meets the preset rules;
[0056] Specifically, the node S sets the directions between the checkpoints that meet the preset rules, including: the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint, and the signature of <hash value of the source checkpoint, hash value of the target checkpoint, block height of the source checkpoint, block height of the target checkpoint>.
[0057] Specifically, the node S is set to satisfy the predetermined rule that the directions between the checkpoints are: the node S is set to satisfy the following conditions: the directions between the checkpoints cannot be set repeatedly and the directions between the checkpoints cannot be set cyclically;
[0058] The inability to repeatedly set the direction between checkpoints means that the target checkpoint heights of the pointing proposals between checkpoints published by the same node cannot be the same;
[0059] The inability to set the pointing between checkpoints cyclically means that the height of the pointing proposal between checkpoints released by the same node cannot be included in the height of the pointing proposal between previously released checkpoints.
[0060] Module M3: Other nodes in the consensus system perform consensus voting on the directions between checkpoints set by node S; when the directions between checkpoints obtain the consensus votes of a preset number of nodes and checkpoint A is in the justified state, the currently pointed checkpoint B reaches the finalized state and the checkpoint is finalized; when there is a network partition, it means that the checkpoint is forked, waiting for the network to recover, and the chain with the most consensus votes is selected as the main chain to continue finalization;
[0061] Specifically, the module M3 adopts: other nodes in the consensus system vote on the directions between the checkpoints set by the node S through IBFT consensus or BFT consensus.
[0062] The justified state indicates that there are blocks following the checkpoint, and there are blocks following the previous checkpoint of the current checkpoint;
[0063] The finalized state is that all nodes in the consensus system cannot fork the currently pointed block.
[0064] Specifically, it also includes: when the directions between the checkpoints set by node S do not meet the preset rules, the funds pledged by node S on the chain will be recovered.
[0065] Example 2
[0066] Embodiment 2 is a preferred embodiment of Embodiment 1
[0067] A block finalization system based on IBFT, including: voting module, cheating penalty module and fork selection module. The specific framework diagram is as follows Figure 1 As shown:
[0068] In the entire consensus system, a checkpoint is set every 50 blocks, that is, the checkpoint must be a multiple of 50. Genesis block is the first checkpoint (a block), and the height of the checkpoint (block height) is recorded as h(c). All nodes in the network will vote on a vote message, and the content of the vote is shown in Table 1. Vote is essentially a link, that is, a direction between two checkpoints, from the source checkpoint to the target checkpoint, such as Figure 3 The specific content of vote is as follows:
[0069] Table 1. Contents of vote
[0070] symbol describe s The hash value of the source checkpoint t The hash value of the target checkpoint h(s) Block height of the source checkpoint h(t) The block height of the target checkpoint Signature <s,t,h(s),h(t)>Signature
[0071] In the vote module, each node can initiate a proposal, which is the vote. Then each node conducts IBFT voting based on this vote. At the same time, the proposal initiated must not violate the rules defined in the cheating penalty module. If the rules are violated, the funds staked by the node on the chain will be recovered. In the vote module, IBFT can be used instead of the verification method of vote. The traditional BFT consensus can be used as the election mechanism, which can simplify the process of checkpoint consensus.
[0072] The cheating penalty module defines the rules for node proposal voting, which can ensure that the final selected checkpoint will not cause conflicts.
[0073] The fork selection module handles the problem of network partition. Once there is a checkpoint fork, it waits for the nodes that cannot communicate to resume communication with each other, and then selects the chain with the most votes as the main chain to continue finalization. The network partition refers to the situation where some nodes in the network are in different network states due to network connection problems and cannot communicate with each other, which indicates a network partition;
[0074] like Figure 2As shown, genesis is the root and the first checkpoint. c1 represents a checkpoint, and c1” is a checkpoint that conflicts with c1. Since the difficulty value is set very small when generating blocks by PoW, the block generation rate is very fast, and checkpoint conflicts often occur. h is the height of the checkpoint. For example, the height h of genesis is 0, and the height of c1 is 1. Link is actually a vote. Nodes will propose a link and conduct IBFT consensus on this link.
[0075] The cheating punishment module can solve the problem of conflicts in the above-mentioned finalized state. That is, when a node publishes a vote proposal, it cannot violate the following principles, otherwise all the assets pledged on the chain will be confiscated:
[0076] 1. Cannot vote repeatedly: The target checkpoint heights of vote proposals published by the same node cannot be the same. That is, h(t1) = h(t2).
[0077] 2. Cannot vote cyclically: The height of a vote proposal published by the same node cannot be included in the height of the vote proposal it published before. That is, h(s1) < h(s2) < h(t2) < h(t1). As Figure 2 shown, link1, link2, and link3 all violate the principle of not voting cyclically.
[0078] If a node violates the above rules, then all the funds pledged by the node on the chain will be confiscated. In the case of less than 1 / 3 malicious nodes, the cheating punishment module can ensure a certain degree of liveness. That is, by combining all the supermajority paths, finally a path where all checkpoints are in the finalized state can definitely be found. The consensus nodes will conduct consensus based on this path.
[0079] In the fork choice module, since each node participating in IBFT consensus has pledged assets on the chain, assume the number of validator sets is determined. If the network is partitioned, then on each partition, the original PoW consensus can still continue, but since 2 / 3 confirmation cannot be obtained, no node will be finalized and can only wait for the network to recover. After the network recovers, the fork choice module will select the chain with the highest justified and the longest to continue generating blocks by PoW.
[0080] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.
[0081] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A block finalization method, characterized in that: include: Step S1: Set checkpoints every preset number of blocks in the consensus system; Step S2: Node S sets the direction between checkpoint A and checkpoint B that meets the preset rules; Step S3: Other nodes in the consensus system perform consensus voting on the directions between the checkpoints set by node S; when the directions between the checkpoints obtain the consensus votes of a preset number of nodes, and checkpoint A is in the justified state, the currently pointed checkpoint B reaches the finalized state, and the checkpoint is finalized; when there is a network partition, it means that the checkpoint is forked, waiting for the network to recover, and the chain with the most consensus votes is selected as the main chain to continue finalization; The justified state indicates that there are blocks following the checkpoint, and there are blocks following the previous checkpoint of the current checkpoint; The node S sets the directions between the checkpoints that meet the preset rules, including: the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint, and the signature of <the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint>; The step S3 adopts: other nodes in the consensus system vote on the directions between the checkpoints set by node S through IBFT consensus or BFT consensus.
2. The block finalization method according to claim 1, characterized in that: The node S is set to satisfy the predetermined rule that the directions between the checkpoints are: the node S is set to satisfy the following: the directions between the checkpoints cannot be set repeatedly and the directions between the checkpoints cannot be set cyclically; The inability to repeatedly set the direction between checkpoints means that the target checkpoint heights of the pointing proposals between checkpoints published by the same node cannot be the same; The inability to set the pointing between checkpoints cyclically means that the height of the pointing proposal between checkpoints released by the same node cannot be included in the height of the pointing proposal between previously released checkpoints.
3. The block finalization method according to claim 1, characterized in that: Also includes: When the directions between the checkpoints set by node S do not meet the preset rules, the funds pledged by node S on the chain will be recovered.
4. A block finalization system, characterized in that: include: Module M1: Set checkpoints every preset number of blocks in the consensus system; Module M2: Node S sets the direction between checkpoint A and checkpoint B that meets the preset rules; Module M3: Other nodes in the consensus system perform consensus voting on the directions between checkpoints set by node S; when the directions between checkpoints obtain the consensus votes of a preset number of nodes and checkpoint A is in the justified state, the currently pointed checkpoint B reaches the finalized state and the checkpoint is finalized; when there is a network partition, it means that the checkpoint is forked, waiting for the network to recover, and the chain with the most consensus votes is selected as the main chain to continue finalization; The justified state indicates that there are blocks following the checkpoint, and there are blocks following the previous checkpoint of the current checkpoint; The node S sets the directions between the checkpoints that meet the preset rules, including: the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint, and the signature of <the hash value of the source checkpoint, the hash value of the target checkpoint, the block height of the source checkpoint, the block height of the target checkpoint>; The module M3 adopts: other nodes in the consensus system vote on the directions between the checkpoints set by node S through IBFT consensus or BFT consensus.
5. The block finalization system according to claim 4, characterized in that: The node S is set to satisfy the predetermined rule that the directions between the checkpoints are: the node S is set to satisfy the following: the directions between the checkpoints cannot be set repeatedly and the directions between the checkpoints cannot be set cyclically; The inability to repeatedly set the direction between checkpoints means that the target checkpoint heights of the pointing proposals between checkpoints published by the same node cannot be the same; The inability to set the pointing between checkpoints cyclically means that the height of the pointing proposal between checkpoints released by the same node cannot be included in the height of the pointing proposal between previously released checkpoints.
6. The block finalization system according to claim 4, characterized in that: Also includes: When the directions between the checkpoints set by node S do not meet the preset rules, the funds pledged by node S on the chain will be recovered.
