A kind of Byzantine failure tolerance common recognition method applied to block chainTechnical field
The invention belongs to block chain technical fields, and in particular to a kind of Byzantine failure tolerance common recognition side applied to block chainMethod.
Background technique
Block chain (Blockchain) is a key concept of bit coin, is substantially a decentralization, can not usurpThe distributed account book changed, while the Floor layer Technology as bit coin.Block chain is a string using the associated generation of cryptography methodBlock, several bit coin network transaction informations are contained in each block, for verifying the validity (anti-fake) of its informationWith the next block of generation.
Under the premise of mutually mistrustful, need to form consistent common recognition to the validity of block.In actual use processIn, data transmission is faced with the various abnormal conditions such as network delay, Network Packet Loss, hacker attacks.For these abnormal conditions, areaBlock chain needs a kind of method, when these abnormal conditions occur, still is able to reach common understanding.
The common recognition method that traditional block chain uses is proof of work, i.e., the block in each block chain includes oneRandom string only searches the character string met certain condition by calculating, and block could generate and be added into block chain.Proof of work has the disadvantage in that (1) wastes computing resource;(2) time that block generates can not determine, may produce soonRaw new block, it is also possible to cross and just generate a new block for a long time;(3) calculating the strong node of power can produce to the weak node of power is calculatedIt is raw to calculate power attack, cause the calculation power between block chain node to compete;(4) there is no certainty, bifurcated can be generated.
Summary of the invention
For drawbacks described above present in the prior art, the present invention provides a kind of Byzantine failure tolerances applied to block chainCommon recognition method can save computing resource, avoid and calculate power competition.
A kind of Byzantine failure tolerance common recognition method applied to block chain is as follows:
A certain number of equity accounts and common recognition account are initially distributed into the node in distributed system;
Each common recognition node participates in the common recognition process that block chain is added in each block after logging in using common recognition account, described is total toKnowing node is the node for possessing common recognition account in distributed system;
The common recognition process of block chain is added for current block, elects a node from common recognition node first as nominationNode is encapsulated from several transaction records are chosen in trading pit into current block by nominated node, and then is initiated about currentThe proposal of block chain is added in block, and moves that a vote be taken simultaneously to this to proposal described in other common recognition node broadcasts, this is mentionedAll final wheel voting results that block chain is added about previous block received in view comprising current block and nominated nodeInformation;
After other common recognition nodes receive the proposal, to the authenticity of the proposal and its promoter, reliability and legalProperty verified, move that a vote be taken after being verified to this, verifying is not by ignoring the proposal then;
In certain time interval T, when being more than certain proportion η1Common recognition node vote through about current block be added blockThe proposal of chain, then node of respectively knowing together, which submit to current block, makes its that local block last-in-chain(LIC) tail be added, and starts about nextThe common recognition process of block addition block chain;
In certain time interval T, when being more than certain proportion η2But it is less than certain proportion η1Common recognition node vote through aboutThe proposal of block chain is added in current block, then enters next round and re-elect nominated node, is saved from nominated node to other common recognitionsPoint broadcast its receive about last round of all voting results information, and then make each common recognition node to the proposal again intoRow is voted, wherein η1And η2It is real number and 0 < η2< η1< 1;
In certain time interval T, it is less than certain proportion η2Common recognition node vote through about current block be added blockThe proposal of chain, then the proposal is cancelled and re-elects nominated node into next round, is selected again from trading pit by nominated nodeTake several transaction records to encapsulate into current block, so initiate about current block be added block chain it is new propose and to itsHe knows together new proposal described in node broadcasts, in the new proposal comprising current block and nominated node receive about previous areaAll final wheel voting results information of block chain are added in block, and then each common recognition node is made newly to move that a vote be taken described.
Further, the quantity for initializing equity account is more than or equal to 1, and the quantity for account of knowing together is more than or equal to 4.
Further, each equity node, which aperiodically passes through, votes to increase or decrease the quantity of common recognition account;WhenIt votes through more than a certain proportion of equity node about the resolution for increasing or decreasing common recognition account, then issues and close to all nodesIn the request for increasing or decreasing common recognition account, comprising increasing or decreasing the distribution letter of account of respectively knowing together after common recognition account in the requestBreath, the equity node is the node for possessing equity account in distributed system.
Further, during common recognition, if be more than it is a certain proportion of common recognition node receive equity node sending aboutThe request of common recognition account is increased or decreased, each node of knowing together suspends common recognition process and updates local common recognition node listing to complete altogetherKnow the increase and decrease operation of node;When being more than increase and decrease operation that a certain proportion of common recognition node completes common recognition node, it is each know together node afterCommon recognition process before continuous.
Further, detailed process of the node as nominated node is elected from common recognition node are as follows: if current common recognitionNode number is N, then presses 0,1,2,3 for each common recognition node ..., and N-1 is numbered, and is counted according to formula p=rand (h, r) %NNumber p is calculated, makes the common recognition node that number is p as nominated node;It is h and the random letter of r that wherein rand (h, r), which is independent variable,Number, h are the length of block chain after current block is added, and r is during knowing together when front-wheel number, and % is complementation symbol.
Further, if a certain common recognition node is added previous block since network cause does not receive other common recognition nodesThe final wheel voting results information of block chain does not complete the submission to previous block so as to cause it, then the common recognition node verification is logicalAfter crossing the proposal that block chain is added about current block, all of block chain are added about previous block by subsidiary in the proposalFinal voting results information of taking turns is added in local ballot statistics pond, and then carrying out submission to previous block makes its that local block be addedChain end.
Further, the certain time interval T=Tbase*Cr, wherein r is during knowing together as front-wheel number, TbaseIt is preset constant with C.
Further, after any common recognition node votes to the proposal, then its voting results information is broadcast to itHe knows together node, and the voting results information that common recognition node is received according to it is to decide whether to submit current block;When appointAfter one common recognition node is completed to the submission of current block, then submits it successful information and be broadcast to other common recognition nodes;When anyAfter node of knowing together completes the increase and decrease operation of common recognition node, is then operated successful information and be broadcast to other common recognition nodes.
Advantageous effects of the invention are as follows:
1. saving computing resource.
It 2. block can be continuously generated, can produce a large amount of blocks in the short time, do not generate area in the case of no transactionBlock.
3. only authorization node just participates in common recognition process, avoids and calculate power competition.
4. having certainty, block is once it is determined that be end-state.
Detailed description of the invention
Fig. 1 is the flow diagram of common recognition process of the present invention.
Fig. 2 is that the state during present invention common recognition shifts schematic diagram.
Fig. 3 is the flow diagram of present invention common recognition node increase and decrease operation.
Fig. 4 is that the state of present invention common recognition node increase and decrease operation shifts schematic diagram.
Specific embodiment
In order to more specifically describe the present invention, with reference to the accompanying drawing and specific embodiment is to technical solution of the present inventionIt is described in detail.
The present invention is applied to the Byzantine failure tolerance common recognition method of block chain, and detailed process is as follows:
Firstly, the initial common recognition account that specified quantity is M in the original block of block chain equity account and quantity are N, M >=1, N >=4;Present embodiment is originated in block chain specifies 3 equity accounts (being denoted as Q1, Q2, Q3) and 4 to be initially total in blockKnow account (being denoted as G1, G2, G3, G4).
Each node for participating in common recognition is logged in using common recognition account, and present embodiment has 4 nodes to participate in common recognition, respectivelyIt is logged in G1, G2, G3, G4.Communication between common recognition node uses P2P peer-to-peer network, and node of knowing together is in subsequent proposition new blockProposal, vote block, need using common recognition account private key to propose, ballot sign, to solve to know togetherThe Verify Your Identity questions of node.
As shown in Figure 1, common recognition process starts, current block height h is 1000, and current pass r is 0.Height is 0~999Block common recognition is completed.Node G1, G2, G3, G4 use random algorithm formula p=rand (h, r) %N computed altitude to be respectively1000 bouts be 0 block nominated node, p=rand (1000,0) %4, it is assumed that p calculate after the result is that 1.Because p is possibleThe result is that 0,1,2,3, respectively correspond G1, G2, G3, G4.Therefore p=1 represents block nominated node as G2.Because of G1, G2, G3,G4 respectively calculates block nominated node, is 1000 to height when there is non-honest node to attempt, the block that bout is 0 generates nominationWhen, remaining all honest node will all refuse the nomination of non-honest node.G2 node selects qualified transaction in trading pit,Upper height subsidiary simultaneously is the vote information of 999 blocks, initiates and broadcast the proposal BlockProposal [1000] of new block,Meanwhile G2 proposes that BlockProposal [1000] vote to new block.
After other nodes receive BlockProposal [1000], first verify that whether nominated node is G2, if notG2 then ignores BlockProposal [1000];Then to it includes height be 999 the vote information of block verify,If verifying does not pass through, ignore BlockProposal [1000];Then the transaction to including in BlockProposal [1000]It is verified, verifies whether transaction therein is all correct legal transaction.BlockProposal [1000] is verified itAfterwards, if there is node not yet submits block that block height is 999 (since network cause causes not receive Partial Height to be 999Block ballot), the subsidiary ballot of BlockProposal [1000] is added to height and is counted in pond for 999 ballot, and is submittedThe block that height is 999.Then node votes to BlockProposal [1000], and ballot is broadcast to other sectionsPoint.
Each node respectively records the vote information of all nodes.As shown in Fig. 2, at T=3 seconds, (T=Tbase*C^r is enabledTbase=3, C=1.5, r=0) within, if there is 3 and the above node are (more than N* η1) to BlockProposal [1000]It is voted, entire block chain network has reached common recognition to height for 1000 block nomination, and each node passes throughBlockProposal [1000] generates No. 1000 block, and is submitted in local block chain database, starts height later and is1001 block common recognition process.
If thering are 2 nodes (to be less than N* η within 3 seconds1, but more than N* η2) to BlockProposal [1000]It votes, expression is likely to form common recognition, then enters second leg r=1.Computed altitude is that the block that 1000 bouts are 1 mentionsFamous person, p=rand (1000,1) %4, it is assumed that the calculated result of p is G3, then the ballot of bout is nominated in G3 broadcast, and request is eachNode is voted again.If had super within T=4.5 seconds (T=Tbase*C^r enables Tbase=3, C=1.5, r=1)It crosses 3 nodes to be voted, then it represents that reach common understanding, submit No. 1000 block, start the common recognition that height is 1001 blocksProcess;Otherwise the request of additional ballot is carried out by ballot quantity or re-start the nomination that height is 1000 blocks.
If only 2 (are less than N* η with lower node within 3 seconds2) BlockProposal [1000] is thrownTicket, the wheel bout are proposed to cancel, then enter second leg r=1.Computed altitude is the block nominator that 1000 bouts are 1, p=Rand (1000,1) %4, according to previous step it is assumed that the calculated result of p is G3.G3 has found BlockProposal [1000]Ballot be less than N* η2, ignore BlockProposal [1000], regenerate new block nomination BlockProposal[1000]*.G3 node reselects qualified transaction in trading pit, while subsidiary upper height is the ballot letter of 999 blocksBreath, initiates and broadcasts the proposal BlockProposal [1000] of new block*.Meanwhile G3 proposes new blockBlockProposal[1000]*It votes.
We assume that the quantity of the honest node in entire block chain network is more than N* η1, in reasonable Network statusUnder, it can always reach the common recognition of block.
The account in addition, equity account can be known together by ballot dynamic increase/reduction;When ballot quantity is greater than M* η1, showVote increase/reduction common recognition account through.As shown in figure 3, being more than half during carrying out common recognition of the height for 1500 blocksEquity account issue the request for increasing common recognition node, each equity node broadcasts oneself, which receive, increases node request, and countsOther nodes receive the case where increasing node request.Once having more than N* η1A node, which shows oneself to receive, increases node request,Each node suspends common recognition process, increases new common recognition node account in local common recognition node listing, then broadcasts oneselfIncrease nodal operation is completed, and counts whether other nodes are completed to increase nodal operation;When having more than N* η1A node showsIncrease nodal operation oneself is completed, each node restarts the common recognition process that height is 1500, as shown in Figure 4.It reduces altogetherThe operation for knowing node is similar with the common recognition operation of node is increased.
In present embodiment, η is set1=2/3, η2=1/3.
The above-mentioned description to embodiment is for that can understand and apply the invention convenient for those skilled in the art.Person skilled in the art obviously easily can make various modifications to above-described embodiment, and described herein generalPrinciple is applied in other embodiments without having to go through creative labor.Therefore, the present invention is not limited to the above embodiments, abilityField technique personnel announcement according to the present invention, the improvement made for the present invention and modification all should be in protection scope of the present inventionWithin.