What are Aura, Babe, Grandpa, and POW in Substrate/Polkadot?
There are different ways that a blockchain network can come to a consensus about changes to the chain. Similarly, Aura, Babe, Grandpa, and Proof Of Work(POW) are all different types of Consensus mechanisms in Substrate/Polkadot. These consensus layers are designed such that they can be easily changed during development and could even be hot-swapped after the chain goes live!
Let’s talk about all these in detail.
AURA(Authority Round)
Aura primarily provides block authority. In Aura, a known set of authorities are allowed to produce blocks. The authorities must be chosen before block production begins and all authorities must know the entire authority set. While for the production of blocks time is divided into “slots” of a fixed length. During each slot, one block is produced, and authorities take turns producing blocks in order forever.
In Aura, forks only happen when it takes longer than the slot duration for a block to traverse the network. Thus forks are uncommon in good network conditions.
BABE(Blind Assignment for Blockchain Extension)
Babe also primarily provides block authoring. It’s a slot-based consensus mechanism with a known set of validators, similar to Aura. Furthermore, each validator is given a weight, which must be assigned before block production can begin. The authorities, unlike Aura, do not follow a strict order. Instead, each authority uses a VRF to create a pseudorandom number throughout each round. They are allowed to make a block if the random number is less than their weight.
Forks are more prevalent in Babe than in Aura, and they happen even in ideal network conditions, because many validators may be able to create a block during the same slot.
Substrate’s implementation of Babe also has a fallback mechanism for when no authorities are chosen in a given slot.
Proof-Of-Work(POW)
It also provides block authoring unlike BABE and Aura, it is not slot-based and does not have a known authoring set. In Proof Of Work, anyone can produce a block at any time, so long as they can solve a computationally challenging problem(typically a hash preimage search). The difficulty of this problem can be tuned to provide a statistical target block time.
GRANDPA(GHOST-based Recursive ANcestor Deriving Prefix Agreement)
It Provides block finalization. It has a known weighted authority set like BABE. However, GRANDPA doesn’t author blocks. It Just listens to gossip about blocks that have been produced by some authoring engine like the three mentioned above.
It works in a partially synchronous network model as long as 2/3 of nodes are honest and can cope with 1/5 Byzantine nodes in an asynchronous setting.
GRANDPA distinguishes itself by reaching agreements on chains rather than blocks, which speeds up the finalization process significantly, even after long-term network partitioning or other networking difficulties.
Each authoring participates in two rounds of voting on blocks. Once 2/3 of the GRANDPA authorities have voted for a particular block, it is considered finalized.