← Back to course
Lecture 09 · Scaling & Infrastructure

L09: Layer 2 & Scaling

Technical Deep Dive
How rollups, state channels, and data availability layers allow Ethereum to process thousands of transactions per second while inheriting Layer 1 security — escaping the trilemma without sacrificing decentralization.
Level: BSc Year 2 Prerequisites: L05 Ethereum, L06 Solidity, L07 DeFi Slides: 36 slides Sections: 7

Ethereum Layer 1 processes approximately 15 transactions per second. Visa’s payment network handles around 65,000 TPS at peak capacity. That gap — more than four orders of magnitude — is the central engineering problem that Layer 2 solutions are designed to close. But the gap is not simply an implementation oversight that can be patched; it is a direct consequence of Ethereum’s foundational design choices.

Every full node on the Ethereum network must independently re-execute every transaction to verify correctness. This redundancy is what makes the chain trustless — no single node’s computation is taken on faith. But it creates a hard ceiling on throughput: the network can only process as many transactions as every node can verify in parallel. Increasing TPS at Layer 1 forces one of three painful trade-offs: larger blocks (which require expensive hardware and push out small operators, reducing decentralization), fewer validators (which shrinks the attack surface, reducing security), or keeping the status quo (which caps throughput at ~15 TPS, sacrificing scalability).

The arithmetic: 30M gas per block ÷ 21,000 gas per simple ETH transfer ÷ 12 seconds per block ≈ 119 transfers per block ≈ 10 TPS for transfers alone. Smart contract calls consume 100,000+ gas each, pushing real-world effective TPS well below that ceiling.

The consequences are tangible for users. During the 2021 NFT boom, gas fees on Ethereum reached $200 per transaction for minting. During the DeFi summer of 2020, a simple token swap could cost more in fees than the swap itself was worth for small portfolios. These fee spikes are not malfunctions — they are the market-clearing mechanism for a fundamentally constrained resource.

Key insight: Layer 2 solutions escape this trade-off by separating execution from settlement. Transactions are executed cheaply off-chain; only the compressed result is posted to Layer 1 for security. One L1 transaction can settle hundreds of L2 transactions.
TPS Comparison
Fig 9.1 — TPS comparison: L1 chains, L2 rollups, and traditional payment networks
Scaling Trilemma
Fig 9.2 — The blockchain scaling trilemma: every L1 design chooses two of three properties
MetricEthereum L1VisaArbitrum (L2)zkSync Era (L2)
Transactions per second~15 TPS~65,000 TPS~4,000 TPS~2,000 TPS
Block/confirmation time12 secondsInstant (settlement 1-3 days)<2 seconds<2 seconds
Average fee (2024)$1–$15~2% merchant fee$0.01–$0.10$0.01–$0.05
Censorship resistanceYesNoYes (via L1)Yes (via L1)
Permissionless accessYesNoYesYes
Trust modelAlgorithmicCentralizedL1-anchoredL1-anchored

A rollup is a Layer 2 scaling solution that executes transactions off-chain while posting transaction data — or cryptographic proofs of those transactions — to Ethereum Layer 1. The name comes from the operation of “rolling up” hundreds of individual transactions into a single compressed batch, much like bundling 500 letters into one package for postal delivery.

The critical distinction between rollups and earlier L2 approaches (sidechains, payment channels) is the data availability guarantee: rollups post enough data to L1 that anyone, at any time, can reconstruct the L2 state from L1 alone. This means the rollup inherits Ethereum’s security properties. If the L2 operator disappears tomorrow, users can prove their balances and withdraw to L1 using only publicly available data.

Rollup Architecture
Fig 9.3 — Rollup architecture: users transact on L2, sequencer posts compressed data to L1 for security

The transaction lifecycle inside a rollup has five distinct phases. First, the user signs a transaction in their wallet and submits it to the rollup’s sequencer — a server (or set of servers) that orders and executes L2 transactions. The user receives a “soft confirmation” within seconds, comparable to a bank’s acknowledgment that a payment has been received. Second, the sequencer batches hundreds of transactions, compresses the resulting state changes, and posts the batch to Ethereum L1 as calldata or (after EIP-4844) as blob data. Third, either a fraud proof or a validity proof is used to verify correctness on L1. Once verified, the transactions receive “hard confirmation” with the full security of Ethereum finality.

