async fn initialize_snapshot_progress(
        config: &SnapshotsCreatorConfig,
        l1_batch_number: L1BatchNumber,
        min_chunk_count: u64,
        conn: &mut Connection<'_, Core>,
    ) -> anyhow::Result<Option<SnapshotProgress>> {
        let snapshot_version = SnapshotVersion::try_from(config.version)
            .context("invalid snapshot version specified in config")?;

        // Sanity check: the selected L1 batch should have Merkle tree data; otherwise, it could be impossible
        // to recover from the generated snapshot.
        conn.blocks_dal()
            .get_l1_batch_tree_data(l1_batch_number)
            .await?
            .with_context(|| {
                format!(
                    "Snapshot L1 batch #{l1_batch_number} doesn't have tree data, meaning recovery from the snapshot \
                     could be impossible. This should never happen"
                )
            })?;

        let distinct_storage_logs_keys_count = conn
            .snapshots_creator_dal()
            .get_distinct_storage_logs_keys_count(l1_batch_number)
            .await?;
        let chunk_size = config.storage_logs_chunk_size;
        // We force the minimum number of chunks to avoid situations where only one chunk is created in tests.
        let chunk_count = distinct_storage_logs_keys_count
            .div_ceil(chunk_size)
            .max(min_chunk_count);

        tracing::info!(
            "Selected storage logs chunking for L1 batch {l1_batch_number}: \
            {chunk_count} chunks of expected size {chunk_size}"
        );
        Ok(Some(SnapshotProgress::new(
            snapshot_version,
            l1_batch_number,
            chunk_count,
        )))
    }
Returns `Ok(None)` if the created snapshot would coincide with `latest_snapshot`.
core/bin/snapshots_creator/src/creator.rs