It is a well-known fact that as more and more users join a peer-to-peer network, the efficiency of the whole system degrades. This scalability problem is the current hurdle that blockchains must overcome to improve accessibility and cost. They must find a way of using these protocols in a way that doesn’t detrimentally influence the decentralisation and security of the blockchain.
To give an example, some smaller transactions on the Ethereum network are currently priced out. It can cost hundreds of dollars in gas fees to execute smart contract transactions. Claiming staking rewards on some protocols can cost more than $100, depending on the level of congestion in the Ethereum network. The exception is if you are staking enough of a token to generate rewards worth more than the gas fees themselves. This problem prevents an entire cohort of smaller investors from being able to interact with the protocols in the way they were intended.
You may have heard of Layer 1 and Layer 2 (L1/L2) solutions for various protocols over the last 24 months. However, these concepts are not yet widely understood. In this article we will be covering the fundamentals of scaling and looking at a few innovative solutions in development – warning, it is a fairly technical read.
L1 vs L2
Layer 1 is the terminology used to describe the underlying main chain. An example of an upgrade to L1 would be the planned Ethereum 2.0 update. This is known as an ‘on-chain’ scaling solution, and generally requires a hard fork as it fundamentally changes the underlying technology.
A Layer 2 solution refers to a secondary framework/protocol that is built on top of the existing main chain (L1). The goal of an L2 solution is to improve the throughput and scale of the main chain without altering the underlying structure of the blockchain. This process is known as ‘off-chain’ scaling.
L2 solutions create a secondary framework that allows transactions and processes to take place independent of the main chain as a second layer. In short, the first layer provides the security and continuity of the ledger while the second layer allows for a higher throughput.
The Scalability Trilemma
The Scalability Trilemma is the ratio between decentralisation, scalability and security. Each concept is regarded as a core ideology behind the blockchain protocol. Finding a balance between all three is essential in order to maintain the legitimacy of a blockchain as a decentralised, secure and practical means of transferring wealth.
Here are a few examples for each side of the trilemma:
- Bitcoin and Ethereum are examples of secure and decentralised projects, but in their current forms lack scalability.
- The XRP Ledger and Stellar are examples of secure and scalable projects, but lack decentralisation.
- NANO and VeChain are decentralised and scalable but lack the security of the other projects.
The Scalability Trilemma is sometimes known as ‘Vitalik’s Trilemma’ due to an interaction that co-founder of Ethereum, Vitalik Buterin, had on Twitter in 2018 with Nouriel Roubini, an American economist.
Umm… the scalability trilemma was about scalable blockchains, not PoS; those are two separate topics. And the trilemma was never an impossibility result, it was claiming that getting 3 of 3 is *hard*.
— vitalik.eth (@VitalikButerin) October 10, 2018
The main issue facing DeFi at the moment is the scalability of the Ethereum network, on which a large portion of DeFi protocols are built.
Layer 2 Solutions: Rollups
You may have heard of Optimistic and ZK-Rollups in the context of Ethereum Layer 2, but what is a Rollup? A Rollup is an off-chain aggregation of transactions verified by an on-chain smart contract. During the process, transactions are rolled up. By bundling these transactions off-chain and then settling them on the main chain at some point in the future, fees and congestion can be reduced by increasing throughput of the network. The computations are handled off-chain while only state transitions are registered on the main chain.
In order to ensure security, guarantees are made that transactions will not be misused, and will eventually be settled on the Layer 1 blockchain. Data is published periodically on-chain so that any outside observer can reconstruct account balances and detect invalidity. Rollups require operators to stake a bond in the Rollup contract similar to the Proof-of-Stake concept. This incentivises the correct execution and verification of transactions.
An Optimistic Rollup is a type of L2 solution that does not do any computation by default. Instead, it proposes a new state to the main chain. This means that although transactions are handled separately to Ethereum, they are essentially signed off or notarised as valid. They are then added to the main network after a set period. I’ll explain why this is necessary later.
The computation of transactions is a slow and expensive interaction with the Ethereum network. Optimistic Rollups allow for up to 100 times improvements in scalability by removing this computational strain and handling transactions outside of the main network.
The term ‘Optimistic’ comes from the fact that aggregators run computation off-chain while only publishing the absolute minimum information required to reconstruct the transaction. The assumption is made that all transactions are valid by default. Therefore, they are ‘optimistically’ publishing transaction results without actually executing those transactions on Ethereum. Proof is only provided in the case of a disputed transaction. Hence, it utilises the ‘fraud-proof’ security model.
Anything that can be handled on Ethereum Layer 1, including both simple transactions as well as smart contracts, can be controlled with Optimistic Rollups. They are compatible with the Ethereum Virtual Machine (EVM) used by Ethereum. I’ll explain what this means later.
Synthetix has integrated L2 staking utilising the Optimistic Ethereum network. It has allowed SNX holders to stake with a substantial reduction in fees. Additionally, there are no fees for claiming rewards.
Since Optimistic Rollups don’t compute transactions, a mechanism for ensuring transactions are indeed legitimate and fraud-free is essential. This mechanism guarantees the security of, and confidence in, the L2 solution and the underlying blockchain.
Here is how it works:
If a fraudulent transaction is noticed, the rollup will execute a fraud-proof and run the computation using the available state data.
This process costs gas because you are now using the main chain to run the equivalent computation and to check if the transaction is valid.
If fraud is proven, the gas cost for running a fraud-proof, as well as an additional forfeit, will be taken from the operator’s bond.
Think of the analogy of perjuring yourself in a court proceeding. The L2 node operator has sworn to tell the truth and nothing but the truth. If it is proven that they have not told the truth, they will be punished in the form of losing some or all of their bond, depending on the severity of the offence.
Wait times for an on-chain transaction can be quite long due to potential fraud challenges outlined above. This reduces the speed of the solution when compared to ZK-Rollups. Even so, all transaction data is stored on the main chain making it more secure and decentralised.
ZK-Rollups are another option for L2 construction. ‘ZK’ stands for ‘zero knowledge proof’, which reduces computing and storage requirements for validating blocks on the main chain. Computing requirements are still necessary for processing the transactions on the second layer. This is done by reducing the amount of data held in a transaction. Zero knowledge of the entire data is required to validate the outcome.
Imagine a high-rise building. You can fit a lot more rooms (transactions) in the same area of land (blocks) using a high-rise compared to having the same number of rooms spread across multiple houses. This means less infrastructure is required to maintain the same amount of living space.
ZK-Rollups bundle hundreds of transfers into a single transaction off-chain, generating a cryptographic proof called a Succinct Non-interactive Argument of Knowledge (SNARK) in the process. This is known as the ‘validity proof’ security model. The SNARK proof compares a snapshot of the sidechain before and after any transfers to that of the sidechain. It reports any change in the state of the hash to the main chain.
The ZK-Rollup contract maintains the state of all transfers that happen on Layer 2 without needing to store the transaction data. This state can only be updated with a validity proof. As a result, validating blocks on the main chain is quicker and cheaper than with Optimistic. The reason is that less data is included in each block. Also, there is no delay when moving funds from Layer 2 to Layer 1 since all of the transactions are pre-verified.
In their current form, ZK-Rollups are not compatible with the EVM and can only handle payment and transfer type transactions. Additionally, validity proofs are process-intensive because validation still needs to occur even if it is off-chain. Thus, applications with lower on-chain activity would be better matched with another solution.
It is important to note that any and all L2 solutions including ZK and Optimistic Rollups are able to run at the same time and can interact with the Ethereum blockchain as they please. This is the beauty of Layer 2 solutions. They are adaptable and can easily be upgraded or changed without affecting the fundamentals of the underlying blockchain they were built to interact with.
Side Note – Ethereum Virtual Machine
We have mentioned the EVM twice now. But, what is it? In its most basic form, the EVM is the state machine of the Ethereum blockchain that allows smart contracts and applications to be created, maintained and executed.
Simple monetary transactions such as the transactions carried out on the BTC network are easy enough to keep track of as they are essentially just numbers moving around wallets. However, since Ethereum is capable of application-based activity, there must be a way of handling these complex conditions throughout the whole existence of the blockchain. This is what the EVM does. It is the core innovation that has made Ethereum suitable for DeFi applications and protocols.
Labelling itself “The Internet of Blockchains”, Polygon is a project that aims to address Ethereum’s scalability problem with the use of a Proof-of-Stake secured sidechain. It does this in conjunction with Layer 2 solutions – ZK and Optimistic Rollups, and Plasma chains. The idea is to turn Ethereum into a scalable multichain network.
Currently, most blockchain ecosystems operate completely isolated from other blockchains. Polygon aims to blur the lines between blockchains by implementing a user friendly, developer friendly method whereby different chains can utilise their Layer 2 solution. This change would allow for blockchain interoperability.
Boasting up to 65,000 transactions per second, Polygon chains use Ethereum as a base layer in order to leverage its security (and popularity). That said, varying levels of dependency on the Ethereum base layer are available depending on the needs of the client DApp.
Polygon is also compatible with the Ethereum Virtual Machine. This means that developers already accustomed to programming Ethereum DApps do not have to learn new processes.
Conceivably, Layer 2 solutions will alleviate network congestion before Ethereum 2.0 can be fully implemented. Still, this is not just a temporary fix. Development of these solutions will also dramatically magnify the scalability that Ethereum 2.0 will bring in the future. They could allow the benefits to be stacked which is extremely exciting for the future of the Ethereum network and the DeFi projects it supports.
Post a Comment