Blockchain operates based on a mechanism called a consensus algorithm, which is used for achieving agreement among participants. In this guide, we will explain these algorithms and reveal the mechanisms within the blockchain.
Consensus
A ‘consensus algorithm’ is an algorithm used in distributed systems or networks to form an agreement among different participants (Consensus means agreement, and algorithm refers to a procedure for solving problems in English). In the case of blockchain, nodes participating in the network generate new blocks based on a specific algorithm. These generated blocks are verified by other nodes while being propagated throughout the network, maintaining data consistency and preventing data tampering and attacks.
In the case of the famous Bitcoin, the ‘Nakamoto Consensus’ includes elements such as PoW (explained later), the longest chain rule, and Sybil resistance.
Common examples of consensus algorithms include ‘Proof of Work’ and ‘Proof of Stake.’ These algorithms are used by nodes on the network to reach a consensus and maintain a common transaction history and state.
PoW – Proof of Work
In PoW, participants known as miners engage in computational work (mining) to solve problems in order to add new blocks to the blockchain. This computation involves finding the nonce value, as previously mentioned in the data structure section. Participants compete to find the correct nonce value. The one who solves it can add the block and receive rewards (both block rewards and transaction fees).
When a block is added, other nodes sequentially verify if the solution is correct (this can be done simply by calculating the hash value of the data containing the nonce value). This process allows the new block to spread across the entire network.
As such, adding a block in PoW involves computational work to solve a problem, which prevents fraud (Sybil resistance), motivates miners with rewards, and allows other nodes to easily verify and quickly prove the correctness of the blocks.
Bitcoin is a well-known blockchain that adopts PoW.
PoS – Proof of Stake
One of the challenges of PoW is the need for extensive computer calculations, which require a large amount of electricity, raising concerns about environmental impacts. To address this issue, the PoS mechanism was devised. In PoS, instead of providing computational power, participants offer tokens as collateral (Staking). The mechanism works as follows:
- A node to generate the block is chosen randomly.
- Other nodes act as validators to verify (approve) whether the block is correct.
- Validators receive rewards for their work.
Validators are selected considering the amount of tokens they have staked.
If a validator acts maliciously, the staked tokens are forfeited.
Ethereum 2.0 (Ethereum after The Merge) is a well-known blockchain that adopts PoS.
Comments