Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor ResetProvider #207

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions crates/derive/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@

use crate::{
stages::NextAttributes,
traits::{OriginAdvancer, ResettableStage},
traits::{OriginAdvancer, ResetProvider, ResettableStage},
types::{StageError, StageResult},
};
use alloc::{boxed::Box, collections::VecDeque};
use async_trait::async_trait;
use alloc::collections::VecDeque;
use core::fmt::Debug;
use kona_primitives::{BlockInfo, L2AttributesWithParent, L2BlockInfo, SystemConfig};

/// Provides the [BlockInfo] and [SystemConfig] for the stack to reset the stages.
#[async_trait]
pub trait ResetProvider {
/// Returns the current [BlockInfo] for the pipeline to reset.
async fn block_info(&self) -> BlockInfo;

/// Returns the current [SystemConfig] for the pipeline to reset.
async fn system_config(&self) -> SystemConfig;
}

/// The derivation pipeline is responsible for deriving L2 inputs from L1 data.
#[derive(Debug)]
pub struct DerivationPipeline<
Expand Down
5 changes: 4 additions & 1 deletion crates/derive/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//! pipeline.

mod data_sources;
pub use data_sources::*;
pub use data_sources::{AsyncIterator, BlobProvider, DataAvailabilityProvider};

mod reset;
pub use reset::ResetProvider;

mod providers;
pub use providers::{ChainProvider, L2ChainProvider};
Expand Down
15 changes: 15 additions & 0 deletions crates/derive/src/traits/reset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Traits for resetting stages.

use alloc::boxed::Box;
use async_trait::async_trait;
use kona_primitives::{BlockInfo, SystemConfig};

/// Provides the [BlockInfo] and [SystemConfig] for the stack to reset the stages.
#[async_trait]
pub trait ResetProvider {
/// Returns the current [BlockInfo] for the pipeline to reset.
async fn block_info(&self) -> BlockInfo;

/// Returns the current [SystemConfig] for the pipeline to reset.
async fn system_config(&self) -> SystemConfig;
}
Loading