From e020a58d2db917a6f4fc4177cbe7a41701975de5 Mon Sep 17 00:00:00 2001 From: refcell Date: Wed, 3 Apr 2024 09:58:59 -0400 Subject: [PATCH] fix(derive): hoist params from types --- crates/derive/src/lib.rs | 3 ++- crates/derive/src/params.rs | 14 ++++++++++++++ crates/derive/src/stages/l1_traversal.rs | 3 ++- crates/derive/src/types/frame.rs | 7 +------ crates/derive/src/types/mod.rs | 5 +---- crates/derive/src/types/system_config.rs | 12 +++--------- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/crates/derive/src/lib.rs b/crates/derive/src/lib.rs index 0349da6ab..dc5ffbdf2 100644 --- a/crates/derive/src/lib.rs +++ b/crates/derive/src/lib.rs @@ -13,7 +13,8 @@ extern crate alloc; mod params; pub use params::{ - ChannelID, CHANNEL_ID_LENGTH, DERIVATION_VERSION_0, FRAME_OVERHEAD, MAX_CHANNEL_BANK_SIZE, + ChannelID, CHANNEL_ID_LENGTH, CONFIG_UPDATE_EVENT_VERSION_0, CONFIG_UPDATE_TOPIC, + DERIVATION_VERSION_0, FRAME_OVERHEAD, MAX_CHANNEL_BANK_SIZE, MAX_FRAME_LEN, MAX_RLP_BYTES_PER_CHANNEL, MAX_SPAN_BATCH_BYTES, }; diff --git a/crates/derive/src/params.rs b/crates/derive/src/params.rs index f14f60d93..c7ba6feb4 100644 --- a/crates/derive/src/params.rs +++ b/crates/derive/src/params.rs @@ -1,5 +1,7 @@ //! This module contains the parameters and identifying types for the derivation pipeline. +use alloy_primitives::{b256, B256}; + /// Count the tagging info as 200 in terms of buffer size. pub const FRAME_OVERHEAD: usize = 200; @@ -23,3 +25,15 @@ pub const CHANNEL_ID_LENGTH: usize = 16; /// [ChannelID] is an opaque identifier for a channel. pub type ChannelID = [u8; CHANNEL_ID_LENGTH]; + +/// `keccak256("ConfigUpdate(uint256,uint8,bytes)")` +pub const CONFIG_UPDATE_TOPIC: B256 = + b256!("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be"); + +/// The initial version of the system config event log. +pub const CONFIG_UPDATE_EVENT_VERSION_0: B256 = B256::ZERO; + +/// Frames cannot be larger than 1MB. +/// Data transactions that carry frames are generally not larger than 128 KB due to L1 network conditions, +/// but we leave space to grow larger anyway (gas limit allows for more data). +pub const MAX_FRAME_LEN: usize = 1000; diff --git a/crates/derive/src/stages/l1_traversal.rs b/crates/derive/src/stages/l1_traversal.rs index 4e05f7671..31385950b 100644 --- a/crates/derive/src/stages/l1_traversal.rs +++ b/crates/derive/src/stages/l1_traversal.rs @@ -108,8 +108,9 @@ impl ResettableStage for L1Traversal { #[cfg(test)] pub(crate) mod tests { use super::*; + use crate::params::{CONFIG_UPDATE_EVENT_VERSION_0, CONFIG_UPDATE_TOPIC}; use crate::traits::test_utils::TestChainProvider; - use crate::types::{Receipt, CONFIG_UPDATE_EVENT_VERSION_0, CONFIG_UPDATE_TOPIC}; + use crate::types::Receipt; use alloc::vec; use alloy_primitives::{address, b256, hex, Address, Bytes, Log, LogData, B256}; diff --git a/crates/derive/src/types/frame.rs b/crates/derive/src/types/frame.rs index d6ee9eed7..b6f23a9a2 100644 --- a/crates/derive/src/types/frame.rs +++ b/crates/derive/src/types/frame.rs @@ -1,14 +1,9 @@ //! This module contains the [Frame] type used within the derivation pipeline. -use crate::params::{ChannelID, DERIVATION_VERSION_0, FRAME_OVERHEAD}; +use crate::params::{ChannelID, DERIVATION_VERSION_0, FRAME_OVERHEAD, MAX_FRAME_LEN}; use alloc::vec::Vec; use anyhow::{anyhow, bail, Result}; -/// Frames cannot be larger than 1MB. -/// Data transactions that carry frames are generally not larger than 128 KB due to L1 network conditions, -/// but we leave space to grow larger anyway (gas limit allows for more data). -const MAX_FRAME_LEN: usize = 1000; - /// A channel frame is a segment of a channel's data. /// /// *Encoding* diff --git a/crates/derive/src/types/mod.rs b/crates/derive/src/types/mod.rs index 2025ab547..7141c998d 100644 --- a/crates/derive/src/types/mod.rs +++ b/crates/derive/src/types/mod.rs @@ -10,10 +10,7 @@ mod batch_type; pub use batch_type::BatchType; mod system_config; -pub use system_config::{ - SystemAccounts, SystemConfig, SystemConfigUpdateType, CONFIG_UPDATE_EVENT_VERSION_0, - CONFIG_UPDATE_TOPIC, -}; +pub use system_config::{SystemAccounts, SystemConfig, SystemConfigUpdateType}; mod rollup_config; pub use rollup_config::RollupConfig; diff --git a/crates/derive/src/types/system_config.rs b/crates/derive/src/types/system_config.rs index 0ddd85862..6e18a2443 100644 --- a/crates/derive/src/types/system_config.rs +++ b/crates/derive/src/types/system_config.rs @@ -1,17 +1,11 @@ //! This module contains the [SystemConfig] type. use super::{Receipt, RollupConfig}; -use alloy_primitives::{address, b256, Address, Log, B256, U256}; +use crate::{CONFIG_UPDATE_EVENT_VERSION_0, CONFIG_UPDATE_TOPIC}; +use alloy_primitives::{address, Address, Log, U256}; use alloy_sol_types::{sol, SolType}; use anyhow::{anyhow, bail, Result}; -/// `keccak256("ConfigUpdate(uint256,uint8,bytes)")` -pub const CONFIG_UPDATE_TOPIC: B256 = - b256!("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be"); - -/// The initial version of the system config event log. -pub const CONFIG_UPDATE_EVENT_VERSION_0: B256 = B256::ZERO; - /// Optimism system config contract values #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -239,7 +233,7 @@ mod test { use super::*; use alloc::vec; - use alloy_primitives::{hex, LogData}; + use alloy_primitives::{b256, hex, LogData, B256}; extern crate std;