WO2022233164A1 - Consensus method for chain-type periodic voting, and storage medium and electronic device - Google Patents

Consensus method for chain-type periodic voting, and storage medium and electronic device Download PDF

Info

Publication number
WO2022233164A1
WO2022233164A1 PCT/CN2022/074000 CN2022074000W WO2022233164A1 WO 2022233164 A1 WO2022233164 A1 WO 2022233164A1 CN 2022074000 W CN2022074000 W CN 2022074000W WO 2022233164 A1 WO2022233164 A1 WO 2022233164A1
Authority
WO
WIPO (PCT)
Prior art keywords
voting
block
chain
votes
vote
Prior art date
Application number
PCT/CN2022/074000
Other languages
French (fr)
Chinese (zh)
Inventor
杨鉴
Original Assignee
杨鉴
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杨鉴 filed Critical 杨鉴
Publication of WO2022233164A1 publication Critical patent/WO2022233164A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • the invention relates to the field of blockchain, in particular to a consensus method, storage medium and electronic equipment for chain periodic voting.
  • the technical problem to be solved by the present invention is to provide a consensus method, storage medium and electronic device for chain periodic voting.
  • a consensus method for chain periodic voting including:
  • Step 1 get voting rights to become a miner
  • Step 2 miners compete to generate blocks by generating random numbers, and the probability of block generation is proportional to the votes held by miners;
  • Step 3 Miners periodically vote on blocks
  • Step 4 select the main chain according to the voting results
  • Step 5 In the main chain, the blocks that meet the termination conditions are terminated to complete the consensus.
  • the beneficial effects of the present invention are: the above-mentioned method effectively combines the confirmation main chain and the finalization process, reduces the complexity of the code, and improves the processing efficiency. In addition, it also has the advantages of proof of rights and interests, low energy consumption, and chain formula to the network environment. High fault tolerance, more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
  • the present invention can also be improved as follows.
  • step 1 is specifically:
  • the abstention record is published.
  • the stakeholder does not choose to abstain from voting and the first preset condition is met, a vote is generated and the voting right is obtained, and the stakeholder who has obtained the voting right becomes a miner;
  • the first preset condition is:
  • Account_stakes is the account equity
  • VRF_Vote Proof is the random number generation function
  • the beneficial effect of adopting the above-mentioned further scheme is that the flexibility of the method can be effectively increased by increasing the abstention selection, and in addition, it has the effect of reducing the processing amount and increasing the processing efficiency for the subsequent data processing.
  • step 4 is specifically:
  • Priority is compared for each branch chain according to weight, and the branch chain with the highest priority is used as the main chain;
  • the weight is: the total number of votes obtained by the root node of a branch chain, all child nodes of the root node, and grandchild nodes of the root node;
  • the weight sums of the respective branch chains are calculated respectively, and the one with the highest weight sum is given priority.
  • step 5 is specifically:
  • the root node block of the branch chain that obtains more than two-thirds of the total votes is terminated as the final block, and the chain where the final block is located is the final chain to complete the consensus;
  • the uninterrupted voting chain is specifically:
  • a miner's M-th voted block to N-th voted block contains at least one final block, wherein the miner's M-th vote to the miner's N-th vote are connected in sequence, N ⁇ 2, M ⁇ N.
  • step 5 also includes:
  • the termination condition is specifically: the block that satisfies the continuous voting interval of no more than n cycles has the voting weight;
  • the first preset period is:
  • n is a positive integer
  • the key forks are as follows:
  • step 5 also includes:
  • the source block is the last voted block connected to the current vote.
  • the retracement point block obtained by the backtracking algorithm is specifically:
  • the backtracking algorithm is specifically:
  • the retracement point block is specifically:
  • step 5 further includes: within the estoppel period, the termination block is withdrawn to the withdrawal point block.
  • Another technical solution of the present invention to solve the above-mentioned technical problem is as follows: a storage medium, in which instructions are stored, and when a computer reads the instructions, the computer is made to execute any one of claims 1 to 8.
  • the beneficial effects of the present invention are: the above-mentioned method effectively combines the confirmation main chain and the finalization process, reduces the complexity of the code, and improves the processing efficiency. In addition, it also has the advantages of proof of rights and interests, low energy consumption, and chain formula to the network environment. High fault tolerance, more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
  • an electronic device comprising a memory, a processor and a program stored on the memory and running on the processor, the processor executes the program
  • a consensus method for chained periodic voting as described in any one of claims 1 to 8 is realized.
  • the beneficial effects of the present invention are: the above-mentioned method effectively combines the confirmation main chain and the finalization process, reduces the complexity of the code, and improves the processing efficiency. In addition, it also has the advantages of proof of rights and interests, low energy consumption, and chain formula to the network environment. High fault tolerance, more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
  • FIG. 1 is a schematic flowchart of an embodiment of a consensus method for chained periodic voting according to the present invention
  • FIG. 2 is a schematic diagram of branch weight calculation provided by an embodiment of a consensus method for chained periodic voting according to the present invention
  • FIG. 3 is a schematic diagram of a block generation empty window provided by an embodiment of a consensus method for chain periodic voting according to the present invention
  • FIG. 4 is a schematic diagram of a miner voting chain provided by an embodiment of a consensus method for chained periodic voting according to the present invention
  • FIG. 5 is a schematic diagram of active voting provided by an embodiment of a consensus method for chained periodic voting according to the present invention
  • FIG. 6 is a schematic diagram of security provided by an embodiment of a consensus method for chained periodic voting according to the present invention.
  • FIG. 7 is a schematic diagram of termination conditions provided by an embodiment of a consensus method for chained periodic voting according to the present invention.
  • FIG. 8 is a schematic diagram of a bifurcation provided by an embodiment of a consensus method for chained periodic voting according to the present invention.
  • FIG. 9 is a schematic diagram of forward movement provided by an embodiment of a consensus method for chained periodic voting according to the present invention.
  • a consensus method for chained periodic voting includes:
  • Step 1 get voting rights to become a miner
  • Step 2 miners compete to generate blocks by generating random numbers, and the probability of block generation is proportional to the votes held by miners;
  • Step 3 Miners periodically vote on blocks
  • Step 4 select the main chain according to the voting results
  • Step 5 In the main chain, the blocks that meet the termination conditions are terminated to complete the consensus.
  • the above method effectively combines the confirmation main chain and the finalization process, and reduces the complexity of the code and improves the processing efficiency. In addition, it also has the proof of stake, low energy consumption, and chain formula to the network.
  • the environment is highly fault-tolerant, with more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
  • Miners generate blocks according to the number of votes and receive rewards. Miners periodically vote on blocks, and then they will receive The branch with the most votes is identified as the main chain.
  • the voting result satisfies certain conditions, it can be determined that the result cannot be changed under certain assumptions (2/3 nodes are honest), which is called the end of the block, and the branch that has been terminated is the final In the main chain, the finalized block data is the final data.
  • step 2 the stakeholder becomes a miner and begins to participate in the creation and maintenance of the blockchain.
  • miners need to compete with each other for the right to create blocks:
  • the miner node performs a random operation with the account private key based on constants (timestamp, block hash value, etc.), expecting the result to reach a certain goal and meet the block production requirements, which is recorded as: Block_Pr oof ⁇ t arg et*votes*efficiency, Among them, target is the target, efficiency represents the block production efficiency, which is affected by various factors, votes is the number of votes currently used by miners, and the block production efficiency is determined as: the closer the target voting block is to the current chain, the correctness of the vote.
  • the miner node will package the transaction and voting information he received to generate a block and publish it to the network.
  • step 3 as with all chain consensus, deciding which branch becomes the main chain is the most important step in the consensus process.
  • miners determine the main chain by voting on each branch.
  • miner nodes periodically (usually in minutes) sign the current main chain top block address and publish it to the network, called voting, and the voting records will be packaged into blocks like transactions.
  • the present invention also includes rewards, punishments and optimization.
  • users who violate the rules such as those who violate the voting rules mentioned above and the abstention rules described in the next section, if they are punished, they will also be punished.
  • Reward users who submit evidence of violations. This requires the user to deposit (or lock) a part of the "deposit" before performing the corresponding operation. As the funds for punishment and reward, this part of the funds will be released after being locked for a period of time. The amount of deposit a user puts in is proportional to the number of votes or stake he gets.
  • the "block hash value" used in calculating voting qualifications can be optimized: because users with small stakes may not be able to obtain voting qualifications for a long time, if they need to be based on the information of the current block at all times Trying to generate votes as a constant adds unnecessary overhead. Therefore, the mth block information before the current block will be used instead (several hours ago), so that users can know that they are eligible to vote several hours in advance, and only need to centrally calculate it every several hours in the future. That's it. But in order to prevent the transfer of funds to gain a competitive advantage, it must be stipulated that the transferred currency must be m blocks before it can be used as a stake to generate votes.
  • abstaining registration For users who have small rights and do not want to spend too much money to participate in mining, they can also issue "abstention" registration. Although this cannot directly participate in system maintenance, it can provide a more accurate number of active votes and speed up the finalization. process and make a certain contribution to the stability of the system. For such abstaining registrations, a small reward (proportional to the amount of stake) can be given, but these abstaining stakeholders are penalized if they are shown to have participated in the voting activity.
  • the block generation rate is set to be fast, resulting in frequent occurrence of short forks, you may wish to set the default estoppel period directly to 1 or 2, and the default endpoint will also be delayed by 1-2 blocks accordingly, which can reduce the number of long forks. to make the system run more smoothly.
  • step 1 is specifically:
  • the abstention record is published.
  • the stakeholder does not choose to abstain from voting and the first preset condition is met, a vote is generated and the voting right is obtained, and the stakeholder who has obtained the voting right becomes a miner;
  • the first preset condition is:
  • Account_stakes is the account equity
  • VRF_Vote Proof is the random number generation function
  • the flexibility of the method can be effectively increased by adding abstention options, and in addition, the processing of subsequent data has the effect of reducing the amount of processing and increasing the processing efficiency.
  • VRF_Vote Proof ⁇ Account_stakes where Account_stakes represents account equity, the larger it is, the higher the possibility of meeting this condition, thus achieving the purpose of generating votes based on equity. Stakeholders who meet the voting qualifications can generate a vote, publish it on the network, and register as a miner (or voter). The registration record and transaction record need to be packaged into the block.
  • the validity period of each vote is the time period between the current block (valued by the hash value constant) and several blocks after it, usually in hours, so as not to cause users to operate too frequently.
  • voting qualification is to be able to reduce and flexibly control the number of validating nodes, so that different projects can balance between security and response speed.
  • step 4 is specifically:
  • Priority is compared for each branch chain according to weight, and the branch chain with the highest priority is used as the main chain;
  • the weight is: the total number of votes obtained by the root node of a branch chain, all child nodes of the root node, and grandchild nodes of the root node;
  • the weight sums of the respective branch chains are calculated respectively, and the one with the highest weight sum is given priority.
  • branches are prioritized not by their length, but by their "weight”.
  • the "weight” here is not equal to the number of blocks, but equal to the number of votes a block gets.
  • the weight of a branch is equal to the total number of votes received by its root node and all its descendant nodes.
  • the two chains should start from their common ancestor when comparing the priorities, and calculate the weights of the two branches to which they belong respectively, and the heavier one takes precedence.
  • the chain with the highest priority is r ⁇ b.
  • the first is to ensure that miners have enough enthusiasm to vote. This can be used to motivate miners by linking the "correctness" of voting with the efficiency of block production: according to "voting last cycle” ( Greater than or equal to one cycle, less than two cycles ago, the distance from the current chain (explained later) to determine the current block generation efficiency.
  • This brings the following two problems: when a fork occurs, if miners choose to vote for the more stable blocks before the fork in order to pursue the correctness of the vote, it will affect the speed of system stability; or miners choose to postpone voting , the strategy of voting after the fork has a clear victory or defeat will also affect the speed of system stability.
  • miners should choose to vote as early as possible and vote for the top block.
  • the miner's block-producing efficiency parameter efficiency in the current chain is affected by the "correctness" of his voting in the previous cycle (1 cycle ⁇ distance from the current position ⁇ 2 cycles), specifically: the closer the voting target block is to the current chain ( The lower the number of descendants after the fork), the higher the correctness and the higher the efficiency of block generation, and vice versa, the voting for the target on the current chain is called “correct” voting;
  • the miner's block production efficiency parameter efficiency in the current chain is affected by the "importance" of his correct votes in the previous cycle (same as above), specifically: the less the total number of correct votes for the voting target at this height, the higher the importance of a single correct vote. , the higher the block generation efficiency, the lower the vice versa;
  • step 5 is specifically:
  • the root node block of the branch chain that obtains more than two-thirds of the total votes is terminated as the final block, and the chain where the final block is located is the final chain to complete the consensus;
  • the uninterrupted voting chain is specifically:
  • a miner's M-th voted block to N-th voted block contains at least one final block, wherein the miner's M-th vote to the miner's N-th vote are connected in sequence, N ⁇ 2, M ⁇ N.
  • the finalization process of chain consensus does not require multiple rounds of voting to maintain a strict synchronization state between nodes, unlike BFT-type protocols.
  • a consensus is reached in the first round of voting, we only need to ensure that this consensus is unique, and do not need to care whether all nodes have received the voting results, so ideally only one round of voting is needed to complete the finalization.
  • the finalized chain does not conflict (security), and at the same time to allow voters to have the opportunity to modify their votes to prevent falling into a situation that can never be finalized (liveness), the situation becomes more complicated, and it is necessary to add new voting rules and postpone the closing time.
  • a vote that does not connect to a source is called a "passive vote”, which acts as a correction to a wrong vote and has no weight, but can be used as a source by subsequent votes. Passive voting can appear in the same cycle as sourced voting, but it also needs to abide by the previous voting rules, otherwise it will also be punished;
  • the genesis block is the first finalized block, which can be used as a source by subsequent votes without violating other rules;
  • the vote whose source is located in the final block is called "rooted vote". Only the "rooted vote” has weight and correctness, thus generating subsequent final blocks progressively. All ancestor blocks before the final block are also regarded as finalized. . "Rooted voting" can be passed backwards; as shown in Figure 4, solid blocks indicate terminated blocks, light solid lines indicate rooted voting, and dark dashed lines indicate rootless voting. So his voting chain was broken. As shown in Figure 5, continuing the situation in Figure 4, when node b becomes the final block, the vote behind the voter becomes a rooted vote, and the voting chain is reconnected.
  • step 5 further includes:
  • the termination condition is specifically: the block that satisfies the continuous voting interval of no more than n cycles has the voting weight;
  • the first preset period is:
  • n is a positive integer
  • the key forks are as follows:
  • This termination condition concentrates all the sources of votes that can generate termination within the range of two cycles before the termination point, so that it is only necessary to check in this range to see if there are enough votes, as shown in Figure 7 , the voting target that satisfies the termination condition of block b is concentrated on the 1-cycle long branch where b is a more node, and the source is concentrated on the 2-cycle long chain before a.
  • step 5 further includes:
  • the source block is the last voted block connected to the current vote.
  • the setback point block obtained by the backtracking algorithm is specifically:
  • the backtracking algorithm is specifically:
  • the retracement point block is specifically:
  • step 5 further includes: within the estoppel period, the end block is withdrawn to the withdrawal point block.
  • Each vote of a miner can only use the target of his last vote or the block within I steps back (including I) as the source.
  • the value of I is taken from the height of the target of this miner's last vote, and the actual retrogress period of the relevant chain.
  • I Miners who violate this rule will be punished, as shown in Figure 9, with estoppel period, vote withdrawal and endpoint advance.
  • the height of the last voting target can be improved to "the last voting was at the position of the height -1 saved in this chain", which corresponds to the improvement of Article 2) of the backtracking algorithm;
  • This rule is violated on the relevant chain” in The "relevant chain” refers to the chain where the source and target in the voting record are located respectively.
  • Counting from the root when a branch gets more than 2/3 of the total votes of the system within a voting cycle, and the distance between the source and the target in the voting records of these votes is less than 2 voting cycles, the end is satisfied. condition, but the final block is not necessarily the root node b of the branch, but the actual retracement point B at b.
  • the I value is 0, which can be completed in about 2/3 of the voting cycle after the block is generated. Occasionally, some serious forks may continue for several days. period, but the overall time must be much less than two periods.
  • the fork can be detected in advance and the termination is delayed, the voting requirements are relaxed, the fault tolerance rate of the system is improved, and the system can be prevented from being swayed from side to side to extend the length of the fork. inactive due to malicious attacks.
  • the branch weight calculation method mentioned by the way - instead of only counting the last vote like the LMD (Latest Message Driven) scheme, it is relatively troublesome to count each vote and vote on a periodic basis, also because doing so is right Such attacks have strong resistance.
  • a storage medium storing instructions, when a computer reads the instructions, the computer is made to execute a consensus method for chained periodic voting as described in any of the above.
  • the above method effectively combines the confirmation main chain and the finalization process, and reduces the complexity of the code and improves the processing efficiency. In addition, it also has the proof of stake, low energy consumption, and chain formula to the network.
  • the environment is highly fault-tolerant, with more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
  • An electronic device comprising a memory, a processor and a program stored on the memory and running on the processor, the processor implements a chain type as described in any of the above when the processor executes the program Consensus method for periodic voting.
  • the above method effectively combines the confirmation main chain and the finalization process, and reduces the complexity of the code and improves the processing efficiency. In addition, it also has the proof of stake, low energy consumption, and chain formula to the network.
  • the environment is highly fault-tolerant, with more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
  • the technical solution of the present invention is essentially or a part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention.
  • the aforementioned storage medium includes: U disk, removable hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present invention relates to the field of blockchains, and in particular, to a consensus method for chain-type periodic voting, and a storage medium and an electronic device. The method comprises: step 1, obtaining a voting right to become a miner; step 2, the miner competing for block output by means of generating a random number, wherein a block output probability is proportional to votes held by the miner; step 3, the miner periodically voting for a block; step 4, selecting a main chain according to a voting result; and step 5, terminating, in the main chain, a block that meets a termination condition, so as to complete a consensus. By means of the present invention, a main chain confirmation process can be effectively combined with a termination process, the complexity of codes is reduced, and the processing efficiency is also improved. In addition, the present invention also has the advantages of low energy consumption of proof of stake, high fault tolerance of a chain-type formula for a network environment, more verification nodes and easier requirements, and the security and flexibility are also guaranteed.

