kona_genesis/system/
update.rs

1//! Contains the [`SystemConfigUpdate`].
2
3use crate::{
4    BatcherUpdate, Eip1559Update, GasConfigUpdate, GasLimitUpdate, OperatorFeeUpdate, SystemConfig,
5    SystemConfigUpdateKind,
6};
7
8/// The system config update is an update
9/// of type [`SystemConfigUpdateKind`].
10#[derive(Debug, Clone, Hash, PartialEq, Eq)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub enum SystemConfigUpdate {
13    /// The batcher update.
14    Batcher(BatcherUpdate),
15    /// The gas config update.
16    GasConfig(GasConfigUpdate),
17    /// The gas limit update.
18    GasLimit(GasLimitUpdate),
19    /// The unsafe block signer update.
20    UnsafeBlockSigner,
21    /// The EIP-1559 parameters update.
22    Eip1559(Eip1559Update),
23    /// The operator fee parameter update.
24    OperatorFee(OperatorFeeUpdate),
25}
26
27impl SystemConfigUpdate {
28    /// Applies the update to the [`SystemConfig`].
29    pub fn apply(&self, config: &mut SystemConfig) {
30        match self {
31            Self::Batcher(update) => update.apply(config),
32            Self::GasConfig(update) => update.apply(config),
33            Self::GasLimit(update) => update.apply(config),
34            Self::UnsafeBlockSigner => { /* Ignored in derivation */ }
35            Self::Eip1559(update) => update.apply(config),
36            Self::OperatorFee(update) => update.apply(config),
37        }
38    }
39
40    /// Returns the update kind.
41    pub const fn kind(&self) -> SystemConfigUpdateKind {
42        match self {
43            Self::Batcher(_) => SystemConfigUpdateKind::Batcher,
44            Self::GasConfig(_) => SystemConfigUpdateKind::GasConfig,
45            Self::GasLimit(_) => SystemConfigUpdateKind::GasLimit,
46            Self::UnsafeBlockSigner => SystemConfigUpdateKind::UnsafeBlockSigner,
47            Self::Eip1559(_) => SystemConfigUpdateKind::Eip1559,
48            Self::OperatorFee(_) => SystemConfigUpdateKind::OperatorFee,
49        }
50    }
51}