Block creation and Validation in DPoS

Published by Mario Oettler on

Witnesses are elected for epochs. An epoch consists of one or more rounds. In each round, each witness is selected in a round-robin fashion to create a block. If more than one round is applied, the order of the witnesses is shuffled in each round.

In EOS, for example, an epoch consists of six rounds. And in each of these rounds, all 21 witnesses create one block. This means each epoch consists of 126 blocks (6 rounds * 21 witnesses).

The order of the witnesses is vital to avoid conflicts on who is allowed to create a block. Typically, a 2/3 majority is necessary to agree on an order. If there are 21 witnesses, at least 15 are necessary to come to an agreement.

Each witness has a pre-defined time to create a block.  This time is called a slot. The time varies between the concrete implementations. The shorter the time, the faster transactions are validated. But it also means that the network latency must be very low. If the network latency is high and a block takes longer to be propagated in the network than the slot-time, the active witness could think that the previous witness failed to produce a block and build upon the penultimate block. This would disrupt the consensus.

After a witness created a block, he sends it to the network. And each other witness can now express agreement to this block by signing it with its private key. If a block has received a majority (typically 2/3) of the possible signatures, it is deemed as final. This block validation process is often called BFT (Byzantine Fault Tolerant).

In Lisk, the number of votes influences the witness’ weight. The higher the weight, the more likely is the witness to be chosen as a block producer. A simple calculation method of the witness weight is to sum all votes a witness has received in the election.

To summarize, in DPoS block producer selection depends on two factors:

  1. Synchronous clocks
  2. Agreed order of witnesses

Finality

In some implementations, a block is considered as final if at least 2/3 of the elected witnesses signed it. In conjunction with penalties for signing blocks on competing branches, this creates finality very quickly.

What happens if a block producer fails to create a block?

If a block producer (witness) doesn’t create a block in his slot, this slot is skipped. This means there is no block created at that time and the chain is held up for the slot time. The chain continues with the next slot and its assigned witness.

Failing block producers are a concern in DPoS systems. If too many block producers miss their slot, this could hold up the whole consensus mechanism. That’s why DPoS protocols usually apply a rule where witnesses are not considered anymore if they fail to deliver blocks for more than 24 hours. This means such witnesses are not scheduled as block producers until they notify the network that they are working again.

While this is just a short-term remedy, voters are expected to withdraw their votes from unreliable voters.

Categories:

if()