Description

一种链式周期投票的共识方法、存储介质及电子设备A consensus method, storage medium and electronic device for chain cycle voting 技术领域technical field
本发明涉及区块链领域,尤其涉及一种链式周期投票的共识方法、存储介质及电子设备。The invention relates to the field of blockchain, in particular to a consensus method, storage medium and electronic equipment for chain periodic voting.
背景技术Background technique
在分布式货币系统中,我们最基本的需求只是能用的“账本”,至于所有节点是否立即同步并不是我们真正关心的内容,从这点上来说很多分布式系统的要求都过于严格,类似于PBFT(实用拜占庭容错)式的共识协议虽然实现了记账功能,但是其节点之间复杂的交互都过于繁琐,消息复杂度太高,不能支撑较多的验证节点,而且在开放网络当中遇到网络状况不好的情况时,反而会降低效率。权益证明机制的出现,实际上已经为最终性的实现打开了大门,因为权益的总量是可以统计的,那么我们根据权益进行的集体决策就有可能得出一个占绝对优势的结果,理论上就可以被“终结”,事实上也已经有了具备最终性的共识协议出现。但是这些终结方案都显得不太完美,比如Casper的方案虽然具备了最终性,但实现方式还是过于复杂了,没有必要把确认主链和终结过程分离,既增加了代码复杂度又降低了效率。In a distributed currency system, our most basic requirement is only a usable "ledger". Whether all nodes are synchronized immediately is not what we really care about. From this point of view, the requirements of many distributed systems are too strict, similar to Although the PBFT (Practical Byzantine Fault Tolerance)-type consensus protocol realizes the accounting function, the complex interaction between its nodes is too cumbersome, and the message complexity is too high to support more verification nodes. When the network condition is not good, it will reduce the efficiency. The emergence of the proof-of-stake mechanism has actually opened the door to the realization of finality, because the total amount of rights and interests can be counted, so our collective decision-making based on rights and interests may come to an absolute advantage. Theoretically It can be "terminated", and in fact, a final consensus protocol has appeared. However, these finalization solutions are not perfect. For example, although Casper's solution is final, its implementation is still too complicated. There is no need to separate the confirmation main chain from the finalization process, which increases code complexity and reduces efficiency.
发明内容SUMMARY OF THE INVENTION
本发明所要解决的技术问题是提供一种链式周期投票的共识方法、存储介质及电子设备。The technical problem to be solved by the present invention is to provide a consensus method, storage medium and electronic device for chain periodic voting.
本发明解决上述技术问题的技术方案如下:一种链式周期投票的共识方 法,包括:The technical solution of the present invention to solve the above technical problems is as follows: a consensus method for chain periodic voting, including:
步骤1,获得投票权成为矿工; Step 1, get voting rights to become a miner;
步骤2,矿工通过生成随机数竞争出块,出块几率与矿工持有的选票成正比; Step 2, miners compete to generate blocks by generating random numbers, and the probability of block generation is proportional to the votes held by miners;
步骤3,矿工周期性的对区块进行投票;Step 3: Miners periodically vote on blocks;
步骤4,根据投票结果选择主链; Step 4, select the main chain according to the voting results;
步骤5,在主链中,将满足终结条件的区块终结,完成共识。Step 5: In the main chain, the blocks that meet the termination conditions are terminated to complete the consensus.
本发明的有益效果是:通过上述方法有效的将确认主链和终结过程结合起来,及降低了代码复杂程度有提高了处理的效率,另外,还具有权益证明低能耗、链式公式对网络环境的高容错、验证节点更多且要求更加宽松,此外还保证了安全性以及灵活性。The beneficial effects of the present invention are: the above-mentioned method effectively combines the confirmation main chain and the finalization process, reduces the complexity of the code, and improves the processing efficiency. In addition, it also has the advantages of proof of rights and interests, low energy consumption, and chain formula to the network environment. High fault tolerance, more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
在上述技术方案的基础上,本发明还可以做如下改进。On the basis of the above technical solutions, the present invention can also be improved as follows.
进一步,步骤1具体为:Further, step 1 is specifically:
当权益人选择弃权时,发布弃权记录,当权益人未选择弃权且满足第一预设条件时,生成选票,获得投票权,获得投票权的权益人成为矿工;When the stakeholder chooses to abstain from voting, the abstention record is published. When the stakeholder does not choose to abstain from voting and the first preset condition is met, a vote is generated and the voting right is obtained, and the stakeholder who has obtained the voting right becomes a miner;
其中,所述第一预设条件为:Wherein, the first preset condition is:
VRF_Vote Pr oof<Account_stakesVRF_Vote Proof<Account_stakes
其中,Account_stakes为账户权益,VRF_Vote Pr oof为随机数生成函数。Among them, Account_stakes is the account equity, and VRF_Vote Proof is the random number generation function.
采用上述进一步方案的有益效果是,通过增加弃权选择可以有效增加方法灵活性,另外对于后续数据的处理有减少处理量增高处理效率的作用。The beneficial effect of adopting the above-mentioned further scheme is that the flexibility of the method can be effectively increased by increasing the abstention selection, and in addition, it has the effect of reducing the processing amount and increasing the processing efficiency for the subsequent data processing.
进一步,步骤4具体为:Further, step 4 is specifically:
根据重量对每个分支链进行优先级比较,将优先级最高的分支链作为主链;Priority is compared for each branch chain according to weight, and the branch chain with the highest priority is used as the main chain;
其中,所述重量为:一个分支链的根节点、所述根节点的所有子节点以及所述根节点的孙节点所获得的选票总数;Wherein, the weight is: the total number of votes obtained by the root node of a branch chain, all child nodes of the root node, and grandchild nodes of the root node;
所述优先级比较具体为:The priority comparison is specifically:
从分支链共同的区块开始,分别计算各自分支链的重量总和,重量总和最高者为优先级。Starting from the blocks common to the branch chains, the weight sums of the respective branch chains are calculated respectively, and the one with the highest weight sum is given priority.
进一步,步骤5具体为:Further, step 5 is specifically:
在投票链不中断的基础上,获得票数超过总票数三分之二的分支链的根节点区块作为终结块终结,该终结块所在链为终结链,完成共识;On the basis that the voting chain is not interrupted, the root node block of the branch chain that obtains more than two-thirds of the total votes is terminated as the final block, and the chain where the final block is located is the final chain to complete the consensus;
其中,所述投票链不中断具体为:Wherein, the uninterrupted voting chain is specifically:
矿工的第M次投票的区块至第N次投票的区块中至少包含一个终结块,其中,该矿工的第M次投票至该矿工的第N次投票依次相连,N≥2,M≤N。A miner's M-th voted block to N-th voted block contains at least one final block, wherein the miner's M-th vote to the miner's N-th vote are connected in sequence, N≥2, M≤ N.
进一步,步骤5还包括:Further, step 5 also includes:
基于终结条件,对第一预设周期内是否存在关键分叉进行判断;Based on the termination condition, determine whether there is a key fork in the first preset period;
其中,终结条件具体为:满足间隔不超过n个周期的连续投票的区块具有投票权重;Among them, the termination condition is specifically: the block that satisfies the continuous voting interval of no more than n cycles has the voting weight;
第一预设周期为:The first preset period is:
n+1个周期,n为正整数;n+1 periods, n is a positive integer;
关键分叉具体为:The key forks are as follows:
无法继续终结的分叉。A fork that cannot continue to terminate.
进一步,步骤5还包括:Further, step 5 also includes:
当终结链断开的情况时,将下次投票的区块的来源块退回至通过回溯算法得到的回撤点区块;When the finalization chain is disconnected, return the source block of the next voting block to the retracement point block obtained through the backtracking algorithm;
其中,来源块为与本次投票相连的上一次投票的区块。Among them, the source block is the last voted block connected to the current vote.
进一步,通过回溯算法得到的回撤点区块具体为:Further, the retracement point block obtained by the backtracking algorithm is specifically:
所述回溯算法具体为:The backtracking algorithm is specifically:
统计当前区块之前的所述第一预设周期内,该区块所在区块链上获得的选票数,得到第一选票总数,判断所述第一选票总数是否大于总票数的三分 之二,若是,则反悔期I=0,若不是,则,将当前区块的高度h的投票回溯至高度为h-1的位置,重新计算所述第一选票总数,判断所述第一选票总数是否大于总票数的三分之二,若是,则反悔期I=1,若不是,则将回溯至高度为h-1的位置的投票与高度为h-1的投票合并,回溯至高度为h-2的位置,重复上述过程,直至所述第一选票总数大于总票数的三分之二,得到反悔期I=i,其中,i为回溯次数;Count the number of votes obtained on the blockchain where the block is located in the first preset period before the current block, obtain the first total number of votes, and determine whether the first total number of votes is greater than two-thirds of the total number of votes , if it is, then the estoppel period I=0, if not, then retrospect the vote of the height h of the current block to the position of height h-1, recalculate the total number of the first votes, and judge the total number of the first votes Whether it is greater than two-thirds of the total number of votes, if so, the estoppel period I = 1, if not, merge the votes backdated to the height h-1 with the votes of the height h-1, backtracked to the height h For the position of -2, repeat the above process until the total number of first votes is greater than two-thirds of the total number of votes, and the estoppel period I=i is obtained, where i is the number of backtracking;
所述回撤点区块具体为:The retracement point block is specifically:
高度为h-I的区块。Blocks with height h-I.
进一步,步骤5还包括:在所述反悔期内,终结区块回撤至所述回撤点区块。Further, step 5 further includes: within the estoppel period, the termination block is withdrawn to the withdrawal point block.
本发明解决上述技术问题的另一种技术方案如下:一种存储介质,所述存储介质中存储有指令,当计算机读取所述指令时,使所述计算机执行如权利要求1至8中任一项所述的一种链式周期投票的共识方法。Another technical solution of the present invention to solve the above-mentioned technical problem is as follows: a storage medium, in which instructions are stored, and when a computer reads the instructions, the computer is made to execute any one of claims 1 to 8. A consensus method for chained periodic voting.
本发明的有益效果是:通过上述方法有效的将确认主链和终结过程结合起来,及降低了代码复杂程度有提高了处理的效率,另外,还具有权益证明低能耗、链式公式对网络环境的高容错、验证节点更多且要求更加宽松,此外还保证了安全性以及灵活性。The beneficial effects of the present invention are: the above-mentioned method effectively combines the confirmation main chain and the finalization process, reduces the complexity of the code, and improves the processing efficiency. In addition, it also has the advantages of proof of rights and interests, low energy consumption, and chain formula to the network environment. High fault tolerance, more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
本发明解决上述技术问题的另一种技术方案如下:一种电子设备,包括存储器、处理器及存储在所述存储器上并在所述处理器上运行的程序,所述处理器执行所述程序时实现如权利要求1至8任一项所述的一种链式周期投票的共识方法。Another technical solution of the present invention to solve the above technical problem is as follows: an electronic device, comprising a memory, a processor and a program stored on the memory and running on the processor, the processor executes the program A consensus method for chained periodic voting as described in any one of claims 1 to 8 is realized.
本发明的有益效果是:通过上述方法有效的将确认主链和终结过程结合起来,及降低了代码复杂程度有提高了处理的效率,另外,还具有权益证明低能耗、链式公式对网络环境的高容错、验证节点更多且要求更加宽松,此外还保证了安全性以及灵活性。The beneficial effects of the present invention are: the above-mentioned method effectively combines the confirmation main chain and the finalization process, reduces the complexity of the code, and improves the processing efficiency. In addition, it also has the advantages of proof of rights and interests, low energy consumption, and chain formula to the network environment. High fault tolerance, more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
附图说明Description of drawings
图1为本发明一种链式周期投票的共识方法实施例提供的流程示意图;FIG. 1 is a schematic flowchart of an embodiment of a consensus method for chained periodic voting according to the present invention;
图2为本发明一种链式周期投票的共识方法实施例提供的分支重量计算示意图;FIG. 2 is a schematic diagram of branch weight calculation provided by an embodiment of a consensus method for chained periodic voting according to the present invention;
图3为本发明一种链式周期投票的共识方法实施例提供的出块空窗示意图;FIG. 3 is a schematic diagram of a block generation empty window provided by an embodiment of a consensus method for chain periodic voting according to the present invention;
图4为本发明一种链式周期投票的共识方法实施例提供的矿工投票链示意图;4 is a schematic diagram of a miner voting chain provided by an embodiment of a consensus method for chained periodic voting according to the present invention;
图5为本发明一种链式周期投票的共识方法实施例提供的有源投票示意图;FIG. 5 is a schematic diagram of active voting provided by an embodiment of a consensus method for chained periodic voting according to the present invention;
图6为本发明一种链式周期投票的共识方法实施例提供的安全性示意图;FIG. 6 is a schematic diagram of security provided by an embodiment of a consensus method for chained periodic voting according to the present invention;
图7为本发明一种链式周期投票的共识方法实施例提供的终结条件示意图;FIG. 7 is a schematic diagram of termination conditions provided by an embodiment of a consensus method for chained periodic voting according to the present invention;
图8为本发明一种链式周期投票的共识方法实施例提供的分叉示意图;FIG. 8 is a schematic diagram of a bifurcation provided by an embodiment of a consensus method for chained periodic voting according to the present invention;
图9为本发明一种链式周期投票的共识方法实施例提供的前移示意图。FIG. 9 is a schematic diagram of forward movement provided by an embodiment of a consensus method for chained periodic voting according to the present invention.
具体实施方式Detailed ways
以下对本发明的原理和特征进行描述,所举实例只用于解释本发明,并非用于限定本发明的范围。The principles and features of the present invention are described below, and the examples are only used to explain the present invention, but not to limit the scope of the present invention.
如图1所示,一种链式周期投票的共识方法,包括:As shown in Figure 1, a consensus method for chained periodic voting includes:
步骤1,获得投票权成为矿工; Step 1, get voting rights to become a miner;
步骤2,矿工通过生成随机数竞争出块,出块几率与矿工持有的选票成正比; Step 2, miners compete to generate blocks by generating random numbers, and the probability of block generation is proportional to the votes held by miners;
步骤3,矿工周期性的对区块进行投票;Step 3: Miners periodically vote on blocks;
步骤4,根据投票结果选择主链; Step 4, select the main chain according to the voting results;
步骤5,在主链中,将满足终结条件的区块终结,完成共识。Step 5: In the main chain, the blocks that meet the termination conditions are terminated to complete the consensus.
在一些可能的实施方式中,通过上述方法有效的将确认主链和终结过程结合起来,及降低了代码复杂程度有提高了处理的效率,另外,还具有权益证明低能耗、链式公式对网络环境的高容错、验证节点更多且要求更加宽松,此外还保证了安全性以及灵活性。In some possible implementations, the above method effectively combines the confirmation main chain and the finalization process, and reduces the complexity of the code and improves the processing efficiency. In addition, it also has the proof of stake, low energy consumption, and chain formula to the network. The environment is highly fault-tolerant, with more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
需要说明的是,权益人依照所持权益多少按几率生成选票,获取投票资格,成为矿工,矿工们依照选票的数量按几率生成区块,获得奖励,矿工周期性地对区块投票,然后将获得选票最多的分支认定为主链,当计票结果满足一定条件,可以确定此结果在特定假设(2/3节点诚实)下无法再改变,此时称为区块终结,已终结的分支为最终主链,已终结的区块数据就是最终数据。It should be noted that stakeholders generate votes according to the amount of equity they hold, obtain voting qualifications, and become miners. Miners generate blocks according to the number of votes and receive rewards. Miners periodically vote on blocks, and then they will receive The branch with the most votes is identified as the main chain. When the voting result satisfies certain conditions, it can be determined that the result cannot be changed under certain assumptions (2/3 nodes are honest), which is called the end of the block, and the branch that has been terminated is the final In the main chain, the finalized block data is the final data.
另外,步骤2中权益人成为矿工后开始参与区块链的创建和维护工作,为了获得奖励,矿工们需要互相竞争创建区块的权力:In addition, in step 2, the stakeholder becomes a miner and begins to participate in the creation and maintenance of the blockchain. In order to obtain rewards, miners need to compete with each other for the right to create blocks:
矿工节点基于常量(时间戳、区块哈希值等)用账户私钥进行一个随机运算,期望结果达到某个目标,满足出块要求,记为:Block_Pr oof<t arg et*votes*efficiency,其中t arg et是目标,efficiency表示出块效率,受到各种因素的影响,votes为矿工当前用于的选票数,出块效率的判定为:目标投票区块距离当前链越近,投票正确性越高,所述出块效率越高;目标投票区块在该高度的正确投票总数越少,该目标投票区块的每个正确投票的重要性越高,所述出块效率越高;当达到出块要求后,矿工节点将他收到的交易和投票信息等打包生成区块并发布到网络。The miner node performs a random operation with the account private key based on constants (timestamp, block hash value, etc.), expecting the result to reach a certain goal and meet the block production requirements, which is recorded as: Block_Pr oof<t arg et*votes*efficiency, Among them, target is the target, efficiency represents the block production efficiency, which is affected by various factors, votes is the number of votes currently used by miners, and the block production efficiency is determined as: the closer the target voting block is to the current chain, the correctness of the vote. The higher the value, the higher the efficiency of the block generation; the less the total number of correct votes of the target voting block at this height, the higher the importance of each correct vote of the target voting block, the higher the efficiency of the block generation; when After reaching the block production requirements, the miner node will package the transaction and voting information he received to generate a block and publish it to the network.
步骤3中,跟所有链式共识一样,决定哪个分支成为主链是共识过程中最重要的一步。在这个过程中,矿工们通过对各个分支进行投票来确定出主 链。为了确定主链,矿工节点周期性(通常以分钟计)地对当前的主链顶端区块地址签名并发布到网络,称为投票,投票记录将和交易一样被打包进区块。In step 3, as with all chain consensus, deciding which branch becomes the main chain is the most important step in the consensus process. In this process, miners determine the main chain by voting on each branch. In order to determine the main chain, miner nodes periodically (usually in minutes) sign the current main chain top block address and publish it to the network, called voting, and the voting records will be packaged into blocks like transactions.
除此之外,本发明还包括了奖惩以及优化的内容,对于用户的违规行为,比如前面提到的违反投票规则和下一节要介绍的违反弃权规则的用户,对其进行惩罚,也会对提交违规证据的用户进行奖励。这需要用户在做相应操作之前存入(或称锁定)一部分“押金”,作为惩罚和奖励的资金,这部分资金会在锁定一段时间之后解押。用户所交押金的金额与他获得的选票数或权益量成正比。In addition, the present invention also includes rewards, punishments and optimization. For users who violate the rules, such as those who violate the voting rules mentioned above and the abstention rules described in the next section, if they are punished, they will also be punished. Reward users who submit evidence of violations. This requires the user to deposit (or lock) a part of the "deposit" before performing the corresponding operation. As the funds for punishment and reward, this part of the funds will be released after being locked for a period of time. The amount of deposit a user puts in is proportional to the number of votes or stake he gets.
计算投票资格时用到的“区块哈希值”可以做一个优化:因为权益小的用户有可能很长时间都不能获得投票资格,如果还要让他们每时每刻根据当前区块的信息作为常量来尝试生成选票的话会增加没必要的开销。所以将用当前区块之前的第m个区块信息来代替(若干个小时以前),这样用户就能提前若干个小时知晓自己获得了投票资格,以后只需要每隔若干个小时集中计算一次就可以了。但是为了防止通过转移资金来获得竞争优势,必须规定:经过转账的货币必须在m个区块之后才能作为权益来生成选票。The "block hash value" used in calculating voting qualifications can be optimized: because users with small stakes may not be able to obtain voting qualifications for a long time, if they need to be based on the information of the current block at all times Trying to generate votes as a constant adds unnecessary overhead. Therefore, the mth block information before the current block will be used instead (several hours ago), so that users can know that they are eligible to vote several hours in advance, and only need to centrally calculate it every several hours in the future. That's it. But in order to prevent the transfer of funds to gain a competitive advantage, it must be stipulated that the transferred currency must be m blocks before it can be used as a stake to generate votes.
对于权益小而且不希望花太多的代价参加挖矿的用户来说,他们也可以发布“弃权”登记,这样做虽然不能直接参与系统维护,但是可以提供更准确的活动选票数,加快最终化进程,为系统的稳定做出一定的贡献。对于这样的弃权登记,可以给予一小部分奖励(与权益数量成正比),但是这些弃权的权益人如果被证明参与到了投票活动中的话,则会受到惩罚。For users who have small rights and do not want to spend too much money to participate in mining, they can also issue "abstention" registration. Although this cannot directly participate in system maintenance, it can provide a more accurate number of active votes and speed up the finalization. process and make a certain contribution to the stability of the system. For such abstaining registrations, a small reward (proportional to the amount of stake) can be given, but these abstaining stakeholders are penalized if they are shown to have participated in the voting activity.
由于矿工登记记录没有交易费奖励给区块生成者,为了激励矿工将它们打包进块中,我们要根据生成块中登记记录的数量来调整出块效率参数efficiency,从而影响该矿工下一次出块的速度,使得打包的登记记录越多越好。该数量的标准值每隔一段时间应该做一次调整。Since there is no transaction fee rewarded to the block generator for the miner's registration record, in order to motivate the miner to pack them into the block, we need to adjust the efficiency parameter efficiency according to the number of registration records in the generated block, thus affecting the miner's next block generation speed, so that the more registration records are packaged, the better. The standard value of this quantity should be adjusted at regular intervals.
如果出块速率设置得较快,导致短分叉频繁出现,不妨把默认的反悔期 直接设为1或2,默认终结点也相应延迟1-2个区块,可以减少长分叉的出现次数,使系统运行得更加顺畅。If the block generation rate is set to be fast, resulting in frequent occurrence of short forks, you may wish to set the default estoppel period directly to 1 or 2, and the default endpoint will also be delayed by 1-2 blocks accordingly, which can reduce the number of long forks. to make the system run more smoothly.
优选地,在上述任意实施例中,步骤1具体为:Preferably, in any of the above embodiments, step 1 is specifically:
当权益人选择弃权时,发布弃权记录,当权益人未选择弃权且满足第一预设条件时,生成选票,获得投票权,获得投票权的权益人成为矿工;When the stakeholder chooses to abstain from voting, the abstention record is published. When the stakeholder does not choose to abstain from voting and the first preset condition is met, a vote is generated and the voting right is obtained, and the stakeholder who has obtained the voting right becomes a miner;
其中,所述第一预设条件为:Wherein, the first preset condition is:
VRF_Vote Pr oof<Account_stakesVRF_Vote Proof<Account_stakes
其中,Account_stakes为账户权益,VRF_Vote Pr oof为随机数生成函数。Among them, Account_stakes is the account equity, and VRF_Vote Proof is the random number generation function.
在一些可能的实施方式中,通过增加弃权选择可以有效增加方法灵活性,另外对于后续数据的处理有减少处理量增高处理效率的作用。In some possible implementations, the flexibility of the method can be effectively increased by adding abstention options, and in addition, the processing of subsequent data has the effect of reducing the amount of processing and increasing the processing efficiency.
需要说明的是,权益人根据当前常量(区块哈希值,时间戳等),用账户私钥进行一个随机数的运算,再与账户掌握的权益数进行比较,达到要求者获得投票资格。此过程记为:VRF_Vote Pr oof<Account_stakes,其中Account_stakes表示账户权益,其越大,满足此条件的可能性越高,由此达到根据权益生成选票的目的。满足投票资格的权益人即可生成一张选票,发布到网络上,登记成为矿工(或称投票者),登记记录和交易记录一样需要被打包进区块。每张选票的生效期为当前(哈希值常量取值的)区块至其之后的若干个区块之间的时间段,通常以小时计,才不至于使用户操作得过于频繁。It should be noted that the stakeholder uses the account private key to perform a random number operation according to the current constants (block hash value, timestamp, etc.), and then compares it with the number of stakes held by the account, and those who meet the requirements are eligible to vote. This process is recorded as: VRF_Vote Proof<Account_stakes, where Account_stakes represents account equity, the larger it is, the higher the possibility of meeting this condition, thus achieving the purpose of generating votes based on equity. Stakeholders who meet the voting qualifications can generate a vote, publish it on the network, and register as a miner (or voter). The registration record and transaction record need to be packaged into the block. The validity period of each vote is the time period between the current block (valued by the hash value constant) and several blocks after it, usually in hours, so as not to cause users to operate too frequently.
投票资格的引入是为了能够降低并灵活控制验证节点的数量,以便不同的项目在安全性和响应速度之间做出平衡。通过控制获得选票的难度,我们可以把系统总选票数控制在需要的数目左右。根据概率,设定的总票数越多,实际产生的选票数量越接近于理想数量,我们根据总选票数来进行的各种投票结果就更加可靠,但是选票越多,投票节点就越多,共识速度就越慢,这需要根据不同需求进行权衡。The introduction of voting qualification is to be able to reduce and flexibly control the number of validating nodes, so that different projects can balance between security and response speed. By controlling the difficulty of getting votes, we can keep the total number of votes in the system around what is needed. According to the probability, the more the total number of votes set, the closer the actual number of votes to the ideal number, the more reliable the various voting results we conduct based on the total number of votes, but the more votes, the more voting nodes, and the consensus The slower the speed, which needs to be weighed according to different needs.
优选地,在上述任意实施例中,步骤4具体为:Preferably, in any of the above embodiments, step 4 is specifically:
根据重量对每个分支链进行优先级比较,将优先级最高的分支链作为主链;Priority is compared for each branch chain according to weight, and the branch chain with the highest priority is used as the main chain;
其中,所述重量为:一个分支链的根节点、所述根节点的所有子节点以及所述根节点的孙节点所获得的选票总数;Wherein, the weight is: the total number of votes obtained by the root node of a branch chain, all child nodes of the root node, and grandchild nodes of the root node;
所述优先级比较具体为:The priority comparison is specifically:
从分支链共同的区块开始,分别计算各自分支链的重量总和,重量总和最高者为优先级。Starting from the blocks common to the branch chains, the weight sums of the respective branch chains are calculated respectively, and the one with the highest weight sum is given priority.
需要说明的是,在协议中,分支的优先级不是取决于它们的长度,而是取决于它们的“重量”。“重量”在这里也并不等于区块个数,而是等于区块所获得的选票数。定义:一个分支的重量等于它的根节点和其所有子孙节点所获得的选票总数。在此计算方式下,两条链在比较优先级时应该从它们共同的祖先出发,分别计算它们各自所属的两个分支的重量,较重者优先。为了找到主链,我们需要逐个比较当前存在的竞争分支,找出优先级最高的链,如图2所示,图中所示的分支结构中,优先级最高的链为r→b。To be clear, in the protocol, branches are prioritized not by their length, but by their "weight". The "weight" here is not equal to the number of blocks, but equal to the number of votes a block gets. Definition: The weight of a branch is equal to the total number of votes received by its root node and all its descendant nodes. In this calculation method, the two chains should start from their common ancestor when comparing the priorities, and calculate the weights of the two branches to which they belong respectively, and the heavier one takes precedence. In order to find the main chain, we need to compare the currently existing competing branches one by one and find the chain with the highest priority, as shown in Figure 2. In the branch structure shown in the figure, the chain with the highest priority is r→b.
投票过程中还有一些问题需要解决,首先是要保证矿工有足够的积极性进行投票,这一点可以利用使投票“正确”性与出块效率挂钩的方法来激励矿工:根据“上周期投票”(大于等于一个周期,小于两个周期以前的投票)到当前链的距离远近(后面会解释)来确定当前出块效率。这又带来下面两个问题:在产生分叉时,如果矿工都为了追求投票的正确性而选择投向分叉之前较稳定的区块的话,就会影响系统稳定的速度;或者矿工选择推迟投票,等分叉已有明显胜负之后再投票的策略,同样也会影响系统稳定的速度。对这两个问题,我们首先在原有周期投票的规则上稍加修改,之前的规则是“投票目标间隔不能小于一个周期的长度”,现在增加“在当前链中记录投票的区块与下一个投票目标间隔不能小于一个周期-1的长度”。按照新的规则,每当有矿工投票给较早的区块,或者推迟投票,此次投票与上次投票之间的 间隔就会大于一个周期,而超过一个周期的地方出现一个空窗,每当区块的“往前2周期-1”处位于这个空窗内,这个矿工在此区块位置的“上周期投票”都不存在,因此其正确性为零,无法出块。例如:如图3所示,当前矿工在a区块位置有一个空窗,导致a之后2周期-1出的b区块位置无法出块。There are still some problems to be solved in the voting process. The first is to ensure that miners have enough enthusiasm to vote. This can be used to motivate miners by linking the "correctness" of voting with the efficiency of block production: according to "voting last cycle" ( Greater than or equal to one cycle, less than two cycles ago, the distance from the current chain (explained later) to determine the current block generation efficiency. This brings the following two problems: when a fork occurs, if miners choose to vote for the more stable blocks before the fork in order to pursue the correctness of the vote, it will affect the speed of system stability; or miners choose to postpone voting , the strategy of voting after the fork has a clear victory or defeat will also affect the speed of system stability. For these two issues, we first slightly modified the original cycle voting rules. The previous rule was that "the interval between voting targets cannot be less than the length of one cycle", and now we add "record the voting block in the current chain and the next one." The voting target interval cannot be less than the length of a period-1". According to the new rules, whenever a miner votes for an earlier block, or postpones the vote, the interval between this vote and the last vote will be greater than one cycle, and an empty window will appear where it exceeds one cycle. When the "previous 2 cycles -1" of the block is within this empty window, the miner's "last cycle vote" at this block position does not exist, so its correctness is zero and the block cannot be produced. For example: As shown in Figure 3, the current miner has an empty window at the position of block a, which results in the block position of block b, which is 2 cycles after a, and cannot produce blocks.
所以为了尽量少出现这种空窗,矿工应该选择尽早投票,且投给最顶端的区块。其次,利用使投票的“重要性”也和出块效率挂钩的方法来解决,用“正确投票总数越少,自己投票的重要性越高”的判定,来使矿工在分叉之后投票分散的时候的投票具有更高的价值。即,投票需满足:Therefore, in order to minimize this kind of empty window, miners should choose to vote as early as possible and vote for the top block. Secondly, use the method of linking the "importance" of voting with the efficiency of block production, and use the judgment of "the less the total number of correct votes, the higher the importance of one's own vote", to make the miners vote dispersed after the fork. votes at times have higher value. That is, voting needs to satisfy:
矿工每两次投票的间隔必须大于等于一个投票周期,否则会被惩罚;The interval between every two votes of miners must be greater than or equal to one voting cycle, otherwise they will be punished;
每个矿工在当前链上的投票被记录的位置距离下次投票的目标必须大于等于一个投票周期-1的长度,否则也会被惩罚;Each miner's vote on the current chain is recorded and the distance from the target of the next vote must be greater than or equal to the length of one voting cycle -1, otherwise it will also be punished;
矿工在当前链的出块效率参数efficiency受到他的上周期(1周期≤距离当前位置<2周期)投票的“正确性”影响,具体为:该投票目标区块距离当前链的距离越近(分叉之后的子孙代数越少),正确性越高,出块效率越高,反之越低,目标在当前链上的投票称为“正确”投票;The miner's block-producing efficiency parameter efficiency in the current chain is affected by the "correctness" of his voting in the previous cycle (1 cycle ≤ distance from the current position < 2 cycles), specifically: the closer the voting target block is to the current chain ( The lower the number of descendants after the fork), the higher the correctness and the higher the efficiency of block generation, and vice versa, the voting for the target on the current chain is called "correct" voting;
矿工在当前链的出块效率参数efficiency受到他的上周期(同上)正确投票的“重要性”影响,具体为:投票目标在该高度的正确投票总数越少,单个的正确投票重要性越高,出块效率越高,反之越低;The miner's block production efficiency parameter efficiency in the current chain is affected by the "importance" of his correct votes in the previous cycle (same as above), specifically: the less the total number of correct votes for the voting target at this height, the higher the importance of a single correct vote. , the higher the block generation efficiency, the lower the vice versa;
此处存在一个信息的完整性问题,即在一条链中存储的数据能不能包含完整的投票和分支信息。如果可以的话不仅能简化比较优先级的算法,还能为之后的“最终化”提供支撑,更重要的是让共识过程有完整的记录,这保证了系统的客观性和可验证性。要讨论这一点,需要看矿工们有没有足够的理由去打包所有的投票信息,毕竟投票是不提供手续费的。There is an information integrity problem here, that is, whether the data stored in a chain can contain complete voting and branch information. If possible, it can not only simplify the algorithm for comparing priorities, but also provide support for the subsequent "finalization". More importantly, the consensus process has a complete record, which ensures the objectivity and verifiability of the system. To discuss this, we need to see whether miners have enough reason to package all the voting information, after all, voting does not provide fees.
因此分两种情况来看:So there are two cases:
对于指向本链的投票,矿工自然会尽量地多保存到块,以此来保证自身 链的竞争力;For votes pointing to this chain, miners will naturally save as many blocks as possible to ensure the competitiveness of their own chain;
对于指向其它链的投票,首先,记录它们并不会增加对方链条的竞争力,因为其指向的链本身也会记录,相反这些投票很可能在更大的分支之间做比较时转而帮助己方获胜。其次对出块矿工而言,如果记录了某个矿工的错误投票,就降低了这个矿工在本链出块的效率,从而增加了一些自己出块成功的几率,虽然只是小小的激励,但也足以促使矿工去记录这些本就不复杂的投票信息了。与此同时,每个区块也会尽量引用这些其它分支的区块(块头),用来支撑收集到的投票记录,从而完善了区块树。For votes pointing to other chains, first of all, recording them does not increase the competitiveness of the other chain, because the chain they point to is also recorded, on the contrary these votes are likely to help oneself when comparing between larger branches win. Secondly, for block miners, if the wrong vote of a certain miner is recorded, it will reduce the efficiency of the miner to generate blocks in this chain, thereby increasing the probability of successful block generation. Although it is only a small incentive, but It is also enough to prompt miners to record these uncomplicated voting information. At the same time, each block will try to refer to the blocks (block headers) of these other branches to support the collected voting records, thus completing the block tree.
优选地,在上述任意实施例中,步骤5具体为:Preferably, in any of the above embodiments, step 5 is specifically:
在投票链不中断的基础上,获得票数超过总票数三分之二的分支链的根节点区块作为终结块终结,该终结块所在链为终结链,完成共识;On the basis that the voting chain is not interrupted, the root node block of the branch chain that obtains more than two-thirds of the total votes is terminated as the final block, and the chain where the final block is located is the final chain to complete the consensus;
其中,所述投票链不中断具体为:Wherein, the uninterrupted voting chain is specifically:
矿工的第M次投票的区块至第N次投票的区块中至少包含一个终结块,其中,该矿工的第M次投票至该矿工的第N次投票依次相连,N≥2,M≤N。A miner's M-th voted block to N-th voted block contains at least one final block, wherein the miner's M-th vote to the miner's N-th vote are connected in sequence, N≥2, M≤ N.
需要说明的是,链式共识的终结过程不像BFT类型的协议那样,需要用多轮投票来保持节点之间严格的同步状态。当第一轮投票达成共识后,我们只需要保证这个共识是唯一的,而并不需要关心是否所有节点都接收到了投票结果,因此在理想情况下只需要一轮投票即可完成终结。但为了保证被终结的链不产生冲突(安全性),同时还要让投票者有机会修正自己投票,以防止陷入永远无法终结的境地(活性),情况就变得更加复杂了,需要增加新的投票规则并且推迟终结的时间。It should be noted that the finalization process of chain consensus does not require multiple rounds of voting to maintain a strict synchronization state between nodes, unlike BFT-type protocols. When a consensus is reached in the first round of voting, we only need to ensure that this consensus is unique, and do not need to care whether all nodes have received the voting results, so ideally only one round of voting is needed to complete the finalization. However, in order to ensure that the finalized chain does not conflict (security), and at the same time to allow voters to have the opportunity to modify their votes to prevent falling into a situation that can never be finalized (liveness), the situation becomes more complicated, and it is necessary to add new voting rules and postpone the closing time.
根据周期投票的机制和非诚实用户不超过1/3的前提,我们可以确定:只要一个分支在一个周期之内获得了2/3以上的选票,那么这个分支就不应该有竞争者,可以被终结。但是要保证所有被终结的分支都不相互冲突,即安全性,我们需要有一条从创世区块开始的连续的终结链。这需要投票者的 投票也能够前后连贯,为此我们修改了刚才的投票规则,在原有的规则上增加:According to the mechanism of periodic voting and the premise that dishonest users do not exceed 1/3, we can determine that as long as a branch has obtained more than 2/3 of the votes in a cycle, then this branch should have no competitors and can be end. But to ensure that all finalized branches do not conflict with each other, i.e. security, we need to have a continuous chain of finalizations starting from the genesis block. This requires that the votes of the voters can also be coherent. For this reason, we have modified the voting rules just now and added to the original rules:
在每次投票时需要向前连接他上一次的投票,称为“来源”。不连接来源的投票称为“无源投票”,作为对错误投票的修正,没有权重,但是可以被后面的投票用作来源。无源投票可以与有来源的投票在同一个周期内同时出现,但自身也需遵守之前的投票规则,否则也会被惩罚;Each vote needs to be connected forward to his previous vote, called "source". A vote that does not connect to a source is called a "passive vote", which acts as a correction to a wrong vote and has no weight, but can be used as a source by subsequent votes. Passive voting can appear in the same cycle as sourced voting, but it also needs to abide by the previous voting rules, otherwise it will also be punished;
创世块是第一个终结(finalized)块,在不违反其它规则的情况下创世块可被后面的投票用作来源;The genesis block is the first finalized block, which can be used as a source by subsequent votes without violating other rules;
来源位于终结块的投票称为“有根投票”,只有“有根投票”才具有权重和正确性,从而递进地产生后续的终结块,终结块之前的所有祖先块同时也视为已终结。“有根投票”可以向后传递;如图4所示,实心块表示已终结块,浅色实线表示有根投票,深色虚线表示无根投票,且图4中投票者因为前后冲突,因此他的投票链断了。如图5所示,继续图4的情况,当节点b成为了终结块之后,此投票者后面的投票又变成了有根投票,投票链重新连接起来。保证投票不冲突的原理很简单:因为投票者每次投票都只能与他上一次投票相连,所以如果存在冲突的投票,就不能在一条链上保持首尾相连,投票链就不会冲突。既然单个投票者的投票链不会冲突,那么基于连续投票链来生成的终结点也不会存在冲突,由此保证了安全性。如图6所示,只有连续的投票链才能终结区块。The vote whose source is located in the final block is called "rooted vote". Only the "rooted vote" has weight and correctness, thus generating subsequent final blocks progressively. All ancestor blocks before the final block are also regarded as finalized. . "Rooted voting" can be passed backwards; as shown in Figure 4, solid blocks indicate terminated blocks, light solid lines indicate rooted voting, and dark dashed lines indicate rootless voting. So his voting chain was broken. As shown in Figure 5, continuing the situation in Figure 4, when node b becomes the final block, the vote behind the voter becomes a rooted vote, and the voting chain is reconnected. The principle of ensuring that votes do not conflict is very simple: because each vote of a voter can only be connected to his previous vote, if there are conflicting votes, they cannot be kept end-to-end on a chain, and the voting chain will not conflict. Since the voting chains of a single voter will not conflict, the endpoints generated based on the continuous voting chain will not conflict, thus ensuring security. As shown in Figure 6, only a continuous voting chain can finalize blocks.
优选地,在上述任意实施例中,步骤5还包括:Preferably, in any of the above embodiments, step 5 further includes:
基于终结条件,对第一预设周期内是否存在关键分叉进行判断;Based on the termination condition, determine whether there is a key fork in the first preset period;
其中,终结条件具体为:满足间隔不超过n个周期的连续投票的区块具有投票权重;Among them, the termination condition is specifically: the block that satisfies the continuous voting interval of no more than n cycles has the voting weight;
第一预设周期为:The first preset period is:
n+1个周期,n为正整数;n+1 periods, n is a positive integer;
关键分叉具体为:The key forks are as follows:
无法继续终结的分叉。A fork that cannot continue to terminate.
需要注意的是,出现分叉后,很可能有超过1/3的选票被投向错误的分支,一旦出现这种情况,终结链就断了而且无法恢复。所以要保证活性就比较复杂:首先要对这种情况——称为“关键分叉”——能够察觉;然后允许下次投票的来源从本次投票位置倒退回分叉的地方,给投票者一个反悔的空间,使他们能够及时改正之前的决定,回到主链上来;最后把终结位置也推迟到分叉的地方。It should be noted that after a fork occurs, it is very likely that more than 1/3 of the votes will be cast to the wrong branch. Once this happens, the finalization chain will be broken and cannot be recovered. Therefore, it is more complicated to ensure liveness: first, we must be able to detect this situation - called "critical fork"; then allow the source of the next vote to go back from the current voting position to the fork, and give the voter A space for repentance, so that they can correct their previous decisions in time and return to the main chain; finally, the final position is also postponed to the fork.
为了能够察觉关键分叉,要对终结条件做一些调整,之前的条件是一个分支“在一个投票周期之内获得超过总数2/3的选票”,改为“在一个投票周期之内获得超过总数2/3的选票,且这些选票的投票目标距离来源都小于两个周期”,换句话说,必须是由连续投票(间隔不到两周期)选出来的分支才能被终结。此终结条件把能产生终结的所有投票的来源都集中在终结点之前的两个周期范围之内,这样只需要在这个范围进行检查,看是否有足够的投票就可以了,如图7所示,满足区块b的终结条件的投票目标集中在b为更节点的1周期长的分支上,而来源集中在a之前2周期长的链上。To be able to detect key forks, some adjustments have to be made to the finalization condition. The previous condition was that a branch "receives more than 2/3 of the total number of votes within a voting cycle" to "receives more than 2/3 of the total number of votes within a voting cycle" 2/3 of the votes, and the voting targets of these votes are less than two cycles away from the source", in other words, the branch elected by consecutive votes (less than two cycles apart) can be terminated. This termination condition concentrates all the sources of votes that can generate termination within the range of two cycles before the termination point, so that it is only necessary to check in this range to see if there are enough votes, as shown in Figure 7 , the voting target that satisfies the termination condition of block b is concentrated on the 1-cycle long branch where b is a more node, and the source is concentrated on the 2-cycle long chain before a.
优选地,在上述任意实施例中,步骤5还包括:Preferably, in any of the above embodiments, step 5 further includes:
当终结链断开的情况时,将下次投票的区块的来源块退回至通过回溯算法得到的回撤点区块;When the finalization chain is disconnected, return the source block of the next voting block to the retracement point block obtained through the backtracking algorithm;
其中,来源块为与本次投票相连的上一次投票的区块。Among them, the source block is the last voted block connected to the current vote.
优选地,在上述任意实施例中,通过回溯算法得到的回撤点区块具体为:Preferably, in any of the above embodiments, the setback point block obtained by the backtracking algorithm is specifically:
所述回溯算法具体为:The backtracking algorithm is specifically:
统计当前区块之前的所述第一预设周期内,该区块所在区块链上获得的选票数,得到第一选票总数,判断所述第一选票总数是否大于总票数的三分之二,若是,则反悔期I=0,若不是,则,将当前区块的高度h的投票回溯 至高度为h-1的位置,重新计算所述第一选票总数,判断所述第一选票总数是否大于总票数的三分之二,若是,则反悔期I=1,若不是,则将回溯至高度为h-1的位置的投票与高度为h-1的投票合并,回溯至高度为h-2的位置,重复上述过程,直至所述第一选票总数大于总票数的三分之二,得到反悔期I=i,其中,i为回溯次数;Count the number of votes obtained on the blockchain where the block is located in the first preset period before the current block, obtain the first total number of votes, and determine whether the first total number of votes is greater than two-thirds of the total number of votes , if it is, then the estoppel period I=0, if not, then retrospect the vote of the height h of the current block to the position of height h-1, recalculate the total number of the first votes, and judge the total number of the first votes Whether it is greater than two-thirds of the total number of votes, if so, the estoppel period I = 1, if not, merge the votes backdated to the height h-1 with the votes of the height h-1, backtracked to the height h For the position of -2, repeat the above process until the total number of first votes is greater than two-thirds of the total number of votes, and the estoppel period I=i is obtained, where i is the number of backtracking;
所述回撤点区块具体为:The retracement point block is specifically:
高度为h-I的区块。Blocks with height h-I.
需要说明的是,察觉到关键分叉后,我们使用一种回溯算法来找到分叉点和它对应的投票反悔期长度:It should be noted that, after detecting the key fork, we use a backtracking algorithm to find the fork point and its corresponding estoppel period:
当生成一个高度为h的块a时,我们使用一个自然数I来表示a位置的临时“反悔期”,高度h-I的区块称为临时“回撤点”,回撤点通常也等同于分叉点。I的取值基于于以下计算结果:When a block a of height h is generated, we use a natural number I to represent the temporary "retroversion period" at the position of a. The block of height h-I is called the temporary "retracement point", and the retraction point is usually equivalent to a fork. point. The value of I is based on the following calculation results:
1)a之前(包括a)两个投票周期内的链上获得的选票数超过总选票的2/3时,I=0,同一投票人只计最后一次投票;1) When the number of votes obtained on the chain before a (including a) in the two voting cycles exceeds 2/3 of the total votes, I=0, and the same voter only counts the last vote;
2)上述票数小于等于总选票的2/3时,将目标是h高度的所有投票往前回溯到高度h-1,再和目标高度h-1的所有投票一起往前回溯到h-2,以此类推,当回溯到高度h-i时,满足1)条件,则n=I,由于对高度为h的区块的绝大部分投票都保存在高度h+1的区块中,所以上面这个工作实际上是在生成a的下一个区块a’的时候来做的,对应的I值也保存在a’中,但这并不影响算法实现,因为n在被使用的时候a’必定早就生成了。更进一步地,可以把“目标是h高度的所有投票”改进为“保存在h+1高度的所有投票”并以此类推,这样能够把那些没有在第一时间被记录或者推迟发布的投票都计算进来。2) When the above number of votes is less than or equal to 2/3 of the total votes, all the votes with the target height of h are backtracked to the height h-1, and then all the votes with the target height of h-1 are backtracked forward to h-2, By analogy, when backtracking to height h-i, the condition 1) is satisfied, then n=I, since most of the votes for the block with height h are stored in the block with height h+1, so the above work In fact, it is done when the next block a' of a is generated, and the corresponding I value is also stored in a', but this does not affect the implementation of the algorithm, because a' must be early when n is used. generated. Further, "all votes targeted at height h" can be improved to "all votes saved at height h+1" and so on, so that those votes that were not recorded or delayed in the first time can be released. Calculate in.
3)a位置的临时回撤点高度不能低于a前2周期处的临时回撤点高度;如图8所示,当大于三分之一的选票在A处分叉,且网络刚好在此时出现了 故障,导致这些投票信息全部丢失时为最坏情况,此时需要一个检测长度的时间才能察觉到分叉。3) The height of the temporary retracement point at position a cannot be lower than the height of the temporary retracement point 2 cycles before a; as shown in Figure 8, when more than one third of the votes fork at A, and the network happens to be here The worst case is when a fault occurs when all the voting information is lost, and it takes a detection length of time to detect the fork.
4)a位置的实际回撤点取自a位置之后(包括a)2周期内最早的那个临时回撤点,实际反悔期I也由此而来;因此,在最坏的情况下一个区块在其生成后需要等2个周期才能被终结。但通常情况下,只要区块之后的一条链在这2个周期之前获得了2/3的选票,就不会再有回撤点早于它了,可以立即被终结。4) The actual retracement point of position a is taken from the earliest temporary retracement point in 2 cycles after position a (including a), and the actual reversal period I also comes from this; therefore, in the worst case, a block It needs to wait 2 cycles after it is generated before it can be terminated. But normally, as long as a chain after the block gets 2/3 of the votes before these 2 epochs, there will be no retracement point before it and can be terminated immediately.
优选地,在上述任意实施例中,步骤5还包括:在所述反悔期内,终结区块回撤至所述回撤点区块。Preferably, in any of the above embodiments, step 5 further includes: within the estoppel period, the end block is withdrawn to the withdrawal point block.
需要说明的是,获得了反悔期之后,投票回撤和区块终结过程如下:It should be noted that after the estoppel period is obtained, the process of voting withdrawal and block finalization is as follows:
矿工的每次投票只能使用他上次投票目标或其回溯I步(包括I)以内的区块作为来源,I值取自于此矿工上次投票目标的高度上,相关链的实际反悔期I,违反此规则的矿工将被惩罚,如图9所示,反悔期、投票回撤和终结点前移。“上次投票目标的高度上”可改进为“上次投票在本链保存的高度-1的位置上”,与回溯算法第2)条的改进相对应;“相关链上违反此规则”中的“相关链”是指投票记录中的来源和目标分别所在的链,当投票的来源和目标不在同一链上时,分别取得两条链上在来源高度的实际反悔期,然后取其中较短的一个。Each vote of a miner can only use the target of his last vote or the block within I steps back (including I) as the source. The value of I is taken from the height of the target of this miner's last vote, and the actual retrogress period of the relevant chain. I, Miners who violate this rule will be punished, as shown in Figure 9, with estoppel period, vote withdrawal and endpoint advance. "The height of the last voting target" can be improved to "the last voting was at the position of the height -1 saved in this chain", which corresponds to the improvement of Article 2) of the backtracking algorithm; "This rule is violated on the relevant chain" in The "relevant chain" refers to the chain where the source and target in the voting record are located respectively. When the source and target of the vote are not on the same chain, the actual estoppel period at the source height on the two chains is obtained respectively, and then the shorter one is taken. one of.
从根部算起,当一个分支在一个投票周期之内获得的选票超过系统总选票的2/3,而且这些选票的投票记录中来源和目标之间的距离都小于2个投票周期时,满足终结条件,但终结区块不一定是分支的根节点b,而是b处的实际回撤点B。Counting from the root, when a branch gets more than 2/3 of the total votes of the system within a voting cycle, and the distance between the source and the target in the voting records of these votes is less than 2 voting cycles, the end is satisfied. condition, but the final block is not necessarily the root node b of the branch, but the actual retracement point B at b.
依照这种方法,在通常(较理想)情况下,I值都为0,可以在生成区块后大约2/3个投票周期完成终结,偶尔会有一些分歧比较严重的分叉可能会延续几个周期的长度,但总体时间一定远小于两个周期。在一些网络状况很 差或遭受攻击导致投票特别分散的情况下,可以预先察觉到分叉并且延迟终结,放宽投票要求,提高系统容错率,可以防止被比如“左右摇摆以延长分叉长度”式的恶意攻击而导致失去活性。顺便提到的分支重量计算方式——不是像LMD(Latest Message Driven)方案那样只统计最后一次投票,而是相对麻烦地把每次投票都统计在内,并且按周期投票,也是因为这样做对此类攻击具有较强的抵抗力。According to this method, under normal (ideal) conditions, the I value is 0, which can be completed in about 2/3 of the voting cycle after the block is generated. Occasionally, some serious forks may continue for several days. period, but the overall time must be much less than two periods. In some cases where the network conditions are very poor or the voting is particularly scattered due to an attack, the fork can be detected in advance and the termination is delayed, the voting requirements are relaxed, the fault tolerance rate of the system is improved, and the system can be prevented from being swayed from side to side to extend the length of the fork. inactive due to malicious attacks. The branch weight calculation method mentioned by the way - instead of only counting the last vote like the LMD (Latest Message Driven) scheme, it is relatively troublesome to count each vote and vote on a periodic basis, also because doing so is right Such attacks have strong resistance.
一种存储介质,所述存储介质中存储有指令,当计算机读取所述指令时,使所述计算机执行如上述任一项所述的一种链式周期投票的共识方法。A storage medium storing instructions, when a computer reads the instructions, the computer is made to execute a consensus method for chained periodic voting as described in any of the above.
在一些可能的实施方式中,通过上述方法有效的将确认主链和终结过程结合起来,及降低了代码复杂程度有提高了处理的效率,另外,还具有权益证明低能耗、链式公式对网络环境的高容错、验证节点更多且要求更加宽松,此外还保证了安全性以及灵活性。In some possible implementations, the above method effectively combines the confirmation main chain and the finalization process, and reduces the complexity of the code and improves the processing efficiency. In addition, it also has the proof of stake, low energy consumption, and chain formula to the network. The environment is highly fault-tolerant, with more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
一种电子设备,包括存储器、处理器及存储在所述存储器上并在所述处理器上运行的程序,所述处理器执行所述程序时实现如上述任一项所述的一种链式周期投票的共识方法。An electronic device, comprising a memory, a processor and a program stored on the memory and running on the processor, the processor implements a chain type as described in any of the above when the processor executes the program Consensus method for periodic voting.
在一些可能的实施方式中,通过上述方法有效的将确认主链和终结过程结合起来,及降低了代码复杂程度有提高了处理的效率,另外,还具有权益证明低能耗、链式公式对网络环境的高容错、验证节点更多且要求更加宽松,此外还保证了安全性以及灵活性。In some possible implementations, the above method effectively combines the confirmation main chain and the finalization process, and reduces the complexity of the code and improves the processing efficiency. In addition, it also has the proof of stake, low energy consumption, and chain formula to the network. The environment is highly fault-tolerant, with more validating nodes and more relaxed requirements, in addition to ensuring security and flexibility.
读者应理解,在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情 况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。The reader should understand that in the description of this specification, reference to the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples", etc., is intended to incorporate the embodiment or example. A particular feature, structure, material, or characteristic described is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine the different embodiments or examples described in this specification, as well as the features of the different embodiments or examples, without contradicting each other.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的方法实施例仅仅是示意性的,例如,步骤的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个步骤可以结合或者可以集成到另一个步骤,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the method embodiments described above are only illustrative. For example, the division of steps is only a logical function division. In actual implementation, there may be other division methods. For example, multiple steps may be combined or integrated into another A step, or some feature, can be ignored, or not performed.
上述方法如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,RandomAccessMemory)、磁碟或者光盘等各种可以存储程序代码的介质。If the above method is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or a part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes: U disk, removable hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes.
以上,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or modifications within the technical scope disclosed by the present invention. Replacement, these modifications or replacements should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (10)

  1. 一种链式周期投票的共识方法,其特征在于,包括:A consensus method for chain cycle voting, characterized in that it includes:
    步骤1,获得投票权成为矿工;Step 1, get voting rights to become a miner;
    步骤2,矿工通过生成随机数竞争出块,出块几率与矿工持有的选票成正比;Step 2, miners compete to generate blocks by generating random numbers, and the probability of block generation is proportional to the votes held by miners;
    步骤3,矿工周期性的对区块进行投票;Step 3: Miners periodically vote on blocks;
    步骤4,根据投票结果选择主链;Step 4, select the main chain according to the voting results;
    步骤5,在主链中,将满足终结条件的区块终结,完成共识。Step 5: In the main chain, the blocks that meet the termination conditions are terminated to complete the consensus.
  2. 根据权利要求1所述的一种链式周期投票的共识方法,其特征在于,步骤1具体为:A consensus method for chained periodic voting according to claim 1, wherein step 1 is specifically:
    当权益人选择弃权时,发布弃权记录,当权益人未选择弃权且满足第一预设条件时,生成选票,获得投票权,获得投票权的权益人成为矿工;When the stakeholder chooses to abstain from voting, the abstention record is published. When the stakeholder does not choose to abstain from voting and the first preset condition is met, a vote is generated and the voting right is obtained, and the stakeholder who has obtained the voting right becomes a miner;
    其中,所述第一预设条件为:Wherein, the first preset condition is:
    VRF_VoteProof<Account_stakesVRF_VoteProof < Account_stakes
    其中,Account_stakes为账户权益,VRF_VoteProof为随机数生成函数。Among them, Account_stakes is the account equity, and VRF_VoteProof is the random number generation function.
  3. 根据权利要求1所述的一种链式周期投票的共识方法,其特征在于,步骤4具体为:A consensus method for chain periodic voting according to claim 1, wherein step 4 is specifically:
    根据重量对每个分支链进行优先级比较,将优先级最高的分支链作为主链;Priority is compared for each branch chain according to weight, and the branch chain with the highest priority is used as the main chain;
    其中,所述重量为:一个分支链的根节点、所述根节点的所有子节点以及所述根节点的孙节点所获得的选票总数;Wherein, the weight is: the total number of votes obtained by the root node of a branch chain, all child nodes of the root node, and grandchild nodes of the root node;
    所述优先级比较具体为:The priority comparison is specifically:
    从分支链共同的区块开始,分别计算各自分支链的重量总和,重量总和最高者为优先级。Starting from the blocks common to the branch chains, the weight sums of the respective branch chains are calculated respectively, and the one with the highest weight sum is given priority.
  4. 根据权利要求1所述的一种链式周期投票的共识方法,其特征在于,步骤5具体为:The consensus method for chain periodic voting according to claim 1, wherein step 5 is specifically:
    在投票链不中断的基础上,获得票数超过总票数三分之二的分支链的根节点区块作为终结块终结,该终结块所在链为终结链,完成共识;On the basis that the voting chain is not interrupted, the root node block of the branch chain that obtains more than two-thirds of the total votes is terminated as the final block, and the chain where the final block is located is the final chain to complete the consensus;
    其中,所述投票链不中断具体为:Wherein, the uninterrupted voting chain is specifically:
    矿工的第M次投票的区块至第N次投票的区块中至少包含一个终结块,其中,该矿工的第M次投票至该矿工的第N次投票依次相连,N≥2,M≤N。A miner's M-th voted block to N-th voted block contains at least one final block, wherein the miner's M-th vote to the miner's N-th vote are connected in sequence, N≥2, M≤ N.
  5. 根据权利要求4所述的一种链式周期投票的共识方法,其特征在于,步骤5还包括:The consensus method for chain periodic voting according to claim 4, wherein step 5 further comprises:
    基于终结条件,对第一预设周期内是否存在关键分叉进行判断;Based on the termination condition, determine whether there is a key fork in the first preset period;
    其中,终结条件具体为:满足间隔不超过n个周期的连续投票的区块具有投票权重;Among them, the termination condition is specifically: the block that satisfies the continuous voting interval of no more than n cycles has the voting weight;
    第一预设周期为:The first preset period is:
    n+1个周期,n为正整数;n+1 periods, n is a positive integer;
    关键分叉具体为:The key forks are as follows:
    无法继续终结的分叉。A fork that cannot continue to terminate.
  6. 根据权利要求5所述的一种链式周期投票的共识方法,其特征在于,步骤5还包括:A consensus method for chained periodic voting according to claim 5, wherein step 5 further comprises:
    当终结链断开的情况时,将下次投票的区块的来源块退回至通过回溯算法得到的回撤点区块;When the finalization chain is disconnected, return the source block of the next voting block to the retracement point block obtained through the backtracking algorithm;
    其中,来源块为与本次投票相连的上一次投票的区块。Among them, the source block is the last voted block connected to the current vote.
  7. 根据权利要求6所述的一种链式周期投票的共识方法,其特征在于,通过回溯算法得到的回撤点区块具体为:A consensus method for chain periodic voting according to claim 6, characterized in that the retracement point block obtained by the backtracking algorithm is specifically:
    所述回溯算法具体为:The backtracking algorithm is specifically:
    统计当前区块之前的所述第一预设周期内,该区块所在区块链上获得的选票数,得到第一选票总数,判断所述第一选票总数是否大于总票数的三分之二,若是,则反悔期I=0,若不是,则,将当前区块的高度h的投票回溯至高度为h-1的位置,重新计算所述第一选票总数,判断所述第一选票总数是否大于总票数的三分之二,若是,则反悔期I=1,若不是,则将回溯至高度为h-1的位置的投票与高度为h-1的投票合并,回溯至高度为h-2的位置,重复上述过程,直至所述第一选票总数大于总票数的三分之二,得到反悔期I=i,其中,i为回溯次数;Count the number of votes obtained on the blockchain where the block is located in the first preset period before the current block, obtain the first total number of votes, and determine whether the first total number of votes is greater than two-thirds of the total number of votes , if it is, then the estoppel period I=0, if not, then retrospect the vote of the height h of the current block to the position of height h-1, recalculate the total number of the first votes, and judge the total number of the first votes Whether it is greater than two-thirds of the total number of votes, if so, the estoppel period I = 1, if not, merge the votes backdated to the height h-1 with the votes of the height h-1, backtracked to the height h For the position of -2, repeat the above process until the total number of first votes is greater than two-thirds of the total number of votes, and the estoppel period I=i is obtained, where i is the number of backtracking;
    所述回撤点区块具体为:The retracement point block is specifically:
    高度为h-I的区块。Blocks with height h-I.
  8. 根据权利要求7所述的一种链式周期投票的共识方法,其特征在于,步骤5还包括:在所述反悔期内,终结区块回撤至所述回撤点区块。The consensus method for chain periodic voting according to claim 7, wherein step 5 further comprises: within the estoppel period, the end block is withdrawn to the withdrawal point block.
  9. 一种存储介质,其特征在于,所述存储介质中存储有指令,当计算机读取所述指令时,使所述计算机执行如权利要求1至8中任一项所述的一种链式周期投票的共识方法。A storage medium, wherein an instruction is stored in the storage medium, and when a computer reads the instruction, the computer is made to execute a chain cycle according to any one of claims 1 to 8 Consensus method for voting.
  10. 一种电子设备,包括存储器、处理器及存储在所述存储器上并在所述处理器上运行的程序,其特征在于,所述处理器执行所述程序时实现如权 利要求1至8任一项所述的一种链式周期投票的共识方法。An electronic device, comprising a memory, a processor, and a program stored on the memory and running on the processor, characterized in that, when the processor executes the program, any one of claims 1 to 8 is implemented A consensus method for chained periodic voting described in item .
