pub async fn get_storage_logs_chunk(
        &mut self,
        l2_block_number: L2BlockNumber,
        l1_batch_number: L1BatchNumber,
        hashed_keys_range: std::ops::RangeInclusive<H256>,
    ) -> DalResult<Vec<SnapshotStorageLog>> {
        // We need to filter the returned logs by `l1_batch_number` in order to not return "phantom writes", i.e.,
        // logs that have deduplicated writes (e.g., a write to a non-zero value and back to zero in the same L1 batch)
        // which are actually written to in future L1 batches.
        let storage_logs = sqlx::query!(
            r#"
            SELECT
                storage_logs.hashed_key AS "hashed_key!",
                storage_logs.value AS "value!",
                storage_logs.miniblock_number AS "miniblock_number!",
                initial_writes.l1_batch_number AS "l1_batch_number!",
                initial_writes.index
            FROM
                (
                    SELECT
                        hashed_key,
                        MAX(ARRAY[miniblock_number, operation_number]::INT []) AS op
                    FROM
                        storage_logs
                    WHERE
                        miniblock_number <= $1
                        AND hashed_key >= $3
                        AND hashed_key <= $4
                    GROUP BY
                        hashed_key
                    ORDER BY
                        hashed_key
                ) AS keys
            INNER JOIN storage_logs
                ON
                    keys.hashed_key = storage_logs.hashed_key
                    AND storage_logs.miniblock_number = keys.op[1]
                    AND storage_logs.operation_number = keys.op[2]
            INNER JOIN initial_writes ON keys.hashed_key = initial_writes.hashed_key
            WHERE
                initial_writes.l1_batch_number <= $2
            "#,
            i64::from(l2_block_number.0),
            i64::from(l1_batch_number.0),
            hashed_keys_range.start().as_bytes(),
            hashed_keys_range.end().as_bytes()
        )
        .instrument("get_storage_logs_chunk")
        .with_arg("l2_block_number", &l2_block_number)
        .with_arg("min_hashed_key", &hashed_keys_range.start())
        .with_arg("max_hashed_key", &hashed_keys_range.end())
        .report_latency()
        .expect_slow_query()
        .fetch_all(self.storage)
        .await?
        .iter()
        .map(|row| SnapshotStorageLog {
            key: H256::from_slice(&row.hashed_key),
            value: H256::from_slice(&row.value),
            l1_batch_number_of_initial_write: L1BatchNumber(row.l1_batch_number as u32),
            enumeration_index: row.index as u64,
        })
        .collect();
        Ok(storage_logs)
    }
Constructs a `storate_logs` chunk of the state AFTER processing `[0..l1_batch_number]`
batches. `l2_block_number` MUST be the last L2 block of the `l1_batch_number` batch.
core/lib/dal/src/snapshots_creator_dal.rs