Exercises: Layer 2 Scaling: Rollups, State Channels, and Sidechains
Conceptual Questions
Exercise 18.1 — The Throughput Bottleneck
Explain in your own words why simply increasing Ethereum's block size would not solve the scaling problem. Your answer should address: (a) what happens to full node requirements, (b) the effect on decentralization, and (c) why decentralization matters for security. Use specific numbers where possible (e.g., current block sizes, node counts, hardware costs).
Exercise 18.2 — The Core L2 Principle
A friend tells you, "Layer 2 solutions just move transactions off-chain, so they're no more secure than a regular database." Write a clear, two-paragraph response explaining why this characterization is incorrect. Be sure to distinguish between execution (which moves off-chain) and verification (which remains on-chain).
Exercise 18.3 — Fraud Proofs vs. Validity Proofs
Compare the security models of optimistic rollups and ZK-rollups by answering the following: 1. What assumption must hold for an optimistic rollup to be secure? What happens if this assumption fails? 2. What assumption must hold for a ZK-rollup to be secure? What happens if the prover goes offline? 3. Which approach would you prefer for a protocol managing $10 billion in assets? Why?
Exercise 18.4 — The 7-Day Problem
A DeFi protocol on an optimistic rollup wants to offer users instant withdrawals to Ethereum L1. Describe two different mechanisms that could provide this service. For each, explain: (a) who bears the risk of the 7-day challenge period, (b) what fee structure would make economic sense, and (c) what happens if a fraud proof invalidates the state root during the withdrawal period.
Exercise 18.5 — State Channel Limitations
Explain why state channels are well-suited for the Lightning Network (Bitcoin payments) but poorly suited for a decentralized exchange (like Uniswap). Your answer should address at least three specific limitations of state channels that make DEX operation impractical.
Exercise 18.6 — Sidechain Security
After the Ronin bridge hack of March 2022, some commentators argued that sidechains are fundamentally insecure and should be abandoned. Others argued that the hack was a failure of specific implementation (too few validators, poor key management), not a fundamental flaw. Take a position and defend it. Be sure to compare the security model of a sidechain with that of a rollup.
Analytical Exercises
Exercise 18.7 — Rollup Economics Calculation
An optimistic rollup batches 2,000 transactions into a single L1 submission. The L1 submission costs 500,000 gas. Each compressed transaction adds 80 bytes of calldata (at 16 gas per byte). Assume the current Ethereum gas price is 30 gwei and ETH is priced at $3,000.
Calculate: 1. The total gas cost of the batch submission 2. The cost in USD for each L2 user 3. How the per-user cost changes if the batch size increases to 10,000 transactions 4. Compare these costs to a direct L1 transaction costing 21,000 gas
Exercise 18.8 — ZK Proof Economics
A ZK-rollup's prover costs $200 in compute to generate a proof for a batch of 5,000 transactions. The proof verification on L1 costs 400,000 gas. The compressed transaction data costs 50 bytes per transaction (at 16 gas per byte).
Using the same gas price assumptions as Exercise 18.7: 1. Calculate the total cost (proving + L1 gas) for the batch 2. Calculate the per-transaction cost 3. How many transactions must a batch contain for the proving cost per transaction to drop below $0.001? 4. Compare the per-transaction cost to the optimistic rollup from Exercise 18.7
Exercise 18.9 — Data Availability Cost Analysis
Before EIP-4844, a rollup posting 128 KB of calldata paid approximately 2,048,000 gas (128,000 bytes x 16 gas/byte). After EIP-4844, the same data posted as a blob costs approximately 131,072 gas in the blob fee market (assuming a blob base fee of 1 wei per gas unit).
- Calculate the cost savings as a percentage
- If a rollup processes 1 million transactions per day and each transaction requires 50 bytes of data, how many blobs (each 128 KB) does it need per day?
- At pre-EIP-4844 costs, what would the daily DA cost be? At post-EIP-4844 costs?
- Explain why this cost reduction was so significant for L2 adoption
Exercise 18.10 — Lightning Network Routing
Consider a Lightning Network with the following channel capacities:
Alice --[1.0 BTC]--> Bob --[0.5 BTC]--> Carol --[2.0 BTC]--> Dave
\--[0.8 BTC]--> Eve --[0.3 BTC]--/
- What is the maximum payment Alice can route to Dave through Bob and Carol?
- What is the maximum payment Alice can route to Dave through Eve?
- If Alice wants to send 0.7 BTC to Dave, can it be done in a single payment? Why or why not?
- How could multi-path payments solve this problem?
Design Exercises
Exercise 18.11 — Choosing the Right L2
For each of the following applications, recommend the most appropriate L2 approach (optimistic rollup, ZK-rollup, state channel, sidechain) and justify your choice:
- A high-frequency trading platform for cryptocurrency derivatives
- A social media tipping service where users send $0.01 tips to content creators
- A blockchain-based gaming platform with millions of daily active users
- A decentralized lending protocol with $5 billion in deposits
- A supply chain tracking system for a large retailer
Exercise 18.12 — Modular Architecture Design
Design a modular blockchain stack for a decentralized social media platform that must support: - 100,000 posts per day - Micropayments ($0.001-$0.10) for content engagement - Persistent storage of post content - Privacy for direct messages
Specify which technology you would use for each layer (execution, settlement, data availability) and justify your choices. Address the tradeoffs you are making.
Exercise 18.13 — Security Stage Assessment
Using the L2Beat Stage classification (Stage 0, 1, 2), describe the specific technical requirements a rollup must meet to advance from Stage 0 to Stage 1, and from Stage 1 to Stage 2. For each transition, identify: (a) the technical milestone, (b) the trust assumption being removed, and (c) the risk that justifies the training wheels at the earlier stage.
Programming Exercises
Exercise 18.14 — Batch Compression Simulator
Extend the rollup_simulation.py code to add the following features:
1. Support different transaction types (simple transfers, token swaps, contract calls) with different compression ratios
2. Implement a dynamic batching strategy that triggers batch submission when either (a) the batch reaches a maximum size or (b) a maximum wait time is reached
3. Plot the relationship between batch size and per-transaction cost
Exercise 18.15 — State Channel Extension
Extend the state_channel.py code to implement:
1. A timeout mechanism: if one party does not respond within N seconds, the other party can force-close the channel
2. Multi-party channels: extend the two-party model to support three or more participants
3. A dispute resolution mechanism that verifies nonce ordering and selects the highest-nonce valid state
Discussion Questions
Exercise 18.16 — The Centralization Tradeoff
Most L2 rollups currently operate with centralized sequencers. Is this acceptable? Consider: (a) the practical benefits (lower latency, simpler engineering), (b) the risks (censorship, MEV extraction, single point of failure), and (c) the fact that users can force-include transactions via L1. At what point, if ever, should a rollup with a centralized sequencer be considered "decentralized enough"?
Exercise 18.17 — The L2 Fragmentation Debate
Some argue that having hundreds of L2s creates an unacceptable user experience — users must manage assets across multiple chains, pay bridging fees, and navigate incompatible ecosystems. Others argue that competition between L2s drives innovation and that interoperability solutions will eventually make the underlying chain invisible to users. Take a position and defend it.
Exercise 18.18 — Modular vs. Monolithic
The modular blockchain thesis argues for specialization — separate layers for execution, settlement, and data availability. The monolithic thesis (championed by Solana and others) argues that a single, highly optimized chain can achieve sufficient scalability without the complexity of multi-layer architectures. Evaluate both positions. Under what circumstances might each approach be superior?