Thanks for signing up.
We'll see you soon 👋
We'll see you soon 👋
With Ethereum's price soaring over the psychological threshold of $1,000, sending a single transaction to Ethereum's chain (L1) is becoming prohibitively expensive. The figure below depicts the average transaction fee of an Ethereum transaction in USD throughout the past year. At the time of writing the average transaction fee is over 5$ per transaction (not too bad), but a few days ago we almost reached the 18$ mark. If you are a regular Ethereum DApps user these days your ETH balance may be suffering trying to fund all of your transaction; if, on the other hand, you are a blockchain startup subsidising the transaction fees of your thousands of users, well... I wouldn't be surprised if you are bankrupt by now.
Fortunately, this is a well-known limitation of the Ethereum network, along with its scalability, and as such there are already schemes in place to circumvent these issues in the shorter and longer term. Allow me to welcome you to the fascinating world of Layer 2 (L2) improvements.
The term "Layer 2" is used to refer to any solution or protocol designed to help scale Ethereum applications. They are called Layer 2 solutions because they complement Ethereum's core protocol, i.e. the Layer 1,. Their use doesn't require any change over the base protocol (no forks or node updates required). The main goal of Layer 2 solutions is to minimise the number of transactions that an application needs to commit to the Ethereum blockchain for its right (and secure) operation. This has several interesting consequences:
L2 solutions pave the way to Ethereum's scalability. They offer an infrastructure on top of the network to scale without compromising its base decentralization and security, and avoiding breaking changes in the core protocol right away (enabling a progressive migration).
All L2 solutions are based on the same principles. They build an infrastructure on top of Ethereum which accepts user transactions, validates them, aggregates them, and commits them to Layer 1 (i.e. Ethereum's main chain). The aggregation of transactions is done in a way where they can still be individually verified once they are anchored to mainnet. Thus, L2 transactions can be considered secure and immutable the moment the L2 batch they belong to has been anchored to mainnet. The specifics of how this is done varies substantially among L2 solutions, but let's have a look at two wide-spread L2 solutions to understand their operation in detail.
Rollups are solutions that bundle (or "roll up") sidechain or off-chain transactions into a single transaction that is then committed to L1. To secure all of these bundled transactions, and to make them individually verifiable, a cryptographic proof is generated from the bundle. In the early days, this proof could be something as simple as a Merkle Proof, but with the recent advancements in cryptography, these proofs are now generated through zk-SNARKs (zero knowledge succinct non-interactive argument of knowledge), and other zero-knowledge constructions.
A requirement for rollups to work is to have some kind of Ethereum-compatible independent blockchain (either with a reduced number of nodes or with additional features for high-performance) responsible for handling signature verification, contract execution, etc. able to verify the validity of the transactions that are afterwards bundled for their commitment in the main Ethereum chain. L2 rollup sidechains are responsible for verification and contract execution, while the L1 exclusively stores immutably transactions' data.
Rollups are the perfect L2 solution if you want to reduce users fees (you pay fees for a single L1 transaction for each X transactions bundled from the side-chain); open participation (there are no prerequisites to start using rollups, just install your preferred sidechain compatible client, and start sending transactions seamlessly); and fast transactions throughput (bear in mind that the sidechain is in the end an independent Ethereum-compatible blockchain with its own ledger, its own consensus, and its own economy. Without any changes in Ethereum's L1 protocol we can leverage its trust while operating in a high-performant sidechain).
Actually, this approach of sharding several sidechain networks processing and bundling transactions independently, and committing them to a main chani is the core architecture proposed for Ethereum 2.0 (but lets leave Eth 2.0 for some other day).
Rollups can be classified into two types according to the security model they use:
But L2 does not live by rollups alone! Another wide-spread L2 solution used by many DApps in the Ethereum ecosystem are state channels and payment channels. Channels allow participants to transact a finite number of times while only submitting two transactions to the network on chain: one to open the channel, and another one to close it. This allows for extremely high transactions throughput without the need of side-chains or an external infrastructure. Bitcoin Lightning network and Ethereum's Raiden, which you have probably already heard about, are two well-known L2 solutions based on channels.
This L2 solution is really useful if your app needs to perform lots of state updates (like in micropayments or games). The only thing to keep in mind before using channels is that they can only be used when the number of participants are known upfront, and if we can be sure participants will be available throughout the life of the channel.
Channels work as follows:
There are infinite ways of implementing these channels, but according to their complexity, they are usually categorized in these two types of channels: payment channels (simpler and only used to deal with payments, these are the ones used in Bitcoin); state channels (more complex and able to support more complex computations and not just payments, these are used for complex applications such as games).
Finally, to learn the details about channels, I highly recommend checking this simple Solidity example that explains how to build your own micropayments channels for Ethereum. If you are not afraid of code, this is the perfect way to get your hands dirty and deeply understand how channels work.
You may be wondering, all L2 solutions are rollup or channel-based? Well, not exactly. There are hybrid solutions, more complex constructions of optimistic and ZK rollups, full-fledged sidechains and much more. But I think this is enough for now. If you want to keep learning about L2 solutions in my absence take a look here and here. I hope that if you've made it this far you're not as scared about Ethereum's transaction fees and its scalability limitations anymore. Remember, there is alway an elegant L2 solution for everything 😎 See you soon with more blockchain related posts!
Engineers who find a new job through Golang Works average a 15% increase in salary.Start with GitHubStart with TwitterStart with Stack OverflowStart with Email