From 8067d9be30ee9771ce48327b47531cdc2817bf4b Mon Sep 17 00:00:00 2001 From: refcell Date: Sun, 28 Apr 2024 12:20:32 -0700 Subject: [PATCH] feat(plasma): Online Plasma Input Fetcher Stub --- Cargo.lock | 3 +++ crates/plasma/Cargo.toml | 26 +++++++++++++++--- crates/plasma/src/lib.rs | 5 ++++ crates/plasma/src/online.rs | 54 +++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 crates/plasma/src/online.rs diff --git a/Cargo.lock b/Cargo.lock index a189b0925..ee68fe018 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1806,10 +1806,13 @@ version = "0.0.1" dependencies = [ "alloy-consensus", "alloy-primitives", + "alloy-provider", + "alloy-transport-http", "anyhow", "async-trait", "kona-derive", "kona-primitives", + "reqwest", "serde", "serde_json", "tokio", diff --git a/crates/plasma/Cargo.toml b/crates/plasma/Cargo.toml index 2a3097f3a..8fe13aa69 100644 --- a/crates/plasma/Cargo.toml +++ b/crates/plasma/Cargo.toml @@ -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", +] diff --git a/crates/plasma/src/lib.rs b/crates/plasma/src/lib.rs index 4fec9fa22..2585370b7 100644 --- a/crates/plasma/src/lib.rs +++ b/crates/plasma/src/lib.rs @@ -11,5 +11,10 @@ pub mod source; pub mod traits; pub mod types; +#[cfg(feature = "online")] +pub mod online; +#[cfg(feature = "online")] +pub use online::OnlinePlasmaInputFetcher; + #[cfg(test)] pub mod test_utils; diff --git a/crates/plasma/src/online.rs b/crates/plasma/src/online.rs new file mode 100644 index 000000000..60b6227d4 --- /dev/null +++ b/crates/plasma/src/online.rs @@ -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 for OnlinePlasmaInputFetcher { + async fn get_input( + &mut self, + _fetcher: &AlloyChainProvider, + _commitment: Bytes, + _block: BlockID, + ) -> Option> { + unimplemented!() + } + + async fn advance_l1_origin( + &mut self, + _fetcher: &AlloyChainProvider, + _block: BlockID, + ) -> Option> { + unimplemented!() + } + + async fn reset( + &mut self, + _block_number: BlockInfo, + _cfg: SystemConfig, + ) -> Option> { + unimplemented!() + } + + async fn finalize(&mut self, _block_number: BlockInfo) -> Option> { + unimplemented!() + } + + fn on_finalized_head_signal(&mut self, _callback: FinalizedHeadSignal) { + unimplemented!() + } +}