cygaar Profile picture
Aug 19 19 tweets 6 min read Read on X
Layer 2 blockchains are probably one of the most misunderstood topics in crypto, so let's fix that.

A guide on how L2s actually work 🧵: Image
By now you probably know that L2s are Ethereum's way of scaling.

You've probably wondered why L2s are so cheap when compared to L1.

Or maybe you've asked yourself what ZK/OP proofs are.

This post will answer those questions and give you a base understanding of L2s.
Let's first start by going over how Ethereum (and other L1s) work.

When a transaction is processed by a L1 chain, every node in the network must process it.

Txs are priced based on how much compute, storage, and data is used (gas usage). Compute and storage cost a lot. Image
Eth txs are particularly expensive due to Eth's constraints on block sizes.

Because of this, there's a relatively small amount of compute and storage that can be done per block.

However, data is very cheap. In fact, Eth added a separate system just for data - EIP-4844 blobs. Image
L2s are built on the premise of cheap data with minimized compute on the L1.

Users submit txs to the L2, where they're quickly processed and batched together. These batches are then compressed and sent as raw data to L1.

The L1 then stores this data to be used later. Image
Notice that the L1 doesn't actually compute anything here - this is a key concept for rollups.

The L1 only stores data as blobs (not in contract "storage"), rather than processing every tx.

All the processing is done on the L2, which is cheaper/faster than the L1. Image
Because only data is submitted to the L1, and data is very cheap, L2s are able to scale Ethereum's tx throughput.

Depending on the type of txs being executed, L2s can theoretically process hundreds of more txs per second when compared to the L1.

This is a huge boost.
An important property of L2s is that they rely on the final ordering of L1 txs to derive their own final ordering.

If the L1 were to re-org L2 data batch txs, the L2 itself would re-org.

This is what we mean when we say L2s derive their state from the L1.
So far the flow looks like this: users submit txs to the L2 -> the L2 process all of these txs -> L2 batches the txs -> L2 send compressed tx data to L1 as blobs.

But how does the L1 know that the computations on the L2 are correct? All we've done so far is send data to the L1. Image
This is where we get into optimistic and zero-knowledge proofs.

Optimistic (fraud) proofs use economic security while zk proofs use advanced cryptography.

Both methods of proving are used with the tx data to prove to the L1 that the results computed by the L2 are correct.
The L1 has a contract that tracks the state of the L2. You can think of this as the L1's viewpoint of the L2.

When a tx batch is submitted by the L2, it's telling the L1 that the L2 world has changed.

The L2 will then send a proof to prove that the state change is correct. Image
The proof finalizes a set of txs on the L2. Verifying proofs on the L1 is what we refer to as "settlement".

Settlement is important because it allows users to withdraw their funds from the L2 bridge.

Without proper settlement, a bad actor could steal funds from the bridge!
Summary so far: users submit txs to the L2 -> txs are batched and sent to the L1 -> L1 finalizes its ordering -> L2 finalizes its ordering -> L2 submits proof to the L1 to finalize state changes.

This is all theoretical, so lets walk through a simple example. Image
Lets say Bob swaps USDC for ETH on an L2.

This tx is sent to the L2 where it is processed quickly. At this point the tx is "soft" confirmed.

If you trust the L2 operator, you can treat this state as finalized. If you want stronger guarantees, you can wait for the L1 data batch.
The L2 then waits for more txs to come in to form a batch. The is then submitted to the L1 as part of a blob.

Once the L1 finalizes, the L2 ordering is finalized.

It's important to note that at this point, the swap tx is finalized on the L2 itself. The swap cannot be reverted.
But what about settlement?

Settlement is used to finalize the L1's view of the L2, allowing for bridge withdrawals.

In our example, the L2 would submit a proof (OP or ZK) after several batches have been submitted. The proof type will determine how long it takes to finalize. Image
OP proofs can take up to 7 days, while ZK proofs will usually take 1 day at most.

Once the poof is verified on the L1, the L1 will update it's state of the L2.

Bob can now withdraw their new ETH from the L2 back to the L1 as a result of this settlement.
Let's summarize the key points from above:

- L2s save gas costs by moving tx processing offchain, and instead submit tx data to the L1
- L2s derive their final ordering from the ordering of the L1
- L2s submit proofs to the L1 to allow funds to be withdrawn from the L2 bridge
If you want to go a bit more depth into how L2s work, I recommend reading this post from Vitalik: .

In the future, I'll go more in depth into various rollup components.

