Layer 2 —Optimism
Optimism is an optimistic rollup built on top of Ethereum, so what is exactly an Optimism Rollup and how does it work? let's dive into more details
0x02 what is Optimism rollup?
Optimistic rollups sit in parallel to the main Ethereum chain on layer 2. They can offer improvements in scalability because they don’t do any computation by default. Instead, after a transaction, they propose the new state to Mainnet or “notarise” the transaction.
With Optimistic rollups, transactions are written to the main Ethereum chain as
calldata, optimising them further by reducing the gas cost.
As computation is the slow, expensive part of using Ethereum, Optimistic rollups can offer up to 10–100x improvements in scalability dependent on the transaction. This number will increase even more with the introduction of shared chains as more data will be available if a transaction is disputed.
There is a smart contract on Ethereum (call it
RollupL1) that allows deposits/withdrawals of ETH. When your money is in
RollupL1, you can consider it to be in L2. The L2 money processes much faster than L1 because L2 txns are much more efficient and faster.
There is a program that lives outside of Ethereum (call it
RollupL2). It can process txns much faster because it does not have to go through Ethereum’s slow and expensive consensus mechanism. It can process a bunch of txns, combine them (roll them up) into a batch, and submit the batch to
By processing transactions off-chain, you can save more in 2 ways.
- data compression: a batch takes up less space than individual txns stacked on top of each other.
- you only have to go through Ethereum’s slow and expensive consensus only once.
Optimistic rollups get around this by blind trust: they simply trust the newly submitted state without doing any verification (they are very optimistic ✨). But, they lock up the newly submitted batch for a week (called the “challenge window”). Anyone can submit mathematical proof during this challenge window and receive a reward if they find a fraudulent state update. If the batch is not disputed during the week, it’s considered final.
The reward is financed by the deposit of those who submit the batch. If you want to submit a batch, you need to submit a deposit.
0x03 functions of Optimism contract
- a 2-way bridge to move money between L1 and L2
- processing transactions and rolling them up into a batch
- disputes/proof of invalid state update
stay tuned for the code part!