Three core components of every rollup:
Sequencer — Orders and executes transactions on the L2. Currently centralized on most rollups, creating a temporary trust assumption.
Prover — Generates fraud proofs (optimistic) or validity proofs (ZK) for L1 verification.
Bridge — Locks assets on L1 and mints equivalent tokens on L2; holds billions in locked value and is a prime attack target.
The escape hatch: Even if the sequencer goes offline, users can force-exit by submitting a withdrawal transaction directly to the L1 rollup contract. This “escape hatch” is the defining property that separates a true rollup from a sidechain, where users have no recourse if the operator disappears.
Rollup Execution Flow
Fig 9.4 — Step-by-step rollup execution flow from user transaction to L1 finality

All rollups share the same fundamental architecture: execute off-chain, post data to L1, verify on L1. The critical design choice is how they prove that off-chain execution was correct. Two families have emerged, built on fundamentally different cryptographic assumptions — each with distinct trade-offs in cost, withdrawal time, and engineering complexity.

Optimistic vs ZK Rollups
Fig 9.5 — Optimistic vs ZK rollup comparison: proof mechanism, finality time, and EVM compatibility

Optimistic rollups take the simpler approach: they assume all transactions are valid by default and submit batches without a proof. A challenge period — currently seven days on Arbitrum and Optimism — gives any observer time to submit a fraud proof if they detect an invalid state transition. If a fraud proof is submitted and verified, the malicious batch is rejected and the submitter is slashed. If no challenge arrives within seven days, the batch is finalized. The optimistic approach is called “innocent until proven guilty.”

ZK rollups take the opposite approach: they generate a cryptographic validity proof — a zero-knowledge proof (SNARK or STARK) — that mathematically certifies the entire batch was executed correctly. The L1 contract verifies the proof in a single on-chain call. No challenge period is needed. Withdrawals can be processed in minutes rather than days. The trade-off is engineering complexity: generating ZK proofs for general-purpose EVM computation requires specialized compilers and sophisticated cryptographic infrastructure that took years to build.

Optimistic rollups (2024):
• Arbitrum Nitro: ~4,000 TPS, EVM-equivalent
• Optimism OP Stack: powers Base, Mode, Zora
• Base (Coinbase): ~2,000 TPS, institutional backing
Withdrawal time: 7 days via canonical bridge
Proof type: Fraud proofs (interactive bisection)
ZK rollups (2024):
• zkSync Era: ~2,000 TPS, zkEVM compatible
• StarkNet: ~1,000 TPS, Cairo VM
• Polygon zkEVM: EVM-equivalent
Withdrawal time: Minutes (after proof generation)
Proof type: Validity proofs (SNARK/STARK)
PropertyOptimistic RollupZK Rollup
Proof typeFraud proof (post-hoc)Validity proof (pre-hoc)
Challenge period7 daysNone
Withdrawal time7 days (canonical bridge)Minutes
EVM compatibilityFull (EVM-equivalent)Partial (improving rapidly)
Proof generation costLow (no proof needed)Higher (GPU/FPGA intensive)
On-chain verification costHigher (re-execution on fraud)Fixed (proof verification)
Engineering complexityModerateVery high
Security assumptionAt least 1 honest observer onlineSoundness of ZK proof system
Leading examplesArbitrum, Optimism, BasezkSync Era, StarkNet, Polygon zkEVM
Fraud Proof Timeline
Fig 9.6 — Fraud proof challenge window: the 7-day timeline from batch submission to finality
The honest minority assumption: Optimistic rollups are secure if at least one honest party is watching the chain and willing to submit a fraud proof when they detect invalid state. This is a weaker assumption than ZK proofs (which require no active watchers) but is practically satisfied by the economic incentive — challengers earn a reward for successful fraud proofs.

Two infrastructure components determine whether a rollup achieves its security and cost promises in practice: the sequencer that orders transactions and the data availability layer that stores batch data. Getting either wrong leads to censorship, insolvency, or complete security failure.

