Layer 2 & Scaling
Ethereum L1 does ~15 tx/s. That's the global throughput. L2s are how we get to Visa-scale without abandoning L1 security.
1. The scaling problem in one sentence
Every full node must re-execute every tx. To scale, you either (a) move execution off L1 and post only results ("rollups"), or (b) run a separate chain ("sidechain") and hope it stays honest.
2. The scaling landscape
| Type | Who verifies? | Security | Examples |
|---|---|---|---|
| Optimistic rollup | L1 accepts unless fraud proof within 7d | ~L1 (assumes 1 honest watcher) | Optimism, Arbitrum, Base |
| zk rollup | L1 verifies a succinct proof per batch | L1 (cryptographic) | zkSync, Starknet, Polygon zkEVM |
| Validium | Like zk but data off-chain | Depends on DA committee | Immutable X |
| Sidechain | Own validator set | Own security budget | Polygon PoS, BNB Chain |
| State channel | Peer-to-peer, settle later | L1 for disputes | Lightning (BTC), (rare on ETH) |
3. How a rollup works (big picture)
The security model is: "L1 is your settlement and data availability layer; the L2 is just an execution shortcut."
4. Costs & UX
- Post-EIP-4844 (blobs): L2 tx costs dropped 10–100×. Typical tx on Base/Optimism: $0.01–$0.10.
- Withdrawals: optimistic = 7 days (or bridge with liquidity for instant UX). zk = minutes-hours depending on proof cadence.
- Same EVM, same Solidity, same wallet, different chainId. Porting is often a config change.
5. Deploying to Base / Optimism / Polygon
// hardhat.config.js
networks: {
base: { url: "https://mainnet.base.org", accounts: [PK] },
optimism:{ url: "https://mainnet.optimism.io", accounts: [PK] },
polygon: { url: "https://polygon-rpc.com", accounts: [PK] },
}
npx hardhat run scripts/deploy.js --network base
That's it. Verify on the L2's block explorer (Basescan, Arbiscan, etc.) with the same plugin.
6. Nuances that bite in production
- Pre-compiles differ slightly — some L2s lack
blockhashhistory or have subtly differentblock.timestamp. - Gas pricing model differs — Arbitrum has an L1 data fee component; your estimates need to include it.
- Sequencer is centralized today — downtime = no tx inclusion. Decentralized sequencers are coming (2025–26).
- Bridging — users bridge ETH → L2 ETH. Use canonical bridges for safety; 3rd-party bridges (LayerZero, Wormhole) for speed. Biggest DeFi hacks in history have been bridges.
- Chain-agnostic code — use
block.chainidnot hard-coded IDs. Keep deployments scriptable.
7. Data availability (DA)
"Where is the full tx data stored?" On L1 calldata (rollup) = max security. On a DA committee (validium) = cheaper, weaker. Modular chains (Celestia, EigenDA) provide cheap DA for L2s — this is 2025's hot infra category.
8. zk proofs, intuition-only (Phase 13 goes deeper)
A SNARK lets a prover convince a verifier that "I executed these 1,000 txs correctly starting from state S_0 and ending at state S_1" with a ~200-byte proof verifiable in milliseconds. The L1 verifier contract is just some elliptic-curve pairings.
9. Bridging pattern you'll actually build
// L1 deposit
Bridge.depositETH{value: 1 ether}() → emits Deposit(user, 1 ether)
// L2 relayer / bridge watcher mints 1 L2-ETH to user on L2
// L2 withdraw
Bridge.withdrawETH(1 ether) on L2 → state posts to L1
// After finality window, user calls Bridge.finalize(user, 1 ether) on L1
10. Project
wallet_switchEthereumChain.Quiz
- Validators are slow
- L1 needs 7 days to finalize
- The challenge period: anyone can submit a fraud proof during that window if the withdrawal references invalid state
- Gas fees need to be low