PCT/CN2022/074000 2021-05-07 2022-01-26 Consensus method for chain-type periodic voting, and storage medium and electronic device WO2022233164A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110495622.6A CN113660299A (en) 2021-05-07 2021-05-07 Chain type periodic voting consensus method, storage medium and electronic device
CN202110495622.6 2021-05-07

Publications (1)

Publication Number Publication Date
WO2022233164A1 true WO2022233164A1 (en) 2022-11-10

Family

ID=78489096

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/074000 WO2022233164A1 (en) 2021-05-07 2022-01-26 Consensus method for chain-type periodic voting, and storage medium and electronic device

Country Status (2)

Country Link
CN (1) CN113660299A (en)
WO (1) WO2022233164A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113660299A (en) * 2021-05-07 2021-11-16 杨鉴 Chain type periodic voting consensus method, storage medium and electronic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108416593A (en) * 2018-03-20 2018-08-17 杨鉴 A kind of block chain common recognition method and system proved based on network dispersion degree
CN109784885A (en) * 2018-12-29 2019-05-21 杨鉴 A kind of block chain ballot common recognition method and system based on equity
US20200092085A1 (en) * 2018-09-18 2020-03-19 Nhn Corporation Blockchain system including a distributed network of a plurality of nodes and a method for achieving an agreement between the plurality of nodes executed by processors of the block chain system
CN112182661A (en) * 2020-08-31 2021-01-05 武汉市果壳璐网络科技有限公司 Block chain consensus method, device, storage medium and equipment
CN113660299A (en) * 2021-05-07 2021-11-16 杨鉴 Chain type periodic voting consensus method, storage medium and electronic device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108416593A (en) * 2018-03-20 2018-08-17 杨鉴 A kind of block chain common recognition method and system proved based on network dispersion degree
US20200092085A1 (en) * 2018-09-18 2020-03-19 Nhn Corporation Blockchain system including a distributed network of a plurality of nodes and a method for achieving an agreement between the plurality of nodes executed by processors of the block chain system
CN109784885A (en) * 2018-12-29 2019-05-21 杨鉴 A kind of block chain ballot common recognition method and system based on equity
CN112182661A (en) * 2020-08-31 2021-01-05 武汉市果壳璐网络科技有限公司 Block chain consensus method, device, storage medium and equipment
CN113660299A (en) * 2021-05-07 2021-11-16 杨鉴 Chain type periodic voting consensus method, storage medium and electronic device