The sequencer is the off-chain server that receives user transactions, orders them, and executes them against the L2 state before batching and posting to L1. Today, every major rollup runs a single centralized sequencer operated by the team — Offchain Labs for Arbitrum, OP Labs for Optimism, Coinbase for Base. Centralized sequencers create three risks: censorship (the operator can refuse to include certain transactions), MEV extraction (the operator can reorder transactions for profit at users’ expense), and single point of failure (if the sequencer goes down, users must fall back to costly L1 transactions). All major rollup teams are working on decentralized sequencer designs, but none have fully shipped at scale as of 2024.

Sequencer Architecture
Fig 9.7 — Sequencer architecture: centralized today, decentralized in the roadmap

Data availability (DA) is perhaps the most underappreciated concept in rollup security. For a rollup to be trustless, the transaction data that the sequencer posts to L1 must be publicly accessible for long enough that any observer can reconstruct the L2 state and compute fraud proofs or verify ZK proofs. If the data disappears — even briefly — a malicious sequencer could post an invalid state root and no one could prove it was wrong.

Before March 2024, rollups posted their data as Ethereum calldata — data permanently stored on-chain. Calldata is the most secure DA option (it lives on L1 forever) but also the most expensive, because it competes with smart contract execution for the same block space.

EIP-4844, activated on Ethereum in March 2024 as part of the Dencun upgrade, introduced blob-carrying transactions. Blobs are a new data type that attaches up to 128 KB of data per blob to a block, with separate pricing from calldata. Blobs are designed to be stored by nodes for only ~18 days before being pruned — long enough for fraud proof windows but cheap enough to reduce L2 data costs by 80–90%.

EIP-4844 impact: Arbitrum fees dropped from ~$0.10 to ~$0.01 per transaction within 24 hours of Dencun activation. Base fees dropped below $0.001 during off-peak hours. This brought Ethereum L2 costs within range of traditional payment fees.
Data Availability
Fig 9.8 — Data availability layers: on-chain calldata, blobs, and alternative DA solutions
Data Availability Layers
Fig 9.9 — The DA spectrum: Ethereum calldata (most secure) to alternative DA layers (cheaper but with trust assumptions)
Alternative DA layers: Some rollups post data to external networks — Celestia, EigenDA, or Avail — rather than Ethereum L1 directly. These are called validiums (ZK proofs on L1, data off-chain) or optimiums. They achieve much lower costs but introduce an additional trust assumption: the DA layer must remain honest and available. The security guarantee is weaker than a full rollup. This is a deliberate design choice, not a flaw, for applications that accept the trade-off.
Gas Savings Analysis
Fig 9.10 — Gas cost savings: L1 calldata vs EIP-4844 blobs vs alternative DA layers

State channels represent an alternative scaling approach for specific use cases. Rather than posting data to L1 for every batch, two parties lock funds in an L1 smart contract, conduct unlimited off-chain transactions by exchanging signed state updates, and only settle the final state on L1 when they close the channel. The Lightning Network for Bitcoin is the most prominent example. State channels achieve near-zero fees and instant finality for the parties involved, but require participants to be online to dispute fraudulent channel closures and only work well for repeated interactions between known parties — they cannot support the general-purpose DeFi composability that rollups enable.

State Channels
Fig 9.11 — State channel lifecycle: open, transact off-chain, settle on-chain

Bridges are the connective tissue of the multi-chain ecosystem: they allow assets to move between Layer 1, Layer 2 rollups, and alternative blockchains. They are also, by a large margin, the most exploited infrastructure in crypto history. Between 2021 and 2023, bridge hacks resulted in over $2.5 billion in losses — including the Ronin bridge hack ($625M), Wormhole ($320M), Nomad ($190M), and the Harmony Horizon bridge ($100M). Understanding why bridges are dangerous requires understanding how they work.

