Loading Now
×

What is Consensus Protocol in blockchain

What is Consensus Protocol in blockchain

**Blockchain Consensus Protocols Explained**

Today, we are going to discuss a product that is of utmost importance. So please pay attention. Let’s get started with the Consensus Protocol. Before diving into the Consensus Protocol, let’s review the topics covered so far. They have covered hashing algorithms, immutable ledger, mining, and distributed P2P network. These four are crucial pillars that strengthen our foundation for the Consensus Protocol. For those who haven’t watched these videos, I would strongly recommend watching them before this one to enhance your understanding and clarify your basics.

Essentially, the Consensus Protocol protects us in two ways: firstly, it prevents attacks, and secondly, it resolves the issue of competing chains. I will explain these two aspects in detail.

In this video, we will discuss the prevention of attacks, and we will cover the issue of competing chains in the next video. This is part 1. So let’s see how many types of Consensus Protocols exist. There are mainly two famous types of Consensus Protocols: one is Proof of Work, and the other is Proof of Stake. There are many other types, but Proof of Work is used in Bitcoin, and that’s why we will discuss how the Proof of Work Consensus Protocol operates in our blockchain today.

When we were talking about attacks, we discussed the immutable ledger. If you paid close attention to that video, you would remember that we mentioned that when someone attacks an intermediary node and makes changes, all subsequent nodes become entirely altered and corrupted. As soon as we introduce corruption, changes occur. This whole process is carried out through our distributed P2P network, making our immutable ledger concept effective.

Now, we will see how to deal with a situation where an attacker tries to alter only the final part without touching any intermediary nodes. We will see how the Consensus Protocol handles this.

First, let’s understand what Proof of Work is. Why is Proof of Work important, and where did the term come from? When a miner adds a block to our blockchain, it takes a lot of time for a miner to add a block. As we saw in the mining video, a computer has to solve a mathematical problem, and only when that problem is solved is a specific block added. Solving this mathematical problem takes a lot of time, energy, and a lot of electricity because the hardware required for this needs to be kept cool, resulting in high electricity bills.

This is why it can be said that the miners are rewarded for the work they put in. When they mine a block, they first receive a certain amount of Bitcoin and a specific transaction fee for verifying the transactions they added to our block. So, think of it this way: if a miner solves a problem, they get to add a block, and for that, they are rewarded.

If a miner creates some disturbance or engages in any malicious activity, the blocks they have added to the blockchain will be removed, and they will not receive any incentives for their actions. Therefore, miners are generally aware that they should not engage in any activities that could cause them to lose their incentives or suffer significant losses.

Firstly, it becomes the miners’ own responsibility. The second thing that the protocol does is when a miner adds a block to the blockchain and informs that they have mined a block, this information reaches all the nodes. However, the nodes do not directly add the block to their blockchain. What happens is that as soon as the nodes become aware that a block has been mined, an algorithm runs on all the nodes. This algorithm checks to verify the authenticity of the mined block and ensures that no malicious block is being added to the blockchain. This verification process is conducted by all nodes, which means that as soon as a block is added to the blockchain and this information is communicated to the nodes, they will first verify the authenticity of the block before adding it to their blockchain.

This algorithm is not a small one; it is quite extensive. I have covered some steps, but it can be even more extensive. It involves verifying transactions, ensuring that they are not double-spending, and checking the previous block’s correctness. Once this verification is complete, the block is added to their blockchain. This way, any malicious activity, such as an attacker or hacker, is prevented.

Firstly, if there is any disturbance, the miner will receive nothing. The second thing is that all nodes will verify the authenticity of the block on their end. Once they verify the block using the algorithm, they will add it to their blockchain. This is how the protocol works, preventing attacks. We will discuss how competitive chains work in the upcoming video, but before that, some people might wonder if running this algorithm on all nodes is time-consuming. Does it take a lot of time? The answer is no. When a miner solves a mathematical problem, it may take hours, days, or even longer to solve. However, verifying the solution using this algorithm is quick and takes only seconds.

