Istanbul BFT consensus algorithm detailed documentation
Istanbul BFT as a class BFT algorithm has been the practice in the etheric Square. Although Istanbul there are still some potential problems, but the algorithm idea and implementation is still worth learning and reference.
the term
- Validator: Block verifier.
- Proposer: the blocks will.
- Round: several rounds of consensus. Made from a round block by block a proposal to start, ending submission to block or change the number of rounds (round number may change because of an error or block update).
- Proposal: a new block in the process proposed.
- Sequence: the height of the proposal. And a sequence corresponding to block high.
- Blocklog: inside information recorded in the backlog in the future.
core.backlogs
- Round state:
Round
andSequence
bind together to formview
, - Consensus proof: block signature submission. Each
validator
is signed will block it after verification. - Snapshot: Voting validator of state.
Consensus Algorithm Description
Istanbul BFT modified from PBFT algorithm consists of three phases: PRE-PREPARE
, PREPARE
and COMMIT
. In N
network nodes, the algorithm can tolerate up to F
one error nodes, wherein N=3F+1
. Before the beginning of each round, validator
will choose one of them as proposer
the default round-robin fashion (in addition to sticky way, the search stickyProposer
method to see the details). Then proposer will block a proposal put forward, and broadcast PRE-PREPARE
information. Upon receipt of a validator PRE-PREPARE
message will state flag is PRE-PREPARED
then broadcast PREPARE
information. This step is to ensure that all of the validator be verified in the same seqnence consensus and round (the code for the view) on. Upon receipt of 2F+ 1
a PREPARE
message, validator enter PREPARED
and broadcast status COMMIT
information. This step is to inform the peer node has received the proposed block, and the block will be inserted into the chain. Finally, Validator wait 2F + 1
months COMMIT
, then go to COMMITTED
state block is then inserted into the chain.
Istanbul BFT algorithm block is determined, and legal bifurcation means that the chain does not necessarily block in the chain. In order to prevent a malicious node generates a different chain, the block is inserted into the chain before , each of the validator need 2F + 1
a COMMIT
signature into the region of the header extraData
field. Therefore, the block can be self-validation (because of the signature) and light client is also supported. However, dynamicextraData
It can also cause block hash calculation. Because a block can be verified different validator, so there will be a different signature, so there will be a different hash same block. Solution is to calculate the hash of the block when the COMMIT
signature excluded. Therefore, we can guarantee any course conducted at the same time block hash consensus verify consistency.
Consensus state
New Round
: A proposer sends a new block proposal. validator waiting forPRE-PREPARE
information.PRE-PREPARED
: A validator has receivedPRE-PREPARE
information and broadcastPREPARE
information. Then wait2F + 1
twoPREPARE
orCOMMIT
information.PREPARED
: A validator has received2F + 1
aPREPARE
message and broadcastCOMMIT
information. Then wait for2F + 1
aCOMMIT
messageCOMMITTED
: A validator has received2F + 1
aCOMMIT
message and at this time can be inserted into the proposed block chain.FINAL COMMITTED
: A validator has been successfully inserted into the block chain, and wait for the next round.ROUND CHANGE
: A validator waiting on the next round of the same2F + 1
numberROUND CHANGE
information.
State transition
- NEW ROUND -> PRE-PREPARED:
- Proposer collectible trading in txpool in.
- Proposer put forward a proposal and block broadcast to validator. Then enter the
PRE-PREPARED
state. - Each validator into the
PRE-PREPARED
state, upon receipt ofPRE-PREPARED
the information and accompanied by the following:- Block proposal is effective from the proposer.
- Effective header area.
- sequence and state validator round and block matching proposal.
- Validator broadcast
PREPARE
information to other validators.
- PRE-PREPARED -> PREPARED:
- Validator receive
2F + 1
validPREPARE
information, and enter thePREPARED
state. Effective information needs to meet the following criteria:- sequence and round match.
- Trading hash match.
- Information from validators is known.
- Once in the
PREPARED
state, Validator COMMIT broadcast information.
- Validator receive
- PREPARED -> COMMITTED:
- Validator receive
2F + 1
a · validCOMMIT
information in order to enter theCOMMITTED
state. Effective information needs to meet the following criteria:- sequence and round match.
- block hash match
- Information from validators is known.
- Validator receive
- COMMITTED -> FINAL COMMITTED:
- Validator to
2F + 1
a commitment of the signatures into the header regionextraData
and attempt to insert the block into block chain. - When you insert a block success, Validator into the
FINAL COMMITTED
state.
- Validator to
- COMMITTED FINAL -> NEW ROUND:
Validators choose a new proposer start a new round.
potential problems
- Fail-Stop failures
- This article analyzes the IBFT
- No incentives