Crypto 101 with Vin: Consensus Mechanisms
Consensus is a general agreement and a consensus mechanism or consensus algorithm is the method that distributed systems, in this case blockchain networks, use to achieve agreement. A successful consensus mechanism is fault tolerant so long as a majority of nodes in a network agree on the state of a blockchain.
A single network does not have to use a single method, but can use a hybrid of two or more mechanisms to take advantage of the perks that different types of algorithms can provide. We’ll be using some more abstracted language here, so before you continue, make sure you’re able to understand the basics of how a blockchain works.
Common Types of Consensus Mechanisms
Proof of Work (PoW)
Proof of Work requires participants to “work” by completing random calculations to find some output by trial and error. All participants are racing against each other to do this. The work itself is arbitrary, but it is used to prevent participants from gaming the system. A winner gets randomly selected in a manner which weights chances proportionally to the “work” done. The reward for winning is the right to mine the next block and collect some reward. This could be newly minted coins or fees collected from transactions.
One downside is energy consumption. The Bitcoin network and Ethereum, initially at least, have an increasing difficulty for the calculations. This means that participants with higher calculation throughput are more likely to win the rewards because they have a greater ability to stumble upon the correct output(s).
Proof of Stake (PoS)
Proof of Stake does not require participants to do any work to increase odds of being selected. It is an alternative method that weights chances of being selected to validate a new block on how many coins a participant has staked. The more coins a participant has staked, the more likely they will be selected to validate a new block. The blocks also get verified by other validating nodes enhancing security.
Staking mechanisms punish participants that might harm the network, i.e. reverting blocks, by taking away the participants’ staked tokens. A malicious actor having a majority to conduct illegal actions usually by multiple identities is called a Sybil Attack. It would be very expensive to successfully attack the network like that since that would require an attacker to have a majority (51%) of tokens on a network.
A variation on this is Delegated Proof of Stake (DPoS), which allows users to delegate their coins to a particular Validator. Any rewards earned by the validator is split fairly to the users who have delegated to the validator’s own pool. One such network is Cardano.
The downside to staking is that it more heavily rewards participants with larger stakes.
Practical Byzantine Fault Tolerance (pBFT)
Fault tolerance is a system’s ability to operate despite some failure in the system. BFT is based off of the Byzantine General’s Problem where there are several generals that must coordinate an action, attack or retreat, while they can only communicate by one message at a time. If all generals agree on one action, they will be fine, but if some attack while others retreat there is a defeat. Being Byzantine fault tolerant means a system can tolerate up to one third of nodes not reaching consensus. PoW and PoS are such systems
PBFT optimizes the solution to allow the system to operate despite malicious nodes. The system relies on the number of malicious nodes being less than one-third of the number of all nodes. As more nodes enter the system, the system is more secure. The implementation is complicated, but below is an example.
Example: A client can request an action from the a leader. A Primary node is appointed to broadcast a command to backup nodes, then the other nodes validate that command with each other. The primary node gets changed based on a number of things every few rounds of requests. The request is considered successful if the client receives the same number of replies from nodes greater than the maximum number of bad actors allowed.
Proof of Capacity
Proof of Capacity uses digital storage space to speed up the block production time. The faster a network can produce blocks, the more transactions per second it can handle making it more usable. The first step in this method is to plot the storage space AKA hard drive. This means computing the hashes and saving them to plots or sections of a hard drive. Then every couple of hashes get “scooped” into pairs. A nonce contains some number (8192) of hashes.
The step after is the actual mining. A scoop number gets calculated. Then you visit that number scoop on each nonce. We take the data from the scoop and calculate a deadline value. We take the value from whichever nonce has the shortest deadline value. The deadline denotes time since last block. If no other miner has claimed the right to make the next block, then we can produce the block.
Although the initial part of plotting is work intensive, the subsequent step of using those plots is simply reading the data making it more efficient than PoW and less cost prohibitive in terms of processing power.
Despite these advantages, the plotted data is useless for anything other than mining and this mechanism is not well adopted.
Less Common Consensus Mechanisms
The following are less commonly used and there are many more spinoffs that come with different names that seek to compensate for problems not addressed or to build on top of existing mechanism. The following is a shortened list to make you aware they exist
- Proof of Authority — limited participants, highly centralized, low fees, short block time; nice for limiting use
- Proof of Burn — distribution of new tokens goes only to those willing to burn(send to un-spendable address)
- Proof of Elapsed Time — participants must sleep for a verifiably random interval; first to wake up is allowed to commit the new block
- Proof of Activity — hybrid between PoW and PoS
- Directed Acyclic Graph (DAG) Consensus — creates tree like structure in which a node can’t reference back to itself like a folder system; allows parallel processing of transactions
Even then there are still more like Solana’s hybrid proof-of-history and PoS which can get even more complicated or Cosmos’s Tendermint algorithm. I can’t possibly create an exhaustive list, but this all leads into…
The Blockchain Trilemma
All these consensus mechanisms you’ve just read about all try to achieve three things.
Security: Can the network resist bad actors and accurately maintain its state?
Scalability: Can the network handle the amount of transactions it is receiving in a timely manner?
Decentralization: Are the nodes and validators of the network sufficiently decentralized?
Hopefully when you are considering using a certain blockchain network, you will consider what consensus mechanism the network implements. This is important because the mechanism impacts the 3 properties above and those same things impact usability. If a blockchain isn’t fast or it isn’t secure, or it does not provide enough incentive for using it, Why use it at all?
Thanks for reading and check in next time.
Kakavarna.eth — Automation Engineer(9–5), crypto investor, and gamer with opinions