From a80f5ac075740d404c24cc4c16dc7b7853fe1e74 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Fri, 27 Dec 2024 22:15:29 -0500 Subject: [PATCH 1/2] feat: eigenda integration using hokulea crate --- .vscode/settings.json | 6 +++ Cargo.lock | 88 +++++++++++++++++++++++++++++----- Cargo.toml | 23 +++++---- bin/host/Cargo.toml | 3 ++ bin/host/src/lib.rs | 42 ++++++++++++---- build/risczero/fpvm/Cargo.lock | 44 ++++++++++++++--- build/risczero/fpvm/Cargo.toml | 2 +- crates/common/Cargo.toml | 4 +- crates/common/src/client.rs | 6 ++- justfile | 9 +++- 10 files changed, 186 insertions(+), 41 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..346e4c16 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "rust-analyzer.linkedProjects": [ + "./Cargo.toml", + "./build/risczero/fpvm/Cargo.toml" + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 080917f5..3ce83eea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3989,6 +3989,71 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "hokulea-client" +version = "0.1.0" +source = "git+https://github.com/Layr-Labs/hokulea?branch=kailua-compatible#840a41cf1c37d8c9297fc13358f18fac15a7ce44" +dependencies = [ + "alloy-consensus 0.8.1", + "hokulea-proof", + "kona-client", + "kona-driver", + "kona-executor", + "kona-preimage", + "kona-proof", + "tracing", +] + +[[package]] +name = "hokulea-eigenda" +version = "0.1.0" +source = "git+https://github.com/Layr-Labs/hokulea?branch=kailua-compatible#840a41cf1c37d8c9297fc13358f18fac15a7ce44" +dependencies = [ + "alloy-primitives", + "async-trait", + "kona-derive", + "op-alloy-protocol", + "tracing", +] + +[[package]] +name = "hokulea-host" +version = "0.1.0" +source = "git+https://github.com/Layr-Labs/hokulea?branch=kailua-compatible#840a41cf1c37d8c9297fc13358f18fac15a7ce44" +dependencies = [ + "alloy-primitives", + "alloy-provider 0.8.1", + "alloy-rlp", + "anyhow", + "async-trait", + "clap", + "hokulea-client", + "hokulea-proof", + "kona-host", + "kona-preimage", + "reqwest", + "tokio", + "tracing", +] + +[[package]] +name = "hokulea-proof" +version = "0.1.0" +source = "git+https://github.com/Layr-Labs/hokulea?branch=kailua-compatible#840a41cf1c37d8c9297fc13358f18fac15a7ce44" +dependencies = [ + "alloy-primitives", + "async-trait", + "hokulea-eigenda", + "kona-derive", + "kona-driver", + "kona-preimage", + "kona-proof", + "op-alloy-genesis", + "op-alloy-protocol", + "op-alloy-rpc-types-engine", + "tracing", +] + [[package]] name = "home" version = "0.5.9" @@ -4592,6 +4657,7 @@ dependencies = [ "bytemuck", "c-kzg", "hashbrown 0.15.0", + "hokulea-proof", "kona-derive", "kona-driver", "kona-executor", @@ -4635,6 +4701,7 @@ dependencies = [ "boundless-market", "clap", "hashbrown 0.15.0", + "hokulea-host", "kailua-build", "kailua-client", "kailua-common", @@ -4680,7 +4747,7 @@ dependencies = [ [[package]] name = "kona-client" version = "0.1.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus 0.8.1", "alloy-eips 0.8.1", @@ -4713,7 +4780,7 @@ dependencies = [ [[package]] name = "kona-derive" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus 0.8.1", "alloy-eips 0.8.1", @@ -4732,7 +4799,7 @@ dependencies = [ [[package]] name = "kona-driver" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus 0.8.1", "alloy-primitives", @@ -4750,7 +4817,7 @@ dependencies = [ [[package]] name = "kona-executor" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus 0.8.1", "alloy-eips 0.8.1", @@ -4768,7 +4835,7 @@ dependencies = [ [[package]] name = "kona-host" version = "0.1.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus 0.8.1", "alloy-eips 0.8.1", @@ -4805,19 +4872,18 @@ dependencies = [ [[package]] name = "kona-mpt" version = "0.1.1" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-trie 0.7.6", - "serde", "thiserror 2.0.4", ] [[package]] name = "kona-preimage" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-primitives", "async-channel", @@ -4831,7 +4897,7 @@ dependencies = [ [[package]] name = "kona-proof" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus 0.8.1", "alloy-eips 0.8.1", @@ -4860,7 +4926,7 @@ dependencies = [ [[package]] name = "kona-std-fpvm" version = "0.1.1" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "async-trait", "cfg-if", @@ -4872,7 +4938,7 @@ dependencies = [ [[package]] name = "kona-std-fpvm-proc" version = "0.1.1" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 11b1aa4a..65b1ac80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,15 +63,20 @@ kailua-contracts = { path = "crates/contracts" } kailua-host = { path = "bin/host" } # Kona -kona-client = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87", default-features = false } -kona-derive = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87", default-features = false, features = ["serde"] } -kona-driver = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87" } -kona-executor = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87" } -kona-host = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87" } -kona-mpt = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87", features = ["serde"] } -kona-preimage = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87", features = ["rkyv"] } -kona-proof = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87" } -kona-std-fpvm = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87" } +kona-client = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-derive = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-driver = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-executor = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-host = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-mpt = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-preimage = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-proof = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } +kona-std-fpvm = { git = "https://github.com/anton-rs/kona", rev = "7a40d87", default-features = false } + +# Hokulea +hokulea-eigenda = { git = "https://github.com/Layr-Labs/hokulea", branch = "kailua-compatible", default-features = false } +hokulea-proof = { git = "https://github.com/Layr-Labs/hokulea", branch = "kailua-compatible", default-features = false } +hokulea-host = { git = "https://github.com/Layr-Labs/hokulea", branch = "kailua-compatible", default-features = false } # RISC Zero zkVM bonsai-sdk = { version = "1.2.0", features = ["non_blocking"] } diff --git a/bin/host/Cargo.toml b/bin/host/Cargo.toml index fa246f55..29c4408a 100644 --- a/bin/host/Cargo.toml +++ b/bin/host/Cargo.toml @@ -35,6 +35,9 @@ kona-derive.workspace = true kona-host.workspace = true kona-preimage.workspace = true +# Hokulea +hokulea-host.workspace = true + # zkVM bonsai-sdk.workspace = true boundless-market.workspace = true diff --git a/bin/host/src/lib.rs b/bin/host/src/lib.rs index 4270a560..163c73cb 100644 --- a/bin/host/src/lib.rs +++ b/bin/host/src/lib.rs @@ -18,15 +18,17 @@ use alloy::primitives::{keccak256, B256}; use alloy::providers::{Provider, ProviderBuilder, ReqwestProvider}; use alloy_chains::NamedChain; use alloy_eips::eip4844::IndexedBlobHash; +use anyhow::anyhow; use anyhow::bail; use boundless_market::storage::StorageProviderConfig; use clap::Parser; +use hokulea_host::eigenda_blobs::OnlineEigenDABlobProvider; +use hokulea_host::eigenda_fetcher::FetcherWithEigenDASupport; +use hokulea_host::start_native_preimage_server; use kailua_client::{parse_b256, BoundlessArgs}; use kailua_common::blobs::BlobFetchRequest; use kailua_common::precondition::PreconditionValidationData; -use kona_host::fetcher::Fetcher; use kona_host::kv::SharedKeyValueStore; -use kona_host::start_native_preimage_server; use kona_preimage::{BidirectionalChannel, HintWriter, OracleReader, PreimageKey, PreimageKeyType}; use op_alloy_genesis::RollupConfig; use op_alloy_protocol::BlockInfo; @@ -76,6 +78,17 @@ pub struct KailuaHostCli { /// Storage provider to use for elf and input #[clap(flatten)] pub boundless_storage_config: Option, + + #[clap(flatten)] + pub eigenda_args: EigenDAArgs, +} + +#[derive(Parser, Debug, Clone)] +pub struct EigenDAArgs { + /// URL of the Ethereum RPC endpoint. + #[clap(long, env)] + #[arg(required = false)] + pub eigenda_proxy_address: Option, } /// Starts the [PreimageServer] and the client program in separate threads. The client program is @@ -97,13 +110,24 @@ pub async fn start_server_and_native_client( let kv_store = args.kona.construct_kv_store(); let fetcher = if !args.kona.is_offline() { let (l1_provider, blob_provider, l2_provider) = args.kona.create_providers().await?; - Some(Arc::new(RwLock::new(Fetcher::new( - kv_store.clone(), - l1_provider, - blob_provider, - l2_provider, - args.kona.agreed_l2_head_hash, - )))) + let eigenda_blob_provider = OnlineEigenDABlobProvider::new_http( + args.eigenda_args + .eigenda_proxy_address + .expect("missing eigenda_proxy_address") + .clone(), + ) + .await + .map_err(|e| anyhow!("Failed to load eigenda blob provider configuration: {e}"))?; + Some(Arc::new(RwLock::new( + FetcherWithEigenDASupport::new_from_parts( + kv_store.clone(), + l1_provider, + blob_provider, + eigenda_blob_provider, + l2_provider, + args.kona.agreed_l2_head_hash, + ), + ))) } else { None }; diff --git a/build/risczero/fpvm/Cargo.lock b/build/risczero/fpvm/Cargo.lock index 4c8c2532..6ae72cfc 100644 --- a/build/risczero/fpvm/Cargo.lock +++ b/build/risczero/fpvm/Cargo.lock @@ -1402,6 +1402,36 @@ dependencies = [ "digest", ] +[[package]] +name = "hokulea-eigenda" +version = "0.1.0" +source = "git+https://github.com/Layr-Labs/hokulea?branch=kailua-compatible#840a41cf1c37d8c9297fc13358f18fac15a7ce44" +dependencies = [ + "alloy-primitives", + "async-trait", + "kona-derive", + "op-alloy-protocol", + "tracing", +] + +[[package]] +name = "hokulea-proof" +version = "0.1.0" +source = "git+https://github.com/Layr-Labs/hokulea?branch=kailua-compatible#840a41cf1c37d8c9297fc13358f18fac15a7ce44" +dependencies = [ + "alloy-primitives", + "async-trait", + "hokulea-eigenda", + "kona-derive", + "kona-driver", + "kona-preimage", + "kona-proof", + "op-alloy-genesis", + "op-alloy-protocol", + "op-alloy-rpc-types-engine", + "tracing", +] + [[package]] name = "http" version = "1.1.0" @@ -1590,6 +1620,7 @@ dependencies = [ "bytemuck", "c-kzg", "hashbrown 0.15.0", + "hokulea-proof", "kona-derive", "kona-driver", "kona-executor", @@ -1634,7 +1665,7 @@ dependencies = [ [[package]] name = "kona-derive" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -1653,7 +1684,7 @@ dependencies = [ [[package]] name = "kona-driver" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -1671,7 +1702,7 @@ dependencies = [ [[package]] name = "kona-executor" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -1689,19 +1720,18 @@ dependencies = [ [[package]] name = "kona-mpt" version = "0.1.1" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-trie", - "serde", "thiserror 2.0.4", ] [[package]] name = "kona-preimage" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-primitives", "async-trait", @@ -1714,7 +1744,7 @@ dependencies = [ [[package]] name = "kona-proof" version = "0.2.0" -source = "git+https://github.com/ethereum-optimism/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" +source = "git+https://github.com/anton-rs/kona?rev=7a40d87#7a40d87b616556f76fc49f1651e035b975a2ed1a" dependencies = [ "alloy-consensus", "alloy-eips", diff --git a/build/risczero/fpvm/Cargo.toml b/build/risczero/fpvm/Cargo.toml index 5004b379..8b82a803 100644 --- a/build/risczero/fpvm/Cargo.toml +++ b/build/risczero/fpvm/Cargo.toml @@ -12,7 +12,7 @@ rkyv = "0.8.9" kailua-common = { path = "../../../crates/common" } -kona-proof = { git = "https://github.com/ethereum-optimism/kona", rev = "7a40d87" } +kona-proof = { git = "https://github.com/anton-rs/kona", rev = "7a40d87" } risc0-zkvm = { version = "1.2.0", features = ["std", "heap-embedded-alloc", "unstable"] } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index ca79d212..536d9a8b 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -28,9 +28,11 @@ kona-driver.workspace = true kona-derive.workspace = true kona-executor.workspace = true kona-mpt.workspace = true -kona-preimage = { workspace = true, features = ["serde"] } +kona-preimage = { workspace = true, features = ["serde", "rkyv"] } kona-proof.workspace = true +hokulea-proof.workspace = true + risc0-zkvm.workspace = true risc0-zkvm-platform.workspace = true diff --git a/crates/common/src/client.rs b/crates/common/src/client.rs index dcd99072..9e386020 100644 --- a/crates/common/src/client.rs +++ b/crates/common/src/client.rs @@ -18,13 +18,15 @@ use alloy_consensus::Header; use alloy_eips::eip4844::FIELD_ELEMENTS_PER_BLOB; use alloy_primitives::{Address, Sealed, B256}; use anyhow::{bail, Context}; +use hokulea_proof::eigenda_provider::OracleEigenDAProvider; +use hokulea_proof::pipeline::OraclePipeline; use kona_derive::traits::BlobProvider; use kona_driver::Driver; use kona_executor::TrieDBProvider; use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; use kona_proof::errors::OracleProviderError; use kona_proof::executor::KonaExecutor; -use kona_proof::l1::{OracleL1ChainProvider, OraclePipeline}; +use kona_proof::l1::OracleL1ChainProvider; use kona_proof::l2::OracleL2ChainProvider; use kona_proof::sync::new_pipeline_cursor; use kona_proof::{BootInfo, FlushableCache, HintType}; @@ -66,6 +68,7 @@ where let mut l1_provider = OracleL1ChainProvider::new(boot.clone(), oracle.clone()); let mut l2_provider = OracleL2ChainProvider::new(boot.clone(), oracle.clone()); + let eigenda_blob_provider = OracleEigenDAProvider::new(oracle.clone()); // If the claimed L2 block number is less than the safe head of the L2 chain, the claim is // invalid. @@ -95,6 +98,7 @@ where beacon, l1_provider.clone(), l2_provider.clone(), + eigenda_blob_provider, ); let executor = KonaExecutor::new(&cfg, l2_provider.clone(), l2_provider, None, None); let mut driver = Driver::new(cursor, executor, pipeline); diff --git a/justfile b/justfile index 8d1ac5ae..a6e692af 100644 --- a/justfile +++ b/justfile @@ -18,6 +18,9 @@ devnet-build +ARGS="-F devnet -F prove": (build ARGS) devnet-up: make -C optimism devnet-up > devnet.log +altda-devnet-up: + DEVNET_ALTDA=true GENERIC_ALTDA=true make -C optimism devnet-up > devnet.log + devnet-down: make -C optimism devnet-down @@ -79,7 +82,7 @@ devnet-validate target="debug" verbosity="" l1_rpc="http://127.0.0.1:8545" l1_be --validator-key {{validator}} \ {{verbosity}} -devnet-prove block_number block_count target="debug" verbosity="" data=".localtestdata": (prove block_number block_count "http://localhost:8545" "http://localhost:5052" "http://localhost:9545" "http://localhost:7545" data target verbosity) +devnet-prove block_number block_count target="debug" verbosity="" data=".localtestdata": devnet-build (prove block_number block_count "http://localhost:8545" "http://localhost:5052" "http://localhost:9545" "http://localhost:7545" "http://localhost:3100" data target verbosity) bench l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc data start range count target="release" verbosity="-v": ./target/{{target}}/kailua-cli benchmark \ @@ -94,13 +97,14 @@ bench l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc data start range count target= {{verbosity}} # Run the client program natively with the host program attached. -prove block_number block_count l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc data target="release" verbosity="": +prove block_number block_count l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc eigenda_proxy_rpc data target="release" verbosity="": #!/usr/bin/env bash L1_NODE_ADDRESS="{{l1_rpc}}" L1_BEACON_ADDRESS="{{l1_beacon_rpc}}" L2_NODE_ADDRESS="{{l2_rpc}}" OP_NODE_ADDRESS="{{rollup_node_rpc}}" + EIGENDA_PROXY_ADDRESS="{{eigenda_proxy_rpc}}" L2_BLOCK_NUMBER={{block_number}} CLAIMED_L2_BLOCK_NUMBER=$((L2_BLOCK_NUMBER + {{block_count}} - 1)) @@ -134,6 +138,7 @@ prove block_number block_count l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc data --l1-beacon-address $L1_BEACON_ADDRESS \ --l2-node-address $L2_NODE_ADDRESS \ --op-node-address $OP_NODE_ADDRESS \ + --eigenda-proxy-address $EIGENDA_PROXY_ADDRESS \ --data-dir {{data}} \ --native \ {{verbosity}} From ccc1b47f7e08783c3c616139276d57878c5ef1a9 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Thu, 2 Jan 2025 11:16:40 -0500 Subject: [PATCH 2/2] chore: put hokulea code behind eigenda feature flag --- .vscode/settings.json | 5 +++++ README.md | 14 ++++++++++++++ bin/host/Cargo.toml | 5 ++++- bin/host/src/lib.rs | 32 ++++++++++++++++++++++++++++---- build/risczero/Cargo.toml | 1 + build/risczero/build.rs | 17 ++++++++++++++++- build/risczero/fpvm/Cargo.toml | 3 +++ crates/common/Cargo.toml | 7 +++++-- crates/common/src/client.rs | 18 ++++++++++++++++-- justfile | 9 ++++++++- 10 files changed, 100 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 346e4c16..ce4dd6e0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,10 @@ "rust-analyzer.linkedProjects": [ "./Cargo.toml", "./build/risczero/fpvm/Cargo.toml" + ], + "rust-analyzer.cargo.features": [ + "eigenda", + "prove", + "devnet" ] } \ No newline at end of file diff --git a/README.md b/README.md index 44652a36..b984cec5 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,20 @@ Kailua enables rollup operators to add a new fault proof contract, compatible wi * `just devnet-down` to stop the running docker containers. * `just devnet-clean` to cleanup the docker volumes. +## AltDA + +### EigenDA + +The EigenDA integration uses the [hokulea](https://github.com/Layr-Labs/hokulea) library to allow the kona derivation pipeline to understand eigenDA blobs. All of this extra code is feature guarded in Kailua behind the `eigenda` feature flag. + +To run against a devnet using eigenDA for altDA, use the following commands: +```bash +just eigenda-devnet-build # builds with the -F eigenda feature flag +just eigenda-devnet-up # starts the optimism devnet with altda enabled +# At this point, must wait for a few minutes for the devnet to finalize block 1 so that we can prove it: +RISC0_DEV_MODE=true just eigenda-devnet-prove 1 1 +``` + ## Questions, Feedback, and Collaborations We'd love to hear from you on [Discord][discord] or [Twitter][twitter]. diff --git a/bin/host/Cargo.toml b/bin/host/Cargo.toml index 29c4408a..1d97e529 100644 --- a/bin/host/Cargo.toml +++ b/bin/host/Cargo.toml @@ -36,7 +36,7 @@ kona-host.workspace = true kona-preimage.workspace = true # Hokulea -hokulea-host.workspace = true +hokulea-host = { workspace = true, optional = true } # zkVM bonsai-sdk.workspace = true @@ -52,4 +52,7 @@ zeth-preflight-optimism.workspace = true [features] prove = [ "risc0-zkvm/prove" +] +eigenda = [ + "hokulea-host" ] \ No newline at end of file diff --git a/bin/host/src/lib.rs b/bin/host/src/lib.rs index 163c73cb..97103465 100644 --- a/bin/host/src/lib.rs +++ b/bin/host/src/lib.rs @@ -18,13 +18,9 @@ use alloy::primitives::{keccak256, B256}; use alloy::providers::{Provider, ProviderBuilder, ReqwestProvider}; use alloy_chains::NamedChain; use alloy_eips::eip4844::IndexedBlobHash; -use anyhow::anyhow; use anyhow::bail; use boundless_market::storage::StorageProviderConfig; use clap::Parser; -use hokulea_host::eigenda_blobs::OnlineEigenDABlobProvider; -use hokulea_host::eigenda_fetcher::FetcherWithEigenDASupport; -use hokulea_host::start_native_preimage_server; use kailua_client::{parse_b256, BoundlessArgs}; use kailua_common::blobs::BlobFetchRequest; use kailua_common::precondition::PreconditionValidationData; @@ -48,6 +44,18 @@ use zeth_core_optimism::OpRethCoreDriver; use zeth_preflight::client::PreflightClient; use zeth_preflight_optimism::OpRethPreflightClient; +#[cfg(feature = "eigenda")] +use { + anyhow::anyhow, + hokulea_host::{ + eigenda_blobs::OnlineEigenDABlobProvider, eigenda_fetcher::FetcherWithEigenDASupport, + start_native_preimage_server, + }, +}; + +#[cfg(not(feature = "eigenda"))] +use kona_host::{fetcher::Fetcher, start_native_preimage_server}; + /// The host binary CLI application arguments. #[derive(Parser, Clone, Debug)] pub struct KailuaHostCli { @@ -108,6 +116,8 @@ pub async fn start_server_and_native_client( let hint_chan = BidirectionalChannel::new()?; let preimage_chan = BidirectionalChannel::new()?; let kv_store = args.kona.construct_kv_store(); + + #[cfg(feature = "eigenda")] let fetcher = if !args.kona.is_offline() { let (l1_provider, blob_provider, l2_provider) = args.kona.create_providers().await?; let eigenda_blob_provider = OnlineEigenDABlobProvider::new_http( @@ -132,6 +142,20 @@ pub async fn start_server_and_native_client( None }; + #[cfg(not(feature = "eigenda"))] + let fetcher = if !args.kona.is_offline() { + let (l1_provider, blob_provider, l2_provider) = args.kona.create_providers().await?; + Some(Arc::new(RwLock::new(Fetcher::new( + kv_store.clone(), + l1_provider, + blob_provider, + l2_provider, + args.kona.agreed_l2_head_hash, + )))) + } else { + None + }; + // Create the server and start it. let server_task = task::spawn(start_native_preimage_server( kv_store, diff --git a/build/risczero/Cargo.toml b/build/risczero/Cargo.toml index eae2ae17..c5f194e5 100644 --- a/build/risczero/Cargo.toml +++ b/build/risczero/Cargo.toml @@ -11,3 +11,4 @@ methods = ["fpvm"] [features] debug-guest-build = [] +eigenda = [] diff --git a/build/risczero/build.rs b/build/risczero/build.rs index a3b766ec..2568e8ab 100644 --- a/build/risczero/build.rs +++ b/build/risczero/build.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::vec; + fn main() { // Build a reproducible ELF file using docker under the release profile #[cfg(not(any(feature = "debug-guest-build", debug_assertions)))] @@ -29,7 +31,20 @@ fn main() { // Build ELFs natively under debug #[cfg(any(feature = "debug-guest-build", debug_assertions))] - let build_opts = Default::default(); + let features = if cfg!(feature = "eigenda") { + vec!["eigenda".to_string()] + } else { + vec![] + }; + let build_opts = { + std::collections::HashMap::from([( + "kailua-fpvm", + risc0_build::GuestOptions { + features, + ..Default::default() + }, + )]) + }; risc0_build::embed_methods_with_options(build_opts); println!("cargo:rerun-if-changed=src"); diff --git a/build/risczero/fpvm/Cargo.toml b/build/risczero/fpvm/Cargo.toml index 8b82a803..0dc8e361 100644 --- a/build/risczero/fpvm/Cargo.toml +++ b/build/risczero/fpvm/Cargo.toml @@ -21,3 +21,6 @@ c-kzg = { git = "https://github.com/risc0/c-kzg-4844.git", branch = "p1.0.3" } crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.0" } sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" } + +[features] +eigenda = ["kailua-common/eigenda"] \ No newline at end of file diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 536d9a8b..a383db13 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -31,10 +31,13 @@ kona-mpt.workspace = true kona-preimage = { workspace = true, features = ["serde", "rkyv"] } kona-proof.workspace = true -hokulea-proof.workspace = true +hokulea-proof = { workspace = true, optional = true } risc0-zkvm.workspace = true risc0-zkvm-platform.workspace = true serde.workspace = true -tracing.workspace = true \ No newline at end of file +tracing.workspace = true + +[features] +eigenda = ["hokulea-proof"] diff --git a/crates/common/src/client.rs b/crates/common/src/client.rs index 9e386020..df38e02f 100644 --- a/crates/common/src/client.rs +++ b/crates/common/src/client.rs @@ -18,8 +18,6 @@ use alloy_consensus::Header; use alloy_eips::eip4844::FIELD_ELEMENTS_PER_BLOB; use alloy_primitives::{Address, Sealed, B256}; use anyhow::{bail, Context}; -use hokulea_proof::eigenda_provider::OracleEigenDAProvider; -use hokulea_proof::pipeline::OraclePipeline; use kona_derive::traits::BlobProvider; use kona_driver::Driver; use kona_executor::TrieDBProvider; @@ -35,6 +33,11 @@ use risc0_zkvm::sha::{Impl as SHA2, Sha256}; use std::fmt::Debug; use std::sync::Arc; +#[cfg(feature = "eigenda")] +use hokulea_proof::{eigenda_provider::OracleEigenDAProvider, pipeline::OraclePipeline}; +#[cfg(not(feature = "eigenda"))] +use kona_proof::l1::OraclePipeline; + pub fn run_client< O: CommsClient + FlushableCache + Send + Sync + Debug, B: BlobProvider + Send + Sync + Debug + Clone, @@ -68,6 +71,7 @@ where let mut l1_provider = OracleL1ChainProvider::new(boot.clone(), oracle.clone()); let mut l2_provider = OracleL2ChainProvider::new(boot.clone(), oracle.clone()); + #[cfg(feature = "eigenda")] let eigenda_blob_provider = OracleEigenDAProvider::new(oracle.clone()); // If the claimed L2 block number is less than the safe head of the L2 chain, the claim is @@ -91,6 +95,7 @@ where let cursor = new_pipeline_cursor(&boot, safe_head, &mut l1_provider, &mut l2_provider).await?; let cfg = Arc::new(boot.rollup_config.clone()); + #[cfg(feature = "eigenda")] let pipeline = OraclePipeline::new( cfg.clone(), cursor.clone(), @@ -100,6 +105,15 @@ where l2_provider.clone(), eigenda_blob_provider, ); + #[cfg(not(feature = "eigenda"))] + let pipeline = OraclePipeline::new( + cfg.clone(), + cursor.clone(), + oracle.clone(), + beacon, + l1_provider.clone(), + l2_provider.clone(), + ); let executor = KonaExecutor::new(&cfg, l2_provider.clone(), l2_provider, None, None); let mut driver = Driver::new(cursor, executor, pipeline); diff --git a/justfile b/justfile index a6e692af..096e6f01 100644 --- a/justfile +++ b/justfile @@ -18,9 +18,16 @@ devnet-build +ARGS="-F devnet -F prove": (build ARGS) devnet-up: make -C optimism devnet-up > devnet.log -altda-devnet-up: +[group('eigenda')] +eigenda-devnet-build +ARGS="-F devnet -F prove -F eigenda": (build ARGS) + +[group('eigenda')] +eigenda-devnet-up: DEVNET_ALTDA=true GENERIC_ALTDA=true make -C optimism devnet-up > devnet.log +[group('eigenda')] +eigenda-devnet-prove block_number block_count target="debug" verbosity="" data=".localtestdata": eigenda-devnet-build (prove block_number block_count "http://localhost:8545" "http://localhost:5052" "http://localhost:9545" "http://localhost:7545" "http://localhost:3100" data target verbosity) + devnet-down: make -C optimism devnet-down