TLDR:
Proof of Work: validators compete based on energy usage; has high energy costs; decentralised, apart from chip manufacturers; battle hardened and proven.
Proof of Stake: validators chosen probabilistically based on ETH at stake; very low energy costs; yet, nothing really at stake, the rich get richer, and not yet proven.
Proof of Authority: validators hand picked; algorithm cycles between them; no energy costs and highly scalable; yet centralised and not censorship resistant.
Blockchain Trilemma - you can only have 2-of-1 in decentralisation, security, scalability. No single algorithm is better than the other, it depends on use-case.
To kick things off this week, I’ve set a couple of goals that will influence future posts:
To build a short course on “NFT Tech”. The topics I want to cover in this course will influence many of the upcoming blog posts that I write, and I’ll explain more about the course in a future post.
To make posts shorter and more digestible so they are easier for people to consume in today’s busy lives.
The latter is a goal I set before but have struggled with so far. I’m hoping though that it will be easier with the clear focus on this short course as I can take on smaller topics that will be condensed into the course.
In this week’s post I’m going to cover the topic of Consensus Algorithms, which are a really important part of crypto and Web3 that most people seem to have a limited understanding on as Consensus doesn’t get as much hype as say the “blockchain” does.
Consensus Algorithms
One of the key components in a blockchain network is the “Consensus Algorithm”. At its core the consensus algorithm is what it says on the tin: it’s the rules by which network participants reach consensus on the current state of the network.
Consensus on Bitcoin is achieved through what is known as Nakamoto “Proof of Work” (PoW). And up until the Paris fork last year in 2022, Ethereum also used its own version of PoW, but since its moved over to using “Proof of Stake” (PoS). Plus when we speak about private blockchains or some highly scalable networks like Binance Smart Chain, they tend to use something called “Proof of Authority” (PoA). We’ll cover these three classes of Consensus Algorithm below.
Consensus is a crucial part of the network as its what gives it its main centralisation or decentralisation properties. And crucially it’s how network participants are able to run their software in all different parts of the world and still achieve a singular cohesive blockchain that we can all interpret as a single source of truth.
Really Consensus is the unsung hero of crypto and Web3 and where a lot of the magic of this technology lies.
Proof of Work
Bitcoin created PoW consensus, which in of itself was a significant innovation. In PoW network validators take a set of transactions that network participants want to send and stick them together into a block of memory that is no larger than the Consensus rules (on Bitcoin this is 4MB blocks). Validators then run this block of memory through a hashing function (SHA256 on Bitcoin) over and over to find the hash that the current Consensus rules will accept.
Hashing can be thought of as nothing more than passing this block of data through a black box that spits out a number on the other side. By just changing a single bit of data in that block of memory the function will spit out an entirely new hash.
The validating actors in PoW are called miners. Miners do all this at massive scale running billions upon billions of hashes per second to try and get one that is accepted by the current PoW difficulty. A successfully mined block is then one who’s hash has a certain number of 0’s at the start based on the current difficulty. In Bitcoin the difficulty is updated regularly by the algorithm to ensure a new block gets mined approximately every 10 minutes.
There’s an environmental complaint that mining wastes a lot of electricity. However, the fact that you need to run billions of computations for the network to accept a set of transactions is exactly what protects the network from outside attackers coming in and changing the contents of the blockchain to something else. PoW consensus is what keeps the Bitcoin blockchain secure and immutable.
Miners are incentivised to play in favour of the network because if they help the network and successfully mine a block then they get some BTC as a reward. Yet, if they do not they waste lots of electricity and hence money.
PoW is highly decentralised as anyone can run their own miner. It tends only to centralise on hardware manufacturers who have a monopoly on developing the hardware needed to compete. It also somewhat centralises on mining pools that group hashing power together so you can get a portion of the BTC reward even if you never successfully mine a block, however it’s easy for miners to switch between the mining pool they belong to so its not a very rigid form of centralisation.
PoW has the longest history of surviving without malicious actors taking over since Bitcoin is almost 15 years old.
Proof of Stake
Ethereum was created using PoW. But the Ethereum foundation began to feel like the energy that miners used to validate transactions on the network was a burden and could be reduced massively by moving over to PoS.
Vitalik Buterin, Ethereum founder, describes PoS as a virtual version of PoW. Instead of using lots of computational power and hence energy (and real world money) to validate transactions, validators now lock-up a portion of their Ether to get a chance to validate a block and be rewarded with more ETH from doing so.
In PoS there’s no longer a race against the clock to mine the next block of transactions, instead its just a game of chance where the more ETH you stake the more chance you have of being the validator and hence of earning the ETH rewards. The catch is that if you don’t play by the consensus rules then you risk being penalised by the network and having your ETH slashed!
The beauty of PoS is that it simulates PoW without needing to burn through a lot of real world energy. However, the obvious counter-argument is that ultimately there’s nothing really at stake here, the stake is something internal to the network, its not supported by anything from the outside physical world. So what’s there to stop a significant player buying lots of ETH, or coercing validators with lots of ETH, and having a malicious influence.
Moreover, in this system the rich get richer, as unlike in PoW there’s no real cost involved. With PoS you just post up your ETH in the network and as long as you are behaving inline with the algorithm, you will validate more and more blocks, earn more and more rewards, and have a bigger and bigger influence.
PoS has great promise in being a low cost alternative to PoW that’s a lot better for the environment. However, it still has to prove itself against the test of time, it’s not been used with a lot of money at play in any other chain. Ethereum has been using it for less than 1 year and will be its biggest testing ground.
Proof of Authority
Proof of Authority is the simplest and least robust scheme of the three, and it’s entirely centralised. Validators are hand picked by the creators of the network and only those who have been selected can validate transactions. This means PoA systems often have a consortium of entities, or just a single entity, that owns all the validators.
In PoA consensus the set of validators simply take turns to create a new block of transactions on the blockchain. There’s no competition involved or chance, it’s just a cyclic algorithm that cycles through giving each validator a turn to create a block.
The beauty of this system is that allows for highly scalable systems, since essentially it turns the blockchain network into a centralised database shared by a set of participants that simulate the functionality of smart contracts and tokenisation. Networks like Base, Coinbase’s permissioned Layer-2 for Ethereum, and Goerli, the Ethereum testnet.
PoA networks are blindingly fast. However, the obvious downfall is that they are not decentralised. In principle the validators can collude and change the chain, so its not immutable and not permissionless or censorship-resistant. If the centralised validators see you as a bad actor from their perspective they can simply block your access and block your funds, in this regard its not too different from the traditional financial system.
Conclusion
No single Consensus algorithm is “better” than another, it all depends on the goals for each network. Whether it be decentralisation, scalability or security, you can never have all three, there’s always a compromise where you prioritise two over another. This is known as the “Blockchain Trilemma”.
There are also other types of Consensus Algorithm that are derivations or combinations of these. For example Lisk use a DPoS, ie. a “delegated” PoS where each validator is firstly picked through network participants delegating their LSK stake towards a validator they like, and then the algorithm runs cyclically like PoA picking one validator at a time.
Hopefully this post has given you an understanding on the importance of Consensus and why its also crypto’s unsung hero. It may help to clarify why “Consensus” is such a common term in the space with large companies like “Consensys” and regular annual events like Consensus happening later this month.
Keep buildin’ builders.
Great thread!!