diff --git a/Cargo.lock b/Cargo.lock index 171dfe4..80614e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1723,6 +1723,7 @@ name = "hokulea-eigenda" version = "0.1.0" dependencies = [ "alloy-primitives", + "alloy-rlp", "async-trait", "kona-derive", "op-alloy-protocol", @@ -1740,6 +1741,7 @@ dependencies = [ "async-trait", "clap", "hokulea-client", + "hokulea-eigenda", "hokulea-proof", "kona-host", "kona-preimage", diff --git a/README.md b/README.md index 32b65b7..2452616 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,24 @@ Then run hokulea: ```bash cd bin/client just run-client-native-against-devnet -``` \ No newline at end of file +``` + +To use eigenda proxy within optimism devnet, modify ops-bedrock/docker-compose.yaml + +``` + da-server: + image: ghcr.io/layr-labs/eigenda-proxy:v1.6.1 + environment: + EIGENDA_PROXY_ADDR: 0.0.0.0 + EIGENDA_PROXY_PORT: 3100 + EIGENDA_PROXY_METRICS_ENABLED: "true" + EIGENDA_PROXY_METRICS_PORT: 7300 + EIGENDA_PROXY_MEMSTORE_ENABLED: "true" + EIGENDA_PROXY_MEMSTORE_EXPIRATION: 45m + EIGENDA_PROXY_MEMSTORE_PUT_LATENCY: 0s + EIGENDA_PROXY_MEMSTORE_GET_LATENCY: 0s + EIGENDA_PROXY_EIGENDA_CERT_VERIFICATION_DISABLED: "true" + ports: + - "3100:3100" + - "6969:7300" +``` diff --git a/bin/client/justfile b/bin/client/justfile index 9ac832d..fb05bd2 100644 --- a/bin/client/justfile +++ b/bin/client/justfile @@ -120,7 +120,7 @@ run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc rollu cd $(git rev-parse --show-toplevel) echo "Running host program with native client program..." - cargo r --bin hokulea-host --release -- \ + cargo r --bin hokulea-host -- \ --l1-head $L1_HEAD \ --agreed-l2-head-hash $AGREED_L2_HEAD_HASH \ --claimed-l2-output-root $CLAIMED_L2_OUTPUT_ROOT \ diff --git a/bin/host/Cargo.toml b/bin/host/Cargo.toml index e286988..69820d0 100644 --- a/bin/host/Cargo.toml +++ b/bin/host/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" # Workspace hokulea-proof.workspace = true hokulea-client.workspace = true +hokulea-eigenda.workspace = true # Kona kona-preimage = { workspace = true, features = ["std"] } diff --git a/bin/host/src/eigenda_fetcher/mod.rs b/bin/host/src/eigenda_fetcher/mod.rs index 643785d..74b9e9c 100644 --- a/bin/host/src/eigenda_fetcher/mod.rs +++ b/bin/host/src/eigenda_fetcher/mod.rs @@ -4,8 +4,10 @@ use crate::eigenda_blobs::OnlineEigenDABlobProvider; use alloy_primitives::{keccak256, B256}; use alloy_provider::ReqwestProvider; +use alloy_rlp::Decodable; use anyhow::{anyhow, Result}; use core::panic; +use hokulea_eigenda::BlobInfo; use hokulea_proof::hint::{ExtendedHint, ExtendedHintType}; use kona_host::{blobs::OnlineBlobProvider, fetcher::Fetcher, kv::KeyValueStore}; use kona_preimage::{PreimageKey, PreimageKeyType}; @@ -136,6 +138,14 @@ where trace!(target: "fetcher_with_eigenda_support", "Fetching hint: {hint_type} {hint_data}"); if hint_type == ExtendedHintType::EigenDACommitment { + let item_slice = hint_data.as_ref(); + + // the fourth because 0x01010000 in the beginnin is metadata + match BlobInfo::decode(&mut &item_slice[4..]) { + Ok(cert_blob_info) => info!("cert_blob_info {:?}", cert_blob_info), + Err(e) => info!("cannot decode cert_blob_info {:?}", e), + } + let cert = hint_data; info!(target: "fetcher_with_eigenda_support", "Fetching AltDACommitment cert: {:?}", cert); // Fetch the blob sidecar from the blob provider. diff --git a/crates/eigenda/Cargo.toml b/crates/eigenda/Cargo.toml index 258342d..baa1f5f 100644 --- a/crates/eigenda/Cargo.toml +++ b/crates/eigenda/Cargo.toml @@ -9,6 +9,7 @@ kona-derive.workspace = true # Op Alloy op-alloy-protocol.workspace = true alloy-primitives.workspace = true +alloy-rlp.workspace = true tracing.workspace = true async-trait.workspace = true diff --git a/crates/eigenda/src/certificate.rs b/crates/eigenda/src/certificate.rs new file mode 100644 index 0000000..afcb198 --- /dev/null +++ b/crates/eigenda/src/certificate.rs @@ -0,0 +1,62 @@ +use alloy_primitives::Bytes; +use alloy_rlp::{RlpDecodable, RlpEncodable}; + +use alloc::vec::Vec; + +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct G1Commitment { + pub x: [u8; 32], + pub y: [u8; 32], +} + +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct BlobQuorumParam { + pub quorum_number: u32, + pub adversary_threshold_percentage: u32, + pub confirmation_threshold_percentage: u32, + pub chunk_length: u32, +} + +/// eigenda v1 blob header +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct BlobHeader { + pub commitment: G1Commitment, + pub data_length: u32, + pub blob_quorum_params: Vec, +} + +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct BatchHeader { + pub batch_root: Bytes, + pub quorum_numbers: Bytes, + pub quorum_signed_percentages: Bytes, + pub reference_block_number: u32, +} + +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct BatchMetadata { + pub batch_header: BatchHeader, + pub signatory_record_hash: Bytes, + pub fee: Bytes, + pub confirmation_block_number: u32, + pub batch_header_hash: Bytes, +} + +/// eigenda v1 blob verification proof +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct BlobVerificationProof { + pub batch_id: u32, + pub blob_index: u32, + pub batch_medatada: BatchMetadata, + pub inclusion_proof: Bytes, + pub quorum_indexes: Bytes, +} + +/// eigenda v1 certificate +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct BlobInfo { + /// v1 blob header + pub blob_header: BlobHeader, + /// v1 blob verification proof with merkle tree + pub blob_verification_proof: BlobVerificationProof, +} diff --git a/crates/eigenda/src/lib.rs b/crates/eigenda/src/lib.rs index b62f3f5..68e0d5d 100644 --- a/crates/eigenda/src/lib.rs +++ b/crates/eigenda/src/lib.rs @@ -26,3 +26,6 @@ pub use eigenda_blobs::EigenDABlobSource; mod eigenda_data; pub use eigenda_data::EigenDABlobData; + +mod certificate; +pub use certificate::BlobInfo;