Consensus Protocol
To understand the consensus mechanism, it is helpful to compare blockchain systems to traditional banking systems.
In a banking system, there is a central authority (the bank) that is responsible for verifying and processing all transactions. This central authority also keeps track of all account balances and ensures that all transactions are legitimate.
In a blockchain system, there is no central authority, rather, it operates as a decentralized peer-to-peer network. This means all nodes in the network must agree on the state of the ledger for transactions to be processed. This is where the consensus mechanism comes in.
Blockchain involves numerous processes, and every node in the network has to convey its approval or disapproval for each of these operations. This collective agreement or disagreement mechanism is referred to as consensus.
Every node in a blockchain network is a computer that runs specialized software to maintain and validate the blockchain. For example, Bitcoin nodes use the Bitcoin Core software, and Ethereum nodes use the Geth software. This software includes a consensus protocol, or consensus algorithm, which is a set of rules that the nodes follow to reach a consensus.
Consensus mechanisms are the algorithms that ensure that all nodes in a blockchain network agree on the state of the ledger. They are essential to the security and integrity of blockchains, and they have four main jobs:
Selection of miners and validators and incentivizing them: Choosing miners and validators is a big part of how consensus mechanisms work in a blockchain. These mechanisms have to decide who gets the job of checking and adding new blocks to the blockchain. Plus, they need to make sure these miners and validators are rewarded and encouraged to be honest participants in the network.
Verification of new blocks and adding them to the blockchain: In the blockchain, transactions are first verified before being included in a block. Once a new block has been proposed, the consensus mechanism needs to verify that it is valid and that all of the transactions in the block are legitimate. Once the block has been verified, it is added to the blockchain. Since multiple nodes may attempt to create a block, a consensus mechanism is employed to determine which one gets the chance to do so. When a miner or validator successfully creates a block, it is propagated to all nodes in the network. Each node then independently verifies the block, and the verification information is shared across the network. For a block to be added to every node's copy of the blockchain, more than 50% of the nodes must agree on its validity. This process is facilitated by the consensus mechanism, ensuring that all nodes maintain an identical copy of the blockchain.
Punishing miners and validators who work inappropriately: In the event of a miner or validator acting maliciously by including unverified transactions in a block, the process remains the same. The block is sent to every node for verification, and if more than 50% of nodes find it invalid, the miner doesn't receive rewards, and the block is discarded. The consensus mechanism enforces these rules and can prevent the malicious actor from further participation. If a miner or validator tries to cheat the system, the consensus mechanism needs to detect this and punish them appropriately. This helps to deter malicious behavior and maintain the security of the network.
Solving the double spending problem: The double spending problem is the risk that a digital currency can be spent twice. Consensus mechanisms prevent double spending by ensuring that all nodes in the network agree on the order of transactions and the state of the ledger.
The consensus algorithm operates independently on each node. It ensures that every process within the blockchain is shared across all nodes, facilitated by consensus information. This consensus data empowers collective decision-making within the blockchain.
There are many different consensus protocols, each with its own advantages and disadvantages. Some of the most common consensus protocols include:
Proof-of-work (PoW): PoW is the consensus protocol used by Bitcoin and many other early blockchains. In PoW, miners compete to solve a complex mathematical puzzle. The first miner to solve the puzzle is rewarded with the right to add a new block to the blockchain.
Proof-of-stake (PoS): PoS is a more energy-efficient consensus protocol that is used by many newer blockchains. In PoS, validators are selected to add new blocks to the blockchain based on the amount of cryptocurrency they stake.
Delegated proof-of-stake (DPoS): DPoS is a variation of PoS that is used by some blockchains, such as EOS and TRON. In DPoS, users vote for delegates to represent them and produce blocks on their behalf.
Last updated