Security properties promised by blockchain are truly inspiring. It is envisioned that blockchain technology and applications built on top of it will revolutionize a broad set of financial service industries as well as non-financial sectors.
Among the many technical components that a blockchain system is composed of, the distributed consensus protocol is the key technology that enables blockchain decentralization.
The distributed consensus protocol is what ensures that all participants agree on a unified transaction ledger without the help of a central authority.
History
Although the idea of blockchain was proposed in 2008 for Bitcoin implementation, consensus protocols have been in existence since the 70s. Firstly a group of computer scientists began thinking about the solution to the following question:
“Is it feasible for a set of machines to come to an agreement, and how?”
This question gave rise to a long and complex problem known as “consensus” and became fundamental to studying decentralized systems.
Initially, there were just the “classical consensus protocols” that can be easily identified due to one property: all to all voting. In 2008, with Bitcoin, Satoshi Nakamoto introduced the second family of protocols, known as “longest-chain consensus protocols.” After this, several variations to the classical and longest-chain protocols have been proposed over the years.
Consensus Protocol
In centralized systems, only one entity dominates the system, and consensus among administrators is reached without complex governance systems.
In a distributed system, where there is no central governing authority, all participants collectively decide and agree upon what is best for the network.
Searching how to achieve this in an environment where strangers do not trust each other was probably the hardest development part for blockchain. It led to a set of algorithms to achieve consensus amongst the participating nodes. Consensus algorithms are a set of protocols that provide a technique with the help of which users or machines can coordinate in a distributed and decentralized setup.
The goal is to ensure that all entities in the system collectively agree upon one thing (a single source of truth), even if some entities fail individually. This mechanism aims to make the system fault tolerant.
Consensus Protocol Properties
Various types of consensus algorithms have been devised over time for varying applications, but all these algorithms must demonstrate the following properties for tolerating halting failures:
1. Termination: Achieving consensus on a given data value should come to an end
2. Agreement seeking: Each consensus protocol should try to bring about as much agreement as possible from the network
3. Collaborative: The participants of the system should work in unison for the welfare of the group by achieving a result that favors the best interest of the group
4. Cooperative: The participants should work more as a team and not prioritize their interests
5. Egalitarian: A system that is trying to achieve consensus must be as egalitarian as possible. Each vote cannot be less important than another
6. Inclusive: The system should involve as many entities as possible in the consensus process
7. Participatory: Everyone should actively participate in the entire consensus process
8. Integrity: if there is a value that is decided by many correct processes, then that same value must be decided by any correct process
Consensus Protocol Types
While many consensus protocols are proposed and working, we can generally categorize them as Voting-based and Proof-based consensus algorithms.
Voting-based consensus algorithms provide reasonable fault tolerance and have mathematical solid proofs to ensure security and stability. Some notable voting-based algorithms are practical Byzantine Fault Tolerance (pBFT), delegated Byzantine Fault Tolerance (dBFT), Federated Byzantine Agreement (FBA), Raft, etc. However, they have a very democratic nature, and sometimes they can be slow or inefficient when the network grows.
Proof-based consensus algorithms are more suited to distributed ledgers for large, permissionless blockchains. Here, a participant node needs to provide sufficient proof of something to be able to contribute to the decision-making at consensus time. Some examples of Proof-based consensus algorithms are Proof of Work (PoW used by Bitcoin) and Proof of Stake (PoS that Ethereum 2.0 uses).
Consensus Protocol Comparison
Proof of Work (PoW)
Description. It describes a system that requires a considerable amount of effort to be done for mining a new block to prevent malicious uses of computing power and other possible attacks on the system, such as denial-of-service attacks and other service abuses like spamming by making the service requester do some demanding work.
The PoW consensus mechanism requires the network mining nodes to prove that the work done and submitted by them qualifies them to receive the right to add new transactions containing blocks to the blockchain. In PoW, nodes that will add the next block to the blockchain are selected in proportion to their computing power
Advantages. Reaches consensus quickly, rules out the possibility of spamming, and is the most tested protocol over time
Drawbacks. A lot of power is consumed and wasted in mining; hardware dependency can lead to mining centralization
Security. PoW is open to 51% attack along with selfish mining and eclipse attack
Application. Bitcoin, Ethereum, Litecoin, bitcoin cash, Zcash
Throughput. Sub-ten [10m-60m]
Proof of Stake (PoS)
Description. It is an alternative to PoW as it is more energy efficient. The PoS consensus algorithm uses a selection process that is pseudorandom in nature to pick the validator of the subsequent block from the existing nodes. The process is based on a mix of several factors, which include randomization and staking age along the node’s wealth
In PoS, the individual node that creates the next block is selected based on how much they have “staked” compared to other competitor nodes. The stake is usually based on the number of coins the network node has for the blockchain it is attempting to mine. In these systems, the transaction fee is generally the reward, and users who want to be among the participants in the forging process need to lock their stake (a certain amount of coins) in a network. The chances of a node being selected to forge the next block as the validator depends on the size of its stake, which means that the chances of the node winning the next block increases as its stake increases.
Advantages. It is advantageous over PoW protocols because of reduced energy consumption, easy staking, and being environmentally friendly
Drawbacks. Large stakeholders can dominate the network
Security. Despite being secure against 51% of attacks, it is vulnerable to nothing-at-stake attacks, grinding, long-range attacks
Application. Peercoin, Ethereum 2.0, Nxt, ShadowCash, Qora, Blackcoin
Throughput. Tens [10-60m]
Practical Byzantine Fault Tolerance (PBFT)
Description. Practical Byzantine Fault Tolerance is primarily modeled to provide Byzantine state machine replication, which is tolerant to the system's malicious nodes (Byzantine faults) that fail or propagate incorrect information to its peer nodes. The main objective of such a consensus mechanism is to prevent the system from catastrophic system failures by reducing the influence of the compromised nodes on the network functioning and to reach the right consensus with the help of honest nodes. This protocol is outlined such that it works well for non-synchronized systems and provides high performance with a reduced runtime, although it has a slight delay in data transfer
Advantages. Transaction finality, higher energy efficiency, and low reward variance
Drawbacks. Works fine with only small consensus group sizes, and if the primary node does not work, the implementation is to be done all over again, thus reducing the efficiency
Security. Open to Sybil attacks
Application. Hyperledger Fabric, Zilliqa
Throughput. Thousands [1s-1m]
Key Takeaways
● Various design choices in the consensus protocol can significantly impact a blockchain system's performance, including its transaction capacity, scalability, and fault tolerance
● Deciding which consensus protocol or blockchain implementation to use in a project, we must consider each project’s properties and goals. Knowing the benefits and drawbacks of each consensus protocol type can help arrive at a better decision
About Encora
Fast-growing tech companies partner with Encora to outsource product development and drive growth. Contact us to learn more about our software engineering capabilities.