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

Free lesson

Validity rollups: a proof instead of a wait

After this lesson: I can explain what a validity proof replaces in a rollup.

60 min lesson1 commandRollup lab: batches, fraud proofs, data availability and exits in Python

Seven days is a long time to wait

An optimistic rollup's batch is only final after its challenge window, often seven days. Somebody moving funds back to the main chain has to wait that long.

A validity rollup removes the wait. It posts a proof with each batch, and the main chain checks the proof before it accepts anything.

By the end of this lesson

Note

I can explain what a validity proof replaces in a rollup.

Key words

WordWhat it means
Validity rollupa rollup that posts a proof with every batch
Validity proofa short proof that the new root follows from the old one
Proverthe computer that makes the proof
Verifierthe contract that checks the proof
Succinctshort and quick to check, whatever the size of the work

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

The proof is checked before the batch counts

The statement is: applying these transfers to the state with the old root gives the new root. In the Zero-knowledge proofs module you wrote a statement as constraints. Here the constraints are the rollup's own rules.

A prover makes a short proof that a valid run exists. The contract checks it. A batch with a wrong root has no valid proof, so it is refused at once.

Post an honest and a lying batch

Command
docker exec jupyter python3 steps/validity.py

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

Worked example: what the lab printed

BatchCheck at postingWhat happensFinal after
HonestTrueaccepted600 slots, 2 hours
Lying at step 11Falserefused at oncenever
Optimistic, for comparisonnoneaccepted, open to challenge50400 slots, 7.0 days

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

Try it: when each rollup is final

Code: python
SLOT_SECONDS = 12
window = 50400
proof_delay = 600     # slots until the proof is ready
posted = 1000

print("optimistic final at slot", posted + window, "after", window * SLOT_SECONDS / 86400, "days")
print("validity final at slot", posted + proof_delay, "after", proof_delay * SLOT_SECONDS / 3600, "hours")
# Make the proof take 7200 slots. Is the validity rollup still final first?

What the proof replaces, and what it costs

The proof replaces two things: re-running the batch to check it, and the wait for anybody to object. A succinct proof is checked in about the same time for ten transfers or ten million.

It costs work elsewhere. Making the proof takes far more computing than running the transfers. The whole rollup must also be written as constraints, which is hard to get right.

What the lab does not do

Note

The lab has no proof system. Its toy check re-runs the batch, which a real verifier never does, and it says so in the script. It shows when the main chain decides, not how a proof is made.

A common mistake

Warning

Many people think a ZK rollup keeps its transactions private. Most do not: the batch's data is still published, so anybody can rebuild the state. The proof is used because it is short to check, not to hide anything.

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.