What is a Consensus algorithm?
The consensus is very important in all spheres of our lives, using it, the parties involved are willing to make decisions on important issues. Blockchain systems are no exception as they use consensus mechanisms to enable participants to reach an agreement within the network. Without a consensus algorithm, a blockchain network is no more than an immutable database.
Blockchain projects are decentralized and do not have any central authority within the network so consensus algorithms are important for them. It allows nodes to have a collective agreement with each other, motivates participants to obey the rules, ensures justice, avoids problems such as double-spending, and provides that the network remains fault-tolerant. The consensus mechanism remains the network safe and functional.
Stability and trustlessness
Trusting an authority is necessary to keep the network operating in centralized systems. Consensus algorithms allow blockchains to work without requiring the participants to trust each other. This fundamental mechanism guarantees that all processed data is valid and that the distributed ledger is up-to-date. Since a decentralized system regulates itself own, it’s necessary to align the interests of the participants in order to ensure that it operates efficiently.
The consensus mechanism uses economic benefits to reward users for good conduct while punishing bad actors. It is responsible for ensuring fairness and equity among network participants. Everyone can join the network and have the same rights to vote.
Double spending is one of the main problems of digital payments. The consensus algorithm prevents double-spending by ensuring that only verified and valid transactions are included on the public ledger. A consensus algorithm, also allows the network to continue operating even when major attacks, crashes, and other incidents occur, ensuring that the blockchain is fault-tolerant as well as stable and secure.
Types of Consensus mechanisms
Proof-of-Work (PoW) is the oldest and most common of blockchain consensus algorithms. It’s been first introduced in Bitcoin and combines the features of P2P networks, Merkle chains, and cryptographic signatures. In Proof-of-Work, miners hash the data and constantly use their computing resources to solve complex mathematical puzzles in order to validate transactions and add them to the blockchain. Miners in PoW networks compete with each other to earn block rewards, and they also get a share of transaction fees. In PoW, the protocol lays out conditions for what makes a block valid. All miners are trying to find a valid hash, the only way to do this is by brute-force inputs. For the big blockchains, this hash is extremely difficult. In order, to compete with other miners, you need special hashing hardware (ASICs) to have a chance of generating a valid block. The network must verify that the miner has created a valid block. The algorithm needs to run the miner’s data through a function and if it produces a valid hash, it will be approved, and the miner will be rewarded. Otherwise, the network would reject it, and the miner would have lost time and energy for nothing.
These puzzles ensure that miners are devoted a considerable amount of resources - a mix of time and calculation power. When malicious miners want to damage the ecosystem, they have to spend a lot of money. For a 51% attack, the attackers need to have very expensive equipment to take over the majority of the network. However, PoW cannot operate at maximum speeds and maintaining an efficient and scalable network.
Examples: Bitcoin, Litecoin, Ethereum
Proof-of-Stake (PoS) has been suggested as an alternative to Proof-of-Work. There is no concept of miners, specialized equipment, or huge energy consumption. Instead of mining, users are required to stake or lock up their coins in a network wallet for a certain period to validate blocks. The amount of staked coins is used as the measure to determine who will verify the next block through a random selection process. For example, if a user stakes 55% of the total staked coins, it is a 55% chance of being chosen to validate the next block on the blockchain. In PoS blockchain networks, active stakers are rewarded with transaction fees only. Since stakers don’t have to operate mining rigs this consensus model is more energy-efficient than the PoW algorithm. Besides, blockchains using the PoS consensus mechanism generally provide stronger protection against 51% attacks as malicious parties lose their stake if the network detects a fraudulent transaction.
Besides, taking 51% of all coins is much more expensive than getting 51% of computing power. The user receives a proportion of the transaction fees, depending on the amount of stake but if the user attempts to cheat by making invalid transactions, he will lose a portion or all of their stake.
Examples: Ethereum (soon), QTUM
Delegated Proof-of-Stake (DPoS)
The Delegated Proof-of-Stake (DPoS) consensus algorithm operates in the same way as the PoS model but the stakers in the DPoS model outsource the validation of the blocks to a number of delegates. These delegates protect the blockchain system while being responsible for maintaining a network consensus during the validation of new blocks. DPoS networks use a democratic voting mechanism where the stakeholders cast their votes on the delegates.
Voting power is proportional to the number of coins held by each user. The rewards of a successful block validation are shared between the delegates and the stakeholders who have selected them. DPoS allows for block validators checking cause stakeholders to cast their votes based on reputation. Misbehavior or unreliable delegates can be replaced with others anytime. Validators do not compete with each other, they are working together. This algorithm helps blockchain to achieve fast transaction speed and high scalability but also have a higher level of possible centralization.
The Leased Proof-of-Stake (LPoS) mechanism allows users who have not run a full node to lease their tokens to mining nodes. Leased tokens are locked into the user’s account and cannot be transferred or traded. Tokens remain in the full control of the account holder and leases can be canceled at any time. Received rewards are shared proportionally with the leasers. Leased tokens are used to grow the “weight” of the miner, which increases their’s chances of finding the next block.
Leased Proof-of-Stake improves network security. The more tokens are used to protect the network, the harder it is for an attacker to obtain the tokens required to carry out a 51% attack. Tokens can be leased to a node from a user’s cold storage address, but the node can only have a minimum balance. Such a scheme significantly reduces the risk that tokens will be hacked since the leased funds are not transferred to the miner.
Byzantine Fault Tolerance (BFT) is a very interesting blockchain consensus mechanism. There is a logical dilemma, called the Byzantine Generals’ Problem, which includes several Byzantine army generals who have surrounded a city. Each general is located at a distance from the others, so they need to communicate with each other to decide whether to attack or not. However, they need to reach a consensus, to do this, every general requires to make a decision that cannot be reversed later.
The biggest issue is the message delivery problem. They have to use couriers to carry a message to the other generals, that could be delayed, lost, or destroyed if one of the generals sends out fraudulent information. In terms of blockchain networks, the Byzantine generals represent the nodes (miners, delegates, stakeholders, etc.) that must reach a consensus on the current state of the ecosystem and execute the same action to avoid failure. Byzantine Fault Tolerance represents a group of consensus mechanisms that are resistant to failures related to the Byzantine Generals’ Problem. A blockchain using BFT runs even though some of its nodes behave maliciously or cease to operate.
Delegated Byzantine Fault Tolerance (dBFT)
dBFT is the DPoS of BFT-focused blockchain consensus mechanisms
Like in DPoS systems, stakeholders use delegates – called bookkeepers – to reach consensus and generate new blocks. Also, holders vote for their bookkeeper of choice in real-time, rather than using a fixed term. These bookkeepers require to use their real identities in order to secure stakeholder votes. There’s no anonymity on dBFT blockchains, the level of centralization remains high but it ensures a rapid block generation, high scalability, and energy-efficiency.
Proof-of-Authority(PoA) is a consensus mechanism that uses a reputation-based model to verify transactions and generate blocks. Trustworthy validators within PoA blockchains stake their reputation by leveraging their real identities. They are pre-approved and chosen by network participants to serve as moderators responsible for block validation and generation. They are not only staking their reputation, but they also invest money to support the ecosystem. This allows the network to eliminate validators with a dubious reputation while incentivizing honest nodes. As the number of validators is limited in PoA networks, the consensus mechanism allows the blockchain to achieve a high level of scalability. PoA blockchains are highly centralized, making the consensus algorithm a good choice for private chains and enterprise use. In addition to the high level of centralization, the limitations of the consensus model include the lack of privacy as the identities of validators are visible to all participants within PoA blockchains.
Another variation of the consensus mechanism is PoI (Proof-of-Importance). PoI is based on the idea that network activity, not just the amount of coins, should be rewarded. The odds of staking a block are a function of several factors, including balance, reputation (determined by a separate purpose-designed system), and the number of transactions made from and to that address. This means that users who actively help the economy are rewarded. Each user is given a trust score, the higher it is, the more chance they have of being rewarded.
Anyone who contributes can gain extra tokens, POI gives similar opportunities to everyone. The main aim is to empower regular people.