The core bridge problem: A bridge must lock assets on the source chain and mint equivalent representations on the destination chain. This creates a massive honeypot: the bridge contract on the source chain holds the entire backing supply for all bridged assets. A single smart contract vulnerability can drain the entire locked pool. Bridge contracts are therefore among the highest-value targets in all of blockchain infrastructure.
Bridge Types
Fig 9.12 — Bridge architecture spectrum: from trust-minimized native rollup bridges to trusted third-party cross-chain bridges

Bridge security exists on a spectrum. At the most trustless end sit native canonical bridges — the official bridge contracts deployed by rollup teams themselves. The Arbitrum canonical bridge is secured by the rollup’s fraud proof mechanism: assets are only unlocked on L1 after the 7-day challenge period. The zkSync canonical bridge verifies validity proofs on L1 before releasing funds. These bridges inherit the rollup’s security guarantees. The trade-off is the withdrawal delay (seven days for optimistic rollups) and a lack of general cross-chain routing.

Third-party cross-chain bridges — Wormhole, LayerZero, Stargate, Across — offer faster withdrawals and routing between arbitrary chains by introducing their own security model: a set of validators or relayers that attest to the state of the source chain on the destination chain. The security reduces to the honesty and competence of this validator set. If validators collude or a private key is compromised, all locked assets are at risk. The Wormhole hack exploited a signature verification bug; the Ronin hack compromised five of nine validator keys through a social engineering attack on Axie Infinity team members.

Bridge Risk Landscape
Fig 9.13 — Bridge risk landscape: attack vectors, historical losses, and security architecture trade-offs
Bridge TypeSecurity ModelWithdrawal TimeHistorical LossesBest Use Case
Native rollup bridgeL1 fraud/validity proofs7 days / minutesNear zeroL1 ↔ single L2
Liquidity networkLP slippage + rebalancingMinutesLowFast withdrawals
External validator bridgeMultisig validator setMinutesHigh ($2.5B+ losses)Multi-chain routing
Light client bridgeOn-chain proof verificationHoursVery lowTrust-minimized cross-chain
Practical guidance: For moving assets between Ethereum and an L2 rollup, always prefer the native canonical bridge if the withdrawal delay is acceptable. For frequent cross-chain operations that require speed, third-party bridges are a pragmatic choice — but treat them as centralized infrastructure with smart contract risk, not as trust-minimized systems. Diversifying bridge exposure reduces concentration risk.

The Layer 2 ecosystem grew from a technical prototype to a multi-billion-dollar production environment between 2021 and 2024. Total Value Locked (TVL) across all L2 rollups exceeded $40 billion by mid-2024. Arbitrum consistently holds the largest share (~40%), followed by Base (~20%), Optimism (~15%), and a rapidly growing cluster of ZK rollups. This distribution reflects both technical maturity and ecosystem effects: Arbitrum was the first major general-purpose optimistic rollup to launch with significant liquidity, and that early mover advantage compounded through DeFi integrations.

The “superchain” paradigm is reshaping the competitive landscape. Coinbase’s Base and Zora both run on the OP Stack, making them compatible with Optimism through shared infrastructure. OP Labs is building a framework for chains to share sequencing, bridging, and governance while maintaining their own application focus. This creates an ecosystem of chains rather than a single monolithic rollup — analogous to AWS regions that share global infrastructure but serve local traffic.

L2 TVL Distribution
Fig 9.14 — L2 TVL distribution: Arbitrum leads, ZK rollups growing rapidly
L2 Ecosystem Map
Fig 9.15 — The L2 ecosystem map: rollup families, TVL, and key DeFi protocols
DeFi composability on L2: By 2024, all major DeFi protocols — Uniswap, Aave, Compound, Curve, GMX — had deployed on at least Arbitrum and Optimism. Total L2 DeFi TVL exceeded the value locked in many standalone L1 chains. The fee reduction from L2 migration revived use cases (small swaps, micro-payments, gaming) that were economically unviable on L1.

The ZK rollup ecosystem is maturing rapidly but remains more fragmented. zkSync Era and StarkNet use custom virtual machines (zkEVM and Cairo VM respectively) that improve proof generation efficiency but require developers to adapt their tooling. Polygon zkEVM and Scroll aim for full EVM bytecode equivalence, accepting slower proof generation in exchange for seamless compatibility with existing Ethereum smart contracts. The practical developer experience gap between optimistic and ZK rollups has narrowed substantially — most major Ethereum dev tools now support both families.

