Layer 2 Scaling
Module 1 of Advanced Protocols
The Scaling Problem
Ethereum processes ~15 transactions per second. Visa processes ~65,000. This limitation comes from blockchain's core trade-off: every node must verify every transaction.
The Trilemma
Decentralization
╱╲
╱ ╲
╱ ╲
╱ ?? ╲
╱________╲
Security ────── Scalability
Traditional blockchains sacrifice scalability. Layer 2s try to have all three.
How L2s Work
Core Insight: Execute transactions off-chain, inherit L1 security.
Layer 2 (Fast, Cheap) Layer 1 (Secure, Slow)
┌──────────────────┐ ┌──────────────────┐
│ Tx1, Tx2, Tx3 │ │ │
│ Tx4, Tx5, Tx6 │──Batch───▶│ Proof/Data │
│ Tx7, Tx8, Tx9 │ │ Posted │
└──────────────────┘ └──────────────────┘
1000s of TPS 15 TPS
$0.01/tx $10/tx
L2s batch many transactions and post a summary to L1. Security comes from the ability to verify this summary on L1.
Rollup Types
Optimistic Rollups
Philosophy: Assume transactions are valid, challenge if fraud detected.
Transaction Flow:
1. Batch posted to L1
2. 7-day challenge period begins
3. Anyone can submit fraud proof if invalid
4. No challenge? Batch finalized
┌─────────────────────────────────────────┐
│ Batch Posted │ Challenge Window │ Final
└────────────────┴─────────────────────┘
Day 0 Days 1-7 Day 7+
Pros:
- EVM compatible (easy to deploy existing code)
- Lower computation overhead
- Mature ecosystem (Arbitrum, Optimism, Base)
Cons:
- 7-day withdrawal delay
- Requires active fraud watchers
- Data still on-chain
ZK Rollups
Philosophy: Prove validity mathematically, no trust required.
Transaction Flow:
1. Execute transactions off-chain
2. Generate cryptographic proof
3. Post proof + data to L1
4. L1 verifies proof → immediately valid
┌─────────────────────────────────────────┐
│ Execute │ Prove │ Verify │ Final
└───────────┴─────────┴──────────┘
Fast Slow Instant Instant
Pros:
- Instant finality (no challenge period)
- Stronger security guarantees
- More data compression possible
Cons:
- Expensive proof generation
- EVM compatibility harder (zkEVMs)
- Less mature
Major L2 Comparison
| L2 | Type | TPS | Avg Fee | TVL |
|---|---|---|---|---|
| Arbitrum One | Optimistic | ~40 | $0.10 | ~$10B |
| Optimism | Optimistic | ~40 | $0.10 | ~$7B |
| Base | Optimistic | ~40 | $0.05 | ~$5B |
| zkSync Era | ZK | ~100 | $0.15 | ~$1B |
| Starknet | ZK | ~100 | $0.05 | ~$500M |
| Polygon zkEVM | ZK | ~50 | $0.02 | ~$100M |
Values approximate and fluctuate
Data Availability
Rollups must make transaction data available so anyone can reconstruct state and verify/challenge.
Options
1. On-Chain (Rollup)
- All data posted to L1
- Most expensive but most secure
- Used by: Arbitrum, Optimism, zkSync
2. Off-Chain (Validium)
- Data stored elsewhere (committee, DA layer)
- Cheaper but additional trust assumptions
- Used by: Immutable X, some Starknet modes
3. Hybrid (Volition)
- Users choose per-transaction
- Security vs cost trade-off per use case
EIP-4844 (Proto-Danksharding)
Introduced "blob" transactions:
- Temporary data storage (~18 days)
- 10-100x cheaper than calldata
- Rollups post data in blobs
- Reduced L2 fees significantly
Bridging to L2
Deposit (L1 → L2)
1. Lock funds on L1 bridge contract
2. L2 sees deposit transaction
3. Mint equivalent tokens on L2
4. User can transact on L2
Time: ~10 minutes (depends on L2)
Withdrawal (L2 → L1)
Optimistic Rollups:
1. Initiate withdrawal on L2
2. Wait 7 days challenge period
3. Prove withdrawal on L1
4. Claim funds
Time: 7+ days (can use fast bridges)
ZK Rollups:
1. Initiate withdrawal on L2
2. Wait for next proof submission
3. Claim funds on L1
Time: Hours (depends on proof frequency)
Fast Bridges
Services that front liquidity to avoid withdrawal delays:
- Hop Protocol
- Across
- Stargate
User pays small fee, receives funds quickly.
zkEVM Types
Not all ZK rollups are created equal:
| Type | EVM Compatibility | Proof Efficiency |
|---|---|---|
| Type 1 | Full Ethereum equivalence | Slowest proofs |
| Type 2 | EVM equivalent | Slow proofs |
| Type 2.5 | EVM equiv + gas changes | Medium |
| Type 3 | Almost EVM equivalent | Faster |
| Type 4 | Compiles Solidity to ZK | Fastest |
Trade-off: More compatibility = slower proofs
- Polygon zkEVM: Type 2 (high compatibility)
- zkSync Era: Type 4 (custom compiler)
- Starknet: Type 4 (Cairo language)
L3s and Appchains
Layer 3s
L2s on top of L2s:
L1 (Ethereum)
└── L2 (Arbitrum)
└── L3 (Your App Chain)
Use cases:
- Application-specific chains
- Custom execution environments
- Further cost reduction
Appchains
Dedicated chains for single applications:
- Custom parameters
- Dedicated blockspace
- Can use any DA layer
Examples:
- dYdX (moved from L2 to Cosmos appchain)
- Immutable X (gaming-focused)
Sequencers and Decentralization
Current State
Most L2s have centralized sequencers:
- Single entity orders transactions
- Can censor transactions
- Can extract MEV
- Single point of failure
Decentralization Roadmap
Current Near-term Long-term
Centralized → Permissioned → Fully
Sequencer Sequencer Set Decentralized
Shared Sequencing
Multiple L2s share decentralized sequencer:
- Atomic cross-L2 transactions
- Reduced fragmentation
- Network effects
Security Considerations
Optimistic Rollup Risks
- Sequencer down: L1 escape hatch exists
- No challengers: Need at least one honest watcher
- Long delays: 7 days for withdrawals
ZK Rollup Risks
- Prover centralization: Most have centralized provers
- Upgrade risk: Many have upgradeable contracts
- New cryptography: Less battle-tested
What to Check
Before using an L2:
- Is there an L1 escape hatch?
- Who can upgrade contracts?
- How decentralized is sequencing?
- What's the challenge/proof mechanism?
The L2 Landscape
L2 Ecosystem
┌─────────────────────────────────────────┐
│ Optimistic Rollups │
│ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ Arbitrum │ │ Optimism │ │ Base │ │
│ └──────────┘ └──────────┘ └────────┘ │
├─────────────────────────────────────────┤
│ ZK Rollups │
│ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ zkSync │ │ Starknet │ │ Scroll│ │
│ └──────────┘ └──────────┘ └────────┘ │
└─────────────────────────────────────────┘
│
All settle to
│
▼
┌───────────────┐
│ Ethereum │
│ Layer 1 │
└───────────────┘
Key Takeaways
- L2s inherit L1 security while providing cheap, fast transactions
- Optimistic rollups are mature and EVM-compatible but have withdrawal delays
- ZK rollups offer faster finality but are more complex
- Data availability is the key trade-off (cost vs security)
- Sequencer decentralization is still in progress
- EIP-4844 dramatically reduced L2 costs
- The future is multi-L2 with shared sequencing and interoperability