A dive into Substrate’s Consensus Mechanism

Dheeraj Kumar
Coinmonks
Published in
3 min readMar 11, 2023

--

Consensus

The consensus mechanism used by the Substrate framework is not fixed or predetermined. Instead, the Substrate framework provides a modular architecture that allows developers to easily create and customize their own blockchain networks and applications. This includes the ability to choose and implement their own consensus algorithm, depending
on the specific requirements and goals of the network. Therefore, the consensus mechanism used by a Substrate-based blockchain will depend on the specific implementation of the network.

The consensus process here is split into two phases:
Block authoring is the process nodes use to create new blocks.
Block finalization is the process used to handle forks and choose the canonical chain.

Block authoring:
To reach a consensus, nodes in the blockchain network are required to produce blocks. So there must be a way to choose which nodes are authorized to produce blocks. Since it is a decentralized network without any trusted nodes, an algorithm must select the block author at each block height.

For a substrate-based chain, one can choose the following block authoring algorithms or create one’s custom.
Aura: Authority-based round-robin scheduling
BABE: Blind assignment of blockchain extension slot-based scheduling
Proof of work computation-based scheduling

Aura:
In aura, a known set of authorities are allowed to produce blocks. The authorities must be chosen before block production begins. Time is divided into fixed-length slots. During each slot, one block is produced, and the authorities take turns producing blocks in order as per round robin algorithm.

Babe:
Like Aura, it is a slot-based consensus algorithm with a known set of validators. In addition, each validator is assigned a weight which must be assigned before block production begins. Unlike Aura, the authorities don’t take turns in order. Instead, during each round, each authority generates a pseudorandom number using a VRF. If the random number is lower than
their weight, they are allowed to produce a block.

Proof of Work:
This mechanism does not have a known authority set, neither it is slot-based. In proof of work, anyone can produce a block at any time, as long as they manage to solve a computationally challenging problem. The difficulty of this problem can be tuned to provide a statistical target
block time.

Finalization:
Blocks that are produced contain a header and transactions. Each block header contains a reference to its parent block, so you can trace the chain back to genesis. Now, there could be more than one block that refers to the same parent. Block finalization is a mechanism aimed to resolve forks so that only the canonical chain exists. We can use the GRANDPA protocol for it or code our own.

Grandpa:
Grandpa provides block finalization. Grandpa does not author blocks, it just listens in the network about the newly produced blocks. In the GRANDPA protocol, the longest chain rule simply says that the best chain is the longest chain. Grandpa validators participate in two rounds of voting on blocks. Once 2/3rd of the grandpa authorities have voted for a particular block, it is considered finalized.

New to trading? Try crypto trading bots or copy trading on best crypto exchanges

Join Coinmonks Telegram Channel and Youtube Channel get daily Crypto News

Also, Read

--

--