When Bitcoin was first proposed and created its biggest achievement was creating first functional electronic money. That all was enable because of different achievement in the field, thanks to the bitcoin and creation of Blockchain. Achieving trust in a decentralised system. Such trust is called consensus. You can think of consensus as a way to reach agreement between a set of people. In terms of a blockchain, except of people you have nodes in the network that need to reach an agreement on a final state of data, the so called truth.
But to achieve such consensus in a blockchain network you need an algorithm which will help with that. Such consensus algorithms are also called a consensus mechanism. Different names but they refer to the same thing.
Consensus mechanism is a set of steps that are taken by nodes to agree on the final state of data. In order to achieve consensus different algorithms can be used.
Below I list and explain 4 different algorithms, in my opinion 4 most popular algorithms, which can be used to reach a consensus. I added pros and cons to each consensus mechanism at the end of each section.
Let’s get started!
Proof of Work
Proof of Work was first introduced in Bitcoin as a mean to achieve consensus. PoW (Proof of Work) is a solution to a process of solving a difficult mathematical problem based on a cryptographic hash algorithm. This proof proves that a miner did spend a lot of time and resources to solve the problem. When a block is 'solved', the transactions contained inside that block are considered confirmed.
In bitcoin, miners must find a numeric solution to the SHA256 algorithm that meets a network-wide target, the difficulty target. This means that miners compete with each other by calculating hashes and miner that calculates the correct one first, wins. Their block gets to be the next in the blockchain.
This work is incentivized, with each block creation new coins are created and those coins are going to the miner that found the correct hashes. This is the most known approach to mining (block creation). It is mostly used when we do not trust the other parties. This approach is considered the old way, Ethereum is slowly moving away from this consensus mechanism and with approach of version 2.0 of Ethereum it will abandon PoW completely.
It is currently the most implemented and used solution, and considered the safest one for the public blockchains;
Slow transactions, requiring specialized mining equipment.
Proof of Stake
Proof-of-Stake (PoS) is a method by which a cryptocurrency blockchain network aims to achieve distributed consensus. Proof-of-Stake asks block producers to prove ownership of a certain amount of cryptocurrency (their "stake" in the cryptocurrency). The common argument against proof-of-stake is the Nothing at Stake problem. The concern is that since it costs validators almost no computational power to support a fork unlike PoW, validators could vote for both sides of every fork that happens. Forks in PoS could then be much more common than in PoW, which some people worry could harm the credibility of the currency.
Attacks more expensive; More decentralized; Faster transactions confirmation times; No wasted computation;
Potential for nothing at Stake attack if PoS is wrongly implemented;
Delegated Proof of Stake
In Delegated-Proof-of-Stake (dPoS), token holders don’t vote on the validity of the blocks themselves, but vote to elect delegates to do the validation on their behalf. Voting can occur in many ways. The most basic approach is having one node equals one vote. This may lead to “Sybil attack” problem, where someone can have thousands of nodes and take over the network.
Second approach is to weight the vote based on how many coins a node has: a stake. All the nodes in the dPoS network system vote on which nodes will become block producers or Witnesses. The voting power is based on a stake—nodes with more (native) cryptocurrency have more voting power. Once the block producers are chosen, they create blocks in a predetermined way. This approach means that the community is allowed to choose which nodes have the power to produce transaction blocks. Each time witnesses produce a block, they are paid for their services. How much they will get paid is set by the
stakeholders via their elected delegates. If a witness fails to produce a block, then they not receive payment, and later may be voted out.
The state of active witnesses is updated once every maintenance interval (1 day) when the votes are gathered. The witnesses are then shuffled, and each witness is given a turn to produce a block at a fixed schedule of one block every 2 seconds. After all witnesses have had a turn, they are shuffled again. If a witness does not produce a block in their turn, then that turn is skipped, and the next witness produces the next block. Anyone can monitor network health by observing the witness participation rate.
Delegates are elected in a manner similar to witnesses. A delegate becomes a co-signer on a special account that has the privilege of proposing changes to the network parameters. This account is known as the genesis account. These parameters include everything from transaction fees, to block sizes, witness pay, and block intervals. After the majority of delegates have approved a proposed change, the stakeholders are granted a 2 weeks review period during which they may vote out delegates and nullify the proposed changes.
Pros: Cheap transactions; scalable;
Cons: Partially centralized.
Proof of Authority
PoA consensus is a straightforward and efficient form of Proof of Stake with known Validators and governance-based penalty system. This means that only trusted nodes can participate in a network as block producers. If their behavior will indicate that they are misbehaving, the trust in them is broken and they get banned from participating in the consensus. A list of block validators is managed by a smart contract with governance by Validators. First validators are chosen by the centralized, trusted authority, which distributes keys to some static number of independent block validators.
Basically, for this to work efficiently, each block producer’s identity has to be known (PoW and PoS do not require this). The most well-known cryptocurrency that uses variant of this approach is Ripple. The PoA protocol is also used on Ethereum’s testnets Kovan and Rinkeby.
Pros: High throughput; scalable, identity known of the validators we put the trust in;
Cons: Centralized system.