Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Last active April 20, 2023 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgcardona/acec7ff5b2907115d242273bc279ce4b to your computer and use it in GitHub Desktop.
Save cgcardona/acec7ff5b2907115d242273bc279ce4b to your computer and use it in GitHub Desktop.

Introduction To Avalanche

Introduction

We're going to go ahead and get started. My name is Gabriel Cardona. I'm Developer Evangelist at Ava Labs. Today's presentation is going to be a high level introduction to the Avalanche Network. We're going to talk about a few of the unique attributes of the Avalanche network which are namely Avalanche Consensus, Subnets and Virtual Machines.

What is Avalanche?

Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and decentralized apps.

We accomplish this through the notion of Subnets. Subnets allow anyone anywhere to spin up a taylor-made network w/ custom virtual machines and complex validator rulesets.

Avalanche is a network of networks. It's a platform of platforms where we invision thousands and thousands of public and private Subnets all emerging into this global marketplace which we call The Internet of Finance.

Brief History

Before we start I want to give a brief history of the evolution of the blockchain revolution. I suspect that most of this information on these next few slides won't be news to the people watching today but in my life I've discovered that to truly appreciate where you're headed it helps to truly understand where you're coming from.

Blockchain 1.0

Blockchain 1.0 was Bitcoin. In the beginning was Bitcoin and Bitcoin was good. Bitcoin proved to the world the need for a robust and decentralized payment network. It started it's life out as P2P electronic cash but for better or worse that's not what it ultimately grew into which is more akin to digital gold. I was salty for a long time about that but I've matured a lot over the last decade and my viewpoint has changed.

Now I realize that Bitcoin has grown into a hedge against inflation for the mom and pop investor. What is inflation? In economics, inflation is a general increase in the prices of goods and services in an economy. What are the long term impacts and effects of inflation? When the general price level rises, each unit of currency buys fewer goods and services; consequently, inflation corresponds to a reduction in the purchasing power of money. So as I see it inflation is a silent form of theft.

Some people argue that taxation is theft. However with taxation at least you can point to some common utilities and infrastructure which we all depend on, such as roads, police and the military, and say that is what our taxes are used for. But with inflation your purchasing power is simply going down continuously with nothing that we can point to in return.

1 out of 5 US dollars that have ever been printed in the entire history of the United States were printed in 2020. Consequently the purchasing power of every single person listening today's $USD has decreased about 20% in the last couple of years and it's going to accelerate. I certainly feel it in the SF Bay Area where everything from rent, bills, groceries, gas etc have all increased in price or decreased in quantity. This is potentially what the beginning of hyper inflation looks like. Don't think that can happen in the US. Check out Zimbabwe, Greece, Venezuela, Argentina etc. Bitcoin, and other cryptos such as AVAX, allow you to opt out of inflation. Trust me, your kids will thank you.

As big of a leap forward as Bitcoin was it still has downsides. Namely it's slow, only a handful of txs per second. It doesn't have fast finality, it takes an hour before you can be confident that your transaction won't be reorged. It's not lightweight and green—we all know the meme about BTC burning more energy each day that some nation states, though I think that's only a short term problem as we move to renewable energy. Every hour enough energy falls on the planet in the form of sunlight to meet over 100% of our energy needs, including fossil fuels, renables and nuclear. So really the problem is about harvesting this energy, storing it and transporting it, which are all problems which I think will be solved within our lifetimes.

So in the long-term I don't think that Bitcoin burning so much energy is a huge problem, but it's certainly a problem in the short-term. And it is really bad optics. You often see headlines that say "Crypto is even worse for the environment than you thought" and they're almost certainly referring to what I'm talking about here which is that Bitcoin's proof-of-work burns more energy than some nation states.

Bitcoin a scripting language, creatively names Script, but it's archaic and cumbersome to use. It's stack based and it doesn't feel modern for someone who has come of age in the era of golang, typescript and python. Lastly it doesn't have tokens. Technically there is an OP code, called OP_RETURN which enables you to write 80 bytes of arbitrary data to the blockchain which can be used to encode asset creation, minting, transferin and burning commands. You can then write wallets which can tease out those 80 bytes and decode them from which you can have tokens but it's really a technical hack and the tokens aren't native to the Bitcoin Virtual Machine.

In summary, Bitcoin was a huge leap forward and kicked off a financial revolution but it left a few things to be desired and inspired engineers to try and do better.