Also Published As

Publication number Publication date
CN113660299A (en) 2021-11-16

Similar Documents

Publication Publication Date Title
Nguyen et al. Proof-of-stake consensus mechanisms for future blockchain networks: fundamentals, applications and opportunities
US11669811B2 (en) Blockchain-based digital token utilization
Grunspan et al. On profitability of selfish mining
US20190236716A1 (en) Consensus system for managing digital record
Ma et al. Market structure in bitcoin mining
Auer Beyond the doomsday economics of'proof-of-work'in cryptocurrencies
Fanti et al. Economics of proof-of-stake payment systems
CN109426952A (en) A kind of block chain framework
US11381589B2 (en) Systems and methods for distributed extended common vulnerabilities and exposures data management
KR20190111707A (en) Blockchain system with consensus algorithm based on proof-of -transaction and method there of
CN112104482B (en) Consensus method based on parallel voting
CN110611701A (en) Parameter configuration and transaction processing method based on block chain
WO2022233164A1 (en) Consensus method for chain-type periodic voting, and storage medium and electronic device
Gans et al. More (or less) economic limits of the blockchain
Boyen et al. Blockchain-Free Cryptocurrencies
CN112288415B (en) Currency age mechanism implementation method for UTXO architecture
CN114185995A (en) Block chain consensus mechanism based on contribution value and credit degree
Kogan et al. Economics of proof-of-stake payment systems
Wang et al. Proof-of-activity consensus algorithm based on K-medoids clustering
Dimitri Consensus: Proof of Work, Proof of Stake and structural alternatives
GB2599734A (en) Blockchain
Biswas et al. Proof of Karma (PoK): A Novel Consensus Mechanism for Consortium Blockchain
Ruan et al. Ursa: Robust performance for Nakamoto consensus with self-adaptive throughput
Kaidalov et al. Ethereum classic treasury system proposal
US20230410102A1 (en) Blockchain

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22798506

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22798506

Country of ref document: EP

Kind code of ref document: A1