Skip to content

Snapshot export for rollup node

Alain Mebsout requested to merge alain@functory@snapshot-copy into master

Context

This MR introduces a new command for the rollup node:

snapshot export [--data-dir <data-dir>] [--dest <path>]
    Export a snapshot of the rollup node state.
    --data-dir <data-dir>: The path to the smart rollup node data directory. Default value is ~/.tezos-smart-rollup-node
    --dest <path>: Directory in which to export the snapshot (defaults to current directory)

which will create a compressed snapshot file (ending in .full or .archive) in dest for the rollup node whose data reside in data-dir for the rollup node's current head.

Depends on !10805 (merged), !10867 (merged), !11041 (merged).
Next MR !10803 (merged).

Design of Snapshots

Snapshots are produced by the rollup node binary that can be called while the rollup node executes as a daemon. To prevent corruption, the process that exports snapshot has to take a lock on both the GC and the processing of blocks while it reads the data of the rollup node. The rollup node snapshot export cannot execute while the rollup node daemon is processing blocks or running a GC. In practice, this means that the rollup node daemon can pause on the processing of blocks for some time (usually a few seconds) while the other rollup node binary produces the snapshot.

Snapshots contain:

  • the stores that contain information about the rollup and the L2 chain with the exclusion of information that is "operator specific" (e.g. about publication of commitments)
  • the full context
  • the pre-images

In order to facilitate checks on import (see !10803 (merged)), snapshots also contain a binary header with the following information:

+---------------------------------+
| History mode (1 byte)           |   H
+---------------------------------+   e
| Rollup address (20 bytes)       |   a
+---------------------------------+   d
| Head level (4 bytes)            |   e
+---------------------------------+   r
| Last commitment hash (32 bytes) |
+=================================+
|                                 |   D
|      Tar archive of data        |   a
|                                 |   t
+---------------------------------+   a

Snapshot archives are compressed using the Gzip algorithm.

Manually testing the MR

dune exec tezt/tests/main.exe -- -f sc_rollup.ml snapshot
Edited by Alain Mebsout

Merge request reports