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    /// An unsafe block signer update error.
29    #[error("Unsafe block signer update error: {0}")]
30    UnsafeBlockSigner(UnsafeBlockSignerUpdateError),
31}
32
33/// An error occurred while processing the update log.
34#[derive(Debug, From, thiserror::Error, Clone, Copy, PartialEq, Eq)]
35#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
36pub enum LogProcessingError {
37    /// Received an incorrect number of log topics.
38    #[error("Invalid config update log: invalid topic length: {0}")]
39    InvalidTopicLen(usize),
40    /// The log topic is invalid.
41    #[error("Invalid config update log: invalid topic")]
42    InvalidTopic,
43    /// The config update log version is unsupported.
44    #[error("Invalid config update log: unsupported version: {0}")]
45    UnsupportedVersion(B256),
46    /// Failed to decode the update type from the config update log.
47    #[error("Failed to decode config update log: update type")]
48    UpdateTypeDecodingError,
49    /// An invalid system config update type.
50    #[error("Invalid system config update type: {0}")]
51    InvalidSystemConfigUpdateType(u64),
52}
53
54/// An error for updating the batcher address on the [crate::SystemConfig].
55#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
56#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
57pub enum BatcherUpdateError {
58    /// Invalid data length.
59    #[error("Invalid config update log: invalid data length: {0}")]
60    InvalidDataLen(usize),
61    /// Failed to decode the data pointer argument from the batcher update log.
62    #[error("Failed to decode batcher update log: data pointer")]
63    PointerDecodingError,
64    /// The data pointer is invalid.
65    #[error("Invalid config update log: invalid data pointer: {0}")]
66    InvalidDataPointer(u64),
67    /// Failed to decode the data length argument from the batcher update log.
68    #[error("Failed to decode batcher update log: data length")]
69    LengthDecodingError,
70    /// The data length is invalid.
71    #[error("Invalid config update log: invalid data length: {0}")]
72    InvalidDataLength(u64),
73    /// Failed to decode the batcher address argument from the batcher update log.
74    #[error("Failed to decode batcher update log: batcher address")]
75    BatcherAddressDecodingError,
76}
77
78/// An error for updating the unsafe block signer address on the [crate::SystemConfig].
79#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
80#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
81pub enum UnsafeBlockSignerUpdateError {
82    /// Invalid data length.
83    #[error("Invalid config update log: invalid data length: {0}")]
84    InvalidDataLen(usize),
85    /// Failed to decode the data pointer argument from the update log.
86    #[error("Failed to decode unsafe block signer update log: data pointer")]
87    PointerDecodingError,
88    /// The data pointer is invalid.
89    #[error("Invalid config update log: invalid data pointer: {0}")]
90    InvalidDataPointer(u64),
91    /// Failed to decode the data length argument from the update log.
92    #[error("Failed to decode unsafe block signer update log: data length")]
93    LengthDecodingError,
94    /// The data length is invalid.
95    #[error("Invalid config update log: invalid data length: {0}")]
96    InvalidDataLength(u64),
97    /// Failed to decode the unsafe block signer address argument from the update log.
98    #[error("Failed to decode unsafe block signer update log: unsafe block signer address")]
99    UnsafeBlockSignerAddressDecodingError,
100}
101
102/// An error for updating the gas config 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 GasConfigUpdateError {
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 config update log.
110    #[error("Failed to decode gas config 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 config update log.
116    #[error("Failed to decode gas config 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 overhead argument from the gas config update log.
122    #[error("Failed to decode gas config update log: overhead")]
123    OverheadDecodingError,
124    /// Failed to decode the scalar argument from the gas config update log.
125    #[error("Failed to decode gas config update log: scalar")]
126    ScalarDecodingError,
127}
128
129/// An error for updating the gas limit on the [crate::SystemConfig].
130#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
131#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
132pub enum GasLimitUpdateError {
133    /// Invalid data length.
134    #[error("Invalid config update log: invalid data length: {0}")]
135    InvalidDataLen(usize),
136    /// Failed to decode the data pointer argument from the gas limit update log.
137    #[error("Failed to decode gas limit update log: data pointer")]
138    PointerDecodingError,
139    /// The data pointer is invalid.
140    #[error("Invalid config update log: invalid data pointer: {0}")]
141    InvalidDataPointer(u64),
142    /// Failed to decode the data length argument from the gas limit update log.
143    #[error("Failed to decode gas limit update log: data length")]
144    LengthDecodingError,
145    /// The data length is invalid.
146    #[error("Invalid config update log: invalid data length: {0}")]
147    InvalidDataLength(u64),
148    /// Failed to decode the gas limit argument from the gas limit update log.
149    #[error("Failed to decode gas limit update log: gas limit")]
150    GasLimitDecodingError,
151}
152
153/// An error for updating the EIP-1559 parameters on the [crate::SystemConfig].
154#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
155#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
156pub enum EIP1559UpdateError {
157    /// Invalid data length.
158    #[error("Invalid config update log: invalid data length: {0}")]
159    InvalidDataLen(usize),
160    /// Failed to decode the data pointer argument from the eip 1559 update log.
161    #[error("Failed to decode eip1559 parameter update log: data pointer")]
162    PointerDecodingError,
163    /// The data pointer is invalid.
164    #[error("Invalid config update log: invalid data pointer: {0}")]
165    InvalidDataPointer(u64),
166    /// Failed to decode the data length argument from the eip 1559 update log.
167    #[error("Failed to decode eip1559 parameter update log: data length")]
168    LengthDecodingError,
169    /// The data length is invalid.
170    #[error("Invalid config update log: invalid data length: {0}")]
171    InvalidDataLength(u64),
172    /// Failed to decode the eip1559 params argument from the eip 1559 update log.
173    #[error("Failed to decode eip1559 parameter update log: eip1559 parameters")]
174    EIP1559DecodingError,
175}
176
177/// An error for updating the operator fee parameters on the [crate::SystemConfig].
178#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)]
179#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
180pub enum OperatorFeeUpdateError {
181    /// Invalid data length.
182    #[error("Invalid config update log: invalid data length: {0}")]
183    InvalidDataLen(usize),
184    /// Failed to decode the data pointer argument from the operator fee update log.
185    #[error("Failed to decode operator fee parameter update log: data pointer")]
186    PointerDecodingError,
187    /// The data pointer is invalid.
188    #[error("Invalid config update log: invalid data pointer: {0}")]
189    InvalidDataPointer(u64),
190    /// Failed to decode the data length argument from the operator fee update log.
191    #[error("Failed to decode operator fee parameter update log: data length")]
192    LengthDecodingError,
193    /// The data length is invalid.
194    #[error("Invalid config update log: invalid data length: {0}")]
195    InvalidDataLength(u64),
196    /// Failed to decode the scalar argument from the update log.
197    #[error("Failed to decode operator fee parameter update log: scalar")]
198    ScalarDecodingError,
199    /// Failed to decode the constant argument from the update log.
200    #[error("Failed to decode operator fee parameter update log: constant")]
201    ConstantDecodingError,
202}