pub async fn recover(
    storage: &mut Connection<'_, Core>,
    snapshot: Snapshot,
) -> SnapshotRecoveryStatus {
    let mut storage = storage.start_transaction().await.unwrap();
    let written_keys: Vec<_> = snapshot.storage_logs.iter().map(|log| log.key).collect();
    let tree_instructions: Vec<_> = snapshot
        .storage_logs
        .iter()
        .map(|log| {
            let tree_key = U256::from_little_endian(log.key.as_bytes());
            TreeInstruction::write(tree_key, log.enumeration_index, log.value)
        })
        .collect();
    let l1_batch_root_hash = ZkSyncTree::process_genesis_batch(&tree_instructions).root_hash;

    let protocol_version = storage
        .protocol_versions_dal()
        .get_protocol_version_with_latest_patch(snapshot.l1_batch.protocol_version.unwrap())
        .await
        .unwrap();
    if let Some(protocol_version) = protocol_version {
        assert_eq!(
            protocol_version.base_system_contracts_hashes,
            snapshot.l1_batch.base_system_contracts_hashes,
            "Protocol version set up with incorrect base system contracts"
        );
    } else {
        storage
            .protocol_versions_dal()
            .save_protocol_version_with_tx(&ProtocolVersion {
                base_system_contracts_hashes: snapshot.l1_batch.base_system_contracts_hashes,
                version: ProtocolSemanticVersion {
                    minor: snapshot.l1_batch.protocol_version.unwrap(),
                    patch: 0.into(),
                },
                ..ProtocolVersion::default()
            })
            .await
            .unwrap();
    }
    storage
        .factory_deps_dal()
        .insert_factory_deps(snapshot.l2_block.number, &snapshot.factory_deps)
        .await
        .unwrap();

    storage
        .storage_logs_dedup_dal()
        .insert_initial_writes(snapshot.l1_batch.number, &written_keys)
        .await
        .unwrap();
    storage
        .storage_logs_dal()
        .insert_storage_logs_from_snapshot(snapshot.l2_block.number, &snapshot.storage_logs)
        .await
        .unwrap();

    let snapshot_recovery = SnapshotRecoveryStatus {
        l1_batch_number: snapshot.l1_batch.number,
        l1_batch_timestamp: snapshot.l1_batch.timestamp,
        l1_batch_root_hash,
        l2_block_number: snapshot.l2_block.number,
        l2_block_timestamp: snapshot.l2_block.timestamp,
        l2_block_hash: snapshot.l2_block.hash,
        protocol_version: snapshot.l1_batch.protocol_version.unwrap(),
        storage_logs_chunks_processed: vec![true; 100],
    };
    storage
        .snapshot_recovery_dal()
        .insert_initial_recovery_status(&snapshot_recovery)
        .await
        .unwrap();

    storage
        .pruning_dal()
        .insert_soft_pruning_log(snapshot.l1_batch.number, snapshot.l2_block.number)
        .await
        .unwrap();
    storage
        .pruning_dal()
        .insert_hard_pruning_log(
            snapshot.l1_batch.number,
            snapshot.l2_block.number,
            snapshot_recovery.l1_batch_root_hash,
        )
        .await
        .unwrap();
    storage.commit().await.unwrap();
    snapshot_recovery
}
Recovers storage from a snapshot.
L2 block and L1 batch are intentionally **not** inserted into the storage.
core/node/test_utils/src/lib.rs