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

feat(derive): Abstract Alt DA out of kona-derive #156

Merged
merged 5 commits into from
Apr 28, 2024
Merged

Conversation

clabby
Copy link
Collaborator

@clabby clabby commented Apr 28, 2024

Overview

Abstracts alternative data availability adapters out of kona-derive by doing away with the DataSourceFactory in favor of adapters implementing the DataAvailabilityProvider trait themselves. Right now, the DataSourceFactory composes the various DA options like so:

struct DataSourceFactory<C, B, PIF, I>
where
    C: ChainProvider + Send + Clone,
    B: BlobProvider + Clone,
    PIF: PlasmaInputFetcher<C> + Clone,
    I: Iterator<Item = Bytes> + Send + Clone,
{ /* ... */ }

Removing the dependency on the DataSourceFactory as a composition type wrapping around the DataAvailabilityProvider trait lends towards more flexibility for other future alternative DA adapter implementors, given that kona-derive's business logic only depends on the DataAvailabilityProvider trait's interface. This also allows us to completely decouple alt data availability modifications from kona-derive, and allow for them to exist as extensions (think: revm + the handler abstractions, allowing for modifications to the base EVM logic). Other consumers of the crate can make new extensions without having to upstream changes to kona-derive for their modifications.

This also makes composition a bit cleaner for the consumer of the library - for example, in the online feature of kona-derive's constructor, we can use the concrete implementations of the various online traits, as well as abstract over the DA (useful, for example, in a rollup client that may support several DAs through configuration at a higher level):

/// Creates a new online stack.
#[cfg(feature = "online")]
pub fn new_online_stack<DAP>(
    rollup_config: Arc<RollupConfig>,
    chain_provider: AlloyChainProvider<ReqwestProvider>,
    dap_source: DAP,
    fetcher: AlloyL2ChainProvider<ReqwestProvider>,
    builder: StatefulAttributesBuilder<
        AlloyChainProvider<ReqwestProvider>,
        AlloyL2ChainProvider<ReqwestProvider>,
    >,
) -> impl NextAttributes + ResettableStage + Debug + Send
where
    DAP: DataAvailabilityProvider + Debug + Send,
{ /* ... */ }

Note that above, we no longer need to supply types for DA options we are not using.

Other File Jumblin'

  1. kona-plasma now contains all logic related to the alternative Plasma DA extension for kona-derive.
  2. kona-providers has been moved back into kona-derive; These providers are specific to the pipeline and pretty minimal interfaces of the full RPCs, shouldn't be useful except to consumers of kona-derive.

@clabby clabby added K-feature Kind: feature A-derive Area: kona-derive crate A-plasma labels Apr 28, 2024
@clabby clabby self-assigned this Apr 28, 2024
@clabby clabby requested a review from refcell April 28, 2024 04:03
Copy link
Collaborator

@refcell refcell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic work, thank you @clabby

@refcell refcell added this pull request to the merge queue Apr 28, 2024
Merged via the queue into main with commit f3a961b Apr 28, 2024
13 checks passed
@github-actions github-actions bot mentioned this pull request Apr 28, 2024
@clabby clabby deleted the cl/abstract-alt-da branch April 28, 2024 16:28
This was referenced May 29, 2024
This was referenced Jun 6, 2024
This was referenced Jun 16, 2024
@github-actions github-actions bot mentioned this pull request Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: kona-derive crate K-feature Kind: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants