diff --git a/crates/protocol/genesis/src/chain/config.rs b/crates/protocol/genesis/src/chain/config.rs index 29c4e30b27..e02e71678b 100644 --- a/crates/protocol/genesis/src/chain/config.rs +++ b/crates/protocol/genesis/src/chain/config.rs @@ -6,9 +6,9 @@ use alloy_eips::eip1559::BaseFeeParams; use alloy_primitives::Address; use crate::{ - AddressList, AltDAConfig, BaseFeeConfig, ChainGenesis, GRANITE_CHANNEL_TIMEOUT, HardForkConfig, - Roles, RollupConfig, SuperchainLevel, base_fee_params, base_fee_params_canyon, - params::base_fee_config, rollup::DEFAULT_INTEROP_MESSAGE_EXPIRY_WINDOW, + AddressList, AltDAConfig, BaseFeeConfig, ChainGenesis, FJORD_MAX_SEQUENCER_DRIFT, + GRANITE_CHANNEL_TIMEOUT, HardForkConfig, Roles, RollupConfig, SuperchainLevel, base_fee_params, + base_fee_params_canyon, params::base_fee_config, rollup::DEFAULT_INTEROP_MESSAGE_EXPIRY_WINDOW, }; /// L1 chain configuration from the `alloy-genesis` crate. @@ -176,6 +176,7 @@ impl ChainConfig { // necessary. channel_timeout: 300, granite_channel_timeout: GRANITE_CHANNEL_TIMEOUT, + fjord_max_sequencer_drift: FJORD_MAX_SEQUENCER_DRIFT, interop_message_expiry_window: DEFAULT_INTEROP_MESSAGE_EXPIRY_WINDOW, chain_op_config: self.base_fee_config(), alt_da_config: self.alt_da.clone(), diff --git a/crates/protocol/genesis/src/rollup.rs b/crates/protocol/genesis/src/rollup.rs index a6048d51e5..240d9ff266 100644 --- a/crates/protocol/genesis/src/rollup.rs +++ b/crates/protocol/genesis/src/rollup.rs @@ -26,6 +26,11 @@ const fn default_granite_channel_timeout() -> u64 { GRANITE_CHANNEL_TIMEOUT } +#[cfg(feature = "serde")] +const fn default_fjord_max_sequencer_drift() -> u64 { + FJORD_MAX_SEQUENCER_DRIFT +} + #[cfg(feature = "serde")] const fn default_interop_message_expiry_window() -> u64 { DEFAULT_INTEROP_MESSAGE_EXPIRY_WINDOW @@ -55,6 +60,9 @@ pub struct RollupConfig { /// The channel timeout after the Granite hardfork. #[cfg_attr(feature = "serde", serde(default = "default_granite_channel_timeout"))] pub granite_channel_timeout: u64, + /// The max sequencer drift after the Fjord hardfork. + #[cfg_attr(feature = "serde", serde(default = "default_fjord_max_sequencer_drift"))] + pub fjord_max_sequencer_drift: u64, /// The L1 chain ID pub l1_chain_id: u64, /// The L2 chain ID @@ -115,6 +123,7 @@ impl<'a> arbitrary::Arbitrary<'a> for RollupConfig { seq_window_size: u.arbitrary()?, channel_timeout: u.arbitrary()?, granite_channel_timeout: u.arbitrary()?, + fjord_max_sequencer_drift: u.arbitrary()?, l1_chain_id: u.arbitrary()?, l2_chain_id: u.arbitrary()?, hardforks: HardForkConfig::arbitrary(u)?, @@ -142,6 +151,7 @@ impl Default for RollupConfig { seq_window_size: 0, channel_timeout: 0, granite_channel_timeout: GRANITE_CHANNEL_TIMEOUT, + fjord_max_sequencer_drift: FJORD_MAX_SEQUENCER_DRIFT, l1_chain_id: 0, l2_chain_id: Chain::from_id(0), hardforks: HardForkConfig::default(), @@ -331,7 +341,7 @@ impl RollupConfig { /// Returns the max sequencer drift for the given timestamp. pub fn max_sequencer_drift(&self, timestamp: u64) -> u64 { if self.is_fjord_active(timestamp) { - FJORD_MAX_SEQUENCER_DRIFT + self.fjord_max_sequencer_drift } else { self.max_sequencer_drift } @@ -774,6 +784,20 @@ mod tests { assert_eq!(config.max_sequencer_drift(10), FJORD_MAX_SEQUENCER_DRIFT); } + #[test] + fn test_fjord_max_sequencer_drift() { + let mut config = RollupConfig { + max_sequencer_drift: 100, + hardforks: HardForkConfig { fjord_time: Some(10), ..Default::default() }, + ..Default::default() + }; + assert_eq!(config.max_sequencer_drift(0), 100); + assert_eq!(config.max_sequencer_drift(10), FJORD_MAX_SEQUENCER_DRIFT); + config.fjord_max_sequencer_drift = 2892; + assert_eq!(config.max_sequencer_drift(0), 100); + assert_eq!(config.max_sequencer_drift(10), 2892); + } + #[test] #[cfg(feature = "serde")] fn test_deserialize_reference_rollup_config() { @@ -861,6 +885,7 @@ mod tests { seq_window_size: 3600, channel_timeout: 300, granite_channel_timeout: GRANITE_CHANNEL_TIMEOUT, + fjord_max_sequencer_drift: FJORD_MAX_SEQUENCER_DRIFT, l1_chain_id: 3151908, l2_chain_id: Chain::from_id(1337), hardforks: HardForkConfig { diff --git a/crates/protocol/registry/src/test_utils/base_mainnet.rs b/crates/protocol/registry/src/test_utils/base_mainnet.rs index 7d0c73e77b..f4b63e5b91 100644 --- a/crates/protocol/registry/src/test_utils/base_mainnet.rs +++ b/crates/protocol/registry/src/test_utils/base_mainnet.rs @@ -45,6 +45,7 @@ pub const BASE_MAINNET_CONFIG: RollupConfig = RollupConfig { seq_window_size: 3600, channel_timeout: 300, granite_channel_timeout: 50, + fjord_max_sequencer_drift: 1800, l1_chain_id: 1, l2_chain_id: Chain::base_mainnet(), hardforks: HardForkConfig { diff --git a/crates/protocol/registry/src/test_utils/base_sepolia.rs b/crates/protocol/registry/src/test_utils/base_sepolia.rs index b52d182efb..74829e7eb8 100644 --- a/crates/protocol/registry/src/test_utils/base_sepolia.rs +++ b/crates/protocol/registry/src/test_utils/base_sepolia.rs @@ -45,6 +45,7 @@ pub const BASE_SEPOLIA_CONFIG: RollupConfig = RollupConfig { seq_window_size: 3600, channel_timeout: 300, granite_channel_timeout: 50, + fjord_max_sequencer_drift: 1800, l1_chain_id: 11155111, l2_chain_id: Chain::base_sepolia(), chain_op_config: BASE_SEPOLIA_BASE_FEE_CONFIG, diff --git a/crates/protocol/registry/src/test_utils/op_mainnet.rs b/crates/protocol/registry/src/test_utils/op_mainnet.rs index 1bb0cbba4e..2b5f5bbeb8 100644 --- a/crates/protocol/registry/src/test_utils/op_mainnet.rs +++ b/crates/protocol/registry/src/test_utils/op_mainnet.rs @@ -45,6 +45,7 @@ pub const OP_MAINNET_CONFIG: RollupConfig = RollupConfig { seq_window_size: 3600_u64, channel_timeout: 300_u64, granite_channel_timeout: 50, + fjord_max_sequencer_drift: 1800, l1_chain_id: 1_u64, l2_chain_id: Chain::optimism_mainnet(), chain_op_config: OP_MAINNET_BASE_FEE_CONFIG, diff --git a/crates/protocol/registry/src/test_utils/op_sepolia.rs b/crates/protocol/registry/src/test_utils/op_sepolia.rs index e912d72ca9..b6ab784f99 100644 --- a/crates/protocol/registry/src/test_utils/op_sepolia.rs +++ b/crates/protocol/registry/src/test_utils/op_sepolia.rs @@ -45,6 +45,7 @@ pub const OP_SEPOLIA_CONFIG: RollupConfig = RollupConfig { seq_window_size: 3600, channel_timeout: 300, granite_channel_timeout: 50, + fjord_max_sequencer_drift: 1800, l1_chain_id: 11155111, l2_chain_id: Chain::optimism_sepolia(), chain_op_config: OP_SEPOLIA_BASE_FEE_CONFIG,