Since a few questions about EOS are still in the air, Attic Lab created this post to ensure that everything is straightforward and clear in terms of understanding EOS consensus algorithm. Here, we are covering everything from the beginning: what is DPoS and its difference comparing to PoS. selection of block producers, and how the consensus is achieved among block producers. Enjoy!
EOS.IO uses the DPoS (Delegated Proof-of-Stake) consensus algorithm that allows you to create blocks within 0.5 seconds and in addition to DPoS, EOS.IO adds asynchronous Byzantine fault tolerance (aBFT, Byzantine Fault Tolerance) to accelerate the achievement of irreversibility. BFT-DPoS will provide 100% confirmation of the transaction’s irreversibility within 1 second.
Comparing to the PoS consensus algorithm, in which token holders vote for the validity of the block, in DPoS, the tokens holders vote for the block producers. The group of producers that received the largest number of votes will be able to collectively organize the generation of blocks. DPoS works faster than most consensus algorithms since block producers compete only at the stage of selecting a group of producers.
Like regular DPoS, BFT-DPoS is divided into two stages: the selection of a group of block producers and the achievement of consensus between them.
Selecting a group of block producers
Top-21 block producers are selected by continuous voting of EOS token holders.
- Each account with EOS tokens is given the opportunity to give 30 votes. Votes can be given in one time, or by adding block producers into your list in turns.
- To vote, token holders need to block some EOS tokens on their account (stake tokens)
- Each vote counts with a “power” equal to the number of staked tokens (for example: token holder A has 15 EOS tokens on the account and he or she stakes 10, token holder B has 10 tokens and stakes 5, token holder C has 5 and stakes 5. Token holder A votes for X and Y block producers, B votes for Y and Z BPs, and C votes for Z producer. In total, block producer X has one vote with power of 10 EOS, producer Y has 2 votes with 15 EOS, and producer Z has 2 votes with power of 10 EOS.
- In case of simultaneous voting for producers, the repeated sending of votes will cancel the previous one. In case if you want to add alternative producers to the voting list, it is not possible to add producers that already exist in the list.
- In order to unlock staked tokens after sending a vote, you should send an unblock request (system undelegatebw with the required parameters). You can unlock the tokens not earlier than three days after sending the request.
- Voting takes place in a continuous mode. You can vote at any time. You can change your voice at any time. You can vote as many as you want.
- The vote loses its “power” every week by approximately 1%. Full strength of the vote has only the first week since sending to the network, after 90 days - 85% of initial power, after 1 year - 50%, after 2 years the voice does not count. Example: token holder A staked 100 EOS, he or she gave a vote for X block producer with power of 100 EOS. The first week it will be 100 EOS, at the beginning of the fourth week the weight of the vote will be 97 EOS. If the vote is sent again for the given block producer, the vote weight will be equal to the amount of stacked tokens on the account at the time of sending.
- Votes will be recalculated approximately every two minutes
Achieving consensus between block producers
The selection of the group of block producers has little effect on the achievement of consensus among the block producers. Therefore, further we assume that all the BPs are selected and are ready to generate blocks.
Conflict resolution. To solve most problems, it is enough to get agreement of > ⅔ producers, that is, in the case of standard conditions (in 21 producers) this is a minimum of 15. The BFT algorithm, which is added to DPoS, allows all producers to sign all the blocks. Once the block is signed by at least 15 BPs it will be considered irreversible. It is impossible for the same producer to sign two blocks with the same timestamp or the same block height.
The order of generating blocks. The first thing block producers agree on is the order in which they will generate the blocks. It is unaccepted that the producer of blocks generates the block in any other time interval which differs from the planned one. Through each 21 block, the order of producers varies. When producers sign a block, they also sign a new order, thus confirming its reliability and preventing the emergence of two different orders. Blocks are produced in rounds of 126, i.e. during one round, one producer is able to generate no more than 6 blocks. At the beginning of each round, the votes are recounted, if the top 21 producers have changed, the replacement occurs.
The time given to the block producer for block generation. To generate a block, each BP has 0.5 seconds. If the producer does not have time in the given period, then the block is skipped. Also, block producers can be replaced if they miss their turn within 24 hours. The block producer, which was replaced, has the right to return in top21 list if he or she confirms/sends a notice that it is ready to work.
Forks. The longest chain of blocks is always selected. Every time an honest block producer sees a chain of blocks that is longer than the rest, he or she switches from the current fork to a longer one. Any other chain cannot be longer if ⅔ the block producers are honest and generate blocks without failures.
TaPoS. The EOS.IO software also uses TaPoS, transactions as proof. All transactions include the header hash of the last block and are considered invalid if this block does not exist in the chain. Thus, users sending a transaction confirm the previous block.
Sending a transaction also signals to the network that the funds are in a particular block. This prevents the appearance of the same transactions on another fork, it lowers the risk of fraud inside the blockchain (it is impossible to transfer transactions from another chain of blocks).
At Attic Lab we tried to make sure that all your questions have been answered regarding the EOS consensus algorithm. In this post we covered all main pain points that people might stick to while understanding the DPoS algorithm. If you have any further questions, please ask them in a comment section below or just send us a message in any of listed social media.