Also, I just want to say that Bitcoin had a radical impact on the lives of many, myself included. In 2011 I fell down the Bitcoin and crypto rabbit hole and I suspect I'll never emerge. It has taught me so much about technology, money, social dynamics and much more. So as gratitude to Satoshi, my wish is that he/she/they/it are out there living there best life. I hope that Satoshi is happy and healthy and working on the next generation of amazing technology.

Blockchain 2.0

Ethereum is Blockchain 2.0. Ethereum is a decentralized app which enables developers to launch their own dapps on top of it in the form of a smart contract. Prior to Ethereum if you wanted to launch your own dapp then you had to roll your own network. This led to a very bespoke environment where few projects were able to reach the network effects required to tip and go mainstream.

By enabling devs to launch their dapps on top of Ethereum, it enabled a huge network effect. This led to a wave of innovation around tokenomics, initial coin offerings, non fungible tokens or NFTs, decentralized finance or DeFi, yield farming, prediction markets, distributed autonomous organizations or DAOs, and so much more. I remain a huge fan of Vitalik and his team and I think is one of the great thinkers of our age. He's still a young man and I suspect that his best days are still ahead of him. Similar to Linus Torvalds chapter 1 being Linux and chapter 2 being git I'm waiting to see what Vitalik does for his chapter 2.

Blockchain 3.0

We view Avalanche as Blockchain 3.0 technology. Similar to Bitcoin and Ethereum we're introducing a handful of new paradigms which we'll go over today.

We'll discuss how Avalanche Consensus is the 3rd major paradigm over 40 years in the field of consensus. We'll discuss how Avalanche is unlike most other existing blockchains in that it's a network of networks instead of a single virtual machine and set of validators.

We'll also dig into Virtual Machines, what they are and how they fit into the Avalanche network. Lastly, we'll discuss how Avalanche enables developers to spin up their own taylor made networks with custom virtual machines and complex validator rulesets.

Avalanche Consensus

First off, what is consensus? If you work in the blockchain space you probably hear the word consensus a dozen times each day but what is it exactly? Consensus is the process by which a group of independent validators come into agreement on a decision. So it's that simple, how do you get a bunch of people or machines to agree on a decision. It's a very rich field of computer science that goes back at least 40 years.

Comparison Chart

As I mentioned, Avalanche Consensus is the 3rd major paradigm in the field of consensus. The first was called Classical Consensus and it goes back to the 70s and 80s. Classical Consensus has low latency and very high throughput. It's lightweight and green. However it isn't very scalable nor robust and it performs poorly in adversarial conditions.

In 2008/2009 when Satoshi Nakamoto released Bitcoin the world was introduced to the 2nd major paradigm in the field of consensus, what ultimately became known as Nakamoto Consensus. Nakamoto Consensus is very scalable, robust and decentralized but it doesn't have low latency, as I mentioned it takes around an hour to be sure your transaction is sufficiently settled that you won't experience a reorg. It doesn't have high throughput, Bitcoin only does a handful of transaction per second. Of course I'm aware of 2nd layer solutions such as the lightning network. I'm referring to the layer 1 Bitcoin protocol and network here. It's not lightweigh or green, as I mentioned Bitcoin burns more energy each day than some nation states. Lastly, Nakamoto Consensus performs ok in adversarial conditions up to the famous 51% attack.

In 2018 a pseudonymous group going by the name "Team Rocket" released a white paper on the InterPlanetary File System, or the IPFS, describing a 3rd major paradigm shift in the field of consensus. This new breakthrough was known as Avalanche Consensus. Avalanche Consensus is the perfect storm of features from Classical and Nakamoto Consensus.

It's very scalable, robust and decentralized. There are currently around 1500 full block and vertex producing validators on the Avalanche network. The protocol theoretically enables millions of validators so it's very decentralized. Avalanche consensus has low latency with subsecond immutable and irreversible finality. There is no notion of a reorg on Avalanche. Within a literal blink of an eye your transaction has settled completely. Avalanche has high throughput with 4,500 transactions per second. It's very lightweight and green and can be run on a PC, a Macbook, a VPS droplet on the cloud and in the future on Internet of Things devices. And Avalanche consensus is parameterizable so it performs very well in adversarial conditions.

Demo

Technically Avalanche is a metastable consensus protocol inspired by epidemic protocols and gossip networks. The process used to determine whether a transaction is preferred or not is referred to as "repeated random subsampling." Here is a great demo created by our Chief Protocol Officer Ted Yin. As I mentioned, Ted was one of the creators of HotStuff, which is the classical consensus protocol behind Facebook's Libra or Diem network. He is now at Ava Labs working on Avalanche Consensus.

