kona_protocol/batch/
traits.rs

1//! Traits for working with protocol types.
2
3use alloc::boxed::Box;
4use async_trait::async_trait;
5use core::fmt::Display;
6use op_alloy_consensus::OpBlock;
7
8use crate::L2BlockInfo;
9
10/// Describes the functionality of a data source that fetches safe blocks.
11#[async_trait]
12pub trait BatchValidationProvider {
13    /// The error type for the [`BatchValidationProvider`].
14    type Error: Display;
15
16    /// Returns the [`L2BlockInfo`] given a block number.
17    ///
18    /// Errors if the block does not exist.
19    async fn l2_block_info_by_number(&mut self, number: u64) -> Result<L2BlockInfo, Self::Error>;
20
21    /// Returns the [`OpBlock`] for a given number.
22    ///
23    /// Errors if no block is available for the given block number.
24    async fn block_by_number(&mut self, number: u64) -> Result<OpBlock, Self::Error>;
25}