Blockchain Consensus Mechanisms

Lina Network

|
July 24, 2020

Before going into each specific application of Blockchain in life, we will learn about the outstanding features of Blockchain compared to the current internet platform as well as in the banking payment system.

Why say Blockchain is the most secure storage platform?

Long time ago, the King ruled, made the final decision for all relevant matters in the country. At the same time, the King was also the one who granted those who had the power under him such as the Prime Minister, the generals, the provincial officials, the district officials … So if we want to overthrow a dynasty, who should be overthrown? Are all the bureaucrats, all the citizens, all the generals or just kill the King?

The traditional internet network will operate in the same way as feudalism, the server will represent the King, where the brain of the entire network, storing information, assigning powers to other computers. If hackers want to get information or steal money from 1 million people, they will just need to hit the master server with the highest authority to get the information of 1 million people, in other words, hit the King of the network without accessing each computer one by one.

Blockchian consensus

Seeing this vulnerability, Blockchain was born as a method to make user information safer. In the Blockchain network, there will not be only one King, but there will be thousands of Kings with equal powers. That is, every problem that happens in the network will have to be met and voted on by all the Kings, ie 51% of the votes agree, the new order will be executed, and no King can make a decision alone, we call that consensus.

Consensus mechanism in Blockchain

The consensus mechanism is a mechanism that helps traders make agreements without any issues of interest or desire for the influence of minorities. Also, ensure that a particular group cannot use its authority to impose or control an entire group of users on the same network.

Consensus Mechanisms in Blockchain

The consensus mechanism is responsible for maintaining the integrity and security of the distributed system. When a transaction takes place, the system on Blockchain sends information to the individual nodes. Transactions only take place when there is more consensus from the same nodes in that network.

Currently, the blockchain platform has two main consensus mechanisms: consensus by Proof of Work and Proof of Stake.

Proof of Work

What is Proof of Work?

Bitcoin mining is the proof of work

Proof-of-Work or PoW, proposed by Satoshi. He solved the problem of cryptologists that existed decades ago. The way to solve consensus is not by means of cryptography, but by combining it with hardware power. In Bitcoin and Ethereum systems, PoW is used to determine which node “win” the right to add a new block to the current blockchain (transaction verification).

PoW is the recognition of the effort spent to complete a job. Any node that finishes the task first will take the right to add a new block to the blockchain. The job here is to find a nonce value that satisfies certain conditions. For example:

hash(nonce) < 000000000000000000285a375f9d33e17…

Here, hash is a cryptographic function, nonce is a random value found so that the hash (nonce) is less than a certain threshold. The value 000000000000000000285a375f9d33e17 … is an example for a certain threshold. The process of finding nonce values is a boring process of trial and error. Nodes usually start with nonce = 0, 1, …, until the hash value of the nonce meets the threshold condition. The example begins with 18 zeros.

Because the process of trial and error is boring, the computational power of the nodes is very important. The faster the processor speed, the faster the error rate will be, and the higher the chance of finding nonce. When a new block is found, it will be announced over the network to the other nodes examined. If all the transactions in that block are correct, the nodes will update to the blockchain that is stored locally at that node.

The problem of conflict is because of geographical distance, nodes will store two different versions of blockchain at the same time. For example, the picture above, countries in the Americas have a blockchain chain is … P → A, while Asian countries have a blockchain chain is … P → B. Mining at this time is still normal.

Then, a new X block found from a node in Asia that is hosting the current chain is … P → B, and the blockchain banana will be updated to be … P → B → X. When this new blockchain was notified to nodes in the Americas, there was a conflict. Series … P → A and series … P → B → X. According to PoW’s law, whichever is longer will be the main chain. Therefore, the nodes in the Americas to update the new blockchain chain are … P → B → X. Then the unity of the blockchain chain on the system is guaranteed.

Is PoW fairly for everyone?

Some people say that it is unfair to assume that a node has very high computing power and a node has very low computing power. For example, A has 100 S9 computers and B has only one S9 computer. So always A will find nonce before B is true or false? This is not true. Because the problem of finding nonce in each node is different, the value of nonce found is also different. See the following example.

A and B each are assigned a different bubble filled tank; In each tank, there is a bubble containing the key inside; The one who finds the key in his tank first is the winner. Although A has a speed of finding the ball 100 times faster than B, but the ability to pick up the ball containing the key is random, so it is possible that B will be able to catch the ball with the key soon, and find the key first. A.

The PoW’s problems

PoW solves the consensus issue well. However, PoW encounters two other problems:

  • Power consumption and hardware race
  • 51% potential attack risk

What is 51% attack?

As we know, PoW is a race to gain the right to add a new block to the blockchain, and the transactions recorded in that block are considered to be confirmed. When a node with computational power occupies the majority of the system (> 50%), it is possible to control the creation of new blocks.

51 attack in blockchain

There are two dangerous threats to the system as follows:

  • Denial of service attack
  • Double spending attack

Is it easy to attack 51%?

51% attack is possible. Currently, mining is mainly done in a centralized form. That is, individuals will join a pool to increase their computing power and competitiveness.

Image for post

As the picture above, only need 3 large pools are BTC.com, AntPool, and SlushPool all together, it can create 51% attack. However, this is a decentralized system with the participation of the whole community, the attack can lead to unfortunate consequences. For example, the community might vote to remove miners from these pools. This is a punishment for hacking the system.

PoW is the first consensus algorithm, so of course there are limitations. Systems with many nodes such as Bitcoin and Ethereum, in addition to the environmental impact of high power consumption, PoW responds well to the current system.

Proof of Stake

The Proof of Stake consensus is an alternative method of deciding who will be entitled to add a new block and confirm the current state of the blockchain. Instead of having miners compete for solutions, with Proof of Shares, the creator of the next block will be decided based on a number of processes based on the number of coins held in the wallet ( their stake. This process relies on the people who hold the most shares to make the right decisions for the entire network.

Consensus Proof of Steak eliminates the enormous energy costs in mining, however, the absence of energy consumption sometimes causes another problem – also known as “nothing at stake. equals 0) ”. In case a chain is “forked”, PoS forgers (the term “forging” is used to replace the term “mining”) will have the opportunity to receive many benefits and rewards when mining. Waterfall on both chains at a negligible cost. This is a problem for the entire network because the main purpose of consensus is to only exist a unique chain and that uniqueness is also the goal of the consensus mechanism.

Not only that, Proof of Stock has another issue related to the distribution of tokens. PoS forgers, with extremely low operating costs, are not under the pressure of having to sell the coins they receive while maintaining the network. Holders of large stakes in joining the Proof of Stock network tend to increase their number of shares in the total volume of circulation because they earn block rewards and transaction fees from user in the network.

The above are the basic technical characteristics of the blockchain which studied and synthesized from the Lina Network technical team. Let’s explore the application of this technology in the following article

Source: Kryptolight, Binance Academy