## L2 Sequencing
### Where are we? Where are we heading?
*Terence Tsao*
Core Dev @ Offchain Labs
---
<!-- .slide: style="text-align: left" -->
## Agenda
* Why do we sequence?
* Sequencing vs. execution
* Sequencer
* Dos and Donts
* Decentralized design goals
* Today's landscape vs. tmw
* Interaction with MEV
---
<!-- .slide: style="text-align: left" -->
## Why do we sequence?
- Txs can be ordered by the parent chain
- Not economical
- Aggregate off-chain, batch, and commit on-chain under a single tx
- Compression
- Minimizes user cost
- At the very least, users can still use parent chain
- Censorship prevention
- Worse UX and higher cost
---
<!-- .slide: style="text-align: left" -->
## Sequencing vs. execution
- Separation of concern is a feature, not a bug!
- Once tx is sequenced, (& posted on parent chain) it's final
- Why separate?
- Because they are!
- Proposer requires the sequence
- Sequencer doesn't require the state
---
<!-- .slide: style="text-align: left" -->
## Sequencing vs. execution
![](https://hackmd.io/_uploads/Hk5JDSidn.png)
[ref](https://developer.arbitrum.io/inside-arbitrum-nitro/#sequencing-followed-by-deterministic-execution)
---
<!-- .slide: style="text-align: left" -->
## Sequencer main role
- Receive txs from users
- Emit ordered and timestamped sequence from users txs
- Emit **soft** commit (ms)
- Emit **hard** commit (parent chain finalization time)
- Proposers take sequenced txs and propose L2 blocks
---
<!-- .slide: style="text-align: left" -->
## Sequencer cannot do
- Change the result of the txs
- Can not censor you forever
- Invariants:
- Collect execution fee
- How much to charge for gas
- Protocol only **trusts** sequencer for one thing, and that is order txs
---
<!-- .slide: style="text-align: left" -->
## Sequencer Design goals
- Liveness
- Minimize the following
- Tx latency
- Toxic MEV (front-running)
- Reduce co-location incentive
- Resolve latency by bidding
- Censorship resistance
---
<!-- .slide: style="text-align: left" -->
## Sequencer designs
- Centralized
- Partial/full decentralized
- Shared/outsourced
---
<!-- .slide: style="text-align: left" -->
## Outsourced designs
- Your sequencer can be outsourced to another
- Sequencer
- L2 chain
- L1 chain
---
<!-- .slide: style="text-align: left" -->
## Break down the problems
Sequencer committee is just a set of computers[1] that implements some ordering policies[2] through some consensus algorithms[3]
---
<!-- .slide: style="text-align: left" -->
## Ordering policy
- First come, first serve
- MEVA (full block auction)
- Time boost
- Continuous time
- Discrete time
---
<!-- .slide: style="text-align: left" -->
## Ordering policy: FCFS
- Easy to understand
- Minimize TX latency
- Minimize Toxic MEV (front-running)
- Can't resolve race by bidding
---
<!-- .slide: style="text-align: left" -->
## Ordering policy: MEVA
- Anyone can become a sequencer by bidding
- Highest bid wins to sequence at a future time
- Rational profit-maxi actor will maximize value
- Bid should be as close as the value extracted
- Unknowns: timing & censorship
---
<!-- .slide: style="text-align: left" -->
## Ordering policy: Time boost
- Allow bidder to buy time / bid up time for adjusted timestamp
$t_\mathrm{adjusted}(T) = t_\mathrm{arrival}(T) - \frac{gB(T)}{B(T)+c}$
- No tx can be held for more than $g$ time
- Resolve race by bidding, no front running if sequencer is honest
- Dist time vs. cont time
- Under analysis which is more efficient
---
<!-- .slide: style="text-align: left" -->
## Ordering policy comparisons
| ordering policy | latency | reduce toxic MEV | resolve race by bidding | trusting sequencer to not reorder|
| --- | --- | --------------- | -------- | -------- |
| FCFC | ✅✅ | ✅ | ❌ | ❓|
| MEVA | ❓ | ❌ | ✅ | ❓ |
| Time-boost | ✅ | ✅ | ✅ | ❓ |
---
<!-- .slide: style="text-align: left" -->
## Sequencer consensus policy
- Leader auction
- Random leader election
- Economic competition
- Threshold cryptography
---
<!-- .slide: style="text-align: left" -->
## Consensus + ordering policy
- Ordering policy can be applied to any design
- Committee reaches consensus on ordering
- Pre-determined safety assumption
- Tradeoffs between latency & size
---
<!-- .slide: style="text-align: left" -->
## Decentralize via committee
- No longer a single sequencer
- Committee can be elected by gov
- Ordering policy is voted through protocol
- Front run can be detected and slashed out of band
- Reserved sequencer for liveness
- Requires manual intervention
---
<!-- .slide: style="text-align: left" -->
## Decentralize via BFT
- Round-based single-leader selection
- Txs are gossiped through p2p network
- Better liveness
- Likely slower
- Manual intervention is no longer required
---
<!-- .slide: style="text-align: left" -->
## Decentralize via committee + threshold decryption
- Leaderless, anyone can batch post
- Encrypted tx goes to all parties
- Parties work together to decrypt a tx
- Parties reach a consensus on ordering
- Require automatic broadcast protocol. Non-trivial latency
---
<!-- .slide: style="text-align: left" -->
## Comparisons
| Consensus | Liveness | Latency | Reduce co-location incentive | Censorship resistance | Trustless |
| -- | -- | -- | -- | -- | -- |
| Centralized | ❌ | ✅✅✅ | ❌ | ❌ |
| Committee | ✅ | ✅✅ | ✅| ✅ |
| BFT | ✅ | ❓ | ✅ | ✅ |
| Committee + Threshold | ✅ | ✅ | ✅✅ | ✅✅ |
---
<!-- .slide: style="text-align: left" -->
## Shared sequencing
- Can achieve efficient data packing
- Cross-domain value extraction
- Automatic inclusion, not execution!
- How to achieve cross-rollup composition?
- Unless it runs every $STF$?
- How to distribute value extraction back to individual rollup?
---
<!-- .slide: style="text-align: left" -->
## Finally. What's next❓
- Sequencer will be decentralized
- Ordering policy will be adopted
- Proposals will go through governence vote
- May the best one win (multiple winners?)
---
<!-- .slide: style="text-align: left" -->
## Thank you! Enjoy rest of ethCc!
Find me @terencechain
---
{"slideOptions":"{\"theme\":\"solarized\"}","title":"L2 Sequencing: Where are we? Where are we heading?","contributors":"[{\"id\":\"be26a7ab-c8e0-4a30-bd7e-266f9e3700bf\",\"add\":8444,\"del\":7564}]"}