What is consensus and how is it achieved
18.11.2021 | asorokin
Along with the idea and technical implementation, the consensus algorithm in cryptocurrencies is crucial for each distributed block chain. It allows to maintain the integrity and security of the network. Satoshi Nakamoto proposed the first consensus algorithm to be developed for blockchain - a Proof of Work. Then the developers came up with all the new ways of confirmation, some of them found their popularity and deserve consideration, others proved to be not viable, or were not accepted by the community. In any case, understanding how proofs work in cryptocurrencies will be useful to any crypto enthusiast.
Consensus protocol and algorithm
Sometimes you can hear some talk about the consensus algorithm being a protocol. However, this comparison is fundamentally wrong. In simple terms, the protocol is a set of rules that govern the transfer of data of the blockchain, and the algorithm is the mechanism for executing these rules.
Blockchain technology is used not only in the free trade field, but also in other economy and government sectors. Regardless of the fields of application, the blockchain maintains agreement between all participants using a consensus protocol that allows nodes to determine when to add new information to the blockchain.
At the same time, the algorithm determines the measures necessary to keep the blockchain operational and comply with the rules defined in the protocol, which ultimately allows to obtain the desired result.
If to make a parallel with the two largest coins in terms of capitalization, then Bitcoin and Ethereum can be considered protocols, but the way transactions are confirmed on the network, Proof of Work or Proof of Stake for the second version of Eth, will be the consensus algorithm. So the bitcoin protocol defines:
consensus among nodes,
data transfer between network participants,
At the same time, the algorithm is responsible for confirming transactions and including them in blocks, checking the latter and the balance of wallets and the validity of signatures. Due to the decentralized nature of the bitcoin blockchain, the algorithm works on the principles of consensus, which increases the reliability and security of the entire network.
In simple terms, consensus refers to agreement on some decision by a majority of a group. People are more likely to implement decisions they accept, and consensus makes acceptance more likely. Concurrently, the opinion of the rest in the group is completely ignored. From a utopian point of view, we can say that consensus allows us to create a just society with equal rights even in a group scattered around the world.
If we talk about the goals of consensus, then we can distinguish the following categories:
agreement in which all parties agree with the decision to the greatest extent possible;
attempt to satisfy the interests of all parties involved in the discussion;
making encourage participants to place the good of the whole group above their own individual preferences;
ensuring equality of all voices;
involving as many participants as possible in the decision-making process.
If we talk about the consensus in the context of cryptocurrencies and free trade, then before Satoshi Nakamoto and his Bitcoin, there were attempts to create a financial system that would take into account the interests of the majority. However, all decentralized peer-to-peer payment systems failed to solve the main task of reaching consensus — Byzantine generals problem.
###Byzantine generals problem or Byzantine fault
Mathematicians believe that formulas and algorithmic solutions can deal with any phenomenon and process in everyday life. So the problem called Byzantine generals problem, in which the consensus will not work in the interests of the entire group, was described, modeled and subsequently solved.Speaking about this issue, we can give one of the classic descriptions:
Several divisions of the Byzantine army are camped in the mountains. Their target is the inhabitants of the valley. After observing the enemy, they must decide upon a common plan of action. In this case, there can be three outcomes:
- everyone decided to attack, in this case the enemy army will be defeated, and the decision will be correct;
- everyone decides to retreat, the war will not be won, but each of the generals will keep his army, such a decision is considered neutral;
- and lastly, while some generals want to attack, others may want to retreat. In this case the enemy will be able to overcome them separately, which will ultimately lead to defeat, which is clearly a negative result.
To achieve an optimal outcome, generals need to express their opinion, and most importantly, communicate it to others correctly. It is in the latter that the main task lies. It is assumed that Byzantium is in decline, and any of the generals can be a traitor, therefore it is impossible to say that the whole group will work in its interests and transmit true information. Therefore, the generals need confirmation of the coordination of actions. As Leslie Lamport proved in 1982, this problem is solvable if and only if more than two-thirds of the generals are loyal, then it will be possible to say that a consensus between the Byzantine generals, in its classical sense, will be achieved.
In the context of cryptocurrencies, consensus allows to add only correct blocks which won’t disrupt the network’s performance, for example, preventing double-spending, or writing off non-existent assets. Only, unlike the Byzantine generals, a cryptocurrency group doesn’t need to reach an agreed ‘truth’ of so many participants, a simple majority is enough. Although the latter makes it easier to carry out the attack, known as 51%, digital assets are already at a stage of development when carrying out these measures for attackers will be so expensive that it becomes nearly impossible.
Why is consensus so important in cryptocurrencies
As stated at the beginning, the consensus algorithm in cryptocurrency is fundamental. It maintains the integrity and security of the distributed computing system. One of the best solutions remains Proof of Work, as it is resistant to all kinds of attacks, including 51% attacks. Organizing the latter, at least in the bitcoin network, becomes more difficult every day. Many miners are working to achieve consensus in the blockchain of the first cryptocurrency, using a huge amount of equipment and the amount of electricity consumed. Therefore, an effective attack will require colossal costs from the attacker, which may become incomparable with the effect obtained. All this allows the digital economic model of free trade to work properly, and the consensus algorithm allows users to agree which of the current versions of the distributed registry is the true one.