pub async fn get_chunk_starts_for_l2_block(
        &mut self,
        l2_block_number: L2BlockNumber,
        key_ranges: &[ops::RangeInclusive<H256>],
    ) -> DalResult<Vec<Option<StorageRecoveryLogEntry>>> {
        let (start_keys, end_keys): (Vec<_>, Vec<_>) = key_ranges
            .iter()
            .map(|range| (range.start().as_bytes(), range.end().as_bytes()))
            .unzip();
        let rows = sqlx::query!(
            r#"
            WITH
            sl AS (
                SELECT
                    (
                        SELECT
                            ARRAY[hashed_key, value] AS kv
                        FROM
                            storage_logs
                        WHERE
                            storage_logs.miniblock_number <= $1
                            AND storage_logs.hashed_key >= u.start_key
                            AND storage_logs.hashed_key <= u.end_key
                        ORDER BY
                            storage_logs.hashed_key
                        LIMIT
                            1
                    )
                FROM
                    UNNEST($2::bytea [], $3::bytea []) AS u (start_key, end_key)
            )
            
            SELECT
                sl.kv[1] AS "hashed_key?",
                sl.kv[2] AS "value?",
                initial_writes.index
            FROM
                sl
            LEFT OUTER JOIN initial_writes ON initial_writes.hashed_key = sl.kv[1]
            "#,
            i64::from(l2_block_number.0),
            &start_keys as &[&[u8]],
            &end_keys as &[&[u8]],
        )
        .instrument("get_chunk_starts_for_l2_block")
        .with_arg("l2_block_number", &l2_block_number)
        .with_arg("key_ranges.len", &key_ranges.len())
        .fetch_all(self.storage)
        .await?;

        let rows = rows.into_iter().map(|row| {
            Some(StorageRecoveryLogEntry {
                key: H256::from_slice(row.hashed_key.as_ref()?),
                value: H256::from_slice(row.value.as_ref()?),
                leaf_index: row.index? as u64,
            })
        });
        Ok(rows.collect())
    }
Gets a starting tree entry for each of the supplied `key_ranges` for the specified
`l2_block_number`. This method is used during Merkle tree recovery.
core/lib/dal/src/storage_logs_dal.rs