Sriram R

Posted on

# Byzantine Generals Problem

Up until now, we thought that none of the nodes could be malicious and try to do something other than what they were supposed to do. Unfortunately, because there is inherent evil in the real world, any node has the potential to turn evil and attempt to upset the peace among other nodes.

In this example, we will look at what could go wrong if a node turned out to be bad.

You might be asking. What do you mean when you say someone is malicious? How does this affect building systems? Here's a good example:

## Problem Statement

Similar to the Two Generals Problem we saw in the previous article, let's imagine a theoretical situation where multiple generals want to attack a fort.

In the Two Generals Problem, we saw that the messages between two generals could be intercepted. Let's assume, for the sake of simplicity, that in this situation, all messages are sent to the other generals and none are lost.

But it's possible that one of the generals is a traitor who really works for the fort and is trying to stop the plan of the other generals to attack. Unluckily for the honest generals, there's no way to know which one or possibly more than one general is a traitor.

Let's say a successful attack is when all honest generals attack, and a successful retreat is when all honest generals retreat. Even if one honest general attacks when others retreat or retreats when others attack, our solution is flawed.

Given these restrictions, the honest generals will have to agree on whether to attack or retreat.

## Scenario

Let's think about these two situations.

1. General 1 tells both General 2 and General 3 to attack, but General 2 tells General 3 that General 1 told him to retreat.  In this situation, General 2 is the traitor.

1. "General 1" told "General 3" to attack, but "General 2" was instructed to retreat. Since General 2 has to tell General 3, General 3 again gets two instructions from General 1 that differ from one another. In this situation, General 1 is the traitor.

Since we are the central entity monitoring all communications, it is clear to us who the traitor is. But when there isn't a central entity keeping an eye on all messages, it's impossible for General 3 to tell who the traitor is and, by extension, what the valid message is.

This is called "Byzantine Behaviour," and we saw a little bit of it in System Models

## Real Life Scenario

The most well-known Byzantine System is Blockchain. Because it is distributed and decentralised by design, it is bound to have nodes that behave in a Byzantine way.

User A claims to have given User B \$200 while User B claims to have received \$100 from User A. Which one of these is the Byzantine Node?

Byzantine systems are also used when you add a third party to your system, like a payment gateway.
Byzantine systems are also used when you add a third party to your system, like a payment gateway.
Let's say you're building an online wallet solution and the user says he added Rs 200 to the wallet but the payment gateway says he only added Rs 100.
Who is the Byzantine one here?

To handle these behaviours, Quorum is used, where the truth is what the majority of nodes agree to. Blockchain uses Proof of Work to deal with these kinds of mistakes.