A gigantic word in cryptocurrency. It influences and sets everything from security and decentralisation to speed and environmental friendliness. It is the essential algorithm that checks the Blockchain — it is the keeper of the truth.
Despite this key importance, it is still very misunderstood.
What is a Consensus Algorithm?
A consensus algorithm is a process used to achieve agreement on a single data value among distributed processes or systems. In Blockchain, these algorithms work as instructions to allow the network to validate and confirm transactions on the Blockchain.
Where does Consensus Fit on the Blockchain?
Let’s consider a typical transaction.
- User requests a transaction — A user requests a value change in the network. This could be a trading value, stored data, contracts, etc.
- The transaction is submitted to the Network — The network nodes check with their own copies of the chain. The scale of the network and where this change is checked depends on the inbuilt rules of the chain.
- Transaction validation — The network either validates the transaction or kicks it out. Again, depending on the Blockchain, this is generally where most of the consensus algorithm work is done. The user asks the nodes of the network to say yes or no to the new Information. Different rules will apply to different Blockchains as to how this is handled. Different nodes might have different opinions, the consensus algorithm is the instrument that overcomes these differences and achieves a network endorsed value on the ledger.
- Block Creation — The transaction is added to the current ‘block’ of transactions. In both of the popular models for consensus PoW and PoS (covered below) nodes must prove themselves to then facilitate this function. Here older blocks are compared against newer blocks in the hash chain. This block of transactions is then mathematically ‘chained’ to older blocks of transactions.
- Block Validation — The transaction is confirmed. Finality is achieved with the user requested change becoming a confirmed part of the chain. At this point the underlying Blockchain algorithm will often reward the validator for their service to the network, in the case of Bitcoin with an amount of coin. In this sequence depending on the Blockchain and the rules set up in it’s code, the consensus algorithm operates at points from transaction validation, to block creation and block validation. At each of these points the nodes check in with their own copy of the Blockchain and use algorithmic instruction to form consensus.
Blockchain nodes must prove themselves worthy to validate and perpetuate the chain.
There are many different ways built in code to achieve this, but the two main working models are PoW and PoS.
Between the two they currently hold a rough 70/30 split in the market.
PoW — Proof of Work
The original algorithm, the Bitcoin Blockchain consensus algorithm, PoW relies on nodes ‘working’ to prove themselves. The ‘work’ is usually achieved by mining. Mining is a competition to solve a complex computational problem, generally the node that solves the problem, gets the right to propose the next block. The network of nodes will then check the solution of the competition and the validity of the block, if it all checks out the successful miner will get the Bitcoins created out of this process.
Bitcoin, Ethereum (Moved to PoS), Litecoin (another Hybrid), XMR… Most Blockchain currently (approx. 70%)
Miners use hardware to solve hard computational problems to compete for the chance to create new blocks and tokens.
It works. It is tried and tested. Top-notch integrity.
Energy consumption, slow and prone to 51% attacks.
Point of Contention: Energy Use
Bitcoin using a PoW consensus, for example, consumes 61.4 TWh annually (April 2018), compared to an Australian annual national average consumption of 224 TWh (estimate for 2014). That’s more annual power consumption than than countries like Switzerland, Singapore and Columbia.
PoS — Proof of Stake
Proof of stake relies on nodes putting forward a stake in the chain. The stake is mostly tokens held as stake. The higher the stake, the more likely the consensus algorithm will pick that node for a chance to validate the block. The main benefit to this model is it’s lighter approach to Proof. There is no mining and all tokens that exist, exist from day one of the chain.
Ethereum, Decred, PIVX… (the other 30%)
Blockchain participants with the most stake — time and token — are selected by algorithm for the right to propose the next block.
Expensive to disrupt or attack, decentralised, low energy consumption and fast.
Nothing to lose if a validator/stakeholder backs the wrong chain.
Point of Contention: Nothing to Lose / Nothing at Stake
The darkness at the heart of PoS is where there is actually nothing at stake for a malicious node or stakeholder to propose or endorse a version of the chain that is not the right one.
Ethereum has recently updated it’s core code with Casper — a move towards addressing Nothing at Stake — prescribing harsh penalties for going against the chain.
Proof of ‘X’
Beyond the main two types of consensus modelling, a whole range of proof algorithms exist. Below are three other varieties usually built on the structures of PoW or PoS, with different ways of approaching ‘proof’.
DPoS — Delegated Proof of Stake
EOS, Steemit, BitShares
Each token has inbuilt voting power. Token holders vote for nodes to have the right to mine/validate.
Democratic, scalable, fast and cheap.
PoA — Proof of Authority
Kovan, Rinkeby and POA Network
Blockchain with system administrators, identity as stake.
Great for private networks needing high throughput.
Proof of Time, Proof of Space, Proof of Spacetime…
Filecoin (Proof of Replication & Proof of Spacetime), Chia
Stake goes beyond token and identity and uses another relative measurement (space or IPFS data for example) to suggest which node gets to propose the next block.
Customisable to the relative measurement.
Generally hard to create incentive. Can become centralised and committee dominated.
World of Consensus
These models are a sample of the possible ways consensus algorithms can operate in the Blockchain. The means to achieve consensus is as varied and as vibrant as the Blockchain itself and with each different expression and application comes new possibilities.