pub async fn load_pending_batch(
    storage: &mut Connection<'_, Core>,
    system_env: SystemEnv,
    l1_batch_env: L1BatchEnv,
    pubdata_params: PubdataParams,
) -> anyhow::Result<PendingBatchData> {
    let pending_l2_blocks = storage
        .transactions_dal()
        .get_l2_blocks_to_reexecute()
        .await?;
    let first_pending_l2_block = pending_l2_blocks
        .first()
        .context("no pending L2 blocks; was environment loaded for a correct L1 batch number?")?;
    let expected_pending_l2_block_number = L2BlockNumber(l1_batch_env.first_l2_block.number);
    anyhow::ensure!(
        first_pending_l2_block.number == expected_pending_l2_block_number,
        "Invalid `L1BatchEnv` supplied: its L1 batch #{} is not pending; \
         first pending L2 block: {first_pending_l2_block:?}, first L2 block in batch: {:?}",
        l1_batch_env.number,
        l1_batch_env.first_l2_block
    );
    Ok(PendingBatchData {
        l1_batch_env,
        system_env,
        pubdata_params,
        pending_l2_blocks,
    })
}
Loads the pending L1 batch data from the database.

# Errors

Propagates DB errors. Also returns an error if environment doesn't correspond to a pending L1 batch.
core/node/state_keeper/src/io/common/mod.rs