For now, if you can understand everything above, you'll be ahead of 95% of CT ;)vitalik.eth.limo/general/2021/0…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with cygaar

cygaar Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @0xCygaar

Jul 24
"Account Abstraction is the future of crypto"

You've probably heard this line many times, but weren't sure what it meant. So let's fix that.

I present to you the beginner's guide to Account Abstraction - what it is, how it works, and how it'll change crypto apps forever 🧵: Image
I'm not going to bore you with the technical and implementation details of Account Abstraction (that'll be a future thread).

Instead, this will be a very high-level overview of AA with practical examples of how it has improved the crypto user experience over the last few years.
Put simply, Account Abstraction is a set of frameworks and standards that turbocharge the capabilities crypto wallets (accounts).

You can think of this like taking a 1999 Honda Civic and giving it the ability to fly - it can still work as a car, but now it can do something new. Image
Read 15 tweets
Apr 18
A beginner's guide to Runes - the new protocol that will bring fungible tokens to Bitcoin at the halving 🧵: Image
To start, what are fungible tokens?

These are tokens that are not unique in nature, can be divided, and are interchangeable. They exist on other blockchains as ERC20s on EVM chains or SPL on Solana.

Examples include memecoins and governance tokens.
Historically, fungible tokens have not been possible on Bitcoin since it doesn't support smart contracts.

However, with the advent of ordinals, we saw the rise of BRC-20s, which inscribed token data in individual SATs (satoshis) and were processed by off-chain indexers. Image
Read 16 tweets
Apr 11
EIP-3074 was just approved to go live in the next Ethereum hard fork.

This EIP will forever change how users interact on EVM chains, making wallet UX simpler, cheaper, and more powerful.

Here's a high level overview of EIP-3074 and how it'll change the game 🧵: Image
The TLDR of 3074 is that it gives EOAs (normal wallets) smart contract capabilities (like account abstraction).

This includes the ability to do single tx approvals, batch txs, wallet asset recovery, sponsored txs, and more.

Let's first talk about the issues with modern wallets.
@lightclients did a great presentation on 3074 which I will reference in this thread.

Here's a list of UX problems - they can be solved through smart contract wallets, but that would force users to migrate wallets which is bad UX and costs money.

Not great. Image
Read 15 tweets
Mar 11
We are now 2 days away from Ethereum's Dencun upgrade, the largest fork since the Merge.

Here's a summary of the biggest changes in Dencun and how they'll affect you 🧵: Image
First off, why the name "Dencun"?

Ethereum has 2 types of clients, an execution client and a consensus client. Each type has its own set of upgrade names.

On the execution side, we have the Cancun upgrade, while the client side has the Deneb upgrade.

Combined, we get Dencun.
Image
Image
1) EIP-4844, proto-danksharding

Sounds scary, but it's a huge step in the right direction for Ethereum scaling. This change has been in the works for 2 years, and introduces "blobs" as ways for rollups to post transaction data.

It also sets the stage for future scaling changes.
Read 10 tweets
Mar 7
The beginner's guide to understanding Bitcoin Ordinals - what they are, how they differ from other NFTs, and why they're here to stay 🧵: Image
In order to understand ordinals, you first need to understand how Bitcoin works.

Bitcoin uses "unspent transaction outputs" or UTXOs to manage balances. You can think of UTXOs as batches of currency that you own.

Bitcoin transactions result in UTXOs being consumed and created.
If you own 0.5 BTC and send 0.2 to someone, you'll receive a UTXO worth 0.3 BTC and the recipient will receive a UTXO of 0.2 BTC. The txn consumes the original 0.5 BTC UTXO, which will no longer exist.

Each UTXO is made up of satoshis (sat), which is the base unit for Bitcoin. Image
Read 16 tweets
Feb 20
A lot of people are wondering how @ethena_labs is able to generate a 27% yield on their "internet bond".

Is it black magic? Are they max levered? What's the catch?

To answer those questions, here's a simple explanation of where the Ethena yield comes from 🧵: Image
Some quick context on Ethena:

Ethena built USDe, a trust-minimized scalable stablecoin that's pegged to the US dollar. They use a combination of staked ETH and perps to maintain the peg.

Ethena also built staked USDe (sUSDe) which generates yield, similar to a traditional bond.
To understand where the 27% yield comes from, we first need to understand how USDe works.

Rather than store a bunch of dollars at a bank (like USDC) to back each token 1:1, USDe uses a combination of Ethereum collateral and perpetual contracts to maintain its peg.
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(