Basically, there are two ways to scale a blockchain. One is to work on the main chain itself to improve transaction capacity.
The other way is to change how people use the blockchain. In other words, instead of putting all the interactions on the main chain, some can go off-chain to alleviate congestion.
Sharding is ETH 2.0’s scalability solution that will take place when Ethereum moves its consensus mechanism from Proof of Work (PoW) to Proof of Stake (PoS).
Sharding is a technique that takes large chunks of computational work and splits it into smaller pieces called “shards.”
The good news is that other solutions can take some of the pressure off Ethereum now, which makes the Sharding solution less urgent.
They have five different solutions for Layer-2.
2. State Channels
4. Optimistic Rollups
Sidechains are independent blockchains that are considered more of a hybrid of Layer 2 and Layer 1. That’s because Layer 2 solutions rely on the security of the main chain. A Sidechain doesn’t do that because it has its own security properties. It also employs its own consensus mechanisms to process transactions.
To understand Sidechains remember that the Ethereum blockchain is the main chain. So if Ethereum is the main chain, then Sidechains are like sister chains. Essentially, Sidechains run alongside the main chain. Furthermore, these blockchains can communicate with each other so that assets can move between the chains.
To create a Sidechain, developers must first create another blockchain and a consensus mechanism like PoW, PoS, Proof of Authority (PoA), or Delegated Proof of Stake (dPoS).
State Channels as a way to conduct interactions off the blockchain that would normally be on the blockchain. For example, only the most important element of a chess game would get broadcast to Ethereum in State Channels—that would be the outcome.
1. Instant withdrawal/settling on mainnet.
2. Extremely high throughput is possible.
3. Lowest cost per transaction - good for streaming micropayments.
Plasma is made up of Merkle trees and smart contracts. This combination enables Plasma to create unlimited child chains, which are smaller versions of the main chain. Note that developers can build multiple chains on top of each child chain to create a tree-like structure. The smaller chains are called child chains or Plasma Chains.
Plasma is a good solution for payments and is great for dealing with non-fungible tokens (NFTs), because each unit of an asset gets a unique ID. Also, Block roots are a “pro” because they behave like “save points” on the blockchain. One of the issues with Sidechains is that the consensus mechanisms can stop producing blocks and even lock up user funds. Plasma users can call on block roots, so if the consensus mechanism stops creating blocks, users can still make claims to Ethereum to get their funds.
The Zero Knowledge Proof Rollup uses validity proofs. This means that every batch includes a Zero-Knowledge Proof (SNARK). The SNARK is cryptographic proof that proves the post-state root is correct after it executes the batch. Moreover, on-chain verification is quick regardless of the computation size.
Furthermore, ZK-Rollups have two types of users: transactors and relayers. Transactors create and broadcast their transfer to the network. Relayers create a rollup by collecting a large number of transfers and rolling them up together. Relayers are tasked with generating the SNARK proof.
Optimistic Rollups are close cousins of ZK-Rollups and have overcome the limitations that hampered Plasma, Sidechains, and State Channels in the past.
Block producers rollups transactions and post the data to Layer 1 with a signature. Everyone assumes the state transition is correct, reminiscent of how courts in the United States presume its citizens are innocent until proven guilty.
There are some complex tradeoffs when deciding between these rollups. A compression trick that ZK Rollups does is leave parts of a transaction off-chain if it’s not relevant to the state update. Optimistic Rollups can’t do this because that data may need to be checked later in a fraud-proof.
Optimistic Rollups work on the assumption that everything is okay until a whistleblower reports otherwise, while ZK Rollups makes no such assumptions. They use complex mathematics and cryptography to verify that everything is okay.
All in all, Optimistic Rollups are a promising option in the near term because they offer developers an easy way to migrate their dApps which enables Ethereum to deal with growing demand while working towards ETH 2.0.
ZK Rollups are the more sophisticated solution. For now, it can do token transfers but implementing general-purpose smart contracts will take more time. ZK Rollups will also fix some of the issues with Optimistic Rollups, like reducing withdrawal times to a few minutes and enabling fast transactions and exits in nearly unlimited amounts.