Rollup lab: batches, fraud proofs, data availability and exits in Python
This lab gives each student a JupyterLab of their own with a toy rollup written in plain Python, short enough to read in full: transfers run off the main chain and posted as a batch with a state root, the rollup's contract on the main chain as a Python class, a lying sequencer caught by bisection inside a challenge window, a validity check, erasure coding and data availability sampling, a blob store that prunes, and withdrawals with and without censorship. Ten small scripts each print what one idea does, the same every time.
It is a model for learning, not a chain: nothing in it talks to a real network, holds real value or uses real keys, and it says nothing about prices or investment. The slot, epoch and blob figures are the real ones. Every copy has no route to the internet and none to any other student, and nothing is downloaded into it.
What students learn
Why a rollup runs transactions off the main chain and posts only the data and a state root on it, and how the main chain refuses a batch that does not start from the last root. They apply a batch of four transfers, one skipped for want of money, and rebuild the balances from the posted data alone. A sequencer lies at transfer 11 of 16 and bisection finds that step in 4 questions, inside a window of 50400 slots, 7.0 days. They compare a validity rollup, final when its proof is checked, stretch data so any half rebuilds it, find that 13 random samples give 99.99% confidence when more than half is hidden, watch a blob pruned after 131072 slots, 18.2 days, and work out a withdrawal leaving after 7.1 days, or 8.0 when the sequencer ignores it. It suits distributed systems, blockchain and security courses; check your own awarding body's unit for the exact wording, none is quoted here.
Run it in your browser
The lab starts one service, jupyter, which writes rollup.py, l1.py, fraud.py, das.py, a starter notebook and the short scripts into its work folder, with nothing downloaded. JupyterLab asks for no token, because the platform's own door already knows who is opening it. The terminal beside the lab has no Python of its own, so it reaches the lab's with docker exec jupyter, followed by the command to run inside.
- Open the Container page. Open Build on the bar and choose Run a container. Anybody may open it, and the Git lab and the SQL lab start with no account. Every other lab needs a free account: create one, sign in, then press Start.
- Find the lab. The Sample labs card lists every sample. Find Rollups: batches, fraud proofs and data availability.
- Press Start. Start runs it as it is, in one press. Edit the file first opens the compose file so you can change it before you start.
- Open it. On the lab's page, the lab bar has a link called JupyterLab: press it to open JupyterLab in your browser and read rollup.py in the file editor. Then press Open terminal and type docker exec jupyter python3 steps/dispute.py to see a lying sequencer caught by bisection and its batch reverted.
What to ask students to hand in
A notebook of their own that uses these files to answer one question they chose, such as how many bisection questions a batch of a million transfers needs, how long a challenge window can be before the data is pruned, or how many samples give a confidence they pick, downloaded from JupyterLab with File, Download. Then a sentence or two in their own words on what they found. Nothing is marked automatically: the sentence shows whether it was understood. For stronger work ask them to explain why a challenge window must end before the blob behind it is pruned.
A basic lesson on this lab
Rollup Basics is a small lesson worked in this lab. In it a student posts a batch, catches a lying sequencer by bisection, watches a challenge window close, samples for withheld data, sees a blob pruned and works out when a withdrawal can leave.
Free personal accounts have it in the Basics module, which is on Home, and every college can copy it from the Library's Basics folder. It is deliberately small: it shows a teacher what a lesson worked in a lab is, and the lab does the rest. Copy it into a module of your own to change it. The undergraduate module Rollups and data availability is worked in the same lab.
The code on GitHub
The compose file has no Dockerfile: it runs one stock public image, the Jupyter Docker Stacks' own scipy-notebook, pinned to a dated tag, as its own unprivileged account with 512 MB of memory, and the toy uses only Python's standard library. The image is licensed BSD-3-Clause and is not distributed by us. The file writes every Python file from fixed text when it starts and every random choice comes from a fixed seed, so every copy prints the same and nothing is downloaded. The limits are honest ones: no real rollup node, main chain or proof system runs in the lab, so the main chain is a Python class, time is a slot number, and the validity check re-runs the batch where a real rollup checks a short proof. Nothing is kept when the lab stops, so a student downloads their notebook first.
Set it as work
Say in the task what to hand in.
- Make the lab. In your module add a task and choose the Container lab card, then In a GitHub repository. Give https://github.com/mitsurutech/lab-rollup-lab with the branch main. The compose file is the default, compose.yaml. Fork the repository first if you want to change it, for example to use a different window, a longer batch or another lie for the sequencer.
- Publish and try it. Publish pins the commit you were shown, so a later change in the repository does not alter a lab you have already set. Start your own copy first.
- Hand it out. Assign it like any task, with a due date if you want one, and say in the task what to do and what to hand in.
- Mark what is handed in. Open a student’s copy and the work they handed in, mark it, and send it back with a reason if it needs more.
Try this lab, and what it costs
A free personal account can work through the basic lessons in this lab, with enough free credit each month to follow most lessons and no card. For a class, a school or college has its first 365 days free for up to 50 students, then pays per student a year, with every lab included and staff free.
Questions people ask
- Why is there no token or password to type?
- A lab's web page is reached only through the platform's own door, which already knows who you are and lets in only you and the staff who teach your module. So JupyterLab is started with no token. Do not run it like that on a machine anybody else can reach.
- Why does the terminal use docker exec jupyter?
- The lab's terminal carries a few clients and no Python. docker exec jupyter runs a command inside the lab's own container, which has Python. JupyterLab also has a terminal of its own, under File, New, Terminal.
- Does the lab run a real rollup or a real chain?
- No. The lab is one stock image with nothing downloaded when it starts, and it carries no rollup node, main chain or proof system. The main chain is a Python class and time is a slot number, but the slot length, the epoch and the 4096 epochs a blob is kept are the real figures, so the arithmetic of windows and pruning is the real one.
- Is there anything about coins or prices in it?
- No. The lab and the module are technical only: how a rollup posts its data, how a wrong batch is caught, how long data is kept and how long leaving takes. Balances are whole numbers in a dictionary, and nothing in the lab is worth anything.