Game theory in consensus
Tags: consensus, gametheory, distributedsystems
Published: 2022-12-21 00:49:04

With the exponential growth of distributed systems (such as blockchains), **consensus is definitely the problem of the century**.

We can define the consensus problem as follows. Given a network in which each agent has its own preference over a set of possible decisions, _the goal is to have a distributed protocol_ (e.g. set of rules agents must follow) _that leads the network to a unique decision, without a central authority_.

For example, imagine that the network should take a decision about a color. Each agent has a favorite color and wants it to be the color everyone will choose after the protocol (e.g. winning decision). That's it. 

Formally, a protocol _solves_ consensus if it satisfies three conditions:

1. **Termination**: every agent reaches a final state in a finite time
2. **Agreement**: all agents will support the same decision
3. **Validity**: the winning decision must be initially supported by at least one agent

These three conditions allow the network to stabilize to a common decision. But, this doesn't guarantee that each agent's preference has the same weight.

So, we introduce the concept of **fair consensus**, where the validity condition is replaced by _fairness_, e.g. the probability that a decision will be the winner is proportional to the number of agents that initially support it.
In this way, **each agent has the same importance as the others**.

Now, these conditions are sufficient if every agent is honest and doesn't try to improve their chances to win.
But in reality, this would never happen.

For this reason, we now argue about **rational fair consensus**, an extension of fair consensus in which there could be _rational agents_. A rational agent is a kind of agent that could decide to not follow protocol rules in order to gain an advantage over others in every possible way. 

For example, imagine that every agent supporting the winning decision will get 100$. A rational agent could say it was supporting the winning decision also if it wasn't, only to get the reward. This is an educational example, but it isn't so different in reality as you might think. An example of "malicious" rational agents could be [Byzantine agents](https://en.wikipedia.org/wiki/Byzantine_fault).

Here comes game theory. **Game theory studies how players** (e.g. agents) **would play a game** (e.g. protocol) in order to have the best reward. The concept of "_utility function_" explains this. A utility function of an agent is a mapping of the reward (called _payoff_ in game theory) with the final state of the game (e.g. winning decision).

In the last decades, mathematicians have been studying **solutions of non-cooperative games** using notions such as [Nash Equilibrium](https://en.wikipedia.org/wiki/Nash_equilibrium) to understand how players would act. A really famous problem is the [Prisoner's dilemma](https://en.wikipedia.org/wiki/Prisoner's_dilemma). I suggest reading it to understand why game theory is so important.


This is the point of intersection. We don't have only to realize a consensus protocol, but we need to find a mathematical way to ensure rational agents will follow protocol rules. 

**If we can find it, distributed systems will be more reliable and secure for end users.**