Consensus Algorithms — Part 1
This post is the first in a series that will address the main consensus algorithms. I will start with the Proof-of-Work that is used by Bitcoin, I will explain its operation and safety issues that must be observed.
Byzantine Generals Problem
Distributed systems need mechanisms that prevent failures (intentional or not) that could corrupt the system.
In 1982 this problem was presented formally in the article The Byzantine Generals Problem coining thus the term to designate it.
The problem is presented through the following metaphor:
We imagine that several divisions of the Byzantine army are camped outside an enemy city, each division commanded by its own general. The generals can communicate with one another only by messenger. After observing the enemy, they must decide upon a common plan of action. However, some of the generals may be traitors, trying to prevent the loyal generals from reaching agreement. The generals must have an algorithm to guarantee that (A) All loyal generals decide upon the same plan of action and (B) A small number of traitors cannot cause the loyal generals to adopt a bad plan.

In the context of crypto-coins, the goal is to allow the blockchain to be updated in a secure and consensual way by the nodes involved. Objectively, among other things, the consensus algorithms seek to make it impossible to make double spend and allow all nodes to agree on the state of the blockchain.
Proof-of-Work (PoW)
Used by Bitcoin, Ethereum, Litecoin and other currencies, it was initially designed to discourage denial of service (DoS) attacks and spam on distributed systems, requiring proof of computational work by the service requester.
By itself, the PoW does not solve the problem of double expenses in a crypto-currency. Although there is no citation of the term ‘blockchain’ in the paper by Satoshi Nakamoto, it is in this way that today it was agreed to designate the solution given by him to reach consensus in the network and solve the problem of double spending.
Let’s look at the example: Alice has only 1 BTC in her wallet and simultaneously spreads 2 transactions on the network, the first sending 1 BTC to Bob and the second sending 1 BTC to Carl. This is possible to do but it is not a double expense, since none of them has been included in any block.
Only confirmed transactions (included in any block) should be considered effective.
In our example, when creating a block, the mining node will disregard one of the two transactions because in the current state in the ledger there is not enough balance to perform both.
Grouping block transactions solves part of the problem. Let’s look at the following situation:
In a short space of time, two distinct miners propagate their blocks, with miner X including the transaction that benefits Bob and miner Y to that benefiting Carl. Part of the nodes of the network accept one block and another part of the network accepts the other block, in this case a dissent is created in the system and two versions of the blockchain are temporarily valid and concurrent.
To reach consensus again and avoid the definitive fork of the network is that PoW is used. In cases of temporary forks the chain with the highest computational power (hashrate) is the one that will be accepted by the network as the main blockchain.

Security
Whenever a new block is mined (after computational work required) and propagated in the network, it is validated by each node and only if it is valid according to the protocol rules will it be accepted.
Miners are encouraged economically to remain honest because they are paid when they can generate a new block to be included in the chain, and if they act dishonestly, beyond failing to earn the reward, they will have wasted the computational effort spent to carry out the proof of work.
The proper functioning of the system using the PoW is based on a scenario in which most of the miners are honest.
51% Attack: If an attacker controls most of the network’s computational power, it will be able to do forks (as in the example above) deliberated choosing one of the chains to engage their superior computing power.
Therefore, you can invalidate previously committed blocks by generating another chain. In practice it would allow the attacker:
- Make double spends from some address controlled by him;
- Censor addresses (not including their transactions in new blocks);
- Increase your earnings with mining rewards by generating larger chains and forcing the negation of blocks spread by honest miners (selfish mining attack).
Even successful an attack of this nature would not allow the attacker:
- Discard old blocks (6 deep blocks) mined before the start of the attack;
- Make transactions from third-party addresses. The attacker does not have the third-party private key.
Concentration
Currently, almost 70% of Bitcoin’s mining power is concentrated in the five largest mining pools. If their controllers decide to act in a coordinated way, they can perform a real attack on the network.
Although possible, this scenario would be economically disastrous for those involved because it would represent financial losses and fall in the value of the currency due to lack of market confidence.
Another scenario would be the case of a conspiracy against the system carried out by Banks and / or Governments that would have sufficient resources to accumulate sufficient computational power. It is a scenario theoretically possible but increasingly impractical as the computational power applied to Bitcoin grows rapidly.
Conclusion
Introduced by Bitcoin as the first consensus algorithm, it allowed the advent of blockchain technology. Their security is a result of network computing power.
Although Bitcoin’s current concentration of miners seems worrisome, a possible attack would amount to damage of image and value in the short term but actions would be taken to defend the technology making it safer.
Even with these problems Proof-of-Work is today the most reliable algorithm since it has been tested in practice since 2009 and is responsible for billions of dollars worth of security.
New algorithms have emerged with the purpose of solving PoW problems, some of them will be addressed in the next posts.