-
Notifications
You must be signed in to change notification settings - Fork 81
feat: support eigenda #516
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
Open
fakedev9999
wants to merge
9
commits into
main
Choose a base branch
from
taehoon/eigenda-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0fda618
feat: support eigenda
fakedev9999 62e0da2
refac: fix EigenDAWitnessExecutor
fakedev9999 8e408e3
chore: fix eigenda range elf build
fakedev9999 68035b7
chore: fix compiler error after rebase
fakedev9999 06073ba
chore: make ci happy
fakedev9999 9977793
feat: add missing changes
fakedev9999 6b7e871
refac: remove unused fetcher
fakedev9999 f2a702e
chore: make fmt happy
fakedev9999 57dfe04
chore: update elfs
fakedev9999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[package] | ||
name = "range-eigenda" | ||
version = "0.1.0" | ||
license.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
# general | ||
rkyv.workspace = true | ||
serde_cbor.workspace = true | ||
|
||
# kona | ||
kona-proof.workspace = true | ||
|
||
# hokulea | ||
hokulea-proof.workspace = true | ||
hokulea-zkvm-verification.workspace = true | ||
|
||
# sp1 | ||
sp1-zkvm.workspace = true | ||
|
||
# op-succinct | ||
op-succinct-client-utils.workspace = true | ||
op-succinct-eigenda-client-utils.workspace = true | ||
op-succinct-range-utils.workspace = true | ||
|
||
# `tracing-subscriber` feature dependencies | ||
tracing-subscriber = { workspace = true, optional = true } | ||
|
||
[features] | ||
embedded = ["sp1-zkvm/embedded"] | ||
tracing-subscriber = ["dep:tracing-subscriber"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//! A program to verify a Optimism L2 block STF with Ethereum DA in the zkVM. | ||
//! | ||
//! This binary contains the client program for executing the Optimism rollup state transition | ||
//! across a range of blocks, which can be used to generate an on chain validity proof. Depending on | ||
//! the compilation pipeline, it will compile to be run either in native mode or in zkVM mode. In | ||
//! native mode, the data for verifying the batch validity is fetched from RPC, while in zkVM mode, | ||
//! the data is supplied by the host binary to the verifiable program. | ||
|
||
#![no_main] | ||
sp1_zkvm::entrypoint!(main); | ||
|
||
use hokulea_proof::{ | ||
canoe_verifier::sp1_cc::CanoeSp1CCVerifier, eigenda_blob_witness::EigenDABlobWitnessData, | ||
}; | ||
use hokulea_zkvm_verification::eigenda_witness_to_preloaded_provider; | ||
use op_succinct_client_utils::witness::{EigenDAWitnessData, WitnessData}; | ||
use op_succinct_eigenda_client_utils::executor::EigenDAWitnessExecutor; | ||
use op_succinct_range_utils::run_range_program; | ||
#[cfg(feature = "tracing-subscriber")] | ||
use op_succinct_range_utils::setup_tracing; | ||
use rkyv::rancor::Error; | ||
|
||
fn main() { | ||
#[cfg(feature = "tracing-subscriber")] | ||
setup_tracing(); | ||
|
||
kona_proof::block_on(async move { | ||
let witness_rkyv_bytes: Vec<u8> = sp1_zkvm::io::read_vec(); | ||
let witness_data = rkyv::from_bytes::<EigenDAWitnessData, Error>(&witness_rkyv_bytes) | ||
.expect("Failed to deserialize witness data."); | ||
|
||
let (oracle, _beacon) = witness_data.clone().get_oracle_and_blob_provider().await.unwrap(); | ||
let eigenda_witness: EigenDABlobWitnessData = serde_cbor::from_slice( | ||
&witness_data.eigenda_data.clone().expect("eigenda witness data is not present"), | ||
) | ||
.expect("cannot deserialize eigenda witness"); | ||
let preloaded_blob_provider = | ||
eigenda_witness_to_preloaded_provider(oracle, CanoeSp1CCVerifier {}, eigenda_witness) | ||
.await | ||
.expect("Failed to get preloaded blob provider"); | ||
|
||
run_range_program(EigenDAWitnessExecutor::new(preloaded_blob_provider), witness_data).await; | ||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "op-succinct-eigenda-client-utils" | ||
version = "0.1.0" | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
# local | ||
op-succinct-client-utils.workspace = true | ||
|
||
# kona | ||
kona-derive.workspace = true | ||
kona-driver.workspace = true | ||
kona-executor.workspace = true | ||
kona-genesis.workspace = true | ||
kona-preimage.workspace = true | ||
kona-proof.workspace = true | ||
|
||
# hokulea | ||
hokulea-eigenda.workspace = true | ||
hokulea-proof = { workspace = true, features = ["sp1-cc"] } | ||
hokulea-witgen.workspace = true | ||
|
||
# general | ||
anyhow.workspace = true | ||
async-trait.workspace = true | ||
serde_cbor.workspace = true | ||
spin.workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use std::{fmt::Debug, sync::Arc}; | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use hokulea_eigenda::{EigenDABlobProvider, EigenDABlobSource, EigenDADataSource}; | ||
use kona_derive::{sources::EthereumDataSource, traits::BlobProvider}; | ||
use kona_driver::PipelineCursor; | ||
use kona_genesis::RollupConfig; | ||
use kona_preimage::CommsClient; | ||
use kona_proof::{ | ||
l1::{OracleL1ChainProvider, OraclePipeline}, | ||
l2::OracleL2ChainProvider, | ||
FlushableCache, | ||
}; | ||
use op_succinct_client_utils::witness::executor::WitnessExecutor; | ||
use spin::RwLock; | ||
|
||
pub struct EigenDAWitnessExecutor<O, B, E> | ||
where | ||
O: CommsClient + FlushableCache + Send + Sync + Debug, | ||
B: BlobProvider + Send + Sync + Debug + Clone, | ||
E: EigenDABlobProvider + Send + Sync + Debug + Clone, | ||
{ | ||
eigenda_blob_provider: E, | ||
_marker: std::marker::PhantomData<(O, B)>, | ||
} | ||
|
||
impl<O, B, E> EigenDAWitnessExecutor<O, B, E> | ||
where | ||
O: CommsClient + FlushableCache + Send + Sync + Debug, | ||
B: BlobProvider + Send + Sync + Debug + Clone, | ||
E: EigenDABlobProvider + Send + Sync + Debug + Clone, | ||
{ | ||
pub fn new(eigenda_blob_provider: E) -> Self { | ||
Self { eigenda_blob_provider, _marker: std::marker::PhantomData } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<O, B, E> WitnessExecutor for EigenDAWitnessExecutor<O, B, E> | ||
where | ||
O: CommsClient + FlushableCache + Send + Sync + Debug, | ||
B: BlobProvider + Send + Sync + Debug + Clone, | ||
E: EigenDABlobProvider + Send + Sync + Debug + Clone, | ||
{ | ||
type O = O; | ||
type B = B; | ||
type L1 = OracleL1ChainProvider<Self::O>; | ||
type L2 = OracleL2ChainProvider<Self::O>; | ||
type DA = EigenDADataSource<Self::L1, Self::B, E>; | ||
|
||
async fn create_pipeline( | ||
&self, | ||
rollup_config: Arc<RollupConfig>, | ||
cursor: Arc<RwLock<PipelineCursor>>, | ||
oracle: Arc<Self::O>, | ||
beacon: Self::B, | ||
l1_provider: Self::L1, | ||
l2_provider: Self::L2, | ||
) -> Result<OraclePipeline<Self::O, Self::L1, Self::L2, Self::DA>> { | ||
let ethereum_data_source = | ||
EthereumDataSource::new_from_parts(l1_provider.clone(), beacon, &rollup_config); | ||
let eigenda_blob_source = EigenDABlobSource::new(self.eigenda_blob_provider.clone()); | ||
let da_provider = EigenDADataSource::new(ethereum_data_source, eigenda_blob_source); | ||
|
||
Ok(OraclePipeline::new( | ||
rollup_config, | ||
cursor, | ||
oracle, | ||
da_provider, | ||
l1_provider, | ||
l2_provider, | ||
) | ||
.await?) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod executor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
name = "op-succinct-eigenda-host-utils" | ||
version = "0.1.0" | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
# sp1 | ||
sp1-sdk.workspace = true | ||
|
||
# local | ||
op-succinct-eigenda-client-utils.workspace = true | ||
op-succinct-client-utils.workspace = true | ||
op-succinct-host-utils.workspace = true | ||
|
||
# kona | ||
kona-preimage.workspace = true | ||
kona-proof.workspace = true | ||
|
||
# hokulea | ||
hokulea-eigenda.workspace = true | ||
hokulea-host-bin.workspace = true | ||
hokulea-proof.workspace = true | ||
hokulea-witgen.workspace = true | ||
|
||
# alloy | ||
alloy-eips.workspace = true | ||
alloy-primitives.workspace = true | ||
|
||
# general | ||
anyhow.workspace = true | ||
async-trait.workspace = true | ||
rkyv.workspace = true | ||
serde_cbor.workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use std::sync::Arc; | ||
|
||
use alloy_eips::BlockId; | ||
use alloy_primitives::B256; | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use hokulea_host_bin::cfg::SingleChainHostWithEigenDA; | ||
use op_succinct_host_utils::{fetcher::OPSuccinctDataFetcher, host::OPSuccinctHost}; | ||
|
||
use crate::witness_generator::EigenDAWitnessGenerator; | ||
|
||
#[derive(Clone)] | ||
pub struct EigenDAOPSuccinctHost { | ||
pub fetcher: Arc<OPSuccinctDataFetcher>, | ||
pub witness_generator: Arc<EigenDAWitnessGenerator>, | ||
} | ||
|
||
#[async_trait] | ||
impl OPSuccinctHost for EigenDAOPSuccinctHost { | ||
type Args = SingleChainHostWithEigenDA; | ||
type WitnessGenerator = EigenDAWitnessGenerator; | ||
|
||
fn witness_generator(&self) -> &Self::WitnessGenerator { | ||
&self.witness_generator | ||
} | ||
|
||
async fn fetch( | ||
&self, | ||
l2_start_block: u64, | ||
l2_end_block: u64, | ||
l1_head_hash: Option<B256>, | ||
safe_db_fallback: bool, | ||
) -> Result<SingleChainHostWithEigenDA> { | ||
// If l1_head_hash is not provided, calculate a safe L1 head | ||
let l1_head = match l1_head_hash { | ||
Some(hash) => hash, | ||
None => { | ||
self.calculate_safe_l1_head(&self.fetcher, l2_end_block, safe_db_fallback).await? | ||
} | ||
}; | ||
|
||
let host = self.fetcher.get_host_args(l2_start_block, l2_end_block, l1_head).await?; | ||
|
||
let eigenda_proxy_address = std::env::var("EIGENDA_PROXY_ADDRESS").ok(); | ||
Ok(SingleChainHostWithEigenDA { kona_cfg: host, eigenda_proxy_address, verbose: 1 }) | ||
} | ||
|
||
fn get_l1_head_hash(&self, args: &Self::Args) -> Option<B256> { | ||
Some(args.kona_cfg.l1_head) | ||
} | ||
|
||
async fn get_finalized_l2_block_number( | ||
&self, | ||
fetcher: &OPSuccinctDataFetcher, | ||
_: u64, | ||
) -> Result<Option<u64>> { | ||
let finalized_l2_block_number = fetcher.get_l2_header(BlockId::finalized()).await?; | ||
Ok(Some(finalized_l2_block_number.number)) | ||
} | ||
|
||
async fn calculate_safe_l1_head( | ||
&self, | ||
fetcher: &OPSuccinctDataFetcher, | ||
l2_end_block: u64, | ||
safe_db_fallback: bool, | ||
) -> Result<B256> { | ||
// For EigenDA, use a similar approach to Ethereum DA with a conservative offset. | ||
let (_, l1_head_number) = fetcher.get_l1_head(l2_end_block, safe_db_fallback).await?; | ||
|
||
// Add a buffer for EigenDA similar to Ethereum DA. | ||
let l1_head_number = l1_head_number + 20; | ||
|
||
// Ensure we don't exceed the finalized L1 header. | ||
let finalized_l1_header = fetcher.get_l1_header(BlockId::finalized()).await?; | ||
let safe_l1_head_number = std::cmp::min(l1_head_number, finalized_l1_header.number); | ||
|
||
Ok(fetcher.get_l1_header(safe_l1_head_number.into()).await?.hash_slow()) | ||
} | ||
} | ||
|
||
impl EigenDAOPSuccinctHost { | ||
pub fn new(fetcher: Arc<OPSuccinctDataFetcher>) -> Self { | ||
Self { | ||
fetcher, | ||
witness_generator: Arc::new(EigenDAWitnessGenerator { | ||
executor: (), // Placeholder - will be created in witness_generator | ||
}), | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod host; | ||
pub mod witness_generator; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: current EigenDA testnet is on holesky so maybe good to test e2e with Noop verifier first. Request has been made to migrate to sepolia.