03 May What Are Consensus Algorithms?
Wondering what are consensus algorithms? The main factors when understanding a Blockchain is that it is a decentralized data source that is open for anyone on the network to view (opensource). Whereby digital information can be written into a blockchain and once that information has been written it cannot be removed or modified due to the cascading domino effect that it would have on all of the other previous blocks. Once a block has been filled with data a new block must be added and chained to the previous block to carry on the cycle. For a new block to be added to the chain there needs to be a consensus algorithm used, something that the whole community agrees on. That algorithm can either be POW or POS, although other algorithms are currently being investigated to further the use cases of Blockchain technology.
What is a computer algorithm?
An algorithm can be described as a set of rules or sequences that a computer program reads and carries out to complete a given task. When a computer is reading an algorithm it could read as follows:
- When “X” has been completed, “X” then goes on to complete “Y”.
- Then when “Y” has been completed, “Y” go on to complete “W”.
Proof of work:
The proof of work (POW) consensus algorithm was discussed within Satoshi Nakamoto’s white paper published in 2008 and was applied to the first-ever Blockchain. Although the first idea for POW algorithms was published in 1993 by Cynthia Dwork (A computer scientist from Harvard University) within her white paper it was only discussed as a potential tool to prevent fraud. Now the POS algorithm has been widely adopted by Blockchains for the purposes of mining cryptocurrency.
When the POW algorithm is applied to a Blockchain it is the process of completing two actions using high-performance computer hardware. The first action is constantly validating and securing a blockchain network by working as a node. A node can be any computer that is tasked with validating the transactions that take place on a Blockchain. The second action is to solve complex computerised math problems known as “hash puzzles” with the intent of creating a new block to add to the chain.
To solve these hash puzzles a huge amount of computer processing power is needed. The type of computer hardware is given the name “a mining rig” and there are currently thousands of these mining rigs located around the world in operation today.
Mining rigs are run and operated by people who refer to themselves as “miners”. Their mining rigs are constantly analysing transactions that take place on a POW Blockchain and are competing with other mining rigs to be the first to create the next block to add to the chain. Once a block is full of transactional data and a new block needs to be added to carry on the process the mining rigs are then tasked with solving the computational hash puzzles.
It is when solving these hash puzzles where the huge amounts of computer processing power come into play as it is using brute force to go through every single possible combination to solve the hash puzzle the quickest, this type of approach is the “proof of work” algorithm because the mining rig has to show evidence that it has completed a form of “work” in solving the hash puzzle. As a reward for their “work”, the miners are given the native token (a cryptocurrency) associated with that particular blockchain that they are mining (a block reward) which holds real-world value.
Advantages of Proof of work:
The main advantage of the POW algorithm is that it makes a Blockchain very secure. Using POW means that it is extremely difficult (but not impossible) for an external hacker to take control of a Blockchain that is using a POW algorithm. The algorithm also prevents the “double-spend” problem whereby a person on the network could spend their holdings more than once as all of the nodes on the network would not allow the same transaction to pass by more than once.
Disadvantages of proof of work:
Due to these mining rigs having to solve complex maths problems a significant amount of electricity is needed to operate the rigs 24/7. Environmental groups are now expressing their concerns about the large amounts of electricity POW algorithm are utilising. A study conducted by Cambridge University in 2020 found that POW algorithms account for 0.40% of the world’s total electricity consumption and that if this type of algorithm was a country then it would consume the total electricity supply of the Czech Republic or Colombia.
Some Blockchains that still use POW algorithms also go through a process called the “halving process” every 4 years. This means that the block rewards given to the miners get halved in amounts thus increasing the need for more electricity and the need for yet even more high-performance computers to give them the faster hash rates (the speed at which a miner can complete the hash puzzle) to break even with profits.
People who live in countries where the cost of electricity is high or is inaccessible are put at a clear disadvantage as it would not be profitable for them to run their own mining rig.
There is also the possibility of a 51% hack attack on a POW algorithm whereby a hacker takes control of more than 50% of the available nodes which has been responsible for disabling smaller Blockchains in the past and causing the native token associated with that Blockchain to plummet in value.
As more miners upgrade their hardware to compete with the next available block creation it also makes the POW algorithm less and less decentralized and more centralized to whoever has the mining rig with the fastest hash rates which starts to defeat the original purpose of a Blockchain being decentralized.
Proof of stake:
The proof of stake (POS) algorithm was created in 2012 and is very different to that of the Proof of Work (POW) algorithm. POS was invented to address the current problems facing POW. Instead of having centralized mining rigs that create new blocks and add them to a chain POS works by using a random selection process by selecting the nodes already on the network to become a validator of the next block. This new algorithm means that there is now no need for expensive mining rigs to create and add new blocks.
This random selection process is based on a combination of factors such as:
- The number of native tokens already stored within the node.
- The age of the node and how long have the tokens been held within the node.
Advantages of Proof of stake:
The most notable advantage of POS is how much more energy-efficient it is when compared to POW as there is now no need for energy-demanding mining rigs. Using POS on a modern home computer that is on the network can act as a node that is validating the blockchain. Using this new algorithm makes this Blockchain much more decentralized as mining rigs are now no longer the only ones who can add a new block to the chain.
Disadvantages of proof of stake:
A POS algorithm appears to still favour the rich as one of its selection processes will be to block reward those who already have a lot of native tokens within their node.
Which consensus algorithm is better?
Reviewing the current data there is overwhelming evidence that a POS algorithm is a much better option to use when protecting the environment due to the POW’s huge carbon footprint and realising that the energy consumption could be put to better uses. POW has created an arms race in computer processing power. A POS algorithm promotes fairness to a blockchain so that the ordinary person does not have to invest huge amounts of funds buying and maintaining their own mining rig because anyone with a modern computer can start validating a blockchain and receive block rewards. POS promotes a more decentralized blockchain as it can not be centralized by a POW algorithm (whoever has the fastest rig). The block reward for POS is subjected to how many native tokens are held within a node this could again put people at a disadvantage if they do not have the funds to buy and store native tokens on their node (home computer).
A blockchain can be operated and updated via two main consensus algorithms (POW and POS). Although other algorithms are currently being investigated these are the two main algorithms. POW was the first algorithm used in the first-ever Blockchain discussed in Satoshi Nakamoto’s white paper. The main incentive of a POW algorithm is to be rewarded in block rewards that hold real-world value. The POS algorithm encourages a person to buy the native tokens associated with that Blockchain and store them onto a node with the hope of being rewarded more of those native tokens (A block reward). Evidence shows that the POS algorithm is the better algorithm on many factors. In the future, it appears that most algorithms may move to a POS algorithm. Although some older Blockchains will always be POW as they were never designed to be operated by the POS algorithm.
Learn more about blockchain
Blockchain Collective is an education body and platform working with Registered Training Organisations (RTOs) and Universities to deliver a benchmark standard of education that empowers professionals and students with the necessary skills for a future in blockchain technology and applied blockchain.
The Advanced Diploma of Applied Blockchain 10747NAT is the first-ever in Australia. This course, and the Diploma of Applied Blockchain 10849NAT, also developed by Blockchain Collective, are designed to equip people willing to gain knowledge and experience in applying blockchain solutions to any kind of business framework.