Solving the blockchain trilemma: A look at some scaling solutions
Table Of Contents-
- The blockchain trilemma
- Layer 1 blockchains
- Layer 2 sidechains
- What are rollups?
- ZK rollups
- Optimistic rollups
- Sidechains vs rollups
- Polygon’s zkEVM
- Application chains
- Avalanche Subnets
- Polygon Supernets
- BNB Application Sidechains
- Klaytn Service Chains
The blockchain trilemma: How to scale while ensuring security and decentralization?
The number of transactions per second (TPS) that a decentralized blockchain protocol can process is limited compared to centralized non-blockchain solutions. This is of major concern because for Web3 to compete with the current financial systems, it needs to be able to serve many users at once. However, focusing too much on making a blockchain scalable can lead to a project making tradeoffs on security and decentralization. This problem is known as the blockchain trilemma.
Layer 2 scaling solutions are one of the answers to these problems. However, the Layer 2 solutions vary quite a bit, and there’s a lot to unpack when trying to understand these new technologies. In this article, we will be going over a few of these solutions to understand how they work.
Layer 1 blockchains
Layer 1 blockchains are the ones you usually hear about. Bitcoin, Ethereum, Solana, and the like. They are the foundations for their respective ecosystems, and they all have their independent consensus mechanisms. Any project that builds on top of these chains inherits the pros and cons of these respective Layer 1s.
For example, Ethereum is secure and decentralized, but it can also get slow and expensive to process transactions on the Ethereum mainnet when the network gets clogged.
The additional solutions to improve the blockchain experience of the end-user are known as Layer 2 scaling solutions, and they have a lot of differences within them. Let us talk in more detail about these.
Layer 2s and sidechains
Layer 2 is a collective term that refers to any scaling solution that is built on top of an existing blockchain system.
These Layer 2 solutions work independently of the parent chain and usually have their own consensus mechanisms. Polygon, StarkNet, Gnosis Chain, Avalanche Subnets, BNB Application Sidechains and so on are all good examples of Layer 2 solutions trying to increase TPS and throughput while keeping up the security standards that are core to blockchain.
Let us first talk about sidechains, one of the most prominent of the many different Layer 2 solutions.
In the context of the EVM ecosystem, a sidechain is a separate blockchain that is typically used for large batch transactions. Sidechains use their own consensus mechanisms, which optimize them for speed and scalability. They typically compromise a bit on the decentralization of the blockchain, but if a sidechain is indeed compromised, the mainnet is not affected. Sidechains are also often EVM-compatible, which means you can deploy the same smart contract to either Ethereum or the sidechain, with minimal changes. This allows DApps to scale without worrying too much about the gas fees. The most prominent example of an EVM-compatible sidechain would be Polygon. Polygon isn’t the only one though. Ethereum’s official blog mentions Polygon, Gnosis Chain, Skale, and Loom network as examples.
To be clear, for a separate blockchain to be considered an Ethereum sidechain, it needs to be able to move assets between itself and Ethereum mainnet. This is powered by smart contracts deployed on either chain. The smart contracts function as bridges for the transfer of funds.
With these bridges, the transfer of funds is typically accomplished through locking and releasing mechanisms, which are out of the scope of this article. If you however are interested in creating a cool EVM-compatible bridge, feel free to check out this tutorial by Antonio–
What are rollups?
Rollups are also a type of Layer 2 scaling solution. What they do is nicely hinted at in the name.
Rollups roll up multiple transactions into one piece of data, and collectively present that data block to the parent chain, in our case Ethereum. This cuts down the number of transactions that Ethereum must process, and thus gives them the throughput that Ethereum just can’t match on its own.
There are two main types of rollups—zero-knowledge (ZK) rollups, and optimistic rollups, and they differ in the way their transactions are verified.
How do we know that the transactions that the rollups are pushing to the parent chain are accurate?
Currently, there exist two solutions to this problem:
- Fraud proof, used by Optimistic rollups.
- Validity proof, used by ZK rollups.
ZK-rollups wait for hundreds, or even thousands of transactions to be bundled together, and then verify their validity by doing a bunch of mathematical operations on them, like how transactions are verified on Ethereum. Once a mathematical proof is generated, the main Ethereum chain includes that batch of transactions on the mainnet as if those transactions were processed on-chain itself.
Zero-knowledge proof is a complex mathematical concept where someone can prove that they are in possession of a piece of data without actually disclosing that information to anyone. I can, for example, prove that I know the password to my mobile by simply unlocking it in front of you, without showing you the password itself.
In a ZK rollup, a mathematical proof is generated that proves that a whole batch of transactions is valid, without including the proof for individual transactions. This makes ZK rollups more efficient and scalable.
StarkNet is a great example of ZK rollups in action. Find out more about StarkNet in our dedicated tutorial series:
This is a good time to mention that StarkEx and ‘StarkNet’ are two different things. While StarkNet is an EVM-compatible ZK rollup, StarkEx is basically a framework for creating ‘STARK proofs’ off-chain. STARK stands for ‘Scalable Transparent ARguments of Knowledge’. These proofs verify the authenticity of a transaction. They are computationally expensive to generate but quite easy to verify.
StarkEx allows projects to generate these STARK proofs off-chain conveniently, thus only verifying them on-chain. Major protocols like ImmutableX use StarkEx as a scaling solution.
As of now, ZK rollups can only process a few types of transactions and cannot process generalized smart contracts. This is where optimistic rollups come in.
Optimistic rollups are a much more generalized version of ZK rollups. They run a version of the EVM called the optimistic virtual machine (OVM). An OVM runs almost exactly like an EVM, except that it processes Layer 2 transactions instead of Layer 1 transactions.
The important thing to note is that the OVM does not check a batch of transactions for validity by default. The validity of such a batch is determined by what is called a fraud proof.
Once a batch of transactions is processed, there is a time period where anyone can challenge the validity of the whole batch. This is known as the fraud-proof window. This window can last as long as 3 weeks but is usually 1-2 weeks long. If a fraud proof submitted by someone is found to be invalid, the entire batch of transactions is rolled back. This means for any transaction to achieve Layer 1 finality, the time taken will be equal to the length of the fraud-proof window.
Optimism and Arbitrum are two prominent examples of Optimistic rollups. They are both almost identical, but with a few key differences. What mostly sets Arbitrum apart from Optimism is the fact that while Optimism uses single-round fraud proofs, Arbitrum uses multi-round fraud proofs to ensure the legitimacy of the transactions. This means that instead of processing an entire batch of transactions on-chain, Arbitrum only requires the fraud proofs for those transactions that are being challenged. This saves a considerable amount of gas since the entire batch is no longer being processed on the chain.
Sidechains vs rollups
If you have read this far, you may be wondering what exactly is the difference between sidechains and rollups?
At its core, both of them serve to increase the scalability of Ethereum, and both of them have similar interfaces for the end-user. However, these are two different technologies, and it is important to know their differences.
- Rollups sit on top of the existing Ethereum network and the compressed transaction data is submitted to the respective rollup contract on the Ethereum mainnet. Different kinds of rollups take different amounts of time to achieve transaction finality, but the core principle remains the same.
- A sidechain like Polygon however is a complete blockchain in its own right. We use the native token of a sidechain to push transactions on them. Yes, tokens like MATIC can be exchanged for Ether using a bridge, but the security of any funds you have on a sidechain is ensured by the sidechain itself, not Ethereum.
Let us take a step back and look at ZK rollups one more from a different perspective.
ZK rollups are transactions that have been proven correct, whereas optimistic rollups are transactions that weren’t disputed within a given time frame or haven’t been proven as incorrect.
Many projects use optimistic rollups because they are compatible with the Ethereum Virtual Machine pretty much out of the box, unlike ZK or Validity rollups that may require their own contract language like Cairo.
This is the reason so many projects like Polygon and Matter Labs (the organisation behind zkSync) have been putting in the effort to develop an EVM that will allow ZK rollups to handle smart contracts. A successful ZK rollup mainnet that can also handle smart contracts will allow Ethereum to scale massively while remaining secure and decentralized.
Polygon has turned out to be one of the first companies to announce the launch of their zkEVM testnet, alongside open-sourcing the code for the whole project.
What this means in essence is that developers can deploy their smart contracts on ZK rollups without changing their code much. One of the major disadvantages of deploying smart contracts on optimistic rollups was that the withdrawal of funds could take weeks depending on the dispute period of that particular rollup. But with the progression of the ZK-SNARK technology, developers can leverage the full potential of rollups without having to wait weeks for their smart contract transactions to gain finality.
The scaling solutions we discussed up until now were either singular blockchains like Polygon or rollups that facilitated cheaper transactions on Ethereum.
Some blockchain projects however aim to do things a little differently. Projects like Avalanche and Polygon Supernets aim to build on the already existing consensus mechanisms to create their own blockchain ecosystems that will allow developers to leverage their toolkits to build their own customized blockchains within the respective ecosystems.
Let us take a look at a few of these projects.
Avalanche is a unique blockchain ecosystem that allows developers to quickly set up their own blockchains within the Avalanche ecosystem, which are powered through a subnet.
A subnet is a set of validators working together to validate transactions on a particular blockchain. While making a new blockchain using the Avalanche protocol, the user can impose certain qualifying conditions for validators who want to join the blockchain’s subnet.
I may want all my validators to belong to a certain geographical area, or maybe I want all my validators to be verified through KYC. Avalanche allows me to impose these conditions, thereby giving me a subnet according to my requirements. If you want to dig into avalanche subnets, feel free to check out our tutorial series starting from here:
Even the primary Avalanche network, without any derived subnets, will consist of at least 3 blockchains.
- X-Chain—This chain is responsible for the creation, management, and transaction of any new tokens on the network.
- C-Chain—The C-chain is based on the Ethereum Virtual Machine and is used to execute smart contracts. The fact that it uses the EVM allows for a fast and convenient transfer of existing solidity code onto the Avalanche Ecosystem.
- P-Chain—The P-chain is the blockchain that holds the metadata for all the derived blockchains that exist in the Avalanche ecosystem. This chain keeps track of all active subnets, while also allowing the creation of new ones.
To understand what Polygon Supernets are, we first need to learn about Polygon Edge.
Edge is a modular framework launched by Polygon that allows you to quickly launch your own EVM-compatible networks, sidechains, or generalized scaling solutions for Ethereum or any other EVM-sidechain.
Polygon Edge provides developers the option to launch their own dedicated Edge chain with just a few lines of configuration code from the documentation, instead of having to fork the entire Ethereum mainnet and tweaking the codebase to fit business needs.
So, what are Polygon Supernets?
Supernets are basically blockchain networks that have been customized and deployed using Polygon Edge.
Supernets are customized and operated for a specific use-case or project, usually having their own dedicated nodes. This combination of customization and dedicated nodes allows DApps to scale easily. As of now, nearly 20 Web3 applications are using Polygon Edge.
One of the biggest challenges when setting up a PoS (Proof of Stake) blockchain network is to bootstrap a reliable validator network. Polygon Edge will allow Supernets to access a pre-vetted validator network, thus bypassing one of the biggest hurdles in setting up a blockchain network. Additionally, these validators will stake and be incentivized in MATIC, thus making it much easier to incentivize the validators sustainably.
All Supernets built using Polygon Edge are capable of exchanging assets and information between each other, and even the Ethereum Mainnet. However, efforts are underway to develop protocols to enable cross-chain communication between all the Supernets, and even other EVM-compatible sidechains.
BNB Application Sidechains
BNB Smart Chain was launched in 2020 and is an EVM-compatible blockchain capable of executing smart contracts. BNB Application Sidechain (BAS) is a framework for creating subchains in the BNB ecosystem that helps developers build their own customizable and flexible blockchains. We can use the tool to develop highly customized blockchains within the BNB ecosystem that can have their own gas tokens and gas fees.
Theoretically, we could even set the gas fees for our blockchain to be zero, but that isn’t recommended because it will incentivize bots to spam the network. It is possible to bridge assets on all the chains within the BNB ecosystem. This means we can leverage NFTs and other tokens on all these chains to get more tokens of a particular type.
If this reminds you of Polygon Supernets where you could one day swap any of your tokens with each other within the EVM ecosystem, then you are on the right track.
These BAS sidechains are basically an L2 scaling solution for the main BNB Smart Chain. As is the case with Polygon Supernets, the BAS team provides us a default set of validators that they deem safe, but we are free to use our own validators if we don’t want to trust the BAS team.
Binance has ambitious plans in store for BAS. They plan to run BAS networks as PoS sidechains as well as ZK rollups in the future. However the first version of BAS and its testnet are based on POS networks.
Node operators do not need to worry about maintenance work if they use services provided by BNB Smart Chain partners.
Klaytn Service Chains
The Klaytn network is a public blockchain network developed by Ground X, that provides a service-centric blockchain platform that aims to meet enterprise-grade reliability.
Klaytn launched its Mainnet called Cypress in 2019, and it had the 4000 transactions per second (TPS) speed, alongside a substantially lower gas fee when compared to Ethereum.
The main Klaytn network can be broken down into three subnetworks—each with a distinct purpose.
- Endpoint Node Network (ENN) consists of Endpoint nodes that are responsible for creating new transactions and handling RPC API requests.
- The Core cell Network (CCN) verifies and executes the transactions that are submitted by the ENN.
CCN is the main module responsible for block generation in the blockchain
- Service Chain Network (SCN) is comprised of the Klaytn subnetworks that are composed of auxiliary blockchains. They are connected to the main chain via ENs.
Any DApps on the Klaytn ecosystem can therefore choose to run either on the main chain through the Cypress mainnet, or can choose to run on their own custom blockchains called ‘service chains’. Klaytn’s official docs recommend using service chains if we want our DApps to have a dedicated execution environment and the highest possible TPS.
To put it all together, Layer 2 scaling solutions are turning out to be a key component in making blockchain technologies more accessible to the end-users. Only through higher transaction speeds and lower gas fees will web3 be able to compete with traditional financial systems.
In this article, we learned that there are many different kinds of scaling solutions, and how these solutions differ in their respective approaches. Not all scaling solutions are the same, nor do they serve the same use cases. It is important to understand their differences and to know about the different kinds of technologies that power the whole web3 stack.
Want to get a complete overview of the Web3 stack?
Learn more with our guide here:
- Connect to the Ethereum, Polygon, BNB Smart Chain, Avalanche, Fantom, Solana, Harmony, Tezos and StarkNet mainnet or testnets through the interface designed to help you get the job done.
- Get access to the Ethereum, Polygon, BNB Smart Chain, Avalanche, Fantom, and Tezos archive nodes to query the entire history of the mainnet—starting at just $49 per month.
- Choose where you want to deploy, and we will provide you with the dedicated managed infrastructure that can handle high-volume, high-velocity read/write access to the network.
- To learn more about Chainstack, visit our Knowledge Center or join our Discord server and Telegram group.
Have you already explored what you can achieve with Chainstack? Get started for free today.