Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Trust, censorship and leaving a rollup

After this lesson: I can work out the earliest slot a withdrawal can leave a rollup.

65 min lesson2 commandsRollup lab: batches, fraud proofs, data availability and exits in Python

One computer decides the order

Most rollups have a single sequencer that decides which transfers go in each batch, and in what order. That makes them fast.

It also raises a fair question: what if the sequencer ignores you, or stops? Today you see what it can and cannot do, and how long leaving takes.

By the end of this lesson

Note

I can work out the earliest slot a withdrawal can leave a rollup.

Key words

WordWhat it means
Censorshipa sequencer leaving out somebody's transfers
Inboxa list on the main chain where users post transfers themselves
Forced inclusiona rule that a transfer in the inbox must enter a batch in time
Withdrawalmoving funds from the rollup back to the main chain
Upgrade keythe power to change the rollup's contract

The cells students fill in are left blank in this preview.

A sequencer can delay but not steal

Every batch must follow the rollup's rules, and a wrong root is caught by a fraud proof or refused for want of a valid proof. So a sequencer cannot take funds or invent balances.

What it can do is choose the order and leave transfers out. If it ignores you, you post your transfer in the main chain's inbox. After a delay, it must be in the next batch, or anybody may post that batch.

Find the lab's three time limits

Command
docker exec jupyter grep -n "SLOTS =" l1.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Work out when a withdrawal can leave

Command
docker exec jupyter python3 steps/withdraw.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Worked example: what the lab printed

CaseIn a batch at slotEarliest exit at slotDays after asking
Optimistic, not censored2400528007.1
Validity, proof after 600 slots240030000.1
Optimistic, censored and forced in9200596008.0

The cells students fill in are left blank in this preview.

Try it: a shorter window

Code: python
SLOT_SECONDS = 12


def days(slots):
    return round(slots * SLOT_SECONDS / 86400, 1)


asked = 5000
included = 5300
for window in (50400, 21600):
    out = included + window
    print("window", window, "slots: exit at slot", out, "which is", days(out - asked), "days after asking")
# Make included 12000, as if the sequencer waited. What changes?

Leaving waits for the batch to be final

A withdrawal is a transfer to the main chain. It is paid out only once the batch that holds it is final. That is after the window in an optimistic rollup, and after the proof in a validity rollup.

A shorter window means faster exits but less time to catch a wrong batch. That trade-off is why windows are measured in days.

A common mistake

Warning

Many people think the sequencer is the part of a rollup you must trust most. It can only delay you. Whoever holds the upgrade key can change the contract itself, so ask who holds it and how long a change must wait.

About this lab and its source: Rollup lab: batches, fraud proofs, data availability and exits in Python

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.