Skip to content

Commit

Permalink
feat(derive): Online Data Source Factory Wiring (#150)
Browse files Browse the repository at this point in the history
* feat(derive): online dap

* fix(derive): data source factory

* fix(derive): batch queue unit test
  • Loading branch information
refcell authored Apr 27, 2024
1 parent e9b7e76 commit af80e7b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/derive/src/online/alloy_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CACHE_SIZE: usize = 16;
/// **Note**:
/// This provider fetches data using the `debug_getRawHeader`, `debug_getRawReceipts`, and
/// `debug_getRawBlock` methods. The RPC must support this namespace.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct AlloyChainProvider<T: Provider<Http<reqwest::Client>>> {
/// The inner Ethereum JSON-RPC provider.
inner: T,
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/online/beacon_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub trait BeaconClient {
}

/// An online implementation of the [BeaconClient] trait.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct OnlineBeaconClient<T: Provider<Http<Client>>> {
/// The inner Ethereum JSON-RPC provider.
inner: T,
Expand Down
4 changes: 2 additions & 2 deletions crates/derive/src/online/blob_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl From<anyhow::Error> for OnlineBlobProviderError {
}

/// An online implementation of the [BlobProvider] trait.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct OnlineBlobProvider<T: Provider<Http<Client>>, B: BeaconClient, S: SlotDerivation> {
/// The inner Ethereum JSON-RPC provider.
_inner: T,
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<T: Provider<Http<Client>>, B: BeaconClient, S: SlotDerivation> OnlineBlobPr
}

/// Minimal slot derivation implementation.
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct SimpleSlotDerivation;

impl SlotDerivation for SimpleSlotDerivation {
Expand Down
12 changes: 10 additions & 2 deletions crates/derive/src/online/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! Contains "online" implementations for providers.

use crate::{
sources::DataSourceFactory,
stages::{
AttributesQueue, BatchQueue, ChannelBank, ChannelReader, FrameQueue, L1Retrieval,
L1Traversal, NextAttributes, StatefulAttributesBuilder,
},
traits::{DataAvailabilityProvider, ResettableStage},
traits::ResettableStage,
types::RollupConfig,
};

Expand All @@ -18,7 +19,14 @@ use core::fmt::Debug;
pub fn new_online_stack(
rollup_config: Arc<RollupConfig>,
chain_provider: AlloyChainProvider<ReqwestProvider>,
dap_source: impl DataAvailabilityProvider + Send + Sync + Debug,
dap_source: DataSourceFactory<
AlloyChainProvider<ReqwestProvider>,
OnlineBlobProvider<
ReqwestProvider,
OnlineBeaconClient<ReqwestProvider>,
SimpleSlotDerivation,
>,
>,
fetcher: AlloyL2ChainProvider<ReqwestProvider>,
builder: StatefulAttributesBuilder<
AlloyChainProvider<ReqwestProvider>,
Expand Down

0 comments on commit af80e7b

Please sign in to comment.