BC1Back
blog

studBit

13 min read

Network consensus

Key Takeaways

  • Blockchain solves the Byzantine Generals Problem using consensus to reach agreement without central control.
  • Proof of Work and Proof of Stake are two major consensus methods that secure blockchains and prevent attacks.
  • PoW protects against Sybil attacks by requiring high computational effort; PoS uses staked coins and random selection.
  • Delegated Proof of Stake adds a voting system, making block validation faster and more scalable.

The Byzantine Generals Problem

The real challenge standing in the way of a system like the blockchain is something called the Byzantine Generals Problem. Conceived in the 1980s, it describes a dilemma in which isolated participants must communicate to coordinate their actions.

The specific dilemma involves a handful of army generals that surround a city, deciding whether to attack it. The generals can only communicate via messenger.

Each must decide whether to attack or retreat. It doesn't matter whether they attack or retreat, as long as all generals agree on a common decision. If they decide to attack, they will only be successful if they move in at the same time. So how do we ensure that they can pull this off?

Sure, they could communicate via messenger. But what if the messenger is intercepted with a message that says we're attacking at dawn, and that message is replaced with "we're attacking tonight"?

What if one of the generals is malicious and intentionally misleads the others to ensure they're defeated ?. We need a strategy wherein consensus can be reached, even if participants turn malicious or messages get intercepted.

What is the primary challenge of the Byzantine Generals Problem?

The issue of not being able to maintain a database isn't a life-and-death situation like attacking a city without reinforcements, but the same principle holds. If there's no one to oversee the blockchain and to give users "correct" information, then the users must be able to communicate amongst themselves.

To overcome the potential failure of one (or several) users, the mechanisms of the blockchain must be carefully engineered to be resistant to such setbacks. A system that can achieve this is referred to as Byzantine fault-tolerant.

What is a Byzantine fault-tolerant system?

The blockchain is a distributed system. This means there is no centralized organization to maintain and verify the entries on the database. It's instead maintained by a large number of computers. But this computers nodes in the network cannot be trusted individually.

Thus it is required that the system provide a mechanism for creating consensus between scattered or distributed parties that do not need to trust each other but just need to trust the mechanism by which their consensus has arrived.

Any computer connected to the blockchain network and using a client can perform the task of validating and relaying transactions

Why is consensus important in a distributed system like the blockchain?

Proof of Work (PoW)

Mining nodes validate transactions, add them to block they are building and then broadcast the state of the completed block to other nodes of the network, in order to randomize the processing of blocks across the nodes and to avoid a certain service abuses.

Blockchain uses various time stamping schemas such as proof of work. Proof of Work describes a system that requires a certain amount of resources or effort to complete an activity, typically this resources is computing time.

What is Proof of Work?

Miners compete to add the next block in the chain by racing to solve a very difficult cryptographic puzzle, the first wins the lottery as a reward for his or her efforts.

A consensus algorithm like BTC proof of work functions to ensure that the next block in the blockchain is the one and only version of the truth.

Network Security

Consensus protocols are primarily economic systems that help prevent certain kinds of attacks.

51% Attack

The network is kept secure by the fact that to gain 51% control over the network, you would need 51% of the network's computational power. However, since Proof of Work incentivizes miners with mining rewards, a lot of different groups of miners are interested in running mining nodes. Therefore, getting 51% of all computational power on a network requires huge investments in equipment and electrical energy. Which means you're likely to end up spending more than you would earn.

To alter the data on the blockchain you would need to alter all the blocks on the chain, redo the proof of work of each block and take control of more than peer-to-peer network. Only then would your alter block become accepted.

What is a 51% attack in the blockchain?

Why is it difficult to execute a 51% attack?

Sybil Resistance

Technically speaking, proof of work is not a consensus protocol by itself - though it is often referred to as such for simplicity. They are actually Sybil resistance mechanisms and block producer selectors - a way to decide who is going to be the producer of the latest block.

