Skip to content

Commit

Permalink
can read eigenda v1 cert
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Dec 20, 2024
1 parent 63e19d9 commit 385c4c4
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bin/client/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ run-client-native-against-devnet verbosity='' block_number='' rollup_config_path
L1_BEACON_RPC="http://127.0.0.1:5052"
L2_RPC="http://127.0.0.1:9545"
ROLLUP_NODE_RPC="http://127.0.0.1:7545"
ROLLUP_CONFIG_PATH="../../../optimism/.devnet/rollup.json"
ROLLUP_CONFIG_PATH="/home/ubuntu/op-main-repo/.devnet/rollup.json"
if [ -z "{{block_number}}" ]; then
BLOCK_NUMBER=$(cast block finalized --json --rpc-url $L2_RPC | jq -r .number | cast 2d)
Expand Down Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
9 changes: 9 additions & 0 deletions bin/host/src/eigenda_fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use kona_preimage::{PreimageKey, PreimageKeyType};
use std::sync::Arc;
use tokio::sync::RwLock;
use tracing::{error, info, trace, warn};
use hokulea_eigenda::BlobInfo;
use alloy_rlp::{Decodable};

/// The [FetcherWithEigenDASupport] struct wraps and extends kona's [Fetcher] struct with the ability
/// to fetch preimages from EigenDA.
Expand Down Expand Up @@ -136,6 +138,13 @@ 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
let cert_blob_info = BlobInfo::decode(&mut &item_slice[4..])?;
info!("cert_blob_info {:?}", cert_blob_info);

let cert = hint_data;
info!(target: "fetcher_with_eigenda_support", "Fetching AltDACommitment cert: {:?}", cert);
// Fetch the blob sidecar from the blob provider.
Expand Down
1 change: 1 addition & 0 deletions crates/eigenda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
76 changes: 76 additions & 0 deletions crates/eigenda/src/certificate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// data struct copied from https://github.com/Layr-Labs/eigenda-client-rs/blob/3ac1f62ae3d99aedf3de7a2fe827fab17db7b874/src/blob_info.rs
use core::fmt;

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,
}

impl BlobQuorumParam {
pub fn to_bytes(&self) -> Vec<u8> {
let mut bytes = Vec::new();
bytes.extend(&self.quorum_number.to_be_bytes());
bytes.extend(&self.adversary_threshold_percentage.to_be_bytes());
bytes.extend(&self.confirmation_threshold_percentage.to_be_bytes());
bytes.extend(&self.chunk_length.to_be_bytes());

bytes
}
}


#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)]
pub struct BlobHeader {
pub commitment: G1Commitment,
pub data_length: u32,
pub blob_quorum_params: Vec<BlobQuorumParam>,
}


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

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

#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)]
pub struct BlobInfo {
pub blob_header: BlobHeader,
pub blob_verification_proof: BlobVerificationProof,
}
4 changes: 4 additions & 0 deletions crates/eigenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ pub use eigenda_blobs::EigenDABlobSource;

mod eigenda_data;
pub use eigenda_data::EigenDABlobData;

mod certificate;
pub use certificate::BlobInfo;

0 comments on commit 385c4c4

Please sign in to comment.