kona_engine/task_queue/tasks/build/
error.rs

1//! Contains error types for the [crate::ForkchoiceTask].
2
3use crate::{
4    EngineTaskError, ForkchoiceTaskError, InsertTaskError,
5    task_queue::tasks::task::EngineTaskErrorSeverity,
6};
7use alloy_rpc_types_engine::PayloadStatusEnum;
8use alloy_transport::{RpcError, TransportErrorKind};
9use kona_protocol::FromBlockError;
10use op_alloy_rpc_types_engine::OpExecutionPayloadEnvelope;
11use thiserror::Error;
12use tokio::sync::mpsc;
13
14/// An error that occurs when running the [crate::ForkchoiceTask].
15#[derive(Debug, Error)]
16pub enum BuildTaskError {
17    /// The forkchoice update is not needed.
18    #[error("No forkchoice update needed")]
19    NoForkchoiceUpdateNeeded,
20    /// The engine is syncing.
21    #[error("Attempting to update forkchoice state while EL syncing")]
22    EngineSyncing,
23    /// Missing payload ID.
24    #[error("Missing payload ID")]
25    MissingPayloadId,
26    /// The initial forkchoice update call to the engine api failed.
27    #[error(transparent)]
28    ForkchoiceUpdateFailed(#[from] ForkchoiceTaskError),
29    /// Impossible to insert the payload into the engine.
30    #[error(transparent)]
31    PayloadInsertionFailed(#[from] InsertTaskError),
32    /// Unexpected payload status
33    #[error("Unexpected payload status: {0}")]
34    UnexpectedPayloadStatus(PayloadStatusEnum),
35    /// The get payload call to the engine api failed.
36    #[error(transparent)]
37    GetPayloadFailed(RpcError<TransportErrorKind>),
38    /// The new payload call to the engine api failed.
39    #[error(transparent)]
40    NewPayloadFailed(RpcError<TransportErrorKind>),
41    /// A deposit-only payload failed to import.
42    #[error("Deposit-only payload failed to import")]
43    DepositOnlyPayloadFailed,
44    /// Failed to re-atttempt payload import with deposit-only payload.
45    #[error("Failed to re-attempt payload import with deposit-only payload")]
46    DepositOnlyPayloadReattemptFailed,
47    /// The payload is invalid, and the derivation pipeline must
48    /// be flushed post-holocene.
49    #[error("Invalid payload, must flush post-holocene")]
50    HoloceneInvalidFlush,
51    /// Failed to convert a [`OpExecutionPayload`] to a [`L2BlockInfo`].
52    ///
53    /// [`OpExecutionPayload`]: op_alloy_rpc_types_engine::OpExecutionPayload
54    /// [`L2BlockInfo`]: kona_protocol::L2BlockInfo
55    #[error(transparent)]
56    FromBlock(#[from] FromBlockError),
57    /// Error sending the built payload envelope.
58    #[error(transparent)]
59    MpscSend(#[from] mpsc::error::SendError<OpExecutionPayloadEnvelope>),
60}
61
62impl EngineTaskError for BuildTaskError {
63    fn severity(&self) -> EngineTaskErrorSeverity {
64        match self {
65            Self::ForkchoiceUpdateFailed(inner) => inner.severity(),
66            Self::PayloadInsertionFailed(inner) => inner.severity(),
67            Self::NoForkchoiceUpdateNeeded => EngineTaskErrorSeverity::Temporary,
68            Self::EngineSyncing => EngineTaskErrorSeverity::Temporary,
69            Self::GetPayloadFailed(_) => EngineTaskErrorSeverity::Temporary,
70            Self::NewPayloadFailed(_) => EngineTaskErrorSeverity::Temporary,
71            Self::HoloceneInvalidFlush => EngineTaskErrorSeverity::Flush,
72            Self::MissingPayloadId => EngineTaskErrorSeverity::Critical,
73            Self::UnexpectedPayloadStatus(_) => EngineTaskErrorSeverity::Critical,
74            Self::DepositOnlyPayloadReattemptFailed => EngineTaskErrorSeverity::Critical,
75            Self::DepositOnlyPayloadFailed => EngineTaskErrorSeverity::Critical,
76            Self::FromBlock(_) => EngineTaskErrorSeverity::Critical,
77            Self::MpscSend(_) => EngineTaskErrorSeverity::Critical,
78        }
79    }
80}