Let me explain with an example. If you look at a Rubik’s cube, which I am showing on the screen, you will see that it has different colored parts, and our task is to arrange them so that all parts of the same color are aligned. If it’s red, it should be all red; if it’s blue, it should be all blue. Now, if you ask someone to solve a Rubik’s cube, it might take them hours, days, or even weeks to solve. But if you are asked whether the Rubik’s cube has been solved correctly, it is very easy to verify that, and it takes only seconds.

The text provides an explanation of how blockchain consensus protocols work, particularly focusing on how they handle the addition of new blocks and resolve conflicts when multiple nodes mine blocks simultaneously. Here’s a translated version:

“So, how long will it take you to check this? It will take some time, but you can check it in a few seconds. You will see and check it.

So, what is happening here? Simply put, this uses a consensus protocol where the correct task needs to be completed through computer calls. If it doesn’t, it can result in a loss from the minus, and incentives from the plus. Their electricity bills are also high, and there is a loss for the hard work they have done. And let’s say they said it’s okay, there’s no problem. But they verify according to the protocol. They check all the nodes connected to their network to see if what they are adding is correct, not just adding anything.

This is our consensus protocol where it prevents attacks. And welcome everyone to the detail channel. Today we are going to read the second part of the consensus protocol, let’s start. Earlier we read how we can prevent attacks through the consensus protocol and in this video, we will see how we can solve the competing chain problem with the consensus protocol. Let’s see with an example. This is our overall network where there are miners A, B, C, and F. And they all have the correct copy of the blockchain. Miners A and C, so they mine a block. And at one point, both A and C mine a block. Now, A has its own blockchain, and C has its own blockchain. Now what will happen? As seen in the distributed P2P network. A will transfer its information throughout the network, and similarly, C will transfer its information throughout the network.

A gives information to F and E, and C gives information to B. Why did this happen? Because F and E were closer to A, they received the information first, and B was closer to C, so they received the information from C first. F and E, upon receiving the information, verify if A’s block is correct, and B verifies if C’s block is correct and sees it as correct, adding it to its blockchain. Now you will see a conflict has started here. The conflict is that A, F, and E have one set of blockchain, and B and C have another set of blockchain. This is a conflict, why? Because now A has given its information to F and E, and B has given its information to A that its block has been added.”

**Explanation of Blockchain Consensus Protocol**

You have added a block to a public wire, and it has been added to your blockchain. Now the problem arises here. If there are different blockchains on two different networks, like here one set of blockchain and another set of blockchain over there, then the consensus protocol says that we will accept the blockchain with the longer chain. We will accept the blockchain that has the longest chain in the network and discard the other one.

**Explaining with an Example**

Let’s assume there is a network A, E, F and another network B, C. A longer blockchain has been created in the A, E, F network, and a shorter blockchain in the B, C network. Now B and C will not add any new blocks to their blockchain. They will wait to see which network mines the next block first. If B and C mine a block first, A, E, F will have to accept their blockchain and discard their current blockchain.

**Computational Power and Consensus**

Here we assume that the computational power of A, E, F, and B, C is equal. Even though the A, E, F network has three nodes and the B, C network has two nodes, their computational power is equal. This means the A, E, F network is more likely to mine the block.

**End of the Example**

When A, E, F mine a new block and send it to the B, C network, B, C will verify it and add it to their blockchain. Now, as A, E, F have a longer blockchain, B, C will have to discard their shorter blockchain and accept the A, E, F blockchain.

**Key Points**

– The consensus protocol says, we will accept the network with the longer chain.

– If there are two blockchains, the one with the longer chain will be considered valid.

– If a network has 51% computational power, its blockchain will be considered valid.

**Miscellaneous Points**

– It is advisable to wait until six confirmations to ensure the transaction is confirmed.

– Transactions from discarded blockchains will not be processed, and those blockchains will be discarded.

This is how the consensus protocol ensures the selection and validity of the correct block in the blockchain.

Post Comment