ChainX: BABE+GRANDPA consensus mechanism

ChainX
3 min readMay 27, 2022

We all know that ChainX adopts the PoS consensus mechanism. But there may be some misunderstandings about PoS. PoS refers to mortgage tokens as voting rights. Generally speaking, the more tokens mortgaged, the greater the voting rights. Proof of stake only allows any node to join, ensuring the openness of the network.
But it also needs to be matched with a consensus algorithm to become an overall decentralized consensus.
There are two most commonly used types: BFT (Byzantine Fault Tolerance) consensus algorithm and Chain based consensus algorithm.

The Chain based consensus algorithm is divided into two steps: block proposal and finality.

In the substrate, BABE and GRANDPA together determine the process of how to generate blocks and how to choose the best fork.

BABE:

The block generation mechanism, which decides which validator generates new blocks.The function is to confirm the generation of each block to promote the network to continuously generate blocks and the chain to move forward. Simply put, it ensures that the network continues to run forward without stalling.

BABE is the abbreviation of Blind Assignment for Blockchain Extension. Simply put, BABE divides time into epochs. Each epoch is divided into a time interval (slot). In each slot, VRF (verifiable random function) is used to select a part of the nodes (slot leaders) that are eligible to produce blocks from a large number of nodes. Here we call it a block producing node for now. Each time interval (slot) selected block producers may be different, there may be multiple nodes, or none of them may be selected. In general, the probability of a node being selected is proportional to the number of tokens it stakes. In Substrate, an interval is roughly 6 seconds.

GRANDPA:

Chain generation mechanism: The function is to quickly confirm the validity of this chain during this period of time, which can ensure that the network is not easy to roll back and is not easy to be tampered with, and also ensures the speed of network processing.

The specific process of GRANDPA:
1/A master node broadcasts the block height after the previous round of confirmation;

2/After waiting for the network delay, each node broadcasts the highest block they think can be confirmed (pre-vote);

3/Each node calculates the block set received in step 2, calculates the highest block that they think can be confirmed, and broadcasts the result (pre-commit);

4/When the node receives enough pre-commit messages to confirm the block, it will form a commit message, which is generally considered to be more than 2/3 can be confirmed.

in other words,As long as more than 2/3 of the validators confirm that a particular block is included on the chain, all blocks before this block are finalized at once. Because the most important and representative block is identified, and this block is correct, then all blocks leading to this block are correct.

Therefore, even after a long period of network segmentation or other network failures, the determination of the final state is significantly accelerated, ensuring the fast operation of the network.

In general, the BABE+GRANDPA consensus mechanism can ensure that the network is fast, continuous, not easy to roll back and traceable.

--

--

ChainX

ChainX is a BTC Layer 2 solution compatible with EVM that utilizes Bitcoin as a gas fee, serving as the predecessor network of BEVM.