Here the squares represent different nodes, and the color of each square represents its current proposal. So, is this transaction blue or is orange. Briefly, it's worth noting that Avalanche consensus can handle non-binary decisions. So for example you can give it 5 options instead of 2 and it will still reach immutable and irreversible consensus. For the sake of this demo, and in most transaction related decisions we're going w/ a binary decision—blue or orange. The darkness of the color shows the node's conviction in that proposal. Does this node kind of think the decision is blue or does it really really believe the decision is blue.

When I click start each node will begin repeatedly and randomly sampling it's peers and changing it's own color and conviction based on the responses. Expectedly, all nodes will collapse to the same color in the end. You can see that it only takes a couple rounds of sampling and the entire set will tip and Avalanche into consensus. I'm going to play that again because I think it's so beautiful. It only takes a couple rounds of sampling and the entire set will tip and Avalanche into consensus.

Network of Networks

So that's Avalanche consensus, which is the 3rd major paradigm shift in the field of consensus. Next let's discuss how Avalanche is a Network of Networks. As I mentioned Avalanche is different than traditional crypto networks like bitcoin and ethereum that have 1 virtual machine and 1 set of miners or validators. Avalanche is a network of networks w/ compound network effects.

CryptoSeq Network Slide

To help visualize this I have a really great slide. Credit and shoutout to the amazing CryptoSeq. You can see the twitter handle at the bottom right. Please go follow them on twitter and check out their medium account for some incredibly deep and insightful posts on the blockchain. Thank you CryptoSeq.

Here you can see the grey oval represents the Avalanche network. Within the network are many different subnetworks or Subnets which are represented by the circles. In each of those Subnets are green squares which represent the different Virtual Machines are blockchains which are running on those Subnets. The lines between the Subnets show that you can move assets and users between the different Subnets. At the top you can see Bitcoin, Ethereum and Cosmos with lines representing the ability to bridge assets from those other networks into the Avalanche Network. Currently bridge.avax.network supports bridging assets from Ethereum into Avalanche and recently we announced that Bitcoin support is coming to the bridge soon. Since launch less than a year ago, the bridge has been used for has been used for nearly 300k transactions with around $50B in ERC-20 assets on Ethereum to be used on Avalanche. These are stunning numbers and with the addition of Bitcoin we expect that number to go up much higher.

I often say that Avalanche's Subnet architecture is primed for compound network effects and what do I mean by that? Most everyone has heard of network effects. Which technically are known as Metcalfe's Law. Metcalfe's Law says that a network's value is proportional to the square of the number of nodes in the network. For example, if a network has 10 nodes, its inherent value is 100 (10×10=100). In other words a product or service gains additional value as more people use it.

A great example of network effects is the telephone network. If only 1 person has a telephone then it's not very useful. For every additional person who plugs into the telephone network then the entire network grows in value for every other user. Perhaps the canonical example of network effects is money. If only 1 person accepts a currency then it's not very useful. For each additional person that accepts the currency then it becomes more valuable for every other user who can then use their currency for goods and services.

So that's network effects but what about compound network effects? Compount network effects are known as Reed's Law which states that the utility of large networks, particularly social networks, can scale exponentially with the size of the network as the number of possible sub-groups grows much more rapidly than either the number of participants or the number of possible pair connections. Even if the utility of groups available to be joined is very small on a per-group basis, eventually the network effect of potential group membership can dominate the overall economics of the system

Avalanche's Subnets are designed and primed for compound networks effects.

Virtual Machines

A Virtual Machine defines the application-level logic of a blockchain. In technical terms, it specifies the blockchain’s state, state transition function, transactions, and the API through which users can interact with the blockchain. Every blockchain on Avalanche is an instance of a VM.

The way to think of a VM is like a class in OOP. A class is a description or an object. It's a template from which you can instantiate as many objects as you wish. Each of these objects, though derived from a common template, are unique and logically separate entities with their own state. Similar to a class, a VM is a blueprint or template from which you can instantiate as many different instances of a blockchain as you wish. Each of these blockchains, though derived from a common template, are unique and logically separate entities with their own state.

As a developer when you write a VM, you don't need to concern yourself with lower-level logic like networking, consensus, or the structure of the blockchain. Avalanche does this behind the scenes so you can focus on the thing you would like to build.

Why VMs?

