What is L2?
Layer-2s refers to off-chain scaling solutions. L2s are based on the logic of executing transactions off-chain, publishing proof, or the data of these transactions to the Ethereum mainnet. Today, L2s are being developed on various networks, primarily Ethereum.
Why do we need L2s?
One of the biggest problems with Ethereum and Bitcoin has been scalability. Scalability refers to how quickly a network can handle the increasing traffic and respond to it. When we execute transactions on the mainnet, the data of transactions are placed in blocks. The size and the producing time of the blocks vary for each blockchain. In Ethereum and Bitcoin, the size of blocks is specific, and the estimated producing time of the blocks can be guessed. This means we can calculate how many transactions can exist in one block. On average, 7 transactions can be done per block in Bitcoin, while 10-25 transactions can be done in Ethereum.
Full nodes are devices that store all existing data since the beginning of the chain. When there is a new block on a blockchain, the full nodes download the latest data and synchronize with the other nodes. Some blockchain projects may try to increase the size of the blocks or speed up block time to increase the throughput, but this will result in harder synchronization of devices and exponentially increase the amount of data you have to download to set up a full node. The exponential rise of data makes it harder to set up full nodes, and if nodes are not synchronized, they will get slashed from the network. The increased hardship of full node formation will damage the decentralization. So while scalability increases, decentralization and security will decrease. This is called the ''Blockchain Trilemma''.
The transaction per second on Ethereum and Bitcoin is currently slow, and transaction costs are high. It is not user-friendly. L2s solutions provide scalability without damaging security and decentralization.
Ethereum and L2
Ethereum's Layer 2 solutions are derived from the need to increase the scalability of Ethereum. These solutions can be listed as Plasma, State Channel, Validium, and Rollups. The foundations of the Plasma solution were first formed by Vitalik Buterin using the shadow chains idea in 2014. The first examples were designed by Vitalik Buterin and Joseph Poon in 2017. Later, it was seen that Plasma was insufficient in some cases. So, different L2 solutions such as Rollups emerged.
Plasma
Plasma is designed of smaller versions of the Ethereum mainnet, called child chains. These chains were first mentioned as shadow chains, and after that, they were called child chains.
When we think of the mainnet as on the very top, many child chains can be added under the mainnet. In fact, any number of child chains can be added under the child chains as well. Child chains forward the data they have on their chains onto the upper chain, and these data finally reach the Ethereum mainnet. Due to the design of the Plasma design, all data is considered correct. Once data is forwarded onto the upper chain, a 7-day challenge period starts. In this time, if someone were to think that the data is incorrect or fraud, they can publish a Fraud proof. So, the published proof and valid state transition will be approved by Plasma smart contract. That's why Plasma solutions have a 7-day waiting period for withdrawals.
As Vitalik Buterin has mentioned before, the Plasma solution's technology is very compatible with the uniqueness of NFTs. Also, Plasma offers more transactions per second and lower transaction costs. However, it has some disadvantages, as all solutions do.
When Plasma was first published, it was thought that it would help solve the Ethereum scalability problem. However, because it could not support EVM, could only allow simple transactions, caused mass exit problems, had long withdrawal periods, etc., more recent solutions have replaced Plasma. Gluon is one of the projects that still use the Plasma solution.
State Channel
State channel solutions use smart contracts and participation funds to execute nearly infinite transactions. These transactions only cost two upper chain transaction fees.
First, the participants lock their funds on the mainnet with a multi-signed smart contract. This is used to declare the first state. After that, the participants can run ultra-cheap and fast transactions off the chain. The resulting state is forwarded to the mainnet via smart contracts. State Channel is closed once all participants approve the final state.
Despite having high TPS and low transaction costs, this solution has some disadvantages. The fund and the time it takes to form a smart contract, the lack of EVM running, and the necessity of constant network observation are just some of them. Also, the participants have to be pre-decided, so this is not an open participation solution. Closed participation indicates that no third party is allowed to join the channel permissionless.
However, State Channel is very fit for payments. Especially for subscriptions that require a specific payment order. Because It does not run EVM or does not allow open participation, it is not considered a general solution. Because of these, there was a search for other solutions, and it was understood that Rollups provided a more general solution. Connext and Raiden are some projects that use the State channel solution.
Rollups
Rollups work by executing transactions on the rollup chain and then sending the data and proofs of these transactions onto the Ethereum mainnet. First, an operator on the rollup chain collects the transactions and executes them. Then, It sends the transaction data and, if necessary, its proofs to the smart contract on the Ethereum mainnet. Since the data is stored in the Ethereum mainnet, the Rollups will share the security with the Ethereum mainnet.
Rollups are divided into two regarding the type of proof they use: Optimistic Rollups and zkRollups. Optimistic Rollups use Fraud proofs, and zkRollups use zero-knowledge proofs(zk proofs).
Due to their mechanism, Optimistic Rollups assume that all transactions made on the chain are valid. They do not verify the validity or do not the calculations of the data sent to the smart contract on Ethereum. Instead, there is a waiting period to challenge the data sent to the mainnet. In this time, if someone were to think that the data is incorrect or fraud, they can publish a Fraud proof. So, the published proof and valid state transition will be approved by Rollup smart contract. In addition, Optimistic rollups are EVM compatibility, and they are suitable for general usage.
On the other hand, there is no waiting period on zkRollups. They are using zero-knowledge proofs. zkRollups use computing power to create a zkproof for transactions executed on the Rollup chain. Then, they publish both zkproof and data to Rollup smart contract on Ethereum mainnet. Because they use zero-knowledge proofs, there can be no fraud. Due to this, withdrawals on zkRollups are instant. However, the zkRollups' EVM compatibility is low.
Some of the Optimistic Rollups are Optimism, Metis, and Boba. Some of the zkRollups are Aztec, zkSync, and Starknet. For further information check out our Rollup issue! (Not available in English yet)
Validium
Validium solutions are very similar to zkRollups, both use zero-knowledge proofs. The most significant difference is data availability. If data is kept on the Ethereum mainnet, it is zkRollup. If data is kept off-chain, it is Validium.
Keeping data off-chain causes Validiums to no longer be at the security level of the Ethereum mainnet and creates different security assumptions. It is necessary to trust a third party that the data is always available and valid. This third party can be a committee or a decentralized storage solution. Storing data off-chain significantly reduces Rollup protocol costs because most of the cost of Rollup protocols is made up of CALL DATA calls.
Existing Starkware validium solutions rely on a committee called the DAC for data availability. If you are a user of existing Validium solutions, your funds can be frozen but not stolen. For further information check out our Validium issue! (Not available in English yet)
Bitcoin and Lightning Network
James A. Donald first suggested Bitcoin's first L2 solution. It has come a long way since its start in February 2015. Lightning Network is actually a State Channel. It was needed because of the long Bitcoin transfer periods, low transaction per second, and high transaction costs.
Just like in State Channel, users have to lock a certain amount of funding on the mainnet. Afterward, a channel can be created between two users on Lightning Network. Previously created channels can be used again too. Imagine a channel between participant A and participant B and another one between participant B and participant C. When participant A wants to send participant C Bitcoin, there is no need to create a new channel between A and C. The previously used channels can be utilized.
Lightning Network stores the transaction on its channel on its own nodes, not on Bitcoin. These nodes are called Watchtower. Watchtowers inspect transactions in order to prevent fraud and punish the channels that commit fraud. Even though this helps prevent more fraud, it lowers the network's privacy.
One of Lightning Network's biggest problems is that participants need to be always online. If one of two users is not online, the payments will not go through. Also, the network can be inadequate against spam attacks. Despite these, Lightning Network is still a big step for using Bitcoin in day-to-day payments. Currently, Lightning Network usage has not reached its adaptation levels, network developments and tests are still ongoing.
Conclusion
We know that the L2 solutions offer users cheap and fast scalability solutions. Despite that, for the L2 solution to be fully successful, it needs to be entirely accepted by the community and be actively utilized. L2 is not just specific for Bitcoin or Ethereum. If someone wishes, they could form their own L2 on any network. It looks like we will hear more of the term L2 due to the network congestion on other chains.
That’s all from L2 Planet for now, hope to see you in other issues :)