Consensus mechanisms
Tags: blockchain
Published: 2023-03-19 15:48:26

**What are consensus mechanisms? **

Consensus mechanisms are a crucial part of blockchain technology because they guarantee the legitimacy and integrity of transactions and data recorded on the blockchain.

**Some popular consensus mechanisms used in blockchain**

**Proof of Work (PoW)**: The oldest and most popular consensus technique in blockchain technology is called Proof of Work (PoW). With proof-of-work, miners compete to figure out a challenging mathematical puzzle; the first one to do so wins newly created currency. Energy is used up during this process since powerful computers are used by the miners to answer these challenges. Yet, because a successful network attack demands a lot of processing power, PoW is also regarded as being quite secure.

**Proof of Stake (POS)**: Proof of Stake (PoS) is a newer consensus technique that tries to lower the energy consumption of PoW. With PoS, validators are selected to validate transactions based on their stake in the network, much as miners in PoW (i.e., the amount of cryptocurrency they hold). A percentage of the stake held by validators must be secured as collateral; otherwise, they risk losing their stake. Although PoS doesn't need as much computing power to validate transactions as PoW, it is thought to be more scalable and energy-efficient.

**Delegated Proof of Stake (DPoS)**: Token owners vote for delegates in a DPoS consensus system, and these delegates validate transactions and add new blocks to the blockchain. Usually, the reputation, level of technical proficiency, and dependability of these delegates are taken into consideration. The network can be controlled by a small number of delegates in DPoS, which is faster and more energy-efficient than PoW but may also be more centralized.

**Proof of Authority (PoA)**: In a PoA consensus method, validators are pre-selected and typically respected individuals or institutions within the community. Each block must be authorized by a particular number of validators before it can be added to the blockchain. Validators create new blocks alternately. PoA is quicker and more energy-efficient than PoW, but because validators are pre-selected, it may be less decentralized.

**Proof of History (PoH)**: Solana, a highly effective blockchain network, invented the Proof of History (PoH) consensus mechanism. PoH is built on employing a verifiable delay function (VDF) to produce a time-ordered sequence of occurrences. The validation of transactions and the construction of a safe and expandable ledger can then be done using this sequence. PoH is intended to be more secure than PoS and more energy-efficient than PoW, removing the need for miners or validators to carry out laborious calculations.

**Hybrid Consensus**: To improve their scalability, security, and decentralization, some blockchains use several different consensus algorithms. To validate transactions and guarantee consensus among network participants, Ripple, for instance, combines PoW and PBFT (Practical Byzantine Fault Tolerance) consensus techniques.


**How this consensus mechanism is used on different blockchain?**

**Proof of Work (PoW) used by bitcoin**: Definition as stated above, the process of PoW in Bitcoin works as follows:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9otrku3v2iz5ei1mnvj.png)

1. A group of pending transactions, known as a block, is created and broadcast to the network.

2. Using processing power, miners compete to solve a cryptographic challenge that is tied to the block. This puzzle demands the miners to locate a hash that satisfies a predetermined set of requirements; this hash is challenging to locate but simple to verify once located.

3. One or more Bitcoins are awarded to the miner who discovers the right hash first and publishes it to the network.

4. The new block is added to other nodes' copies of the blockchain after they have confirmed that it is accurate.

To keep the network's block production rate constant, the puzzle's difficulty is automatically changed. This is crucial for keeping the network secure and preventing inflation.

The Bitcoin network benefits from decentralization and security thanks to PoW. Miners have an economic incentive to act honorably and thwart attempts to alter the blockchain since they must use processing power to solve the challenge.

In general, PoW is a crucial breakthrough in the Bitcoin network since it offers a safe and decentralized means to validate transactions and uphold the network's integrity. Due to the considerable energy consumption required by the processing power needed for mining, some people are worried about how the Bitcoin network may affect the environment.


**Proof of Stake(PoS) used by polygon**: Definition as  stated above, the process of PoS in Polygon works as follows:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bosfuy94w6dmnjm4oea.jpg)

1. When network validators "stake" their Polygon tokens as collateral, their tokens are locked up for a predetermined amount of time.

2. Based on the number of Polygon tokens pledged, validators are chosen at random to verify transactions and build new blocks. A validator's likelihood of selection increases with the number of tokens they have staked.

3. After being chosen, a validator adds a new block to the chain and verifies the transactions contained therein.

4. The new block is added to other nodes' copies of the blockchain after they have confirmed that it is accurate.

A validator's staked tokens may be seized as punishment if they engage in malicious behavior, such as trying to validate an invalid transaction or building an incorrect block.

PoS has various advantages to PoW, including more scalability and less energy use. PoS is more energy-efficient than PoW because it doesn't need as much computing power. Also, it is more open to a larger range of users because validators are chosen based on the quantity of cryptocurrency they own rather than their computer capacity.

Validators are in charge of approving transactions and building new blocks in Polygon's Proof of Stake (POS) implementation of PoS, while delegators can assign their tokens to validators to take part in the network's consensus process. As a result, a larger number of people can take part in safeguarding the network, resulting in a more decentralized network.

Ultimately, PoS is a crucial innovation in the Polygon network since it offers a safe and effective mechanism to confirm transactions and maintain the network's integrity.




**Proof of History(PoH) used by Solana**: Definition as stated above, the process of PoH in Solana works as follows:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41z74g1du2f6rkfre64w.jpg)
1. PoH generators: A collection of PoH generators, or nodes that carry out the verifiable computations required to produce timestamps, form the basis of PoH. Every few milliseconds, each generator creates a fresh timestamp and transmits it to the network.

2. PoH verifiers: The PoH verifiers, which are nodes that verify the timestamps' authenticity, employ the timestamps that the PoH generators have produced. The timestamps are generated in line with the PoH protocol, and the verifiers make sure they are in the right order.

3. Transaction processing: A timestamp from the PoH sequence is included in every new transaction that is sent to the Solana network. This timestamp is needed to confirm the transaction's order and guarantee that it is included in the correct block.

4. Consensus: To ensure that all nodes on the network concur on the state of the blockchain, PoH is utilized in conjunction with a conventional consensus mechanism called Tower BFT.

The Solana blockchain is able to attain great levels of speed, efficiency, scalability, and security thanks to PoH, a novel consensus method. Solana is well-suited for a variety of use cases because it can swiftly and simultaneously handle a high number of transactions thanks to PoH.

**In conclusion**, consensus mechanisms are a key component of blockchain technology, and the choice of one depends on a number of variables, including the goal of the network, the need for scalability, the need for security, and the trade-off between centralization and decentralization.