kona_engine/task_queue/tasks/synchronize/
error.rs

1//! Contains error types for the [crate::SynchronizeTask].
2
3use crate::{EngineTaskError, task_queue::tasks::task::EngineTaskErrorSeverity};
4use alloy_rpc_types_engine::PayloadStatusEnum;
5use alloy_transport::{RpcError, TransportErrorKind};
6use thiserror::Error;
7
8/// An error that occurs when running the [crate::SynchronizeTask].
9#[derive(Debug, Error)]
10pub enum SynchronizeTaskError {
11    /// The forkchoice update call to the engine api failed.
12    #[error("Forkchoice update engine api call failed due to an RPC error: {0}")]
13    ForkchoiceUpdateFailed(RpcError<TransportErrorKind>),
14    /// The finalized head is behind the unsafe head.
15    #[error("Invalid forkchoice state: unsafe head {0} is ahead of finalized head {1}")]
16    FinalizedAheadOfUnsafe(u64, u64),
17    /// The forkchoice state is invalid.
18    #[error("Invalid forkchoice state")]
19    InvalidForkchoiceState,
20    /// The payload status is unexpected.
21    #[error("Unexpected payload status: {0}")]
22    UnexpectedPayloadStatus(PayloadStatusEnum),
23}
24
25impl EngineTaskError for SynchronizeTaskError {
26    fn severity(&self) -> EngineTaskErrorSeverity {
27        match self {
28            Self::FinalizedAheadOfUnsafe(_, _) => EngineTaskErrorSeverity::Critical,
29            Self::ForkchoiceUpdateFailed(_) => EngineTaskErrorSeverity::Temporary,
30            Self::UnexpectedPayloadStatus(_) => EngineTaskErrorSeverity::Temporary,
31            Self::InvalidForkchoiceState => EngineTaskErrorSeverity::Reset,
32        }
33    }
34}