# Introduction to Bytom 2.0 Consensus Algorithm
Epoch：An Epoch is counted with a certain number of blocks (for example, 100). The validator nodes under the same Epoch are fixed, and the next Epoch will generate new validators based on the voting status of the previous Epoch.
Checkpoint：The consensus algorithm does not process all blocks on chain, but uses Checkpoint as a unit to verify. Generally, one Epoch block number is used as a Checkpoint.
Justified：After a Checkpoint receives a 2/3 confirmation (according to the number of nodes or the number of collateral), the status is justified, and the justified node may be overturned.
Finalized：After the subsidiary node of a justified Checkpoint c is justified, Checkpoint c is converted to finalized, and the finalized checkpoint cannot be overturned.
# Why do we need to upgrade the Bytom2.0 consensus?
Vapor also adopts the same DPoS+BFT algorithm as Bytom2.0, and it runs stably for a long time and carries many applications. However, there exist the following problems:
In the case of high-speed block production, 2/3 signature confirmation for each block will take up a lot of network bandwidth. Block production in 0.5 seconds makes the disk space occupied by the data on the chain expand rapidly; it is easy to cause fork (a node continues to produce blocks without receiving the block from the previous node); in addition, it also caused some wallets and browsers (requires block Synchronized) some performance bottlenecks. The consensus algorithm has not undergone effective security verification, and the traditional BFT algorithm generally requires two confirmations.
Bytom2.0 upgraded the consensus to solve the above-mentioned problems:
- Use Checkpoint as a unit
- Greatly reducing the network bandwidth occupied by signature confirmation by verification and signature
- Extend a block of 0.5s to a block of 6s to reduce the probability of fork
- Confirm each Checkpoint twice, the first time is the Justified state, and the second time is Finalized state after finalized confirmation
After Bytom2.0 is upgraded, it can be greatly improved in the following aspects:：
- Energy saving
- Performance boost
- Better economic security
- Stronger scalability
# Consensus process
1.When the Bytom2.0 blockchain just started, the genesis node was responsible for producing blocks. At this time, other nodes can stake BTM to become block producers, and ordinary participants can vote on block producers. 2. Each voting and election round is called an Epoch. An Epoch contains a set of blocks (for example, 100). In this Epoch, the block producers is fixed. The next Epoch starts to re-elect the block producers according to the number of votes. 3. When the next Epoch detects that there are a certain number of legal block producers, the genesis node stops producing blocks and the block producers start producing blocks. 4. Starting from the current Epoch, one block will be produced every 6 seconds, and each block producers will produce blocks in turn according to the number of votes. 5. Bytom2.0 does not verify each block, but uses Checkpoint as a unit for processing. Generally, one Epoch block number is used as a Checkpoint. 6. Bytom2.0 will confirm each Checkpoint twice, the first is when the Checkpoint status is Justified after receiving 2/3 confirmation, and it can be overturned at this time, and after its subsidiary nodes are also confirmed as Justified status, get the second confirmation and get the Finalized status. At this time, the final confirmation is obtained and cannot be overturned. 7. In order to prevent harmless attacks, Bytom2.0 will punish block producers that sign two blocks at the same height at the same time, and confiscate part of their staked BTM. Taking into account the complexity of this part, Bytom2.0 will introduce the mechanism gradually after consensus stabilization.
# Process of vote and block generation
# CheckPoint verification
Each Checkpoint will be verified and signed by Block Producers. When more than 2/3 of the signatures are obtained, the Checkpoint will be confirmed once and set to Justified.
# State transition
As shown in the figure below, there is a link with a yellow arrow from a source checkpoint to a target checkpoint. If the link gets a 2/3 signature, the target becomes justified. If the source is his direct parent node, it will become finalized, and the block production will follow the blockchain with the maximized height justified checkpoint.
Bytom 2.0 consensus algorithm is based on the experience of the Vapor （sidechain of Bytom 1.0) consensus algorithm, while absorbing the relevant design concepts of ETH Casper, but has optimized its complex parts, and launched a consensus innovation suitable for Bytom.
Bytom 2.0 consensus algorithm has advantages in terms of energy-saving, performance, attack resistance, and scalability. As the most important basic protocol at the bottom of the blockchain, the consensus algorithm will definitely play a significant role on Bytom2.0.