Module Mavryk_store_unix_reconstruction.Reconstruction

Storage reconstruction

The storage reconstruction feature aims to re-compute the contexts (ledger state) and the blocks metadata of a full mode storage, and thus, migrate a storage from a full history mode to an archive one.

To do so, it is needed to re-validate the whole chain, by applying (using the standard validation method: Mavryk_validation.Block_validation.apply) all the blocks from the genesis on empty context. As a storage running a full history mode will not store all the ledger state but keeps all the blocks (and operations), it is the only mode that can be reconstructed. The operation consist of two major steps:

As the reconstruction procedure changes the state of the storage, it cannot be run while a node is running on the storage to reconstruct. If the reconstruction is interrupted, it will be resumed if restarted.

type failure_kind =
  1. | Nothing_to_reconstruct
  2. | Cannot_read_block_hash of Mavryk_base.TzPervasives.Block_hash.t
  3. | Cannot_read_block_level of Stdlib.Int32.t
  4. | Cannot_read_resulting_context_hash of Mavryk_base.TzPervasives.Block_hash.t
type Mavryk_base.TzPervasives.error +=
  1. | Reconstruction_failure of failure_kind

reconstruct ?patch_context ~store_dir ~context_dir genesis uau uapo omsl reconstructs the storage located in store_dir and context_dir. The resulting storage will see its history mode changed to archive.