Avalanche introduces a new family of consensus protocols that are claimed to combine the best features of classic protocols and Nakamoto consensus. Described as ‘metastable’, the Avalanche protocol is actually four protocols that build upon each other. These are Slush, Snowflake, Snowball, and finally Avalanche itself
The consensus problem
Consensus is the most important goal that needs to be achieved when many computers in a distributed network work together on the same task. A typical example is a banking system that maintains account balances using multiple servers. Banks don’t rely on one single database to carry their data, but many geographically distributed machines across the globe to handle these transactions. Such system must make sure that its computers are all on the same page, so there are no undesired or unexpected situations where the same money, for example, can be spent twice.
This has been an important problem in Computer Science for a long time. In distributed systems, there exist only two viable solutions to this problem: classic protocols and Nakamoto consensus.
Classic consensus protocols
Classic consensus protocols were developed by two great computer scientists, Leslie Lamport and Barbara Liskov. They are both Turing Award winners which is equivalent to the Nobel Prize in Computer Science. The best features of these protocols include,
- quick finality, and
- quick guarantees about the committed transactions.
But this comes with two big trade offs,
- such consensus model does not scale well beyond 1000 nodes, and
- it requires everyone in the network to know all other participants.
In other words, it is a good choice if you are building a permissioned system but it is not a reliable foundation when you are in a dynamic environment of untrusted nodes.
The second family of consensus protocols appeared in 2009. Satoshi Nakamoto introduced Bitcoin which paved a way for a whole bunch of other similar protocols. The advantages of Nakamoto consensus are,
- we don’t need all the nodes to participate in the consensus all the time, and
- such system can scale to a large number of global nodes.
But, of course, everything comes with a price and Nakamoto consensus is no exception. The biggest drawbacks of Bitcoin are,
- users have to wait for 10 to 60 minutes before their transactions are confirmed,
- throughput is limited to 3-7 transactions per second which is insufficient for a global currency system;
- Bitcoin consumes an enormous amount energy that is enough to power two countries like Denmark.
Avalanche was first proposed in a whitepaper released on May 16, 2018 in an IPFS link by a pseudonymous group of developers by the name of Team Rocket. Cornell professor Emin Gün Sirer assisted Team Rocket with some analysis, and context portions of the whitepaper, along with publicizing the protocol.
According to the whitepaper, Avalanche combines the best of both classical consensus protocols and Nakamoto consensus, in particular,
- quick finality and low latency: it takes about 2 seconds for your payment to be processed and verified;
- higher throughput: from 1000 to 10,000 transactions per second;
- robust: the network maintains undeniable consensus without knowing its participants;
- green: there are no miners and all participants are of the same class.
The whitepaper describes the protocol as metastable. Metastability is the core idea of Avalanche and implies an eventual absolute consensus of the system. This means that, given two choices, the network will always make a decision, i.e. all the nodes will eventually agree on the same thing.
The Avalanche family
Avalanche is a protocol that is comprised of four different protocols building upon each other: Slush, Snowflake, Snowball and Avalanche itself.
Slush is the basic protocol that combines the gossip protocol and the random subsampling procedure.
Let’s consider an example. A network that uses the Slush protocol needs to choose a color: blue or red.
- An individual node randomly picks a small subset of nodes and asks them to choose a color.
- The requesting node receives answers and bases its vote on the majority of received votes.
- This process repeats itself for everybody else.
If you read the above attentively, you may have a question, ‘How does a node know they picked the right color?’ And the answer is that’s what the other protocols in the family are for.
- There is no history, each node only knows their current color,
- Slush is not Byzantine Fault Tolerant,
- There is no guarantee the nodes will eventually come to an agreement, as they can continue flipping colors and maintain a 50/50 situation.
Snowflake is what gives Avalanche its Byzantine Fault Tolerance. Snowflake provides each node with a counter to store the number of consecutive samples of the network that have given the result of all red or all blue.
After a certain number of consecutive samples it accepts the colour for good. This allows correct nodes to commit and means that the nodes will come to consensus. If the streak is broken, then the counter returns to zero and starts again.
Snowball builds upon Snowflake by adding in a state of confidence. It does this in order to make the protocol harder to attack, because it is now able to store information and make decisions based off that information that it was not able to before.
Snowball progresses Snowflake’s counters to ‘confidence counters’. These confidence counters mean that after each query that yields a result of either red or blue, the node increases its confidence counter by one. It switches colours if its confidence in the current colour goes below the confidence value of the other colour.
Instead of coming to a decision on a colour based on the number of consecutive results for a colour as per Snowflake, a node comes to a decision after a number of consecutive queries yield a result that means that nodes’ confidence in a colour exceeds that in other colours.
Avalanche, the final protocol, generalizes Snowball and maintains a dynamic append-only Directed Acyclic Graph (DAG) of all known transactions.
Append-only means that transactions only add on to previous ones. Each new transaction connects to one of the latest transactions.
A DAG is not entirely different from a blockchain and the only big difference is that a blockchain is linear, each new block points back to the single latest one. A DAG, however, is unbounded and can grow in multiple directions, as new transactions can attach to multiple previous transactions, which creates a web-like structure.
The AVA token is what makes Avalanche a proof-of-stake system. Staking in Avalanche is the primary mechanism for preventing Sybil attacks, i.e. an attack on consensus by creating a big number of fake nodes. Unlike Ethereum and others, that stake is not a collateral and will never be lost. If you misbehave there is no risk of your money being taken from you. So the stake here is solely to make sure that you cannot impersonate other people. This is one of the great outcomes of the Avalanche protocol. Staking is not used for consensus, in fact, it is completely independent of it.
Avalanche tackles the consensus problem by introducing a clever combination of gossip protocols and recurring subsampling. And fair governance is achieved via sampling and staking resulting in a direct tie between users and their decisions. Avalanche is quite ambitious but we are yet to see an actual working implementation, as Ethereum’s lead developer Vlad Zamfir expressed his doubts concerning the probabilistic nature of the Avalanche consensus.
NB. Do not confuse the protocol team with the namesake twitter account.