Skip to content

Commit

Permalink
Merge pull request #74 from ethereum-optimism/refcell/hoist-params
Browse files Browse the repository at this point in the history
fix(derive): Hoist Type Params
  • Loading branch information
refcell authored Apr 4, 2024
2 parents 50a4410 + 1d75e28 commit 92fcc87
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
3 changes: 2 additions & 1 deletion crates/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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,
};

Expand Down
14 changes: 14 additions & 0 deletions crates/derive/src/params.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
3 changes: 2 additions & 1 deletion crates/derive/src/stages/l1_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ impl<F: ChainProvider + Send, T: TelemetryProvider + Send> ResettableStage for L
pub(crate) mod tests {
use super::*;
use crate::{
params::{CONFIG_UPDATE_EVENT_VERSION_0, CONFIG_UPDATE_TOPIC},
traits::test_utils::{TestChainProvider, TestTelemetry},
types::{Receipt, CONFIG_UPDATE_EVENT_VERSION_0, CONFIG_UPDATE_TOPIC},
types::Receipt,
};
use alloc::vec;
use alloy_primitives::{address, b256, hex, Address, Bytes, Log, LogData, B256};
Expand Down
7 changes: 1 addition & 6 deletions crates/derive/src/types/frame.rs
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
5 changes: 1 addition & 4 deletions crates/derive/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use alloy_primitives::Bytes;
use alloy_rlp::{Decodable, Encodable};

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;
Expand Down
12 changes: 3 additions & 9 deletions crates/derive/src/types/system_config.rs
Original file line number Diff line number Diff line change
@@ -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))]
Expand Down Expand Up @@ -240,7 +234,7 @@ mod test {

use super::*;
use alloc::vec;
use alloy_primitives::{hex, LogData};
use alloy_primitives::{b256, hex, LogData, B256};

extern crate std;

Expand Down

0 comments on commit 92fcc87

Please sign in to comment.