Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Blockchain is decentralized ledger that is used to record transactions across many computers(nodes) on a network.
Blockchain ledgers are immutable, tamper proof and append only which means that its transaction cannot be edited or deleted.
How It Works
Users of blockchain network sends requests which are known as transaction to the network. This transaction is then broadcasted to other nodes and each nodes will store the broadcasted transaction into their transaction pool, also known as mempool.
A miner collects these transaction and put them in a container called blocks which will then be added to the chain on the network.
A block on the chain extends a previous block and they are connected together using a property called previous Block hash which is the hash of the previous block.
Tampering with a block in a single node will require re-calculation of the cryptographic hash of the remaining blocks in the chain and those block must be broadcasted to the other nodes before the next block is being generated, else the computation is wasted.
State Machine Replication (Consensus)
Consensus is the ability for nodes in a distributed systems to collectively agree on a decision to perform an action on the network.
Problem Statement
Back in the early days of distributed computing, there exist a problem called Byzantine General problem which simply means the process of executing a particular operations at the same time to get same output in a distributed system.
Lets take this below image for example
courtesy : https://www.flickr.com/photos/166102838@N03/31024022797
How do an army general pass messages to all other army generals to attack the castle at the same time knowing fully that if some generals didn't get the message and fails to attack at the said time will result into loss of battle.
The above problem in blockchain simply means that how do we pass a message to all the node to update the copy of the ledger on their node at a given time so that all the node on the network will have an up to date ledger.
Solution
Byzantine Fault Tolerance
Byzantine Fault Tolerance is the feature of distributed system for nodes to reach consensus even when some nodes in the network fails to respond, faulty or act maliciously.
There has been different solution designed to tackle this issue which has all work well based on what you are trying to implement.
We will look into some of those consensus mechanism to see how they works.
1. Proof Of Work
Proof of work is one of the oldest algorithm built originally to deter denial of service attack, spamming and other malicious activities.
It requires the user to find a nonce by continuously using cryptographic hash function to hash a piece of data until a result that match a target is found.
Satoshi Nakamoto uses the proof of work algorithm in the bitcoin network which task miners to search for a nonce that when it is added to the block header will generate an hash with leading zeros that is more than or equal to a given target.
Ethereum which is also a popular blockchain network uses the proof of work algorithm which allows the miner to find a nonce such when it is added to the block header, It will return a number lesser than or equal to a given target.
Nodes on the network search for this nonce and immediately it is found, the proposed block will be sent to other nodes on the network to validate and the blocks get added to the chain. The miner gets the block reward and the transaction fees for the block.
Pros
- It offers full Decentralization.
- Finality is low to achieve because there is a probability of forks and re-org.
- There is 100% liveliness, which means your network will not halt at any given time.
- Requires 51% of the network hashrate to launch an attach which is hard to achieve.
Cons
1. It requires a lot of electricity to run a mining machine.
2. Miners becomes too powerful and they can censor a particular transaction from entering a block.
3. Doesn’t offer inclusiveness.
4. Low throughput.
Few chain implementing this consensus are Bitcoin, Ethereum, ZCash, LiteCoin
2. Proof of Stake
Due to the issues faced by the proof of work algorithm concerning the unnecessary wastage of electricity resources, there has been different effort to create new consensus algorithm that will be better and use less resources compare to proof of work.
Proof of stake is a consensus mechanism which requires a miner(forger) to stake a some amount of native token which will be locked for a number of period. If the forger get selected for that epoch, he gets to create block which will be broadcasted to other validator nodes for validation.
With this solution, the electricity resources has been removed and replaced with the native token which also works.
Pros
- Low energy consumption.
- Requires 51% of the total token staked to launch an attack which will be very hard to come by.
Cons
- Network will halt if there are not enough validators.
- Makes forger more richer and allow easier censorship of a transaction.
- Doesn’t offer inclusiveness.
- Increase risk of fork.
- Low throughput
Example of chains implementing Proof of stake are ReddCoin, Ethereum(casper), NavCoin
3. Hybrid Pow/Pos
Hybrid consensus is a type of consensus that allow both proof of work and proof of stake nodes to work hand in hand to create and validate blocks respectively before adding them to the chain.
Pow miners uses their hardware to create the block while the pos miner uses their stake to validate the blocks and profit for the blocks are shared in between them.
Pros
- Provide Inclusiveness
- Guarantee High finality of transaction
- Fork resistance.
- Makes censorship harder in the network.
- Requires 51% each of the total staked token & hash power to launch an attack
Cons
- Low throughput
- Waste of electricity from the pow miners
Examples of chain implementing hybrid consensus are MemCoin2, Decred, Gulden
4. DPOS (Dedicated Proof Of Stake)
This is similar to Proof of stake with its major different being the fact that there are fix number of block producer which are elected by all token holders.
Those block producer handles block creation and also store the full state of the block chain.
Pros
- There is higher throughput because it requires lesser validators
- Less energy use.
- High finality
Cons
- It is also seen as some sort of centralization by limiting the number of people who can act as a validator.
- Required voting participation from token holders by making sure that token holder voted for the right and stable node to become delegates so that it wont cause harm the network.
5. PBFT (Pratical Byzantine Fault tolerance)
Nodes in the pBFT network are in orderly sequence and one node acts as the leader for the specific epoch
PBFT models goals is to make sure that at least 66% of all the nodes in the network are good nodes and less than 1/3 nodes are malicious.
The higher number of nodes joining a pbft network, the lesser the chance of malicious node rising up to 1/3 percent
Pros
- Instant finality.
- Fork Resistance.
- Less energy consumption
Cons
- Works well in a small grouped sized due to the number of communications going back and forth between the nodes.
Example of chains using this consensus are : Hyperledger, Zilliqa
6. DBFT (Delegated Byzantine Fault Tolerance)
This is a similar consensus mechanism with the PBFT and also the implementation of DBFT is based on PBFT with its only different being that there are elected delegates to participate in block creation and validation just like as it is in DPOS.
Pros
- Instant finality.
- Fork Resistance.
- Less energy consumption.
- High throughput.
Cons
- Less Decentralized because there are limited number of nodes that can become a delegates.
Example of chains using this consensus are : NEO, Binance.
Consensus Mechanism Market Share
Consensus Mechanism Comparison
Below is a tabular comparison of the major consensus mechanism against some of the features available to choose from.
There are others consensus mechanism that we didn't talk about such as :
- Proof Of Capacity (POC).
2. Proof Of Elapsed Time (POET).
3. Proof of Activity.
4. Proof of Importance
5. Proof of Identity
That’s it, you’re all set to tell others that you know how things get done in a blockchain!
Thanks for your read!
Do support and show some love (Claps)
Consensus Algorithm in Blockchain was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.