Layer 2 Solutions Explained: Complete Guide
Rollups, sidechains, and the quest for scale. Learn how Ethereum extends without sacrificing security.
🎯 What You'll Learn
- Understand why Layer 2 exists
- Learn the different L2 approaches
- Know optimistic vs ZK rollups
- Compare L2 security models
- Choose the right L2 for your use case
📚 Prerequisites
Before this lesson, you should understand:
The Scaling Problem
Ethereum processes ~30 transactions per second. Visa does ~65,000. To achieve mass adoption, blockchains must scale.
Layer 2 solutions process transactions off the main chain while inheriting its security.
Layer 1 vs Layer 2
| Layer 1 (Ethereum) | Layer 2 | |
|---|---|---|
| Security | Direct | Derived from L1 |
| Speed | ~30 TPS | 1,000-10,000+ TPS |
| Cost | $5-50/tx | $0.01-0.50/tx |
| Finality | ~15 min | Seconds (soft) → L1 (hard) |
Fast, cheap → Batch & Compress → Post to L1
Final security
Types of Layer 2
1. Rollups
Rollups bundle transactions and post data to L1:
| Type | Proof | Finality |
|---|---|---|
| Optimistic | Fraud proofs (challenge period) | ~7 days |
| ZK | Validity proofs (cryptographic) | Minutes to hours |
2. State Channels
Direct peer-to-peer channels:
- Fast for repeated interactions
- Limited to participants
- Example: Lightning Network
3. Sidechains
Separate chain with own consensus:
- Fast and cheap
- Less secure (own validator set)
- Example: Polygon PoS
4. Validium
ZK proofs but data stored off-chain:
- Very cheap
- Data availability risk
- Example: StarkEx
Optimistic Rollups
Assume transactions are valid, allow challenges.
Challenge period: Anyone can submit fraud proof if batch is invalid.
| Rollup | Status | TVL |
|---|---|---|
| Arbitrum | Live | $8B+ |
| Optimism | Live | $5B+ |
| Base | Live | $2B+ |
Pros & Cons
| Pros | Cons |
|---|---|
| EVM compatible | Long withdrawal time (7 days) |
| Mature technology | Fraud proof game theory |
| High throughput | Centralized sequencer (current) |
ZK Rollups
Prove validity using zero-knowledge proofs.
| Rollup | Status | EVM? |
|---|---|---|
| zkSync Era | Live | Yes |
| StarkNet | Live | No (Cairo) |
| Polygon zkEVM | Live | Yes |
| Scroll | Live | Yes |
Pros & Cons
| Pros | Cons |
|---|---|
| Fast finality | Complex technology |
| Cryptographic security | Expensive proof generation |
| Faster withdrawals | Less mature |
Security Comparison
| Solution | Security Model | Data Availability |
|---|---|---|
| Optimistic Rollup | L1 + fraud proofs | On L1 (calldata) |
| ZK Rollup | L1 + validity proofs | On L1 |
| Validium | Validity proofs | Off-chain |
| Sidechain | Own consensus | Own chain |
Key insight: Rollups inherit L1 security. Sidechains don’t.
Using Layer 2
Bridging Assets
1. Connect wallet to bridge
2. Deposit ETH/tokens on L1
3. Wait for confirmation
4. Assets available on L2
Important: Each L2 has its own bridge. Withdrawals may take time (especially optimistic rollups).
Gas on L2
L2s still use gas, but much cheaper:
| Operation | Ethereum | Arbitrum |
|---|---|---|
| ETH transfer | $2-10 | $0.01-0.05 |
| Swap | $20-100 | $0.10-0.50 |
| NFT mint | $30-150 | $0.20-1.00 |
Practice Exercises
Exercise 1: Calculate Savings (Beginner)
You do 100 swaps/month.
- Ethereum: $30/swap
- Arbitrum: $0.30/swap
Monthly savings?
Answer
Ethereum: 100 × 3,000 Arbitrum: 100 × 30 Savings: $2,970/month
Exercise 2: Security Analysis (Intermediate)
Compare withdrawing from:
- Arbitrum (optimistic rollup)
- zkSync (ZK rollup)
- Polygon PoS (sidechain)
What are the risks and timeframes?
Answer
- Arbitrum: 7 day dispute period, but L1 secured
- zkSync: Fast (hours), proof verified on L1
- Polygon PoS: Fast, but own validator set-bridge exploits possible
Exercise 3: Design Question (Advanced)
Why do optimistic rollups have a 7-day challenge period? What would happen with 1 day?
Knowledge Check
-
What problem does Layer 2 solve?
-
What’s the difference between optimistic and ZK rollups?
-
Why are sidechains less secure than rollups?
-
What is the 7-day challenge period for?
-
Where is transaction data stored in rollups?
Answers
-
Scalability. L1 can’t handle enough transactions cheaply. L2 processes off-chain, posts proofs to L1.
-
Optimistic assumes valid, allows fraud challenges. ZK proves validity cryptographically-faster finality.
-
Own consensus. Sidechains don’t inherit L1 security. Rollups post data/proofs to L1.
-
Fraud proof window. Anyone can challenge an invalid batch. After 7 days, it’s finalized.
-
On Layer 1 (as calldata). This ensures data availability-anyone can reconstruct state.
Summary
| L2 Type | Security | Finality | EVM |
|---|---|---|---|
| Optimistic Rollup | L1 inherited | 7 days | Yes |
| ZK Rollup | L1 inherited | Hours | Varies |
| Sidechain | Own validators | Fast | Yes |
What’s Next?
🎯 Continue learning:
- What Is MEV? - MEV on L2
- Gas Fees - L2 economics
You now understand how Ethereum scales without sacrificing security. 🚀
Questions about this lesson? Working on related infrastructure?
Let's discuss