Blockchain Agreement: Understanding Consensus Algorithm
Aastha Thakker
Cyber security enthusiast | SOC analyst | Digital Forensics | Blogs & Articles | THM - Documentation Team Lead | Gujarat University
Blockchain is a world of endless possibilities, or so they say. But let’s cut the crap and talk about what really makes it tick; consensus algorithms. You know, those boring, technical things that nobody cares about until the network implodes.
I and my friends were starving after skipping our lecture. The age-old question arose: where to eat? Opinions were as diverse as our appetites — Chinese, Mexican, South Indian, vada-pav, pani puri and more. It was clear we needed a single destination to satisfy our tummies.
To make a decision, we need to agree on a single destination. This is essentially what a consensus algorithm does in a blockchain network. One friend chooses the cuisine, then the next time it’s someone else’s turn. This is like a rotating leadership model. (Similar to democratic voting system, um-hum, I am sure you understood now. Wishing you a Happy Independence Day! And I hope you may overcome your biggest fear asap and become independent too!)
In a blockchain network, nodes (like these friends) need to agree on the order of transactions. Consensus algorithms are the rules they follow to reach an agreement. Instead of votes or turns, nodes use complex mathematical calculations and cryptographic techniques to decide which version of the blockchain is the correct one.
Just like the friends need to trust each other to make a fair decision, nodes in a blockchain network need to trust the consensus algorithm to ensure fairness and security.
Consensus algorithms ensure that everyone in the network agrees on the same information, even if there are disagreements or attempts to cheat. This is crucial for maintaining the integrity and security of a blockchain.
Features of Consensus Algorithm
Types of Consensus Algorithms
Just like we have multiple ways to decide where to eat, blockchain networks employ various consensus algorithms to reach agreement on their shared state.
1. Proof Of Work (POW)
When a user initiates a transaction, it gets grouped with other pending transactions into a pool. These transactions need to be validated and added to the blockchain.
Miners — specialized computers on the network — compete to solve a complex mathematical puzzle. This puzzle is based on the cryptographic hash function, typically SHA-256 for Bitcoin. This process involves miners repeatedly hashing the data until they find a valid solution.
The first miner to solve the puzzle successfully creates a new block containing the validated transactions and adds it to the blockchain. This block also includes the hash of the previous block, ensuring the integrity and continuity of the chain.
The newly created block is broadcast to the entire network. Other nodes verify the block by checking the solution and the included transactions. If the block is valid, they accept it and update their copy of the blockchain. The difficulty of the puzzle adjusts over time to maintain a consistent block creation time. As more miners join the network and computational power increases, the puzzle becomes more challenging to solve. The miner who successfully adds a new block is rewarded.
2. Proof Of Stake (POS)
In Proof-of-Stake (PoS), validators secure a portion of their cryptocurrency as a stake to gain the right to validate new blocks on the blockchain. Validators bet on blocks they believe will be added to the chain. If a block they bet on is added, they earn rewards proportional to their bet, which increases their stake. The selection of a validator to create the next block is based on their economic stake in the network, sometimes combined with other factors like the duration they’ve held their stake (coin-age) or a randomized process.
Coin-age based selection: The algorithm tracks the time every validator candidate node stays a validator. The older the node becomes, the higher the chances of it becoming the new validator.
Random Block selection: The validator is chosen with a combination of ‘lowest hash value’ and ‘highest stake’. The node having the best weighted-combination of these becomes the new validator.
Nodes make transactions. The PoS algorithm puts all these transactions in a pool. Once chosen, the validator verifies transactions and proposes a new block. If the network approves this block, the validator regains their stake and earns a reward. If not, they lose their stake. In PoS, there’s a fixed number of coins in circulation, and validators are rewarded with transaction fees. The 51% attack is impractical in PoS, as acquiring 51% of the network’s cryptocurrency is both costly and counterproductive, making such an attack unlikely.
3. Proof Of Activity (POA)
Proof of Activity (PoA) combines elements from both Proof of Work (PoW) and Proof of Stake (PoS) to create a hybrid consensus mechanism. Initially, miners work similarly to how they would in a traditional PoW system. They compete to solve a complex mathematical puzzle (finding the correct nonce and block hash).
Instead of mining a full block of transactions, miners focus on creating an almost empty block. This block includes only the header information and the miner’s reward address.
After the miner successfully mines the block, the system transitions to the PoS phase. A group of validators, also known as signers, is selected to validate the block. Validators are chosen based on the amount of cryptocurrency they hold — the more coins they have, the higher their chances of being selected.
领英推荐
Validators review the header information of the mined block and decide whether to sign it. The process continues until the block receives the required number of signatures from validators.
Once the block has enough signatures, it is marked as a valid, complete block. Only then are the actual transactions added to this block from the transaction pool. The fully signed block, now containing transactions, is added to the blockchain.
The mining rewards are then distributed among both the miner who created the block and the validators who signed it.
4. Proof Of Burn (POB)
Proof of Burn (PoB) is a blockchain consensus mechanism where participants “burn” or permanently remove a portion of their cryptocurrency by sending it to an irretrievable address.
Validators (miners) send their coins to a public, verifiable, and inaccessible address. Once sent, these coins are permanently gone and cannot be spent.
By burning their coins, validators demonstrate a long-term commitment to the network. They are giving up immediate value (the burned coins) in exchange for the chance to earn rewards later.
Validators who burn coins earn the right to mine new blocks. The more coins they burn, the higher their chances of being selected to mine the next block, as the system randomly selects validators based on the amount they’ve burned. Once selected, the validator creates the next block and is rewarded with new coins or transaction fees.
To ensure that mining power isn’t concentrated with early adopters, PoB often requires periodic burning of coins. This means validators need to continually burn coins to maintain or increase their mining capacity.
As coins are burned over time, the total supply of the currency decreases. This reduction in supply can potentially lead to an increase in the value of the remaining coins.
The scarcity created by burning coins may lead to a deflationary effect, where the value of the currency appreciates over time, benefiting holders who do not burn their coins. Unlike PoW, PoB does not require vast amounts of computational power, making it much more energy-efficient.
Similar to PoW, there’s a risk that validators with more resources could dominate the network by burning more coins, potentially leading to centralization. The requirement to continually burn coins may raise concerns about the long-term sustainability of the network.
5. Delegated Proof of Stake (DPOS)
Delegated Proof of Stake (DPoS) is a consensus mechanism that secures blockchain networks through a system of voting and delegation.
In DPoS, users of the blockchain can vote directly or delegate their voting power to someone else to vote on their behalf. In DPoS consensus users can either directly vote or give their voting power to another entity to vote on their behalf.
Selected witness are responsible for creating blocks by verifying transactions.
If they verify and sign all transactions in a block, they receive a reward, which is usually shared with those who have voted for witness.
If a witness fails to verify all transactions in the given time, block is missed, all transactions are left unverified and no reward is distributed to that witness.
The reward is added up to reward of the next witness which verifies that block. Such transactions are collected by the next witness, and such a block is called stolen.
Witnesses must lock up a portion of their stake, which can be seized if they act maliciously. Their reputation and income depend on their performance, ensuring they act in the best interest of the network. As more users apply to become witnesses, competition increases, making reputation crucial for staying in the top tier of witnesses.
In addition to witnesses, users also elect “delegates” who manage the governance of the blockchain. Delegates can propose changes, such as adjusting block sizes or witness rewards, but do not directly control transactions. Users vote on these proposals, and the changes are implemented if approved.
Block validators are full nodes that verify blocks created by witnesses, ensuring they follow the consensus rules. Anyone can run a block validator, but there is no financial incentive for doing so.
In conclusion, consensus algorithms are the backbone of blockchain technology, each with its unique strengths and suited to various applications. Stay tuned for more updates!
If you have any insights on how blockchain can be integrated into real-life scenarios, I would love to hear your thoughts!