1use crate::InteropProvider;
4use alloy_primitives::{Address, B256};
5use core::fmt::Debug;
6use kona_registry::HashMap;
7use thiserror::Error;
8
9#[derive(Debug, Clone, PartialEq, Eq, Error)]
13pub enum MessageGraphError<E: Debug> {
14 #[error("Dependency set is impossibly empty")]
16 EmptyDependencySet,
17 #[error("Missing a RollupConfig for chain ID {0}")]
21 MissingRollupConfig(u64),
22 #[error("Interop provider: {0}")]
24 InteropProviderError(#[from] E),
25 #[error("Remote message not found on chain ID {chain_id} with message hash {message_hash}")]
27 RemoteMessageNotFound {
28 chain_id: u64,
30 message_hash: B256,
32 },
33 #[error("Invalid message origin. Expected {expected}, got {actual}")]
35 InvalidMessageOrigin {
36 expected: Address,
38 actual: Address,
40 },
41 #[error("Invalid message hash. Expected {expected}, got {actual}")]
43 InvalidMessageHash {
44 expected: B256,
46 actual: B256,
48 },
49 #[error("Invalid message timestamp. Expected {expected}, got {actual}")]
51 InvalidMessageTimestamp {
52 expected: u64,
54 actual: u64,
56 },
57 #[error(
59 "Interop has not been active for at least one block on initiating message's chain. Activation time: {activation_time}, initiating message time: {initiating_message_time}"
60 )]
61 InitiatedTooEarly {
62 activation_time: u64,
64 initiating_message_time: u64,
66 },
67 #[error("Message is in the future. Expected timestamp to be <= {max}, got {actual}")]
69 MessageInFuture {
70 max: u64,
72 actual: u64,
74 },
75 #[error(
77 "Message has exceeded the expiry window. Initiating Timestamp: {initiating_timestamp}, Executing Timestamp: {executing_timestamp}"
78 )]
79 MessageExpired {
80 initiating_timestamp: u64,
82 executing_timestamp: u64,
84 },
85 #[error("Invalid messages found on chains: {0:?}")]
87 InvalidMessages(HashMap<u64, MessageGraphError<E>>),
88}
89
90#[allow(type_alias_bounds)]
92pub type MessageGraphResult<T, P: InteropProvider> =
93 core::result::Result<T, MessageGraphError<P::Error>>;
94
95#[derive(Debug, Clone, Error)]
99pub enum SuperRootError {
100 #[error("Invalid super root version byte")]
102 InvalidVersionByte,
103 #[error("Unexpected encoded super root length")]
105 UnexpectedLength,
106 #[error("Slice conversion error: {0}")]
108 SliceConversionError(#[from] core::array::TryFromSliceError),
109}
110
111pub type SuperRootResult<T> = core::result::Result<T, SuperRootError>;
113
114#[derive(Debug, Error, PartialEq, Eq)]
116pub enum InteropValidationError {
117 #[error("interop not enabled")]
119 InteropNotEnabled,
120
121 #[error(
123 "executing timestamp is earlier than initiating timestamp, executing: {executing}, initiating: {initiating}"
124 )]
125 InvalidTimestampInvariant {
126 executing: u64,
128 initiating: u64,
130 },
131
132 #[error("timestamp outside allowed interop window, timestamp: {0}")]
134 InvalidInteropTimestamp(u64),
135}