A blockchain is a peer-to-peer, distributed database that is used for maintaining records. Consensus algorithms are essential since blockchains are distributed systems, and no central authority checks the data before recording it on the blockchain. The decision of who will publish the subsequent block is a crucial component of blockchain technology. The issue is resolved by putting one of the several consensus models into action. There are typically numerous nodes competing at once to publish the next block in permissionless blockchain networks. The usual motivation for doing this is to earn rewards paid in cryptocurrencies and/or transaction fees. They are typically distinct, independent servers and may only communicate through public addresses. Each node's motivation is probably monetary gain, sometimes not the welfare of other publishing nodes or even the network. Blockchain technology makes it possible for people to cooperate despite their mutual mistrust by using consensus models.
Consensus building in distributed systems is challenging because consensus algorithms need to withstand node failures, network segmentation, message delays, out-of-order message arrivals, and corrupted message attacks. They must also cope with selfish and purposefully malicious nodes. To address this, several algorithms have been developed in the research literature, each of which makes the necessary assumptions about synchrony, message broadcasts, failures, malicious nodes, performance, and message security. By achieving consensus, a blockchain network may be sure that every node in the network agrees with the same global state of the blockchain. A consensus protocol's applicability and effectiveness can be assessed based on three essential characteristics.
- Safety: If all nodes generate the same output and the outputs are valid in accordance with the protocol's requirements, a consensus mechanism is deemed to be safe.
- Liveness: If all participating, non-faulty nodes eventually produce a value, a consensus protocol assures liveness.
- Fault Tolerance: A consensus protocol offers fault tolerance if it can recover if a participating node goes down.
Depending on the developers behind different blockchains and their respective choice of consensus mechanisms, some consensus processes may prioritize efficiency and speed while others may prioritize security. Payments may benefit from faster consensus formation techniques, although more secure consensus processes may be beneficial in certain contexts, such as supply chain management or high value transactions.
A consensus method combines a Sybil resistance mechanism, an approach to protect the network from an attacker seeking to gain control by amassing a majority of the network’s voting power, with a chain selection rule (aka fork choice rule). In situations where multiple blocks occupy the same position, a chain selection rule enables nodes to select a single correct block at the head of the chain. For example, Bitcoin uses the longest chain rule, which means that the longest version of the blockchain is considered valid by the nodes' participants. For PoW chains, the longest chain is determined by the chain's total cumulative PoW difficulty (to be explained in the PoW section).
The most well-known Sybil attack in the crypto space is the "51% attack," in which attackers take control of the majority of the network's computing power, also known as "hash rate." In such a scenario, the malicious actor could theoretically influence the ordering of transactions, prevent the confirmation of new transactions, and double-spend the cryptoasset. Resistance to these attacks is essential for distributed blockchains to function properly. PoW and PoS are effective economic deterrents against Sybil attacks because they require users to expend energy or post collateral in order to participate in network validation. Each validator or miner must have "skin in the game" in order to participate in a distributed cryptographic system, which is the crux of the Sybil resistance mechanism.
Proof of Work
PoW was first coined in the early 1990s, but Satoshi Nakamoto (an anonymous individual or group) was the first to implement the technology for digital currencies. PoW is a significant innovation supporting Bitcoin. The informal term for PoW is "mining," which misrepresents the primary function of consensus. The true purpose of mining is to secure the blockchain while keeping system control decentralized and distributed among as many participants as possible.