kona_engine/task_queue/tasks/finalize/
error.rs

1//! Contains error types for the [crate::FinalizeTask].
2
3use crate::{
4    EngineTaskError, ForkchoiceTaskError, task_queue::tasks::task::EngineTaskErrorSeverity,
5};
6use alloy_transport::{RpcError, TransportErrorKind};
7use kona_protocol::FromBlockError;
8use thiserror::Error;
9
10/// An error that occurs when running the [crate::FinalizeTask].
11#[derive(Debug, Error)]
12pub enum FinalizeTaskError {
13    /// The block is not safe, and therefore cannot be finalized.
14    #[error("Attempted to finalize a block that is not yet safe")]
15    BlockNotSafe,
16    /// The block to finalize was not found.
17    #[error("The block to finalize was not found: Number {0}")]
18    BlockNotFound(u64),
19    /// An error occurred while transforming the RPC block into [`L2BlockInfo`].
20    ///
21    /// [`L2BlockInfo`]: kona_protocol::L2BlockInfo
22    #[error(transparent)]
23    FromBlock(#[from] FromBlockError),
24    /// A temporary RPC failure.
25    #[error(transparent)]
26    TransportError(#[from] RpcError<TransportErrorKind>),
27    /// The forkchoice update call to finalize the block failed.
28    #[error(transparent)]
29    ForkchoiceUpdateFailed(#[from] ForkchoiceTaskError),
30}
31
32impl EngineTaskError for FinalizeTaskError {
33    fn severity(&self) -> EngineTaskErrorSeverity {
34        match self {
35            Self::BlockNotSafe => EngineTaskErrorSeverity::Critical,
36            Self::BlockNotFound(_) => EngineTaskErrorSeverity::Critical,
37            Self::FromBlock(_) => EngineTaskErrorSeverity::Critical,
38            Self::TransportError(_) => EngineTaskErrorSeverity::Temporary,
39            Self::ForkchoiceUpdateFailed(inner) => inner.severity(),
40        }
41    }
42}