Dec 06 2024 18:14 — 6 min read

Blockchain 101 \ 4: Consensus

#bitcoin #algorithm #blockchain #fundamental


The problem

Blockchains are designed with decentralization in mind, operating as an digital ledger maintained by a distributed network of computer nodes. For this reason, blockchain technology allows for the creation of trustless economic systems where transparent and trustworthy financial transactions can be carried out without the need for intermediaries. Cryptocurrencies are being adopted as a viable alternative to traditional banking and payment systems, which rely heavily on trust.

As almost distributed computing systems, crypto participants need to agree on the current state of the blockchain, and that is what we call consensus. However, achieving consensus on a distributed network securely and reliably is not easy.

So how can a distributed network of computer nodes reach consensus on a decision, if some of those nodes are likely to fail or be unreliable? This is the fundamental question of the problem known as the Byzantine Generals problem, which gave birth to the concept of Byzantine fault-tolerant systems.

Byzantine Fault Tolerance (BFT)

The Byzantine Generals problem, introduced in 1982 by Leslie Lamport, Robert Shostak, and Marshall Pease, describes a logical dilemma. The problem describes how a group of Byzantine Generals encountered communication problems when trying to reach consensus on their next move.

The problem assumes that each General has his own army and that each General is stationed in different locations around the castle they plan to attack. The Generals must agree on whether to attack or retreat. The issue of attacking or retreating is not important but the consensus of all Generals, that is, agreement on a common decision to coordinate implementation.

Therefore, we can consider the following goals:

  • Each General must decide: attack or retreat (yes or no);
  • The decision cannot be changed after it is made;
  • All Generals must agree on the same decision and proceed synchronously with each other.

The communication problems mentioned above relate to the fact that a General can only communicate with other Generals through messages transmitted by messengers. The central problem of the Byzantine Generals problem here is that messages can be delayed, dropped, or lost.

Additionally, even assuming that the message will be delivered successfully, there remains the possibility that one or more Generals may choose (for any reason) to take harmful action and send a wrong message to cause interference with other Generals, leading to a complete defeat.

If we apply the dilemma to the case of blockchain, each General will represent a network node and the nodes need to reach consensus on the current state of the system. In other words, the majority of participants in a distributed network must agree and take the same action to avoid a complete failure.

Therefore, the only way to achieve consensus in these types of distributed systems is to have a consensus of at least ⅔ or more of the honest and trustworthy network nodes. This means that if the majority of nodes in the network decide to perform malicious actions, the system will be vulnerable to errors and attacks (e.g. 51% attack).

Figure 1: The simple view of Byzantine defeat

So the Byzantine fault tolerance system (BFT) is the system that can solve the problem of the Byzantine generals problem. This means that the BFT system can continue to operate even if some nodes fail or perform harmful actions.

There are many possible solutions to the problem of the Byzantine Generals problem, so there are many ways to construct a BFT system. Likewise, there are different ways for a blockchain to achieve a Byzantine fault-tolerant system, and what we have here are consensus algorithms.

Note: The concept of consensus here will be different from the protocol. Basically, the protocol can be understood as the basic rules of the Blockchain network. As for the consensus algorithm, it is defined as the mechanism by which the protocol rules will be followed.

Consensus algorithms

We can define a consensus algorithm as a mechanism through which a blockchain network achieves consensus. The most popular algorithms are Proof of Work (POW) and Proof of Stake (POS). 

Proof of Work (POW)

The biggest advantage of Proof of Work that has been proven is its ability to operate for a long time of several years - this is the superior advantage of Proof of Work compared to other consensus algorithms.

On the downside, Proof of Work consumes a lot of electricity for mining and has low transaction throughput.

Proof of Stake (POS)

Proof of Stake requires participants to “stake” a portion of the cryptocurrency they hold in the network to verify transactions. Instead of “mining” by solving difficult and complex computationally intensive problems to verify transactions, miners stake transactions by locking up the cryptocurrency. The stakers chosen to complete this block are usually selected based on criteria such as the value they place on the network compared to the total value of the network or the length of time that the cryptocurrency will be locked or other criteria to ensure that stakers are in line with the long-term interests of the whole network.

While Proof of Work prevents bad behavior by non-profit and time-consuming computation, Proof of Stake prevents such behavior by shifting verification authority to whom with the highest total value in the network and thus create the highest of success.

Delegated Proof of Stake (DPOS)

Although Delegated Proof of Stake has a similar name to Proof of Stake, in detail, the operations of these two algorithms are completely different.

In DPoS, instead of staking to validate transactions, token holders vote for a select group to act as validators of transactions. DPoS remains “decentralized” in the sense that all in the network participate in choosing which nodes validate transactions, but centralized in the sense that a smaller group makes the decisions that speed up transactions and verification.

DPoS ensures honesty and fairness by performing continuous voting operations and also continuously shuffling the system to ensure those selected are honest and responsible.

The advantage of DPoS is its scalability and fast transaction verification process, but the disadvantage is that the governance model has not yet been proven to be effective in a large project.

In addition, there are currently several other types of consensus algorithms:

  • Proof of Authority
  • Proof of Weight
  • Proof of History
  • Proof of Reputation
  • Proof of Elapsed Time