In one of the previous articles, we talked about designing and launching a blockchain and choosing an off-the-shelf solution or building your own network. Choosing a blockchain consensus algorithm is an important step that will determine the performance of the network.
In this article, we'll analyze popular consensus mechanisms for different business purposes, examples of their implementation as well as understand what consensus means.
How does blockchain work and what’s the consensus algorithm role
Blockchain is a distributed database that stores transaction information in a decentralized manner without the ability to tamper with or delete data. Therefore, blockchain has no centralized authority to verify and validate transactions. Who then manages the network, and how exactly is security ensured if there is no centralized management?
This is when the consensus mechanism gets in the game, the backbone of the blockchain that keeps it working and secure, ensures that all nodes in the blockchain network are in synchronized.
Thus, we can form the following definition of consensus — it is a protocol by which all users of the network come to a common agreement on the current state of data, and verify transactions from different nodes using cryptographic hashes. The consensus algorithm is designed to ensure the reliability of a network that consists of many users.
Five characteristics of consensus algorithms
- Unified agreement. Unlike centralized systems, users of decentralized networks can work without trusting each other. Consensus protocols ensure the validity and accuracy of the data that participants provide.
- Regulation. The alignment of participants' interests in decentralized systems is considered a prerequisite, which is achieved through consensus protocols. The system then rewards the best users and alienates abusers.
- Fairness and equity. Enables any user to participate in the validation of new blocks.
- Prevention of double-spending. Established consensus mechanism algorithms ensure that only valid and confirmed transactions are added to the blockchain. This solves the traditional problem of double spending of digital currency.
- Fault tolerance. The consensus mechanism ensures that the blockchain is fault-tolerant, consistent, and reliable. That is, it ensures that the system will work indefinitely even in case of any failures.
There are many consensus algorithms that blockchain platforms use. For example, Bitcoin blockchain works on PoW mechanism, Ethereum since recently on PoS (previously supported PoW), VeChain on PoA. Let's take a closer look at the three main consensus algorithms: PoW, PoS, PoA.
PoW (Proof of Work)
A consensus algorithm that makes the Bitcoin blockchain work, as well as cryptocurrencies like Litecoin, Monero and others. The addition and validation of transactions takes place through the use of mining. Participating nodes (miners) solve complex mathematical problems to decrypt the block hash and mine it using processing power. PoW cryptocurrencies can be mined on GPUs, CPUs, ASICs and FPGAs. The miner who finds the block hash first mines it and is rewarded for it.
But the process is not that simple. The level of complexity of mathematical problems is increasing all the time, so you need more computing power to solve them. For example, if previously Bitcoin could be mined on ordinary computers, now it will require high-powered mining farms.
The use of the PoW algorithm ensures that every network transaction is verified and prevents double-spending. In other words, if someone tries to duplicate a transaction in the blockchain, the miners will notice it and not accept the transaction.
But it is important to understand that this effect is achieved through powerful computing hardware. So if you decide to develop a blockchain based on this mechanism, take care in advance to create powerful mining pools. If not, there is a risk of a low hash rate and a 51% attack — when an attacker rents more than 50% of the capacity and gets the power to validate and verify transactions.
Despite this, the PoW algorithm is still one of the most reliable and secure mechanisms, but with problems in network scalability. That is why Ethereum switched to the PoS algorithm in order to scale the network and add new functionality.
In any case, when developing a blockchain on the PoW algorithm, you need to plan a complex launch procedure. The first thing to do is to launch the network with its own validators, and then allow mining by miners, who will gradually build up the capacity.
PoS (Proof of Stake)
PoS is a green alternative to the PoW mechanism, which implies proof of ownership and requires less computing power to mine blocks. Instead of miners, block mining is done by validators who have a certain number of network coins (shares) on their balance sheet.
For example, in the Nxt blockchain, users who have at least 1002 NXT on their account have a chance to form a block. That is, the more coins in the user's balance, the more likely he is to get the right to create a block.
The user whose share is highest is selected by the validator and mines the block. But instead of a reward, he receives commissions for transactions in that block, since the PoS algorithm does not provide a reward.
The process of holding cryptocurrency on the balance to receive a reward for mining a block is called stacking. Many PoS projects allow users of the network to send coins to stacking by locking them in a special smart contract for a certain amount of time. After that time, users are rewarded with the network's native tokens. Stacking returns for validators and cryptocurrency holders depend on the issuance rate as well as the share of coins in circulation.
If you decide to develop a blockchain on the PoS algorithm, pay attention to the process of block finalization, as well as tokenomics, the procedure of electing validators and receiving rewards for blocks. The requirement to have the project's native coins on the balance plays an important role in preventing attacks, as an attacker may not have the funds to conduct a full-fledged attack.
PoA (Proof of Authority)
PoA is a reputation-based consensus algorithm for users. In a blockchain with this mechanism, validators do not bid as in PoS, but earn authority. To become a validator, a user has to confirm his/her identity, after which he/she will get the right to be elected as a validator. A validator's rating and authority varies from 0% to 100% and depends on their workload as well as the level of authority of the other validators.
Therefore, a fixed number of validators are responsible for the performance of the PoA network. This approach ensures high transaction processing speed and network scalability. In addition, validators are highly motivated to keep their work honest and transparent, as their rating depends on it.
A distinctive feature of PoA is the possibility of excessive centralization, which may confuse true supporters of complete decentralization of cryptocurrencies. Therefore, as a rule, this algorithm is used to create a private blockchain with a limited number of network participants.
How to choose a consensus algorithm for blockchain?
When selecting a consensus algorithm, it's important to start with the goals you want to achieve.
- Consider whether you want a private or public blockchain. If private, PoA is the preferred mechanism, if public, PoW or PoS are the best options.
- How critical is decentralization to you? If the project is built on full decentralization, it is worth looking at PoW or PoS, as PoA has limited decentralization.
- Is power consumption critical to you? If so, PoW is definitely not your option, and you should go with PoS, which is much less energy intensive.
- Who will act as block validators? If you want the nodes to be accessible to all users without special equipment — decide PoS. If you want uptime to be supported by mining and equipment, then PoW is your option.
It is critical to understand that each of the above consensus algorithms has its own advantages and disadvantages. Therefore, when choosing, it is important to consider many factors that will affect network performance and transaction validation. You can also contact RVA, getting our fast response as well as studying carefully the requirements of your project and finding the best solution