A method and system for eliminating downtime in the voting proof consensus algorithm
By introducing a timeout reselection mechanism and optimizing the random number generation algorithm, the downtime problem in the voting proof consensus algorithm is solved, the system availability and security are improved, and the fair election of the duty manager and the stable operation of the system are ensured.
Patent Information
- Application Number
- CN202111048646.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-08
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-09-08
AI Technical Summary
Voting proof consensus algorithms are prone to downtime problems, especially when network partitions or on-duty housekeepers fail. The lack of an effective reselection mechanism leads to the system paralysis, and the original random number generation algorithm does not fully respect the opinions of each committee member.
Introduce a timeout reselection mechanism, use time period marking to record the number of nodes and housekeepers in the network partition, re-election or rotation of on-duty housekeepers, and optimize the random number generation algorithm to ensure randomness and consensus through exclusive OR operation and timestamp, ensuring the following A duty housekeeper is recognized by most committee members.
The downtime problem in the PoV consensus algorithm was effectively improved, the availability and security of the system were improved, the election process of the on-duty housekeeper was optimized, and the voting results were more fair. The experimental results showed that the availability and security were improved.
Smart Images

Figure CN114386972B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of blockchain technology improvement, and in particular to a method and system for eliminating downtime in a voting proof consensus algorithm. Background Art
[0002] The blockchain contains the historical records of all node transactions and the identities, time, amount and other related information of both parties in the transaction nodes in the block. Each block uses a hash algorithm to generate an important identification header for sequential connection to form a chain data structure, which can be used as a distributed transaction and log record for the entire system. The blockchain has the characteristics of decentralization, immutability and traceability. Decentralization effectively avoids the damage to the system caused by malicious attacks or breaches of the master node in the traditional storage model; immutability ensures that if a malicious attacker wants to tamper with a certain data in a block, it is necessary to recalculate the block and all subsequent block information, and the huge workload makes the attack almost impossible to achieve; traceability ensures that the operations of each user or attacker can be recorded and then located and tracked, which invisibly increases the cost of destruction. The blockchain perfectly solves a series of problems in data storage, decentralized transactions, bill verification, etc., and has strongly promoted the development and progress of military, science and technology, and finance. Blockchain technology is currently booming, with very strong vitality and extremely broad development prospects.
[0003] With the continuous evolution of blockchain technology and its rich applications in many fields, more and more problems have gradually been exposed. For example, the initial blockchain nodes are open to the whole network, which invisibly increases many risks. In the process of blockchain generation, consensus algorithms are used to reach consensus between nodes. The emerging consensus algorithms each have their own advantages, but they also face problems such as low efficiency, high resource consumption, block generation bifurcation, and susceptibility to various attacks. It can be seen that further improving the usability of blockchain and improving its shortcomings and vulnerabilities are the top priorities of the scientific and industrial research work in the next step.
[0004] The Proof of Work (PoW) consensus algorithm is an algorithm designed based on proof of work. All mining nodes need to solve dynamically adjusted mathematical problems. As time goes by and the number of generated blocks increases, the difficulty of the problem will also increase.
[0005] Specifically, every miner in the entire network is mining for token rewards and generating new blocks. When generating a new block, the miner needs to add a random number to the hash value of the previous block header to form a new mathematical problem, and then increase the difficulty of the hash value to be calculated next time as the number of blocks generated increases, such as constantly limiting the number of leading 0s in the next hash value string. At this time, all miners will try to calculate a solution that meets the conditions. Once the hash value is successfully calculated and a new block is generated, the miner will notify all other miners of this message. After other miners verify the hash value, they recognize its legitimacy, then stop solving this round of mathematical problems and invest their computing power in the generation of the next new block.
[0006] Due to the influence of the incentive mechanism, all nodes will try their best to mine. If someone solves a math problem but has not had time to notify other nodes, the other nodes will continue to calculate the problem and successfully solve it. At this time, two miners will generate two different blocks for the same math problem, and then they will each generate new blocks based on different blocks, which will cause a typical blockchain fork problem. At this time, the PoW algorithm uses the longest chain principle to solve this problem, as long as the final result meets the longest chain principle.
[0007] The main problem with the PoW algorithm is the waste of computing resources. Once a new block is successfully produced by a miner, all the computing efforts made by other nodes before will become useless. In addition, as the difficulty of block generation is constantly adjusted, the current plan is to update the difficulty of the problem every 2016 blocks to ensure that the speed of block generation is constant at 10 minutes. At the same time, the PoW algorithm is prone to bifurcation when generating new blocks. The time period for each node to recognize a new block is relatively long, which affects the efficiency of transaction processing.
[0008] The Proof of Vote (PoV) consensus algorithm is a consensus algorithm based on the voting of participating nodes, and its specific application scenario is the consortium chain.
[0009] The PoV consensus algorithm separates the accounting rights of nodes that calculate and generate new blocks from the voting rights of electing the accounting nodes, and sets up a series of security nodes as verification nodes to supervise the process. This can effectively avoid double-spending attacks, selfish mining, witch attacks and other attacks, and provides good security guarantees.
[0010] The relevant nodes participating in the consensus process in the PoV consensus algorithm are divided into four different roles, namely committee nodes, housekeeper nodes, housekeeper candidate nodes, and user nodes. The responsibility of the committee nodes is to elect nodes that generate blocks and vote on the legitimacy of blocks; the main responsibility of the housekeeper nodes is to participate in bookkeeping, thereby generating new blocks and submitting them; the main job of the housekeeper candidate nodes is to participate in the competition to become a housekeeper and strive for the right to generate blocks; ordinary user nodes are the most basic nodes in the system and can join or exit the network at will. Their main job is to prepare to become candidate housekeeper nodes. At the same time, it is stipulated that these four nodes can be compatible with different identities in certain circumstances. The various nodes of the PoV consensus algorithm and the relationship between them, such as Figure 1 shown.
[0011] The PoV algorithm processes transactions and receives votes from committee members through the elected on-duty steward. If the on-duty steward fails or the network is partitioned, it is easy to cause downtime. In addition, the existing next on-duty steward election algorithm only considers the latest vote and does not fully respect the opinions of each committee member. Summary of the invention
[0012] The purpose of the present invention is to provide a method and system for eliminating downtime in a voting proof consensus algorithm, aiming to solve the above-mentioned technical problems.
[0013] The present invention is implemented as follows: a method for eliminating downtime in a voting proof consensus algorithm, the method for eliminating downtime in a voting proof consensus algorithm comprises the following steps:
[0014] S1. Use time period markers to record the number of nodes in the current network partition and the number of stewards in the current network partition in the parallel voting consensus network;
[0015] S2: Determine whether a partition occurs in the network or the current on-duty housekeeper is down. If so, execute the next step. If not, the network continues to execute the subsequent process of the parallel voting and publicity algorithm until the end of this round.
[0016] S3. Determine whether there is a butler on duty in this partition. If there is no butler on duty in this partition and there are more committee nodes, the partition will re-elect the butler on duty or rotate the committee nodes in this partition after the timeout threshold is reached. If there is a current butler on duty in this partition and there are more committee nodes, continue to complete the next consensus. When the butler on duty needs to be replaced, it can be rotated or elected directly in the butler nodes of this partition.
[0017] A further technical solution of the present invention is: the number and verification information of the next on-duty butler in step S3 are related to the hash value. At this time, the on-duty butler is generated among the butlers in the remaining blocks of this partition, so as to achieve the smooth generation of the next block.
[0018] A further technical solution of the present invention is that the generation of the next on-duty butler comprises the following steps:
[0019] S31. Arrange the timestamps of the votes received from the committee members in chronological order to obtain the latest timestamp C_ time [i], timestamp ;
[0020] S32. Select the next rotating steward with the most votes C_vote , the next steward on duty ;
[0021] S33, perform XOR operation on the timestamp and the value of the next rotating steward to generate a random number R Required random number source R source , random number source ;
[0022] S34, intercept the last 32 bits of the random number source and take the modulus with the number of current partition housekeeper nodes to get the random number ;
[0023] S35. The on-duty steward calculated according to the random number generation algorithm is recognized by the majority of the committee members.
[0024] A further technical solution of the present invention is: through the variable timestamp C_time [i] Guaranteed R The randomness generated by the next rotating steward Guaranteed R Generated consensus.
[0025] A further technical solution of the present invention is: in step S35, the current partition housekeeper node satisfies: ,in, is the total number of housekeeper nodes, The number of housekeeper nodes in the current partition.
[0026] Another object of the present invention is to provide a system for eliminating downtime in a proof-of-vote consensus algorithm, the system for eliminating downtime in a proof-of-vote consensus algorithm comprising:
[0027] The marking module is used to record the number of nodes in the current network partition and the number of stewards in the current network partition using time period marking in the parallel voting consensus network;
[0028] The downtime or partition judgment module is used to judge whether a partition occurs in the network or the current on-duty housekeeper is down. If so, the judgment of whether there is a housekeeper on duty is performed. If not, the network continues to execute the subsequent process of the parallel voting and publicity algorithm until the end of this round;
[0029] Whether there is a butler on duty is used to determine whether there is a butler on duty in this partition. If there is no butler on duty in this partition and there are more committee nodes, the partition will re-elect the butler on duty or rotate the committee nodes in this partition after the timeout threshold is reached; if there is a current butler on duty in this partition and there are more committee nodes, the next consensus will be completed. When the butler on duty needs to be replaced, it can be rotated or elected directly in the butler nodes of this partition.
[0030] A further technical solution of the present invention is that the number and verification information of the next on-duty butler in the judgment of whether there is a on-duty butler are related to the hash value. At this time, the on-duty butler is generated among the butlers in the remaining blocks of this partition, so as to achieve the smooth generation of the next block.
[0031] A further technical solution of the present invention is: the generation of the next on-duty butler includes:
[0032] The latest timestamp unit is used to arrange the timestamps received from the committee node votes in chronological order to obtain the latest timestamp C_time [i], timestamp ;
[0033] The vote counting unit is used to select the next rotating steward with the most votes. C_vote , the next steward on duty ;
[0034] XOR operation unit, used to perform XOR operation on the timestamp and the value of the next rotating steward to generate a random number R Required random number source R source , random number source ;
[0035] Get the random number unit, which is used to intercept the last 32 bits of the random number source and modulo the number of the current partition manager nodes to get the random number ;
[0036] The approval unit is used to obtain the approval of the majority of the committee members for the on-duty steward calculated according to the random number generation algorithm.
[0037] A further technical solution of the present invention is: through the variable timestamp C_time [i] Guaranteed R The randomness generated by the next rotating steward GuaranteedR Generated consensus.
[0038] A further technical solution of the present invention is that the current partition steward node in the recognition unit satisfies: ,in, is the total number of housekeeper nodes, The number of housekeeper nodes in the current partition.
[0039] The beneficial effects of the present invention are: using the timeout re-election mechanism to improve the downtime problem of the PoV consensus algorithm, and optimizing the election process of the on-duty steward to make the voting result more fair. At the same time, experimental tests show that after introducing the timeout re-election mechanism, the availability and security of the PoV consensus algorithm are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a schematic diagram of the various nodes of the PoV consensus algorithm and the relationship between them.
[0041] Figure 2 This is a schematic diagram of network partitioning.
[0042] Figure 3 It is a flow chart of a method for eliminating downtime in a voting proof consensus algorithm provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] This solution aims to solve the downtime problem in the PoV algorithm and introduces a timeout re-election mechanism to ensure the normal progress of the PoV consensus process; at the same time, it optimizes the on-duty steward election algorithm to make the election more fair.
[0044] When the PoV algorithm processes transactions and packages them, the on-duty steward elected by the committee members is responsible. There is only one on-duty steward in each period of time, and the voting for the rotation of the on-duty steward also needs to be processed by the current on-duty steward. This can easily lead to a problem, that is, if the on-duty steward node goes down, the process of calculating the serial number of the next on-duty steward cannot be carried out, and the PoV system will be paralyzed. Figure 2 In addition, when the network is partitioned in the following two ways, there will also be downtime problems:
[0045] ① The majority of committee nodes and on-duty housekeepers are isolated in one partition, and a minority of other nodes are isolated in another partition.
[0046] ② A small number of committee nodes and on-duty housekeepers are isolated in one partition, and most committee nodes are isolated in another partition.
[0047] In the first case, during the operation of the PoV algorithm, the part of the network with only a small number of committee nodes will stagnate due to the lack of a duty steward, while the other part of the nodes will stagnate because the algorithm needs to calculate the next duty steward, but the duty steward is not in this partition, so the subsequent PoV consensus algorithm will also stagnate.
[0048] The second situation is that a few committee nodes and the on-duty steward are isolated in the same zone. At this time, the on-duty steward wants to generate a block, but after continuous communication and waiting, it never receives confirmation from the majority of committee members, and there is no way to generate a new block; although another partition has the majority of committee nodes, because there is no re-election mechanism in the original PoV consensus algorithm, the committee nodes can no longer receive transaction verification requests, and at this time, no partition can operate normally. Therefore, this solution introduces a timeout re-election mechanism to solve the downtime problem of PoV.
[0049] In addition, the election of the on-duty steward in the PoV algorithm is designated by the random number generated by the votes of the committee members. The original random number generation algorithm counts the latest committee votes, but does not fully consider the previous votes of other committee members. Therefore, this scheme also improves the random number generation algorithm.
[0050] Timeout reselection mechanism
[0051] In order to solve the downtime problem that may occur in the original block, this solution introduces a timeout re-election mechanism for the on-duty steward. Consider adding new content to the block, namely the time period mark, the number of nodes in the current network partition, and the number of stewards in the current network partition.
[0052] At this point, there are two situations: When the network is partitioned, the partition without a duty housekeeper node but with more committee nodes will re-elect the duty housekeeper node or rotate in sequence after the timeout threshold is reached by the committee nodes in the partition.
[0053] At the same time, because the number of the next on-duty butler is related to the hash value of the verification information, the on-duty butler will only be generated among the butlers in the remaining blocks in this partition, so as to achieve the smooth generation of the next block.
[0054] It is simpler and clearer for the node that has the current on-duty butler partition and has more committee members. It continues to complete the next consensus. When the on-duty butler needs to be replaced, it can be rotated or elected in sequence in the butler node of this partition, saving the waiting time overhead of the partition without on-duty butler.
[0055]
[0056]
[0057] Election algorithm optimization
[0058] In the original PoV algorithm, the calculation method of the next on-duty steward is related to the latest timestamp and voting value. This calculation method does not take into account the voting intention of the previous committee members, so improvements are proposed:
[0059] The calculation formula of the random number R pointing to the next on-duty butler is as follows:
[0060] The calculation formula of the random number R pointing to the next on-duty butler is as follows:
[0061] Assume that the current on-duty steward has received votes from N committee nodes. First, arrange their timestamps in chronological order to obtain the latest timestamp C_time[i], that is,
[0062] Then select the C_vote with the most votes, that is
[0063] Then perform an XOR operation on these two values to get the random number source Rsource required to generate the random number R
[0064] At this time, you need to intercept the last 32 bits of the random number source and take the modulus with the number of current partition manager nodes to get the random number:
[0065] The current partition manager node should meet the following requirements:
[0066] At this time, the randomness of R generation is guaranteed by the variable C_time[i]. The consensus of R generation is guaranteed. The on-duty steward calculated according to the random number generation algorithm is recognized by the majority of committee members, fully respecting the opinions of each voter.
[0067] Pseudocode representation of the two improvements
[0068] In order to more clearly describe the voting rights change, downtime problem solution and on-duty steward re-election algorithm of this section's blockchain, these processes are considered as an overall process plan, named PoV-Improve plan, and pseudo code is given for description. First, whether a partition is generated or the current on-duty steward is down, if these two situations occur during the operation, at this time, it is necessary to determine whether to re-elect the on-duty steward in the partition based on the number of committee members in the current partition, and use the optimized election method to complete this process.
[0069] The pseudo code of the PoV-Improve scheme is as follows:
[0070]
[0071]
[0072] This solution proposes a timeout re-election mechanism to improve the downtime problem of the PoV consensus algorithm, and optimizes the election process of the on-duty steward to make the voting results more fair. At the same time, experimental tests show that the availability and security of the PoV consensus algorithm have been improved after the introduction of the timeout re-election mechanism.
[0073] The present invention improves the downtime problem existing in the PoV consensus algorithm. In the PoV consensus algorithm, because transaction processing and block generation for a certain period of time are only handled by one on-duty steward, when the on-duty steward is attacked or the system generates a network partition, downtime will occur. In this solution, we propose a timeout re-election mechanism to improve the downtime problem and enhance the availability and security of the PoV consensus algorithm.
[0074] The present invention optimizes the random number generation algorithm when calculating the duty housekeeper, and uses the most voted value in the committee members' votes as the parameter for generating the next duty housekeeper, so that the random number generation process is more fair and reasonable.
[0075] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for eliminating downtime in a voting proof consensus algorithm, characterized in that: The method for eliminating downtime in the voting proof consensus algorithm includes the following steps: S1. Use time period markers to record the number of nodes in the current network partition and the number of stewards in the current network partition in the parallel voting consensus network; S2: Determine whether a partition occurs in the network or the current on-duty housekeeper is down. If so, execute the next step. If not, the network continues to execute the subsequent process of the parallel voting and publicity algorithm until the end of this round. S3. Determine whether there is a butler on duty in this partition. If there is no butler on duty in this partition and there are more committee nodes, the partition will re-elect the butler on duty or rotate the committee nodes in this partition after the timeout threshold is reached to obtain the next butler on duty. If there is a current butler on duty in this partition and there are more committee nodes, continue to complete the next consensus. When the butler on duty needs to be replaced, it can be directly rotated in sequence or elected by the butler nodes in this partition; In step S3, the number and verification information of the next on-duty steward are related to the hash value. At this time, the on-duty steward is generated among the stewards in the remaining blocks of this partition, so that the next block can be generated smoothly; The generation of the next on-duty steward includes the following steps: S31. Arrange the timestamps of the votes received from the committee members in chronological order to obtain the latest timestamp C_time [i], timestamp ; S32. Select the next rotating steward with the most votes C_vote , the next steward on duty ; S33, perform XOR operation on the timestamp and the value of the next rotating steward to generate a random number R Required random number source R source , random number source ; S34, intercept the last 32 bits of the random number source and take the modulus with the number of current partition housekeeper nodes to get the random number ; S35. The on-duty steward calculated by the random number generation algorithm is recognized by the majority of the committee members.
2. The method for eliminating downtime in the voting proof consensus algorithm according to claim 1, characterized in that: By variable timestamp C_time [i] Guaranteed R The randomness generated by the next rotating steward Guaranteed R Generated consensus.
3. The method for eliminating downtime in the voting proof consensus algorithm according to claim 2, characterized in that: In step S35, the current partition manager node satisfies: ,in, is the total number of housekeeper nodes, The number of housekeeper nodes in the current partition.
4. A system for eliminating downtime in a proof-of-vote consensus algorithm, characterized in that: The system for eliminating downtime in the voting proof consensus algorithm includes: The marking module is used to record the number of nodes in the current network partition and the number of stewards in the current network partition using time period marking in the parallel voting consensus network; The downtime or partition judgment module is used to judge whether a partition occurs in the network or the current on-duty housekeeper is down. If so, the judgment of whether there is a housekeeper on duty is performed. If not, the network continues to execute the subsequent process of the parallel voting and publicity algorithm until the end of this round; Whether there is a butler on duty is used to determine whether there is a butler on duty in this partition. If there is no butler on duty in this partition and there are more committee nodes, the partition will re-elect the butler on duty or rotate the committee nodes in this partition after the timeout threshold is reached to obtain the next butler on duty; if there is a current butler on duty in this partition and there are more committee nodes, the next consensus will be completed. When the butler on duty needs to be replaced, it can be rotated or elected directly in the butler nodes of this partition; The number and verification information of the next on-duty butler in the judgment of whether there is an on-duty butler are related to the hash value. At this time, the on-duty butler is generated among the butlers in the remaining blocks of this partition, so that the next block is generated smoothly; The next on-duty steward generation includes: The latest timestamp unit is used to arrange the timestamps received from the committee node votes in chronological order to obtain the latest timestamp C_time [i], timestamp ; The vote counting unit is used to select the next rotating steward with the most votes. C_vote , the next steward on duty ; XOR operation unit, used to perform XOR operation on the timestamp and the value of the next rotating steward to generate a random number R Required random number source R source , random number source ; Get the random number unit, which is used to intercept the last 32 bits of the random number source and modulo the number of the current partition manager nodes to get the random number ; The recognition unit is used to obtain the recognition of the majority of the committee members for the on-duty steward calculated according to the random number generation algorithm.
5. The system for eliminating downtime in the voting proof consensus algorithm according to claim 4, characterized in that: By variable timestamp C_time [i] Guaranteed R The randomness generated by the next rotating steward Guaranteed R Generated consensus.
6. The system for eliminating downtime in the voting proof consensus algorithm according to claim 5, characterized in that: The current partition steward node in the recognition unit satisfies: ,in, is the total number of housekeeper nodes, The number of housekeeper nodes in the current partition.
Citation Information
Patent Citations
Voting-based CONSENSUS METHOD
CN109964446A
Blockchain authoritative node authorization consensus algorithm
CN111612472A
Consensus method based on parallel voting
CN112104482A
