How Do Avalanche Subnetworks Work, and What Makes Them Different From Sidechains?
Avalanche brings two primary innovations to cryptocurrency. The first innovation is the new family of consensus algorithms that enable the speed and efficiency of Classical Consensus systems, with the decentralization and robustness of Nakamoto Consensus systems. This new family of consensus algorithms is known as the Snow Protocols, and the main one is called Avalanche Consensus.
The second innovation brought to cryptocurrency by Avalanche is known as subnetworks. In this article, I will explain what subnetworks are, and why they are very different from sidechains.
What Is A Subnetwork?
A Subnetwork is a network of validators that are validating a collection of blockchains, built on top of Avalanche (or a base-layer network). In many cases, a subnetwork might only contain a single blockchain (also known as a “subchain") but there are plenty of examples where a subnetwork creator would prefer to have multiple chains together.
In the vast majority of cryptocurrencies, there is a single chain, a single virtual machine, a single unit of account, and a single validator set. This lack of basic customizability and interoperability means that most cryptocurrencies are incapable of communicating with each other, unless you use some kind of a centralized sidechain. The innovation Avalanche is bringing is a network that is not limited to a single chain, virtual machine, unit of account, or validator set, but can simultaneously have everything.
As I will explain later, this is not solvable by using Sidechains in a decentralized way, and even the use of sidechains in general do not solve this complex problem without the unsustainability of adding exponentially more complexity with every integration. Subnetworks have many features that a simple sidechain simply wouldn’t have, which includes how easy it is to create one, how reliable it is, how permissionless it is, and the bidirectional interoperability it has.
Creating a subnetwork would be doable in less than an hour, and all you need is a node and the ability to run basic code on the command line. This is in contrast with a sidechain, which would take months of engineering and testing. Subnetworks are made on the protocol-level, and are equipped with the full toolset of utilities that allow it to be interoperable with both the main chain, and each other.
What Is A Sidechain?
A Sidechain is a cryptocurrency protocol built outside of the cryptocurrency’s core protocol, which acts as a second-layer to the cryptocurrency. Sidechains usually work by giving your cryptocurrency to a group of validators (so not permissionless) with the expectation that you cannot be stolen from because the validators are either plentiful and decentralized, or federated, well regulated, and trustworthy.
Sidechains themselves do not have to share the same consensus algorithm as their parent chain, and usually don’t. More often than not, a parent chain will be secured through Nakamoto Consensus, and then a sidechain will use either Federated Classical Consensus, or Classical Consensus with complex Smart Contracts. Bitcoin sidechains usually use the former, and Ethereum sidechains usually use the latter.
In either case, there will always be an understanding that sidechains must be trusted, and carry risk of fund loss when you use them. There is also an understanding that sidechains are far less secure, as you trust the arbitrary whim of the validators, and dont have your transactions being secured on the main chain. Even though users may have cryptographic proof of a transaction or the lack thereof, it is the act of sending your funds to a sidechain in the first place that forces you to trust the consensus quality of the sidechain, and a faulty sidechain could use this to steal your funds.
There is another problem with sidechains, and it is that they “beg the question”. If Nakamoto Consensus is necessary, then why would we want to relocate transactional activity to a Classical Consensus chain? And if Classical Consensus is necessary, then why do we use Nakamoto Consensus at all in the first place? Nakamoto Consensus does not secure or decentralize money if this money is being sent to an arbitrary group of validators with a completely different consensus mechanism. And if Classical Consensus was better than Nakamoto Consensus, then why are we using Nakamoto Consensus, which is constricting base layer transactional activity and preventing large numbers of people from sending their transactions to a Classical Consensus L2?
Let us do some basic math. There are 8 Billion people who need access to finance, and an average of 3 transactions a day each person needs to be able to make. This is 24B transactions a day required to replace the current financial system. Given that there are 86,400 seconds in a day, we need a system with about 278k transactions per second to fill the needs of every human being on Earth. To put this in perspective, Bitcoin can only do about 10 tps (0.0036%), Ethereum can only do about 30 tps (0.0107%), and Eth2.0 can theoretically only do about 1920 (30 × 64) tps (0.69%). In the case of any of these networks, it would be extremely hard to even get users onboarded to a L2 en masse. Assuming you need to make two transactions to onboard yourself to a L2, once to buy and once to transfer to a L2, it would take years or even lifetimes to onboard the world from any of these networks to a L2. In the case of Bitcoin, it would take 152 years to get everyone onboarded to a L2, it would take 50 years to onboard everyone on Ethereum to a L2, and it would take 10 months to onboard everyone using Eth 2.0 to a L2. Basic mathematics say that these numbers here aren’t nearly good enough, and put a real dampener on the ability to meaningfully adopt the base layer, aside from a stepping stone that would be discarded by the vast majority of everyone.
Given that sidechains necessarily require frequent access to the main chain to have reliable cold storage, security, liveness, and decentralization, they simply aren’t an attractive option for users and won’t gain meaningful traction. And the reason that sidechains can’t just be Nakamoto Consensus all the time, is because low-hashrate Nakamoto Consensus chains are highly insecure and unstable, making them a bad design choice for small sidechains. Nakamoto Consensus is also pretty unscalable, and is usually part of the reason you want a sidechain to begin with.
What Are The Differences Between Subnetworks and Sidechains?
Although the concept of Subnetworks and Sidechains sound pretty similar, their fundamental functionality is enormously contrasting. Below is an enumerated list of all the ways they are different.
- Subnetworks share the Consensus Algorithm of the parent network, which makes them reliable. Sidechains will usually use a different consensus algorithm with completely differing characteristics, and expect users to sacrifice security, decentralization, and liveness/reliability for cheapness or new features. If it doesn’t use a different consensus algorithm and uses Nakamoto Consensus instead, then it will be at high risk of hashpower or staking related attacks. Avalanche Consensus is necessary to give subnetworks this property of consensus homogeneity.
- Subnetworks are permissionless because cross-chain transfers are handled on the protocol-level. As opposed to giving your money to someone and hoping they don’t run off with it, a cross-chain transfer is done on the protocol-level, and you aren’t sending your money to anyone other than yourself. The reason that this quality emerges with the introduction of Avalanche, is precisely because the consensus algorithms on the two networks match, and validators on the subnet must also be validators on the mainnet. Sidechains don’t usually do this, and for this reason they usually rely on federated models, models that incorporate security through a different token, or models that constrict the possible decentralization of a sidechain. Classical Consensus for example can’t scale in number of validators, so unfederated sidechains could be more centralized than the federated ones. Nakamoto Consensus would struggle with this in general, because they are very rivalrous and minority chains are very insecure.
- Subnetworks exist on the protocol level, and have to be on the protocol level to offer bidirectional interoperability. Sidechains are by definition a separate third-party network built “outside" the main network. By subnetworks being bidirectionally interoperable, you can create and transfer assets in both directions. As explained in point #2, this is difficult to do outside of Avalanche Consensus because you are usually dealing with a mainchain and sidechain with different consensus algorithms, and an inherent inability for a mainchain to trust assets created on a sidechain, and if its not this, then any scaling benefits offered by multiple chains is defeated because Classical Consensus chains cannot scale in number of validators and you’d have the same handful of validators doing everything, hardly different from a centralized and federated model.
- Subnetworks Are Quick And Easy To Create, and Can Be A Collection of Multiple Blockchains and/or DAGs, Both Backed By Natural Incentives. Although its not impossible for sidechains to consist of multiple chains in a single network, or for sidechains to be easy to create, the reason they aren’t ever this way is because sidechains are consensus schemes built outside of the underlying protocol. It takes exponentially more work the more interoperability and functionality you give a sidechain, and if you were to try to create some standardized protocol to create sidechains with, you’d end up with an expensive mess the second the base layer protocol is changed, as the interests of the base layer validators and sidechain validators have no concrete basis for being well-aligned. Avalanche clears this up by creating a consensus algorithm that both the mainchain and its subnetworks use with a common validator set, aligning the interests of the mainchain with the subnetworks, and delegating the burden of managing subnetwork technology to the mainchain.
- Subnetworks Are Naturally Interoperable With Each Other, Unlike Sidechains, Which Would Be Mathematically Impossible. Building on point #4, there is an astute observation to be made with subnetworks versus sidechains, which is that without an incentive-aligned standardized protocol of sidechain creation, it would be exponentially expensive and mathematically impossible to enable direct crosschain interoperability between sidechains if new sidechains were to continually emerge. Imagine if the number of sidechains increases by 1 every month, each sidechain would need to create support for every new sidechain once a month, which is unsustainable for any practical business model. By having a protocol-level, incentive-aligned, validator-shared subnetwork creation framework, subnetwork creators do not need to worry about crosschain interoperability. Avalanche in all practicality is necessary for this because there is no other way to have a permissionless network thats bidirectionally interoperable with permisionless subnetworks, due to the technical limitations of Nakamoto and Classical Consensus.
Why Are Subnetworks Important?
Subnetworks will be the holy grail of scaling, as well as the holy grail of usecases and innovation. Subnetworks enable a market of competing ideas, while allowing all the ideas to be interoperable with each other and use a common unit of account. There can be a market for privacy-oriented chains, a market for virtual machines, a market for sharding, potentially a market for anything desirable in cryptocurrency. And by being interoperable and monetarily connected with each other, it is easy to switch between subnetworks or use multiple at once.
As for scaling, subnetworks offer a secure avenue for offloading transactional activity to the most secure and reliable L2s in existence, something that is fundamentally the same as the L1, just with likely less validators. Every scaling idea can be tried simultaneously, including onchain scaling, sharding, and more.
Having subnetworks is kinda like sharding, without all the arbitrary parameters. In sharding, you’ve got to choose how many validators are in each shard and/or how many shards there can be. Sharding usually creates a hard limit on the number of validators there can be, constricting decentralization. But with subnetworks, every validator must validate the base layer, and they can create subnetworks as it becomes feasible to do so. The base layer remains an open and attractive option for storing funds, and different kinds of subnetworks can be used for spending.
Contrary to what some people believe, subnetworks are very secure, and are far more secure than sidechains. Because all transactions from one chain to another are connected by a cryptographic proof of spending, you stay in control of your funds until you send them to another person, even after your coins get reminted on a different chain. An attacker attacking a low-value subnetwork with few validators cannot outright steal funds as he cannot force others to sign their keys, and at the very worst could only censor or reverse valid transactions. In the event this does happen, it would just encourage more honest validators to join in. This is a far stronger security model than what most sidechains have.
As for strengthening the subnetworks against DOS attacks, there are multiple permissionless schemes you can use to make it a lot harder to attack. One idea is to have a token that you need to stake in conjunction with the AVAX, with the hope that this would make it very difficult to begin attacking. Another idea is to use coinage, where your time on a subnetwork gives you more voting weight, mitigating latecomer attacks. Both of these ideas could be used to help secure permissionless subnetworks.
Subnetworks are important because they allow for unprecedented innovation, while having unity and interoperability. They also give a way for regulated financial entities to adopt Avalanche, as they can build legally compliant subnetworks using all of its customizable features. Subnetworks are how we are going to be able to try every idea, without having to jump from niche cryptocurrency to niche cryptocurrency.
Do Other Cryptocurrencies Have Subnetworks?
As far as I am aware, no, at least not in their fullest extent. There are a couple of cryptocurrencies that have systems that are similar to having subnetworks, but there are definitely some notable differences to make.
- Polkadot: Polkadot is a sharded, Proof-Of-Stake cryptocurrency that has a sidechain-like feature called parachains. A parachain is another shard on the polkadot network, but each shard is allowed to have a different virtual machine. This means that shards/parachains have a shared security model, but it also means limitations to the kinds of things you can do on a parachain, as well as limitations to Polkadot itself. For example to get a parachain you have to purchase it in a monthly auction. There are also a strict limit to how many validators can exist, how many parachains there can be, and how many validators can be on each parachain. Polkadot has the structure of a normally sharded blockchain, but with some customizability for whoever the highest bidders on each parachain are.
- Cosmos: Cosmos has something called the IBC, or inter-blockchain protocol. This doesn’t have anything to do with creating new subnetworks, but is a protocol that allows different blockchains to communicate with each other, usually through the cosmos platform like a middleman. If Cosmos eventually does create some kind of standard for a sidechain creation process, it would involve separate, independent chains communicating with each other, with or without Cosmos itself. This can’t be honestly called a subnetwork, because its not governed by the parent chain, and it doesn’t remove the need to trust these other chains.
Aside from Polkadot and Cosmos, I can’t think of any other cryptocurrency that would be similar to Avalanche in terms of having a standardized subnetwork creation process, but even these two cryptocurrencies would completely miss the point of what AVAX is doing: Permissionless, Decentralized, Reliable, Industry-Ready blockchains for usecases that need the customizability.
How Do Subnetworks Actually Work?
So to put it in simple terms, a subnetwork is just a group of validators that choose to validate an alternative chain alongside the default subnet. The “default subnet" is the base layer, or main chain, so to speak, except there are three chains a part of it. The P-Chain, the X-Chain, and the C-Chain. The P-Chain is the Platform Chain, The primary chain, the parent chain, and it is the chain that governs all other chains on Avalanche as well as the validators. The X-Chain is the Exchange Chain, a chain designed with UTXOs, made to be similar to Bitcoin and optimized for scalable fund transfer. The C-Chain is the Contract Chain, it’s designed with Account Balances, and has an instance of the Ethereum Virtual Machine running in it. In order to validate any chain on Avalanche, you must validate the default subnet, including all three of these chains.
The P-Chain is the actual core of this model, and its responsible for all the subnetworks that exist on Avalanche. The way it works, is it has a mechanism where you essentially burn your coin on the origin chain (this burned coin is in kind of “limbo" where its not gone forever, it just isn’t controlled by anyone in the present moment), and you remint a new coin on the destination chain, with cryptographic proof that you own it legitimately.
Each chain has an ID, and the platform chain essentially credits one chain, debits the other, and then says “okay subnetwork, validate whatever happens yourself and come back to me when you are done". All transfers done on the subnetwork chain must have cryptographic proof of validity, but the validators of the subnetwork get to relay and retain that information.
In a worst case scenario, a subnetwork could refuse to allow users to take their money out of the subnetwork, but they can’t fake cryptographic proof and steal the coins. This is an advantage over most sidechain models, which have trust instead of cryptographic proof required by the base layer.
Subnetworks are to sidechains, as Bitcoin transfers are to Bank transfers. The difference really is that starkly contrasting, despite being conceptually similar.
In this article I talked about Subnetworks, Sidechains, and why they are so different. In short, Subnetworks exist on the protocol level, which not only makes them easier to build, but is required to make them cryptographically reliable and secure. Sidechains are typically trusted third party entities, and the parent/origin chain has no way to validate their offshore cryptographic honesty. Subnetworks have to have a cryptographic explanation of what happened while coins were gone.
Avalanche Consensus is required to give us Subnetworks that can both scale throughput securely, and remain decentralized and permissionless. You could do one or the other, the former if you use Classical Consensus, and the latter if you use Nakamoto Consensus, but you can’t do both without Avalanche.
Subnetworks are an innovation of Avalanche, because they can’t be done using the other existing consensus mechanisms, without either sacrificing their main benefits, or the main benefits of the underlying blockchain itself. Avalanche (AVAX) is the first cryptocurrency to completely implement working subnetwork technology, and now that its here, we have the opportunity to be more united with the greater cryptocurrency community at large.
Avalanche is an open-source platform for launching decentralized finance applications and enterprise blockchain deployments in one interoperable, highly scalable ecosystem. Developers who build on Avalanche can easily create powerful, reliable, and secure applications and custom blockchain networks with complex rulesets or build on existing private or public subnets.
How Do Avalanche Subnetworks Work, and What Makes Them Different From Sidechains? was originally published in Avalanche Hub on Medium, where people are continuing the conversation by highlighting and responding to this story.