Skip to content

Commit

Permalink
Merge pull request #71 from ethereum-optimism/refcell/arc-rollup-config
Browse files Browse the repository at this point in the history
fix(derive): Share the RollupConfig across Stages with an Arc
  • Loading branch information
refcell authored Apr 1, 2024
2 parents 7ee85a3 + 8622061 commit 97bf8f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions crates/derive/src/stages/channel_bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
traits::{ChainProvider, DataAvailabilityProvider, ResettableStage},
types::{BlockInfo, Channel, Frame, RollupConfig, StageError, StageResult, SystemConfig},
};
use alloc::sync::Arc;
use alloc::{boxed::Box, collections::VecDeque};
use alloy_primitives::Bytes;
use anyhow::anyhow;
Expand All @@ -31,7 +32,7 @@ where
CP: ChainProvider + Debug,
{
/// The rollup configuration.
cfg: RollupConfig,
cfg: Arc<RollupConfig>,
/// Map of channels by ID.
channels: HashMap<ChannelID, Channel>,
/// Channels in FIFO order.
Expand All @@ -48,7 +49,7 @@ where
/// Create a new [ChannelBank] stage.
pub fn new(cfg: RollupConfig, prev: FrameQueue<DAP, CP>) -> Self {
Self {
cfg,
cfg: Arc::new(cfg),
channels: HashMap::new(),
channel_queue: VecDeque::new(),
prev,
Expand Down
7 changes: 4 additions & 3 deletions crates/derive/src/stages/l1_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use crate::{
types::{BlockInfo, RollupConfig, StageError, StageResult, SystemConfig},
};
use alloc::boxed::Box;
use alloc::sync::Arc;
use anyhow::anyhow;
use async_trait::async_trait;

/// The L1 traversal stage of the derivation pipeline.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub struct L1Traversal<Provider: ChainProvider> {
/// The current block in the traversal stage.
pub(crate) block: Option<BlockInfo>,
Expand All @@ -20,7 +21,7 @@ pub struct L1Traversal<Provider: ChainProvider> {
/// The system config
pub system_config: SystemConfig,
/// The rollup config
pub rollup_config: RollupConfig,
pub rollup_config: Arc<RollupConfig>,
}

impl<F: ChainProvider> L1Traversal<F> {
Expand All @@ -31,7 +32,7 @@ impl<F: ChainProvider> L1Traversal<F> {
data_source,
done: false,
system_config: SystemConfig::default(),
rollup_config: cfg,
rollup_config: Arc::new(cfg),
}
}

Expand Down

0 comments on commit 97bf8f1

Please sign in to comment.