Skip to content

Commit

Permalink
feat(plasma): Online Plasma Input Fetcher (#167)
Browse files Browse the repository at this point in the history
* feat(plasma): Online Plasma Input Fetcher Stub

* Update crates/plasma/src/lib.rs

Co-authored-by: clabby <ben@clab.by>

---------

Co-authored-by: clabby <ben@clab.by>
  • Loading branch information
refcell and clabby authored Jun 11, 2024
1 parent 5b19b6d commit 5d327d2
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions crates/plasma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,36 @@ alloy-primitives = { workspace = true, features = ["rlp"] }
async-trait.workspace = true

# Local
kona-primitives = { path = "../primitives" }
kona-derive = { path = "../derive" }
kona-primitives = { path = "../primitives", version = "0.0.1" }
kona-derive = { path = "../derive", version = "0.0.1" }

# `serde` feature dependencies
serde = { version = "1.0.203", default-features = false, features = ["derive"], optional = true }

# `online` feature dependencies
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "cb95183", optional = true }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "cb95183", default-features = false, optional = true }
reqwest = { version = "0.12", default-features = false, optional = true }

[dev-dependencies]
kona-derive = { path = "../derive", features = ["test-utils"] }
tracing-subscriber = "0.3.18"
serde_json = { version = "1.0.117", default-features = false }
tokio = { version = "1.38", features = ["full"] }
tracing-subscriber = "0.3.18"

[features]
default = ["serde"]
serde = ["dep:serde", "kona-primitives/serde"]
serde = [
"dep:serde",
"kona-primitives/serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"kona-derive/serde",
]
online = [
"dep:alloy-provider",
"dep:alloy-transport-http",
"dep:reqwest",
"alloy-provider/reqwest",
"alloy-consensus/serde",
]
5 changes: 5 additions & 0 deletions crates/plasma/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ pub mod source;
pub mod traits;
pub mod types;

#[cfg(feature = "online")]
mod online;
#[cfg(feature = "online")]
pub use online::OnlinePlasmaInputFetcher;

#[cfg(test)]
pub mod test_utils;
54 changes: 54 additions & 0 deletions crates/plasma/src/online.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//! Module contains an online implementation of the Plasma Input Fetcher.
use crate::{
traits::PlasmaInputFetcher,
types::{FinalizedHeadSignal, PlasmaError},
};
use alloc::boxed::Box;
use alloy_primitives::Bytes;
use async_trait::async_trait;
use kona_derive::online::AlloyChainProvider;
use kona_primitives::{
block::{BlockID, BlockInfo},
system_config::SystemConfig,
};

/// An Online Plasma Input Fetcher.
#[derive(Debug, Clone)]
pub struct OnlinePlasmaInputFetcher {}

#[async_trait]
impl PlasmaInputFetcher<AlloyChainProvider> for OnlinePlasmaInputFetcher {
async fn get_input(
&mut self,
_fetcher: &AlloyChainProvider,
_commitment: Bytes,
_block: BlockID,
) -> Option<Result<Bytes, PlasmaError>> {
unimplemented!()
}

async fn advance_l1_origin(
&mut self,
_fetcher: &AlloyChainProvider,
_block: BlockID,
) -> Option<Result<(), PlasmaError>> {
unimplemented!()
}

async fn reset(
&mut self,
_block_number: BlockInfo,
_cfg: SystemConfig,
) -> Option<Result<(), PlasmaError>> {
unimplemented!()
}

async fn finalize(&mut self, _block_number: BlockInfo) -> Option<Result<(), PlasmaError>> {
unimplemented!()
}

fn on_finalized_head_signal(&mut self, _callback: FinalizedHeadSignal) {
unimplemented!()
}
}

0 comments on commit 5d327d2

Please sign in to comment.