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: can read eigenda v1 cert #17

Closed
wants to merge 7 commits into from
Closed
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
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.

22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,24 @@ Then run hokulea:
```bash
cd bin/client
just run-client-native-against-devnet
```
```

samlaf marked this conversation as resolved.
Show resolved Hide resolved
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"
```
2 changes: 1 addition & 1 deletion bin/client/justfile
Original file line number Diff line number Diff line change
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
10 changes: 10 additions & 0 deletions bin/host/src/eigenda_fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: beginnin -> beginning

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close here, 781000e

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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return an error instead of logging like this?

Copy link
Collaborator Author

@bxue-l2 bxue-l2 Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the main reason to do it, is such that you can still run with optimism da-server. And that won't break.

After this PR, we should always use eigenda-proxy

I can work on error cleanup in the above PR

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm. just add a TODO comment here so that we don't forget.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is the plan to not ever merge this PR? In this case let's just close it?

}

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
62 changes: 62 additions & 0 deletions crates/eigenda/src/certificate.rs
Original file line number Diff line number Diff line change
@@ -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,
Comment on lines +1 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prob want to auto generate these using https://docs.rs/prost-build/latest/prost_build/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good idea. But prost probably can't work.

Remember we discuss bytes should not go to Vec, otherwise, rlp isn't compatible.

That is why, I imported alloy_primitives::Bytes, it will have the right rlp encoding behavior.

prost converts bytes to Vec, see https://github.com/tokio-rs/prost?tab=readme-ov-file#fields.

We can create an issue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can customize the type that prost generates. For eg a build.rs with

use prost_build::Config;
use std::io::Result;

fn main() -> Result<()> {
    let mut config = Config::new();
    config.bytes(&["."]);
    config.compile_protos(&["src/scratch.proto"], &["src/"])?;
    Ok(())
}

will generate

    #[prost(bytes = "bytes", tag = "3")]
    pub batch_root: ::prost::bytes::Bytes,

This uses the prost Bytes type instead of the alloy. I'm sure there's a way to generate the alloy one, but it might require some fiddling around. Let's at least add a TODO comment to eventually switch to using prost.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in PR 19

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see 781000e

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

/// 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,
}
3 changes: 3 additions & 0 deletions crates/eigenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ pub use eigenda_blobs::EigenDABlobSource;

mod eigenda_data;
pub use eigenda_data::EigenDABlobData;

mod certificate;
pub use certificate::BlobInfo;
Loading