diff --git a/crates/plasma/src/plasma.rs b/crates/plasma/src/plasma.rs index f29b04765..d14a8d635 100644 --- a/crates/plasma/src/plasma.rs +++ b/crates/plasma/src/plasma.rs @@ -1,72 +1,59 @@ //! Contains the [PlasmaDataSource], which is a concrete implementation of the -//! [DataAvailabilityProvider] trait for the Plasma protocol. Used as an adapter to the +//! [DataAvailabilityProvider] trait for the Plasma source. Used as an adapter to the //! [kona_derive] crate's derivation pipeline construction. -//! -//! [DataAvailabilityProvider]: kona_derive::traits::DataAvailabilityProvider use crate::{source::PlasmaSource, traits::PlasmaInputFetcher}; use alloc::{boxed::Box, fmt::Debug}; use alloy_primitives::{Address, Bytes}; use anyhow::Result; use async_trait::async_trait; -use kona_derive::{ - traits::{ChainProvider, DataAvailabilityProvider}, - types::{BlockInfo, RollupConfig}, -}; -use kona_primitives::BlockID; +use kona_derive::traits::{ChainProvider, DataAvailabilityProvider}; +use kona_primitives::BlockInfo; -/// A factory for creating an Ethereum data source provider. +/// The plasma data source implements the [DataAvailabilityProvider] trait for the Plasma source. #[derive(Debug, Clone, Copy)] -pub struct PlasmaDataSource +pub struct PlasmaDataSource where C: ChainProvider + Send + Clone, - PIF: PlasmaInputFetcher + Clone, + F: PlasmaInputFetcher + Clone, I: Iterator + Send + Clone, { - /// The chain provider to use for the factory. + /// The chain provider. pub chain_provider: C, + /// The plasma input fetcher. + pub plasma_input_fetcher: F, /// The plasma iterator. pub plasma_source: I, - /// The plasma input fetcher. - pub plasma_input_fetcher: PIF, - /// The L1 Signer. - pub signer: Address, } -impl PlasmaDataSource +impl PlasmaDataSource where C: ChainProvider + Send + Clone + Debug, - PIF: PlasmaInputFetcher + Clone, + F: PlasmaInputFetcher + Clone, I: Iterator + Send + Clone, { - /// Creates a new factory. - pub fn new(provider: C, pif: PIF, s: I, cfg: &RollupConfig) -> Self { - Self { - chain_provider: provider, - plasma_source: s, - plasma_input_fetcher: pif, - signer: cfg.genesis.system_config.batcher_addr, - } + /// Creates a new [PlasmaDataSource] from the given providers. + pub fn new(chain_provider: C, plasma_input_fetcher: F, plasma_source: I) -> Self { + Self { chain_provider, plasma_input_fetcher, plasma_source } } } #[async_trait] -impl DataAvailabilityProvider for PlasmaDataSource +impl DataAvailabilityProvider for PlasmaDataSource where C: ChainProvider + Send + Clone + Debug + Sync, - PIF: PlasmaInputFetcher + Clone + Debug + Send + Sync, + F: PlasmaInputFetcher + Clone + Debug + Send + Sync, I: Iterator + Send + Clone + Debug + Sync, { type Item = Bytes; - type DataIter = PlasmaSource; + type DataIter = PlasmaSource; async fn open_data(&self, block_ref: &BlockInfo, _: Address) -> Result { - let id = BlockID { hash: block_ref.hash, number: block_ref.number }; Ok(PlasmaSource::new( self.chain_provider.clone(), self.plasma_input_fetcher.clone(), self.plasma_source.clone(), - id, + block_ref.id(), )) } }