The term Layer 1 refers to the underlying blockchain architecture in the blockchain ecosystem. However, transaction speed suffers when the mainnet gets busy, causing costly transactions to the end users. Within the past couple years, Layer 2 scaling solutions were created to increase transaction throughputs and lessen transaction fees.
Layer 2 is an overlying network built on top of the underlying Layer 1 blockchain. Layer 2 solutions require no changes to the Layer 1 blockchain or mainnet. Layer 2 solutions still leverage the security of the consensus mechanism on the Layer 1 network, but they can drastically speed up transactions by handling them off the mainnet.
Ethereum’s Layer 1 can handle about 15 transactions per second while some Layer 2 projects can ramp this up to 4,000 transactions per second. Scalability upgrades to the Layer 1 Ethereum network are slated for the coming years, and Layer 2 will prevent decentralized applications (dApps) from leaving Ethereum in search for a network with less expensive transaction fees.
Optimistic Rollups vs. ZK-Rollups
Rollups are some of the most promising Layer 2 solutions as they offload transactions on the Ethereum mainnet to their own independent blockchain networks. Two types of rollups currently exist — Zero Knowledge (ZK) and Optimistic. The main difference in them is their process of verifying transactions.
ZK-rollups: ZK-rollups process multiple transfers off the Ethereum mainnet. These transfers are then bundled into a single transaction and posted to Ethereum’s Layer 1. This process reduces the volume of transactions and the amount of data being processed on the Ethereum mainnet, enabling cheaper and faster transactions. When a ZK-rollup is submitted, it is validated at the same time.
Optimistic rollups: Optimistic rollups are similar to ZK-rollups, except that they assume transactions are valid by default. They only run computations in the event the integrity of a transaction is challenged.
How Do ZK-rollups Work?
ZK-rollups use a cryptographic verification known as a zero knowledge (ZK) proof. In a ZK proof, one party (prover) can prove to another party (verifier) that something is true without giving any additional information. This works because the verifier asks the prover to do things that can only be done if the prover definitely knows the secret. If the prover knows it, it can be done; if the prover does not, it cannot be done.
Let's take a look at a tennis analogy to better understand ZK proofs:
The prover and verifier are playing tennis against each other on opposite sides of the net. The prover is trying to prove that they are good at tennis to the verifier.
- The prover hits the ball to the verifier.
- The verifier sends a random return back to the prover — random speed, location, amount of spin.
- The prover must return the ball to a targeted spot on the court. If the prover hits the target, the verifier classifies them as a good tennis player. If they do not hit the mark, they are classified as a bad tennis player. The verifier did not receive any information on the prover, yet was able to verify they are a good tennis player.
How Do Optimistic Rollups Work?
Optimistic rollups automatically assume transactions are valid. However, you can go back and check if the transactions aren't valid, and if they aren't, you can submit fraud proof, which recognizes the transaction as invalid. Therefore, you are being optimistic that the transactions are valid.
Optimistic rollups assume transactions are valid until proven otherwise; ZK-rollups use validity proofs to instantly prove if transactions are valid or not. Therefore, ZK-rollups are more efficient.
Smart Contracts and Gas Fees
A smart contract is an automatically executing transaction on the blockchain that is unalterable once signed by a user. On Ethereum, a smart contract is essentially a block of code, which is what makes it automatically execute. A good analogy to a smart contract would be a vending machine. When you put in money and input what item you want, you automatically get that item.
However, to interact with an application on Ethereum, you will need to pay a gas fee for the computational power required to execute it. Smart contracts are the code that makes up decentralized applications (dApps) on Ethereum. Computational power is the ability of a computer to perform work, and gas is a unit of measure for computational power.
Not all transactions on the blockchain are equal, so gas fees aren’t always the same. A good analogy to compare it to would be gas for a car versus a semi-truck. Cars require less gas as they are lighter in weight and have much smaller engines. On the other hand, semi-trucks require more gas to power them as they are heavy and have larger engines.
Comparing this to the blockchain; larger transactions will require larger gas fees and smaller transactions will require smaller gas fees.
On Ethereum, gas fees are paid in Ether. The more complex your contract, the more gas (ETH) it requires. One of the biggest criticisms of Ethereum is its high gas fees. When the Ethereum mainnet gets congested, the price of gas fees increases. If 100 people are trying to perform a transaction on the blockchain at once, the gas fees will be significantly higher than if only a few people are trying since Ethereum can only handle about 15 to 30 transactions per second. At times, Ethereum gas fees have gotten as high as triple digits. Layer 2 solutions can increase transaction speed and lower fees, which is a huge reason they have become more prominent.
Comparing Optimistic Rollups: Arbitrum L2 vs. Optimism L2
Both Arbitrum and Optimism are Layer 2 Optimistic rollups, meaning they handle transactions on their network and post them on the mainnet as well as use fraud proofs. However, they have their differences, especially when it comes to how the technology resolves a dispute on Layer 2.
For starters, Optimism relies on the Ethereum Layer 1 Ethereum virtual machine (EVM) in order to execute an entire transaction. When the Ethereum mainnet is congested, it affects the efficiency of Optimism. When transactions are disputed, Optimism re-executes disputed transactions on Layer 1 and checks which party is correct in their assertion. However, Optimism needs to port a large amount of data to Layer 1 to compute the disputed transaction and resolve it.
Arbitrum, on the other hand, has its own virtual machine (AVM). The Arbitrum team realized that the process of re-executing disputing transactions can contribute to network congestion significantly. Instead, Arbitrum continuously subdivides the challenge until the disputed information is so small that it can be quickly sent to and resolved on Layer 1.
The Optimism Foundation, the team behind the Optimism protocol, invented optimistic rollups, so people may buy the OP token to bet on the success of the network. However, it’s more technically the governance token for the Optimism protocol.
Polygon Compared to Optimistic Rollups
Polygon increases transaction speeds and reduce fees on the Ethereum blockchain by handling them off the mainnet. Although, each one is a little different in their own way.
What sets Polygon apart from Arbitrum and Optimism is it security mechanisms. Arbitrum and Optimism are secured by the Ethereum base layer. Polygon has its own token (MATIC) and is secured through a proof-of-stake (PoS) consensus mechanism. While Optimism has a native token (OP), it acts as a governance token. Additionally, Polygon is a sidechain, meaning its a completely separate blockchain that runs on top of Ethereum.
Comparing ZK-rollups: Polygon Hermez vs zkSync
Another kind of Layer 2 is zkEVM, which is an EVM-compatible virtual machine that supports ZK proofs. EVM stands for Ethereum Virtual Machine, and it's what allows developers to create smart contracts in the coding language Solidity on Ethereum. Since zkEVM’s use ZK proofs, they prove transactions correct upon execution. ZkEVMs are EVM-compatible because they can run smart contracts on the EVM network with little modification.
Polygon Hermez is a Polygon project building a type 2 zkEVM. What this means is that it strives to be EVM equivalent but not exactly Ethereum equivalent. Being EVM equivalent means that the underlying architecture is similar to Ethereum’s base layer. Vitalik Buterin, the founder of Ethereum, described the goal of type 2 zkEVMs as: “to be fully compatible with existing applications, but make some minor modifications to Ethereum to make development easier and to make proof generation faster.” Type 2 zkEVMs make changes to Ethereum's data structure; however, the EVM is not able to directly access these structures, which means that applications would almost always work. Polygon Hermez improves EVM compatibility with a virtual machine using SNARK and STARK proofs to verify the validity of an execution.
zkSync is a type 4 zkEVM. Type 4 zkEVMs take complicated code for smart contracts and compile it to be ZK-snark friendly. This is beneficial because compiling from high-level languages can save costs and make being a prover easier. Similar to Polygon Hermez, zkSync achieves EVM compatibility at the coding language level.
Buterin tweeted about a post on his blog about the different types of zkEVMs.
Transactions per Second
One of the main reasons Layer 2 cryptos were developed is because Ethereum's mainnet can only handle about 15 transactions per second (TPS). Layer 2s take transactions off of the mainnet, allowing for more transactions per second on the Layer 1 Ethereum blockchain. Below is a breakdown comparing TPS for Polygon, Arbitrum, Optimism, Polygon Hermez and zkSync.
- Polygon: 65,000
- Arbitrum: 40,000
- Optimism: 2,000
- Polygon Hermez: 2,000
- zkSync: 2,000
What Will Happen to Layer 2s Once the Merge is Deployed?
The Ethereum Merge is set to launch in September. However, the merge won't be completed for a couple of years. The merge will make sharding possible as well as put an end to mining. Sharding will allow for future scalability. However, according to Ethereum’s website, the Merge will not result in lower gas fees or faster transaction speeds. Ultimately, the upgrade will change Ethereum’s consensus mechanism from proof of work (PoW) to PoS. The Merge is a significant step in the goal of increasing scalability, sustainability and securitization.
One of the main benefits of Layer 2 solutions is increasing scalability with faster transactions and lower gas fees, so the upgrade is already raising questions of whether Layer 2 solutions will still be needed.
Layer 2 solutions aim to enhance Ethereum and make it more efficient. Although the update will make Ethereum’s mainnet more efficient, it still will only be able to handle so many transactions per second, especially as the blockchain grows and gets more widely adopted. After the Merge, Layer 2s will likely still coexist with Ethereum and continue to make Ethereum more efficient.
What’s the Safest Layer 2?
Rollups are considered secure because of their on-chain data availability. However, ZK-rollups are considered more secure considering they use a cryptographic verification in real time. ZK-rollups are verified to the Layer 1 blockchain ledger faster than optimistic rollups because there is no time gap in which they have to wait to confirm the legitimacy of their transactions. Compared to ZK-rollups, Optimistic rollups excel in the fact that they can run smart contracts directly on the Layer 1 blockchain.
ZK-rollups are not often targeted; however, they have been hacked before. Layer 2s, as well as other crypto projects, will plan attacks to find holes in their platforms and reward hackers to improve security.
How to Bridge Crypto to a Layer 2
You can bridge your crypto to Layer 2 using a crypto wallet. Once you have your crypto wallet set up, you will want to head to the desired Layer 2’s gateway. Most bridges are pretty similar and follow the same method to bridging to Layer 2. Let's take a look at Optimism’s gateway. Once you arrive at the gateway, connect your wallet. Then you input the desired amount of ETH you would like to bridge and press deposit.
After, you will be asked to pay a gas fee to process your transaction. If you confirm your gas fee, your bridging process should be pending. The transactions will not be complete until the deposit time is complete. The amount of time varies for different bridges, but for Optimism, it's about five minutes. Additionally, most Layer 2’s have a challenge period, which is a time period required for withdrawals; the challenge period for Optimism is 7 days. During this time, Optimistic rollup Layer 2s check for fraud proofs. ZK-rollups face no challenge period.
Current Crypto Prices
Since reaching all-time highs in November 2021, crypto prices have seen a significant drop. In November, Bitcoin saw its all-time high of over $69,000, and Ethereum saw its all-time high of over $4,800. However, in June of this year, Bitcoin and Ethereum hit their 52-week lows. Bitcoin saw a price of $17,601.58, and Ethereum saw a price of $883.15. Recently, both tokens have been able to rally, putting Bitcoin around $24,000 and Ethereum around $1,900 as of this writing.
Is it Worth it to Use a Layer 2?
Layer 2 solutions are important because they allow for scalability and lower gas fees. These are crucial to the Ethereum ecosystem, especially since the Surge has not yet been deployed. The Surge is an upgrade coming after the Ethereum Merge that will effect Ethereum transactions speeds.
When there is a benefit there is usually a cost. In this case Layer 1s provide better security as well as more dApps; however, they have substantially higher gas fees.
Frequently Asked Questions
Is Polygon (MATIC) a Layer 2?
Yes, Polygon (MATIC) is a Layer 2 solution on the Ethereum blockchain.
What is Ethereum sharding?
Ethereum sharding splits the Ethereum network into smaller portions known as shards.
What’s a ZK-rollup?
ZK-rollups use a cryptographic verification known as a ZK proof. ZK-rollups move transactions off Layer 1 to Layer 2 and generate ZK proofs for every bundle.
What’s a Optimistic rollup?
Like ZK-rollups, Optimistic rollups moves transactions off Layer 1 to Layer 2 while assuming transactions are valid.