A Sybil attack is the problem when one user or group pretends to be many different users. Security against this type of attack is essential for a decentralized blockchain to allow miners to be rewarded based on the resources they put in, not just random selection.

What is a Sybil attack in the blockchain?

Hypothetically, if we were to choose the producer of a block just by random selection instead of Proof of Work, one could execute a Sybil attack quite easily.

Proof of Work protects against Sybil attacks by making miners put up a large amount of computational power as collateral. At the end of the day what this technology enables is a database that is secured with automatic trusts that is enabled by open source code and encryption, the data is tamper proof.

It's a shared database, its transparent meaning that everyone can see all the transactions & alterations made to the database if needed. The data quality and the resistant of the network is maintained by massive database replications.

How does Proof of Work protect against Sybil attacks?

Proof of Stake (PoS)

Proof of stake is similar to proof of work, both are used to attain consensus and keep the underlying blockchain secure.

The Proof of stake selects a node to be the validator of the next block using a pseudo-random election process based on the combination of parameters such as staking age, randomization and nodes wealth. In proof of stake there is no race against the nodes to validate a transaction. They take part in a lucky draw where the winner is decided by the blockchain, the winner then validates the transaction.

What is Proof of Stake (PoS) in blockchain technology?

As the name implies node on the network stake a certain amount of cryptocurrency in order to become candidates for validating new blocks and earning the fee associated with them. The node that will validate the new block is then chosen by an algorithm from a pool of candidates. To make the selection fair to everyone on the network, the algorithm mixes the amount of stakes with other considerations.

It's worth noting that blocks in proof of stake system are forged rather than mined.

The 2 most popular techniques that proof of stake system use to choose their validators Randomized block selection and Coin age system

The randomized block selection chooses its validators by looking for nodes with the lowest hash value and the highest stake. Because block sizes are public, the next forger can typically be predicted by other nodes.

The coin age selection techniques selects nodes depending on the length of time that their tokens have been staked. The age of a coin is determined by multiplying the number of days the coins have been staked by the number of coins stake. After a forging block, a node currency age is rest to zero and must wait a specific amount of time before forging another block.

This prevents large stake nodes from controlling the consensus mechanism. Each ecosystem that uses the proof of stake algorithm has its own set of rules and procedures to create the best possible combination for respective ecosystem.

Pure PoS blockchains are less common than DPoS (Delegated Proof of Stake) ones, which require that users vote on nodes (witnesses) to validate blocks for the whole network.

The delegates may also be referred to as witnesses and they are responsible for achieving consensus during the generation and validation of new blocks. The voting power is proportional to the number of coins each user holds. The voting system varies from project to project, but in general, each delegate presents an individual proposal when asking for votes.

The DPoS algorithm creates a voting system that is directly dependent on the delegates' reputation. If an elected node misbehaves or does not work efficiently, it will be quickly expelled and replaced by another one.

DPoS blockchains are more scalable, being able to process more transactions per second (TPS), when compared to PoW and PoS.

What are the two most popular techniques used by Proof of Stake systems to choose their validators?

While PoS and DPoS are similar in the sense of stakeholding, DPoS presents a novel democratic voting system, by which block producers are elected. Since a DPoS system is maintained by the voters, the delegates are motivated to be honest and efficient or they get voted out. In addition, DPoS blockchains tend to be faster in terms of transactions per second than the PoS ones.

Ethereum, the leading smart contracts blockchain, has transitioned to Proof of Stake in its migration to ETH 2.0.

Security

The stake acts as a financial incentive for the node to avoid validating or initiating fraudulent transactions. If a fraudulent transaction is detected by the networks the forger node will lose a portion of its stake as well as its right to participate as a forger in the future.

While PoW and PoS are the most common consensus in the blockchain space, there are other consensus algorithms like Proof of History developed by the Solana project, proof of Capacity which allow sharing of memory space of the contributing node on the blockchain network.

*You must link aptos wallets to submit quiz

Link Wallet