pub async fn wait_for_l1_batch(
    pool: &ConnectionPool<Core>,
    poll_interval: Duration,
    stop_receiver: &mut watch::Receiver<bool>,
) -> Result<L1BatchNumber, OrStopped> {
    tracing::debug!("Waiting for at least one L1 batch in db in DB");
    loop {
        if *stop_receiver.borrow() {
            return Err(OrStopped::Stopped);
        }

        let mut storage = pool.connection().await?;
        let sealed_l1_batch_number = storage.blocks_dal().get_earliest_l1_batch_number().await?;
        drop(storage);

        if let Some(number) = sealed_l1_batch_number {
            return Ok(number);
        }

        // We don't check the result: if a stop request is received, we'll return at the start
        // of the next iteration.
        tokio::time::timeout(poll_interval, stop_receiver.changed())
            .await
            .ok();
    }
}
Repeatedly polls the DB until there is an L1 batch. We may not have such a batch initially
if the DB is recovered from an application-level snapshot.

Returns the number of the *earliest* L1 batch.
core/lib/dal/src/helpers.rs