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: eigenda integration using hokulea crate #2

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./build/risczero/fpvm/Cargo.toml"
],
"rust-analyzer.cargo.features": [
"eigenda",
"prove",
"devnet"
]
}
88 changes: 77 additions & 11 deletions Cargo.lock

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

23 changes: 14 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
6 changes: 6 additions & 0 deletions bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ kona-derive.workspace = true
kona-host.workspace = true
kona-preimage.workspace = true

# Hokulea
hokulea-host = { workspace = true, optional = true }

# zkVM
bonsai-sdk.workspace = true
boundless-market.workspace = true
Expand All @@ -49,4 +52,7 @@ zeth-preflight-optimism.workspace = true
[features]
prove = [
"risc0-zkvm/prove"
]
eigenda = [
"hokulea-host"
]
52 changes: 50 additions & 2 deletions bin/host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ use clap::Parser;
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;
Expand All @@ -46,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 {
Expand Down Expand Up @@ -76,6 +86,17 @@ pub struct KailuaHostCli {
/// Storage provider to use for elf and input
#[clap(flatten)]
pub boundless_storage_config: Option<StorageProviderConfig>,

#[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<String>,
}

/// Starts the [PreimageServer] and the client program in separate threads. The client program is
Expand All @@ -95,6 +116,33 @@ 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(
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
};

#[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(
Expand Down
1 change: 1 addition & 0 deletions build/risczero/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ methods = ["fpvm"]

[features]
debug-guest-build = []
eigenda = []
17 changes: 16 additions & 1 deletion build/risczero/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))]
Expand All @@ -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");
Expand Down
Loading