Validity Proof Comparison
Fig 9.16 — ZK proof systems compared: SNARK vs STARK trade-offs in proof size, generation time, and verification cost

Application-specific rollups (“app-chains”) are an emerging category: dedicated L2 environments built for single applications. Immutable X is an L2 for NFT gaming using StarkWare technology; dYdX migrated from Ethereum to its own Cosmos application chain for perpetual trading; Aevo runs a dedicated options trading rollup. The rationale is that application-specific rollups can optimize their execution environment, fee mechanisms, and governance for one use case — at the cost of reduced composability with the broader DeFi ecosystem.

Ethereum’s scaling strategy is often described as “modular”: rather than trying to make the base layer do everything, different functions are separated into specialized layers. Layer 1 becomes the settlement and data availability layer — the supreme court that provides final security guarantees. Layer 2 rollups become the execution layer where most user activity happens. Alternative DA layers (Celestia, EigenDA) may handle data for chains that accept weaker security in exchange for lower cost. This modular design allows each layer to optimize for its function rather than serving all purposes simultaneously.

Scaling Roadmap
Fig 9.17 — Ethereum’s scaling roadmap: from calldata to blobs to full danksharding

EIP-4844 (March 2024) was the first major milestone, adding blob transactions that reduced L2 data costs by 80–90%. The next step, full danksharding, will expand blob capacity from 3–6 blobs per block (current) to potentially 64+ blobs per block using data availability sampling (DAS). DAS allows light clients to verify data availability without downloading entire blobs, by randomly sampling small pieces and using erasure coding to reconstruct missing data with high statistical confidence. Full danksharding is expected to support 100,000+ TPS across the L2 ecosystem.

Scaling Roadmap Evolution
Fig 9.18 — Scaling roadmap evolution: milestones from 2022 to the full danksharding endgame

Today (2024)

EIP-4844 blobs live. L2 fees at $0.01–$0.10. Arbitrum, Base, zkSync in production. ~40B TVL on L2s.

Near-term (2025–26)

Decentralized sequencers launching. More blob capacity. ZK proof times <1 second. Full EVM-equivalent ZK rollups.

Endgame (2027+)

Full danksharding. 100,000+ TPS. Data availability sampling. Most activity on L2; L1 is pure settlement.

Five questions for evaluating any L2:
1. What is the proof type? Fraud proofs (optimistic) vs validity proofs (ZK) — affects withdrawal time and security assumptions.
2. Who controls the sequencer? Centralized sequencers create censorship and MEV risk; check decentralization roadmap.
3. Where is data availability? On Ethereum L1 (most secure) or alternative DA layer (cheaper, weaker guarantees)?
4. What is the bridge security model? Native canonical bridge or third-party bridge with additional trust assumptions?
5. Is the ecosystem liquid? TVL, protocol deployments, and DEX volume indicate whether the L2 has genuine economic activity.

The rollup-centric roadmap represents a philosophical commitment: Ethereum will remain maximally decentralized and secure at Layer 1, even if that means accepting 15 TPS at the base layer forever. The throughput problem is delegated upward to L2s, which can innovate aggressively without altering the social contract of the base layer. This is the same architectural principle used in internet protocol design — the TCP/IP base layer has not fundamentally changed in decades, while applications built on top have scaled from email to video streaming to AI.

For the developer, the practical implication is clear: by 2024, Ethereum L1 is the settlement layer; the application layer is on L2. Building a new DeFi protocol, NFT platform, or payment application on L1 mainnet rather than an L2 is equivalent to building a web app on dial-up when broadband is available. The gas cost alone makes L1-only applications inaccessible to the majority of global users. Understanding rollup architecture, sequencer trust assumptions, and bridge security is no longer a specialist skill — it is foundational knowledge for any Ethereum developer.

Cost Comparison
Fig 9.19 — Transaction cost comparison: Ethereum L1 vs L2 rollups before and after EIP-4844
© 2025 BSc Blockchain Course · Layer 2 & Scaling · Course Home