pub async fn get_expected_l1_batch_timestamp(
        &mut self,
        l1_batch_number: &ResolvedL1BatchForL2Block,
    ) -> DalResult<Option<u64>> {
        if let Some(l1_batch) = l1_batch_number.block_l1_batch {
            Ok(sqlx::query!(
                r#"
                SELECT
                    timestamp
                FROM
                    miniblocks
                WHERE
                    l1_batch_number = $1
                ORDER BY
                    number
                LIMIT
                    1
                "#,
                i64::from(l1_batch.0)
            )
            .instrument("get_expected_l1_batch_timestamp#sealed_l2_block")
            .with_arg("l1_batch_number", &l1_batch_number)
            .fetch_optional(self.storage)
            .await?
            .map(|row| row.timestamp as u64))
        } else {
            // Got a pending L2 block. Searching the timestamp of the first pending L2 block using
            // `WHERE l1_batch_number IS NULL` is slow since it potentially locks the `miniblocks` table.
            // Instead, we determine its number using the previous L1 batch, taking into the account that
            // it may be stored in the `snapshot_recovery` table.
            let prev_l1_batch_number = if l1_batch_number.pending_l1_batch == L1BatchNumber(0) {
                return Ok(None); // We haven't created the genesis L2 block yet
            } else {
                l1_batch_number.pending_l1_batch - 1
            };

            Ok(sqlx::query!(
                r#"
                SELECT
                    timestamp
                FROM
                    miniblocks
                WHERE
                    number = COALESCE(
                        (
                            SELECT
                                MAX(number) + 1
                            FROM
                                miniblocks
                            WHERE
                                l1_batch_number = $1
                        ),
                        (
                            SELECT
                                MAX(miniblock_number) + 1
                            FROM
                                snapshot_recovery
                            WHERE
                                l1_batch_number = $1
                        )
                    )
                "#,
                i64::from(prev_l1_batch_number.0)
            )
            .instrument("get_expected_l1_batch_timestamp#pending_l2_block")
            .with_arg("l1_batch_number", &l1_batch_number)
            .fetch_optional(self.storage)
            .await?
            .map(|row| row.timestamp as u64))
        }
    }
Returns L1 batch timestamp for either sealed or pending L1 batch.

The correctness of the current implementation depends on the timestamp of an L1 batch always
being equal to the timestamp of the first L2 block in the batch.
core/lib/dal/src/blocks_web3_dal.rs