At first, blockchain networks had one Virtual Machine (VM) with a pre-defined, static set of functionality. This rigid, monolithic design limited what blockchain-based applications one could run on such networks.

People who wanted custom decentralized applications had to create their own, entirely new blockchain network from scratch. Doing so required a great deal of time and effort, offered limited security, and generally resulted in a bespoke, fragile blockchain that never got off the ground and achieved the network effects required to tip and go mainstream.

As mentioned before Ethereum made a huge step toward solving this problem with smart contracts so that developers didn’t need to worry about networking and consensus, but creating decentralized applications was still hard. The Ethereum VM has low performance and imposes restrictions on smart contract developers. Solidity and the other few languages for writing Ethereum smart contracts are unfamiliar to most programmers. They're not very expressive and they don't fit into the rest of your development workflow.

Avalanche VMs (AVMs) make it easy to define a blockchain-based decentralized application. Rather than new, limited languages like Solidity, developers can write VMs in Go and using a gRPC API you can actually write your VM in a language other than Golang as long as your VM implements a certain interface. Your blockchain can run as a separate process from AvalancheGo and can communicate with AvalancheGo over gRPC. This is enabled by rpcchainvm, a special VM that uses go-plugin and wraps another VM implementation. The C-Chain, for example, runs the Coreth VM in this fashion.

rpcchainvm has two important parts: a server and a client. The server runs in its own process and allows the underlying VM's methods to be called via gRPC. The client runs as part of AvalancheGo and makes gRPC calls to the corresponding server in order to update or query the state of the blockchain.

Subnets

Lastly we have Subnet, or subnetwork, which is a dynamic set of validators working together to achieve consensus on the state of a set of blockchains. Each blockchain is validated by exactly one Subnets. A Subnets can validate many blockchains. A node may be a member of many Subnets.

So to visualize the heterogenous, or rich and diverse nature of the Avalanche network picture this. A VM is the application level logic of your blockchain. It's the template and can be instantiated into many different blockchains, some of which are public and some of which are private. A blockchain is an instance of a VM. Each blockchain is validated by exactly 1 Subnet. A Subnet can be on a spectrum of public to private and can validate many different blockchains, including many instances of the same virtual machine. A node can be a member of many Subnets, validating many many blockchain including many instances of the same virtual machine, some public and some private. Avalanche is truly a heterogenous network.

Subnets manage their own membership, and may require that their constituent validators have certain properties which is very useful.

Compliance

Avalanche’s Subnet architecture makes regulatory compliance manageable. A Subnet may require validators to meet a set of requirements.

Some for example you can say that:

  • All validators in my Subnet must be located in a given country or legal jurisdiction
  • All validators must pass a KYC/AML checks
  • All validators must hold a certain license

Support for Private Blockchains

You can create a Subnet where only certain pre-defined validators may join and create a private Subnet where the contents of the blockchains would be visible only to those validators. This is ideal for organizations interested in keeping their information private.

Separation of Concerns

In a heterogeneous network of blockchains, some validators will not want to validate certain blockchains because they simply have no interest in those blockchains. The Subnet model allows validators to only concern themselves with blockchains that they care about. This reduces the burden on validators.

Application-Specific Requirements

Different blockchain-based applications may require validators to have certain properties. Suppose there is an application that requires large amounts of RAM or CPU power. A Subnet could require that validators meet certain hardware requirements so that the application doesn’t suffer from low performance due to slow validators.

Primary Subnet

Our mainnet launched in August 2020 w/ what we call the Primary Subnet. It has the X-Chain, C-Chain, and the P-Chain.

Summary

So in summary, Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and decentralized apps.

We accomplish this through the notion of Subnets. Subnets allow anyone anywhere to spin up a taylor-made network w/ custom virtual machines and complex validator rulesets.

Avalanche is a network of networks. It's a platform of platforms where we invision thousands and thousands of public and private Subnets all emerging into this global marketplace which we call The Internet of Finance.

Thank You

Thank you very much. I want to express gratitude to everyone listening today and in the future. I'd like to express gratitude to the SagaXYZ team for the opportunity to present and let everyone know about the amazing Avalanche network. And I'd like to express gratitude to the Ava Labs team. It's truly an honor and a pleasure to work w/ all of you amazing blockstars to change the world each day.

Final Slide

As I mentioned my name is Gabriel Cardona. I am Developer Evangelist at Ava Labs. You can find me at @cgcardona on twitter and telegram. Feel free to reach out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment