Ethereum Layer 2: The Complete Guide
Learn at last about Ethereum's off-chain scalability
by Antonio Fernández from beToken Research
Tired of the astronomical transaction fees on Ethereum today? Bored of waiting hours to see your transactions completed on the Mainnet? Ethereum certainly currently has major scalability issues. Their PoW consensus isn't holding up well in the face of exponentially growing network usage... However, we know there's a lot of work being done to fix this.
While we wait for the slow transition from PoW to PoS that Eth2 will entail, we see the emergence of different projects that improve the scalability of Ethereum, acting in parallel with the blockchain. These protocols are known as Layer 2, and promise a future of low gas and transaction costs. However, it is very likely that, trying to inform yourself about them, you have entered fully into a world of complex cryptographic techniques and endless strange terminologies, and you have been forced to disconnect and forget about the subject...
Don't worry, tokener. Here we provide you with a comprehensive guide to finally learn about these exciting scaling solutions, which promise to help Ethereum become the blockchain of blockchains.
Ethereum's scalability issues
Ethereum, the platform that popularized Smart Contracts, is undoubtedly, along with Bitcoin, one of the largest and most relevant blockchains in the crypto ecosystem. However, the fact that it has so many users, and so many decentralized applications built on top of it, has led to a serious scalability problem.
The reason is simple, Ethereum's consensus mechanism, Proof of Work (PoW), does not scale properly as network utilization increases. Without going into detail about this consensus mechanism (you can find more information in my Blockchain Basics article), it is a very secure and highly decentralized way of creating and adding blocks to the blockchain. However, as of today it only allows Ethereum to process about 16 transactions per second (you can see this Ethereum data and the others I talk about in this section updated daily on Etherscan).
This, with the 1,500 million daily transactions that take place in Ethereum, which vary from simple transfers to updating the status of Smart Contracts in the blockchain, suppose an enormous congestion of the network, which implies that transactions often take a long time. considerable to complete, and, what most people are most concerned about, they cost an overwhelming amount of money.
The latter is due to gas, a very important Ethereum issue in the discussion of this article. This is a variable that is associated with a certain price in Ethers, depending on network congestion. When a transaction is going to be carried out on the network, it can be more complicated than a simple transfer of money. It could be the call of a function and interacting with the state of a Smart Contract, updating several of its internal variables by performing mathematical operations.
Therefore, the more computationally demanding a transaction is, the more gas it requires, and therefore the more money it costs to perform it, which must be paid for it in the form of a transaction fee. Sadly, with the current congestion on Ethereum, even a simple money transfer costs a pretty penny. On a typical day, the average transaction price can vary between 10 and 60 dollars paid in ETH.
This implies that the average user is less and less interested in interacting with Smart Contracts in Ethereum, since it is too expensive for them. And how do you intend to solve this?
Major scalability solutions
This powerful weakness of Ethereum has been one of the main reasons for the rise of Altcoins (Alternative Coins) and their different Proof of Stake (PoS) protocols, many of them seeking to be more scalable, cheaper and more efficient than the blockchain they host. to ETH. Ethereum, to keep up with them, has been developing different scalability solutions that allow it to increase the transactions per second of the blockchain, and thus reduce waiting times and gas costs to levels that compete with its rivals Altcoin. Of course, without compromising security and decentralization, of which Ethereum has always boasted. The two work fronts of Ethereum are:
On-chain scalability: Eth2. The many blockchain developers plan, in the not too distant future, to move from the PoW consensus system to PoS, in a process known as The Merge. Next, they will increase the storage capacity of the blockchain by sharding, that is, dividing this load into 64 blockchains called Shards connected to a main Beacon Chain. If you want to know more about Eth2, I recommend you to visit this web page. Or maybe you want to wait until one of my next articles…
Off-chain scalability: Layer 2. In the hands of different development teams, numerous projects have emerged that seek to reduce the burden of Ethereum transactions by executing them outside the blockchain, that is, off-chain. They are known as Layer 2 because they basically function as a second layer for Ethereum, which is called a Layer 1 platform. In the following sections, we will delve into the intricate world of these off-chain scaling solutions, describing some of the projects most relevant of the three main types of Layer 2: Rollups, Sidechains, and Channels.
The Channels
Channels are a specific Layer 2 scalability solution for cases where a defined set of Ethereum users want to make a large number of transactions between them. It should be noted that there are two types of Channels: State Channels and Payment Channels. To understand how Channels work, let's dig into the first case.
State Channels
Suppose two Ethereum users want to play tic tac toe on the blockchain. To do this, they create a multisig Smart Contract (a Smart Contract that has the signature of the two users, and recognizes them) whose status represents the different positions of a three-in-a-row board. To update the state (make a move), users must send transactions to the Smart Contract, which interprets them as placing a mark on the game board. In addition, to participate in the game, the two users must deposit a certain amount of ETH in the contract, which the winner of the game will take away.
It looks like an interesting game, and the whole process will be done in a secure and decentralized way on the Ethereum network. However, there is a “small” problem: updating the status requires a transaction, so not only would users take forever to finish the game, but they would also spend a fortune in transaction fees.
This is where the State Channels come in. The idea is as follows: the two users also create the multisig Smart Contract with their signatures, depositing in it a balance of ETH that the winner will take. However, once created, they play the game off-chain, that is, they make as many transactions as they want that update the state outside of Ethereum. When they have finished the game, the two users sign the result, and send it back to the Smart Contract, which, based on what is obtained, verifies that the state is signed by the two users, and then sends the ETH To the winner.
The big difference from the previous case is that only two transactions are carried out in Ethereum: the creation of the Smart Contract, and the completion of it that sends money to the winner. This greatly reduces the cost of playing the game, and intermediate transactions are completed much faster, as they are not limited by Ethereum's 16 transactions processed per second.
Payment Channels
Once the concept of State Channel is understood, Payment Channels are exactly the same, only with the simplification that instead of updating a state, users' ETH balances are updated. These can send each other as many transactions as they want, as long as the final transfer does not exceed the ETH initially deposited in the Smart Contract.
Aspects to consider
Raiden Network
The Raiden Network is basically a network of interconnected Payment Channels that runs parallel to Ethereum and supports any ERC-20 token circulating on its Mainnet. Part of the basic concept of the Payment Channel, which allows two users to exchange their money balances bilaterally in an almost unlimited way, as long as the total balance does not exceed their ETH deposit in the Smart Contract. However, this does not allow one of the users to send transactions to a third person who does not belong to the Channel.
Instead of opening a new Channel with that person, which would be very expensive, and would require another deposit of ETH in the new Smart Contract, Raiden Network relies on the fact that the transaction can be sent as long as there is a valid path for it to follow. through a network of Channels connected to each other.
Thanks to this, each Raiden Network node does not have to be connected to all the other nodes, but to the necessary ones so that there is always a path for transactions from one of the network nodes to another. To guarantee security, payments are encrypted with cryptographic proofs, called balance proofs.
Raiden Network is still under development, and its number of nodes and channels is still small, as you can see in its explorer. However, the ambition of the Raiden Network is great, and it aims to make Ethereum, among other things, a more scalable, faster blockchain, and compatible with micropayments.
You can find more detailed information about the Raiden Network on their website.
It might also be interesting to take a look at the Lighting Network, the successful and fully functioning network of Bitcoin Channels that the Raiden Network was based on.
The Sidechains
These scalability solutions are nothing more and nothing less than entire blockchains working in parallel to Ethereum. They are connected to the main network by means of a bidirectional bridge, and they are compatible with the EVM, that is, they allow working with Smart Contracts, but beyond that they work completely independently of the main blockchain: they have their own consensus mechanism and their own transaction validator nodes, in addition to its own token.
These projects can grow independently of Ethereum, and their way of helping Ethereum scalability is basically to reduce network congestion by using those protocols instead of the main Layer 1. Being connected with a two-way bridge, the user can always easily return to Ethereum after taking advantage of a Sidechain's low gas costs and fast transaction completion.
Aspects to consider
Polygon
It is an ambitious protocol that seeks to become the Internet of Ethereum Blockchains. Similar to the Cosmos Network, Polygon offers tools to build and connect EVM-compliant stand-alone blockchains to each other, in pursuit of an Ethereum multichain future, where the main blockchain is connected to various Sidechains that perform specific functions that add value to the ecosystem. on the whole.
As you can see in these images, obtained from the Polygon website, it seeks not only to connect other Altcoin projects with Ethereum, but also its Layer 2 ecosystem. It is an extremely interesting and extensive project, so we will talk about it in one of our next articles.
Be patient, tokener… If you can't wait, here's more info.
Plasma
A more complex system than the previous Layer 2 is known as Plasma. Proposed by the co-founder of Ethereum Vitalik Buterin, and by Joseph Poon, it is an environment that allows the development of decentralized applications with their computation and data storage outside of Ethereum, on a set of parallel blockchains linked to the main blockchain.
As with the Channels, to use Plasma you have to block ETH in a Smart Contract, which basically provides access to a "secondary blockchain" in which you can carry out transactions with the funds initially deposited, which are registered in the blocks of this blockchain. This effectively implies very low gas costs and fast transaction processing once operating within a Plasma network.
Even different Plasma networks can be connected to each other, and built on top of each other, each one serving specific applications. Also, they are open networks, so transactions can be sent between anyone using Plasma.
However, this comes at a price: these mini blockchains tend to be more centralized than Layer 1, as they require an intermediary agent to add the transactions to the blocks. To guarantee the security of the plasma network, the intermediary periodically sends a piece of information about its state, called “state commitment”, to Layer 1, which can be verified by all Plasma users. If one of them discovers that the information is invalid or malicious, they can send cryptographic proof of it to the Plasma Smart Contract at Layer 1, called Fraud Proof. So the Smart Contract punishes the agent who published the invalid state, and rewards the one who discovered the fraud.
This means that, if someone wants to withdraw money from a Plasma network, they usually have to wait a long time to do so, since they have to give time for the status of the network to be verified as correct.
Aspects to consider
Currently, safe and successful Plasma applications have not yet been achieved, due to the technical complexity involved in designing a protocol based on it. However, it is worth keeping an eye out for future advances in this technology.
You can learn more about Plasma on this web page.
The Rollups
Rollups have a different approach than Sidechains and Plasma, which determines their definition: while these two types of Layer 2 perform off-chain transaction computation and storage, Rollups take a hybrid approach: they perform all transaction computation off-chain, and store transaction data on-chain.
One of the benefits of this system is that, since transactions are computed outside of Ethereum, the gas costs are much lower than those of carrying out transactions on the Mainnet. The other is the enormous security of the Rollups, since all the information of the transactions carried out in them is stored in Ethereum, so the Rollups share their security with Layer 1.
We know, therefore, that Rollups allow a user to carry out transactions faster and more expensively, safely, by never being completely disconnected from Ethereum. Now, how can you be sure that the transactions that have been processed off-chain and the information that reaches Ethereum about them are correct? The answer to this question is reached today in two very different ways:
Optimistic Rollups
These Rollups update their status and provide information about the new transactions added to Ethereum without making any computational effort to verify them. The Smart Contract stores all the information that comes to it throughout history, and is initially optimistic about the veracity and validity of the information.
Now, when a user wants to withdraw money from the Rollup, before the information of the last group of transactions is permanently stored in the blockchain and the ETH on-chain is granted, the Smart Contract waits a while. If any of the users of the Rollup discover that the group of transactions is incorrect, fraudulent or invalid, they can send a Fraud Proof to the Smart Contract. It then tries to verify the on-chain code, and if it is invalid, it reverts the Rollup state, discarding the problematic group of transactions.
As this process is associated with a transaction fee in Ethereum, in order to pay it in cases of verifying transactions, all users of the Optimistic Rollup must deposit a certain amount of ETH in the Smart Contract, which guarantees that they will not try to carry out fraudulent actions. If they get caught, they use their ETH to pay for the previous Ethereum transaction and reward users who have discovered the fraud.
This is the least complex Layer 2 technology of all, although its scalability effects are the least of all the options. However, this is enough to make this the most popular and projected Layer 2 option of all.
Aspects to consider about Optimistic Rollups
ZK-Rollups
ZK-Rollups (Zero-Knowledge Rollups) are not optimistic: they play it safe with a little more effort. Every time a new group of transactions is going to be added to the Rollup, and consequently the Smart Contract in Ethereum is updated, whoever is going to add the transactions must perform a complex and computationally demanding cryptographic operation that provides proof that the group is valid, called ZK-SNARK.
Every time the status of the Rollup is updated, a ZK-SNARK must be provided that guarantees that the update is correct. Due to this, if a user wishes to withdraw money from the Rollup, he should not wait for a Fraud Proof to be carried out, since his transaction is already verified beforehand.
However, this comes with a drawback, at least a temporary one: ZK-SNARK technology is very complex, and there is still a lot of work to be done. Because of this, support for EVM and Smart Contracts is not always available in ZK-Rollups, and are often specific to individual applications.
Aspects to consider about ZK-Rollups
You can find more information about Rollups in this article by Vitalik Buterin. Recently, he published another article, called Endgame, in which he argues that a combination of Rollups and Layer 1 are the way forward for the emergence of the ultimate blockchain. Here you have it.
In addition, the success of the Rollups against other Ethereum off-chain scalability solutions can be seen reflected in L2BEAT, a web of stats on the most relevant Layer 2 protocols. As you can see there, the Rollups ecosystem is immense, and numerous relevant projects are currently at stake, sometimes with entire ecosystems generated around them. However, we will describe these projects in another article. If you can't wait, some of the most relevant Rollup projects are: Optimism, Arbitrum, Loopring, ZKSynk, dYdX and Aztec.
Validium
If you feel like your head is going to explode, don't worry, because this is the last Layer 2 we're going to talk about in this article. Validium returns to the idea of Plasma, in which it intends to perform the computation of transactions and their storage off-chain, in a parallel blockchain controlled by a certain agent.
In Plasma, one of the biggest issues currently preventing its successful implementation is a way to control this agent. There, an incorrect state can evolve if the agent simply does not inform Layer 1 of it, since no one can then perform a Fraud Proof.
This is where Validium comes into play. It could be said that it is a combination between Plasma and the ZK-Rollups. Validium maintains transaction computation and off-chain data storage, only Layer 1 is kept up to date with ZK-SYNKs, ensuring that the state stored in Validium is always valid.
Aspects to consider
The most relevant project currently using Validium is Immutable X, a marketplace and exchange for NFTs. This is an interesting project that combines ZK-Rollups and Validium, so it will be discussed in detail in a future article, along with other Layer 2 projects.
Considering all these scalability solutions, it's easy to get confused and confuse them with each other. Luckily, this article describes an interesting way to remember the strengths and weaknesses of the different Layer 2, using a simple table:
All Layer 2 perform transaction computation outside of Layer 1 as the primary method of removing congestion from the main blockchain, while also benefiting those who perform them through high processing speed and low gas costs. However, depending on where the transaction data is stored, the security and degree of decentralization vary.
It is only a matter of time to see which section of the table will dominate in the future as the ultimate Layer 2 technology. Or, who knows, maybe the best of all Layer 2s can be combined into a multi-chain Ethereum ecosystem.
What is clear is that we will soon find ourselves in a world where the high gas costs in Ethereum will no longer be an inexhaustible source of memes, but a bad nightmare forgotten in the past…
The Research Lab is beToken Capital's Blockchain research and innovation area.
We thoroughly analyze protocols in different verticals from technological and investment strategy points of view.
Bitcoin - Ethereum - Layer 1's - DeFi - GameFi - Decentralized Art - Metaverse - DAOs
More information 👉 https://betokencapital.com/research-lab
We love to collect all opinions and points of view. Do you want to collaborate with us? Write to us at subscribers@betoken.capital
Do you want to know us more?
Disclosure:
Authors may own funds and assets mentioned in this newsletter.
beToken my Friend is intended for informational purposes only. It is not intended to serve as investment advice. Consult with your investment, tax or legal advisor before making any investment decision.
Advertising and sponsorship do not influence editorial decisions or content. Third-party advertisements and links to other sites where products or services are advertised are not endorsements or recommendations by beToken.
beToken is not responsible for the content of the advertisements, the promises made or the quality or reliability of the products or services offered in any third party advertisement or content.
If you liked this content on beToken my Friend, why don't you share it?