kona_genesis/system/
errors.rs

1//! Contains error types for system config updates.
2
3use alloy_primitives::B256;
4use derive_more::From;
5
6/// An error for processing the [crate::SystemConfig] update log.
7#[derive(Debug, From, thiserror::Error, Clone, Copy, PartialEq, Eq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub enum SystemConfigUpdateError {
10    /// An error occurred while processing the update log.
11    #[error("Log processing error: {0}")]
12    LogProcessing(LogProcessingError),
13    /// A batcher update error.
14    #[error("Batcher update error: {0}")]
15    Batcher(BatcherUpdateError),
16    /// A gas config update error.
17    #[error("Gas config update error: {0}")]
18    GasConfig(GasConfigUpdateError),
19    /// A gas limit update error.
20    #[error("Gas limit update error: {0}")]
21    GasLimit(GasLimitUpdateError),
22    /// An EIP-1559 parameter update error.
23    #[error("EIP-1559 parameter update error: {0}")]
24    Eip1559(EIP1559UpdateError),
25    /// An operator fee parameter update error.
26    #[error("Operator fee parameter update error: {0}")]
27    OperatorFee(OperatorFeeUpdateError),
28}
29
30/// An error occurred while processing the update log.
31#[derive(Debug, From, thiserror::Error, Clone, Copy, PartialEq, Eq)]
32#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
33pub enum LogProcessingError {
34    /// Received an incorrect number of log topics.
35    #[error("Invalid config update log: invalid topic length: {0}")]
36    InvalidTopicLen(usize),
37    /// The log topic is invalid.
38    #[error("Invalid config update log: invalid topic")]
39    InvalidTopic,
40    /// The config update log version is unsupported.
41    #[error("Invalid config update log: unsupported version: {0}")]
42    UnsupportedVersion(B256),
43    /// Failed to decode the update type from the config update log.
44    #[error("Failed to decode config update log: update type")]
45    UpdateTypeDecodingError,
46    /// An invalid system config update type.
47    #[error("Invalid system config update type: {0}")]
48    InvalidSystemConfigUpdateType(u64),
49}
50
51/// An error for updating the batcher address on the [crate::SystemConfig].
52#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
53#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
54pub enum BatcherUpdateError {
55    /// Invalid data length.
56    #[error("Invalid config update log: invalid data length: {0}")]
57    InvalidDataLen(usize),
58    /// Failed to decode the data pointer argument from the batcher update log.
59    #[error("Failed to decode batcher update log: data pointer")]
60    PointerDecodingError,
61    /// The data pointer is invalid.
62    #[error("Invalid config update log: invalid data pointer: {0}")]
63    InvalidDataPointer(u64),
64    /// Failed to decode the data length argument from the batcher update log.
65    #[error("Failed to decode batcher update log: data length")]
66    LengthDecodingError,
67    /// The data length is invalid.
68    #[error("Invalid config update log: invalid data length: {0}")]
69    InvalidDataLength(u64),
70    /// Failed to decode the batcher address argument from the batcher update log.
71    #[error("Failed to decode batcher update log: batcher address")]
72    BatcherAddressDecodingError,
73}
74
75/// An error for updating the gas config on the [crate::SystemConfig].
76#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
77#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
78pub enum GasConfigUpdateError {
79    /// Invalid data length.
80    #[error("Invalid config update log: invalid data length: {0}")]
81    InvalidDataLen(usize),
82    /// Failed to decode the data pointer argument from the gas config update log.
83    #[error("Failed to decode gas config update log: data pointer")]
84    PointerDecodingError,
85    /// The data pointer is invalid.
86    #[error("Invalid config update log: invalid data pointer: {0}")]
87    InvalidDataPointer(u64),
88    /// Failed to decode the data length argument from the gas config update log.
89    #[error("Failed to decode gas config update log: data length")]
90    LengthDecodingError,
91    /// The data length is invalid.
92    #[error("Invalid config update log: invalid data length: {0}")]
93    InvalidDataLength(u64),
94    /// Failed to decode the overhead argument from the gas config update log.
95    #[error("Failed to decode gas config update log: overhead")]
96    OverheadDecodingError,
97    /// Failed to decode the scalar argument from the gas config update log.
98    #[error("Failed to decode gas config update log: scalar")]
99    ScalarDecodingError,
100}
101
102/// An error for updating the gas limit on the [crate::SystemConfig].
103#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
104#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
105pub enum GasLimitUpdateError {
106    /// Invalid data length.
107    #[error("Invalid config update log: invalid data length: {0}")]
108    InvalidDataLen(usize),
109    /// Failed to decode the data pointer argument from the gas limit update log.
110    #[error("Failed to decode gas limit update log: data pointer")]
111    PointerDecodingError,
112    /// The data pointer is invalid.
113    #[error("Invalid config update log: invalid data pointer: {0}")]
114    InvalidDataPointer(u64),
115    /// Failed to decode the data length argument from the gas limit update log.
116    #[error("Failed to decode gas limit update log: data length")]
117    LengthDecodingError,
118    /// The data length is invalid.
119    #[error("Invalid config update log: invalid data length: {0}")]
120    InvalidDataLength(u64),
121    /// Failed to decode the gas limit argument from the gas limit update log.
122    #[error("Failed to decode gas limit update log: gas limit")]
123    GasLimitDecodingError,
124}
125
126/// An error for updating the EIP-1559 parameters on the [crate::SystemConfig].
127#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
128#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
129pub enum EIP1559UpdateError {
130    /// Invalid data length.
131    #[error("Invalid config update log: invalid data length: {0}")]
132    InvalidDataLen(usize),
133    /// Failed to decode the data pointer argument from the eip 1559 update log.
134    #[error("Failed to decode eip1559 parameter update log: data pointer")]
135    PointerDecodingError,
136    /// The data pointer is invalid.
137    #[error("Invalid config update log: invalid data pointer: {0}")]
138    InvalidDataPointer(u64),
139    /// Failed to decode the data length argument from the eip 1559 update log.
140    #[error("Failed to decode eip1559 parameter update log: data length")]
141    LengthDecodingError,
142    /// The data length is invalid.
143    #[error("Invalid config update log: invalid data length: {0}")]
144    InvalidDataLength(u64),
145    /// Failed to decode the eip1559 params argument from the eip 1559 update log.
146    #[error("Failed to decode eip1559 parameter update log: eip1559 parameters")]
147    EIP1559DecodingError,
148}
149
150/// An error for updating the operator fee parameters on the [crate::SystemConfig].
151#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
152#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
153pub enum OperatorFeeUpdateError {
154    /// Invalid data length.
155    #[error("Invalid config update log: invalid data length: {0}")]
156    InvalidDataLen(usize),
157    /// Failed to decode the data pointer argument from the eip 1559 update log.
158    #[error("Failed to decode eip1559 parameter update log: data pointer")]
159    PointerDecodingError,
160    /// The data pointer is invalid.
161    #[error("Invalid config update log: invalid data pointer: {0}")]
162    InvalidDataPointer(u64),
163    /// Failed to decode the data length argument from the eip 1559 update log.
164    #[error("Failed to decode eip1559 parameter update log: data length")]
165    LengthDecodingError,
166    /// The data length is invalid.
167    #[error("Invalid config update log: invalid data length: {0}")]
168    InvalidDataLength(u64),
169    /// Failed to decode the scalar argument from the update log.
170    #[error("Failed to decode operator fee parameter update log: scalar")]
171    ScalarDecodingError,
172    /// Failed to decode the constant argument from the update log.
173    #[error("Failed to decode operator fee parameter update log: constant")]
174    ConstantDecodingError,
175}