Blockchain Technology, Part - 05
???????????? ?????????? ?? ??
Experienced Full Stack Engineer | Next.JS, MERN
Blockchain Architecture
Transaction Flow - Traditional systems
In order to understand the working of a blockchain network, first consider a?traditional?banking transaction model. Here Alice wants to send some money to Bob. Let's see what are the steps involved in a traditional banking system for this transaction to be finalized.
Now let's consider the transaction steps in a blockchain:
Need for a Consensus
The previous unit explained how a transaction takes place in a blockchain network. Also, the unit?mentions about?'consensus algorithm' that is used?to find the winning block.?Let's see what goes around it.
In simple words, the consensus is a process by which an agreement is reached between different nodes in a network on the final state of data. When different nodes are participating in a distributed network, achieving an agreement?becomes a challenge. In the case of a blockchain network, the agreement is about which block to be added to the blockchain network.?In a decentralized, distributed network no single person or entity is responsible for providing the single value of truth. Rather here, every member is equally responsible for providing the truth value, and the consensus algorithms help to reach an agreement among the various participants.??
Common types of consensus mechanisms in distributed networks are :
Let's start with the theoretical background for consensus mechanisms. Before we take a read?into consensus mechanisms in blockchain networks, consider a problem.
Two Generals Problem
The Two Generals Problem is a classic computer science thought experiment. The Two Generals Problem is however related to the Byzantine Generals problem but is not the same.?
Let us imagine two Generals, General 1 and General 2 commanding two parts of the same army positioned on opposite sides of an enemy city. The city can defend against a single General’s army attacking. If both the Generals attack at the same time, the city would collapse. Therefore, Generals have to communicate with each other to synchronize their attacking time. The only way to communicate is through a messenger who will have to travel through the enemy territory.?
In the first scenario, let us assume that General 1 who is the leader sending a message “ Attack on Monday Morning” through a messenger to General 2. General 2 receives the message and sends an acknowledgment “I confirm Attack Monday Morning”. Thus General 1 receives General 2’s confirmation, however,?is this enough to achieve synchronization? General 2 still doesn’t know whether General 1 has received his confirmation message. One solution to this is for General 1 to send a message to General 2 stating that the confirmation was received. Then again General 1 doesn’t know whether General 2 has received the confirmation message from General 1 of receiving the confirmation message from General B.?Ultimately this scenario will lead to a loop with an infinite number of confirmation messages being exchanged.
In the second scenario, let us assume that General 1 sends a message “Attack on Monday Morning” to General 2. In this case, General 1 doesn’t get a reply message from General 2. There are two possibilities for this scenario. Either the messenger sent by General 1 was captured by the enemy or the confirmation messenger sent by General 2 was captured by the enemy. However, in both cases, synchronization is not achieved. Thus there is no solution to the Two Generals Problem and to this date, it remains unsolvable.
What if there are more than two nodes?
领英推荐
Byzantine Generals Problem
Now let's consider a slightly different problem.
Byzantine Generals Problem(BGP)
Byzantine Generals Problem is applicable?in distributed networks.
In the above diagram, a network with?a commander and two lieutenants are shown. In this case, the commander is a malicious node who gives different commands to different lieutenants. Thus failing the network in reaching an agreement.
In the second case, Commander is genuine but Lieutenant 2?acts as a malicious node and sends across different messages to its peers. Again failing the network in reaching an agreement. In both cases, Lieutenant 1 is not able to point out the malicious actor and is receiving contradictory messages from his peers. Thus the network fails to reach an agreement on whether to attack or retreat.
This concept was a thought experiment proposed by Lamport and others in 1982. It describes a group of army generals who lead different parts of the Byzantine army, planning to attack or retreat from a city. The generals need to agree to strike at the same time in order to win. They communicate among them using a messenger. Here the issue is that one or more generals can be traitors who could send misleading messages. Therefore there is a need for a feasible mechanism that allows for agreement among the generals, even in the presence of?disloyal ones, so that the attack can still take place at the same time. As an analogy to distributed systems, the generals can be considered nodes, the traitors as byzantine malicious nodes, and the messenger as a channel of communication among the generals.
Byzantine Fault Tolerance
In a distributed network like blockchain, the chances of having malicious nodes are high. The scenarios described in previous?units need to be considered in such a network.?Byzantine Fault Tolerance (BFT) is the ability of a distributed system to reach consensus in a network, even when?some network nodes fail to respond or respond with incorrect information. In other words, Byzantine Fault Tolerance is the property of a system?to tolerate the class of failures?that belong to?the Byzantine Generals Problem.?Thus blockchains should find a mechanism to be Byzantine Fault Tolerant. This is where the relevance of consensus algorithms come in.
CAP Theorem
CAP stands for Consistency, Availability, and Partition Tolerance. CAP theorem, also known as Brewer’s Theorem is a concept that a distributed database system can have only two of the three: Consistency, Availability, and Partition Tolerance.?Eric Brewer introduced it?in 1998 as a conjecture.
In blockchains, consistency is sacrificed in favor of availability and partition tolerance. In this scenario, consistency is achieved over time. Consistency is achieved as a result of validation from multiple nodes over time. Different consensus mechanisms are used for achieving this purpose.
Blockchain Features
Let's recap. By now you should be able to explain the importance of the following features in Blockchain.