Legend:
Library
Module
Module type
Parameter
Class
Class type
Snapshots for the store
Snapshots are canonical representations of the store and its associated context. Its main purposes it to save and load a current state with the minimal necessary amount of information. This snapshot may also be shared by third parties to facilitate the bootstrap process.
A snapshot of a block B is composed of :
The snapshot format version (see version), as a file;
The metadata of the snapshot (see metadata), as a file;
Some data to ensure snapshot consistency at import (see block_data), as a file;
A single context containing every key that the block B-1 needs (see below), as a file;
The set of (cemented and floating) blocks and their operations from the genesis block up to B -- it might contain less blocks if the snapshot is created from a store using a Rolling history mode of if it is created as a Rolling snapshot. Block's metadata are not exported. The cemented blocks are exported as a directory containing cycles as files, as well as some indexing data. The floating blocks are stored as a single file ;
The set of necessary Tezos protocols, as a directory containing the protocols as single files.
There are two kinds of snapshot formats that can be exported:
Raw is a directory containing the aforementioned data as independent files;
Tar is a tar archive containing all the data as a single archive file. To achieve better performances while loading the snapshot's information (version and metadata), we store first the version and then the metadata, to avoid seeking through the whole file.
Importing a snapshot will initialize a fresh store with the data contained in the snapshot. As snapshots may be shared between users, checks are made to ensure that no malicious data is loaded. For instance, we export the context of block B-1 to make sure that the application of the block B, given its predecessor's context, is valid.
Depending on the history mode, a snapshot might contain less blocks. In full, all blocks are present and importing such a snapshot will populate the Cemented_store with every cycle up to the snapshot's target block. Meanwhile, in Rolling, only a few previous blocks will be exported (max_op_ttl from the target block), only populating a Floating_block_store. Thus, the snapshot size greatly differs depending on the history mode used.
Snapshots may be created concurrently with a running node. It might impact the node for a few seconds to retrieve the necessary consistent information to produce the snapshot.
export ?snapshot_path snapshot_format ?rolling ~block ~store_dir
~context_dir ~chain_name genesis reads from the store_dir and context_dir the current state of the node and produces a snapshot, of the given snapshot_format, in snapshot_file if it is provided. Otherwise, a snapshot file name is automatically generated using the target block as hint. If rolling is set, only the necessary blocks will be exported.
import ~snapshot_path ?patch_context ?block ?check_consistency
~dst_store_dir ~dst_context_dir chain_name ~user_activated_upgrades
~user_activated_protocol_overrides genesis populates dst_store_dir and dst_context_dir with the data contained in the snapshot_file. If check_consistency is unset, less security checks will be made and the import process will be more efficient. If block is set, the import process will make sure that the block is the correct one we load. patch_context, user_activated_upgrades and user_activated_protocol_overrides are passed to the validator in order to validate the target block.