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
| Word | What it means |
|---|---|
| Validity rollup | a rollup that posts a proof with every batch |
| Validity proof | a short proof that the new root follows from the old one |
| Prover | the computer that makes the proof |
| Verifier | the contract that checks the proof |
| Succinct | short 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
docker exec jupyter python3 steps/validity.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: what the lab printed
| Batch | Check at posting | What happens | Final after |
|---|---|---|---|
| Honest | True | accepted | 600 slots, 2 hours |
| Lying at step 11 | False | refused at once | never |
| Optimistic, for comparison | none | accepted, open to challenge | 50400 slots, 7.0 days |
The cells students fill in are left blank in this preview.
Try it: when each rollup is final
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.