Skip to content

Commit

Permalink
Merge branch 'comm-host-client-proxy-return-rollup-blob' of https://g…
Browse files Browse the repository at this point in the history
…ithub.com/Layr-Labs/hokulea into comm-host-client-proxy-return-rollup-blob
  • Loading branch information
immersify-app committed Jan 2, 2025
2 parents 781000e + c69886f commit 303e4b1
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 29 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Hokulea

![](./hokulea.jpeg)
Hokulea is a library to provide the altda providers for a derivation pipeline built with [kona](https://github.com/anton-rs/kona) to understand eigenDA blobs, following the [kona book](https://anton-rs.github.io/kona/sdk/pipeline/providers.html#implementing-a-custom-data-availability-provider) recommendation (also see this [comment](https://github.com/anton-rs/kona/pull/862#issuecomment-2515038089)).

### Running against devnet

First start the devnet:
```bash
git clone https://github.com/ethereum-optimism/optimism.git
cd optimism
DEVNET_ALTDA=true GENERIC_ALTDA=true make devnet-up
git clone -b v1.10.0 https://github.com/ethereum-optimism/optimism.git
# this patches the optimism devnet to use the eigenda-proxy instead of their da-server
git patch optimism/ops-bedrock/docker-compose.yml < op-devnet.docker-compose.yml.patch
DEVNET_ALTDA=true GENERIC_ALTDA=true make -C ./optimism devnet-up
```
Then run hokulea:
```bash
Expand All @@ -32,3 +33,4 @@ To use eigenda proxy within optimism devnet, modify ops-bedrock/docker-compose.y
EIGENDA_PROXY_MEMSTORE_GET_LATENCY: 0s
EIGENDA_PROXY_EIGENDA_CERT_VERIFICATION_DISABLED: true
```
![](./hokulea.jpeg)
4 changes: 4 additions & 0 deletions bin/client/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ 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"
<<<<<<< HEAD
ROLLUP_CONFIG_PATH="/Users/bowenxue/Documents/eigenda-integration/optimism/.devnet/rollup.json"
=======
ROLLUP_CONFIG_PATH="{{justfile_directory()}}/../../optimism/.devnet/rollup.json"
>>>>>>> c69886f10873ba2f4f0d787af746f394873c74d1
if [ -z "{{block_number}}" ]; then
BLOCK_NUMBER=$(cast block finalized --json --rpc-url $L2_RPC | jq -r .number | cast 2d)
Expand Down
4 changes: 2 additions & 2 deletions bin/host/src/eigenda_fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloy_rlp::Decodable;
use anyhow::{anyhow, Result};
use core::panic;
use hokulea_eigenda::BlobInfo;
use hokulea_eigenda::BLOB_ENCODING_VERSION;
use hokulea_eigenda::BLOB_ENCODING_VERSION_0;
use hokulea_proof::hint::{ExtendedHint, ExtendedHintType};
use kona_host::{blobs::OnlineBlobProvider, fetcher::Fetcher, kv::KeyValueStore};
use kona_preimage::{PreimageKey, PreimageKeyType};
Expand Down Expand Up @@ -174,7 +174,7 @@ where
// blob header
// https://github.com/Layr-Labs/eigenda/blob/f8b0d31d65b29e60172507074922668f4ca89420/api/clients/codecs/default_blob_codec.go#L25
// raw blob the immediate data just before taking IFFT
raw_blob[1] = BLOB_ENCODING_VERSION;
raw_blob[1] = BLOB_ENCODING_VERSION_0;
raw_blob[2..6].copy_from_slice(&rollup_data_len.to_be_bytes());

// encode length as uint32
Expand Down
1 change: 0 additions & 1 deletion crates/eigenda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ alloy-primitives.workspace = true
alloy-rlp.workspace = true
tracing.workspace = true
async-trait.workspace = true
thiserror.workspace = true
bytes.workspace = true
rust-kzg-bn254.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/eigenda/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloy_rlp::{RlpDecodable, RlpEncodable};

use alloc::vec::Vec;

// ToDo use prost to generate struct from proto file
// TODO: use prost to generate struct from proto file
// see seggestion, https://github.com/Layr-Labs/hokulea/pull/17#discussion_r1901102921

#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)]
Expand Down
2 changes: 1 addition & 1 deletion crates/eigenda/src/constant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// This minimal blob encoding contains a 32 byte header = [0x00, version byte, uint32 len of data, 0x00, 0x00,...]
/// followed by the encoded data [0x00, 31 bytes of data, 0x00, 31 bytes of data,...]
pub const BLOB_ENCODING_VERSION: u8 = 0x0;
pub const BLOB_ENCODING_VERSION_0: u8 = 0x0;
8 changes: 4 additions & 4 deletions crates/eigenda/src/eigenda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ where
.reference_block_number as u64;
let l1_block_number = block_ref.number;

// ToDo make it part of rollup config
let stale_gap = 100 as u64;
// TODO: make it part of rollup config
let stale_gap = 100_u64;

// check staleness
// ToDo this would require the op-rollup to follow the same pattern
// TODO: this would require the op-rollup to follow the same pattern
// but passing blockId to proxy which implement the logic,
// see https://github.com/ethereum-optimism/optimism/blob/0bb2ff57c8133f1e3983820c0bf238001eca119b/op-alt-da/damgr.go#L211
if rbn + stale_gap < l1_block_number {
// ToDo double check
// TODO: double check
return Err(PipelineErrorKind::Temporary(PipelineError::EndOfSource));
}

Expand Down
38 changes: 27 additions & 11 deletions crates/eigenda/src/eigenda_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,48 @@ impl EigenDABlobData {

#[cfg(test)]
mod tests {
use crate::BLOB_ENCODING_VERSION_0;

use super::*;
use alloc::vec;
use alloy_primitives::Bytes;
use kona_derive::errors::BlobDecodingError;

fn generate_blob_data(content: &[u8]) -> EigenDABlobData {
let mut blob = vec![0; 32];
blob[1] = BLOB_ENCODING_VERSION_0;
blob[2..6].copy_from_slice(&(content.len() as u32).to_be_bytes());
blob.extend_from_slice(&helpers::convert_by_padding_empty_byte(content));
EigenDABlobData {
blob: Bytes::from(blob),
}
}

#[test]
fn test_decode_success() {
let data = EigenDABlobData {
blob: Bytes::from(vec![1, 2, 3, 4]),
};
let content = vec![1, 2, 3, 4];
let data = generate_blob_data(&content);
let result = data.decode();
assert!(result.is_ok());
assert_eq!(result.unwrap(), Bytes::from(vec![1, 2, 3, 4]));
assert_eq!(result.unwrap(), Bytes::from(content));
}

#[test]
fn test_decode_empty_blob() {
let data = EigenDABlobData {
blob: Bytes::from(vec![]),
};
fn test_decode_success_empty() {
let content = vec![];
let data = generate_blob_data(&content);
let result = data.decode();
assert!(result.is_ok());
assert_eq!(result.unwrap(), Bytes::from(vec![]));
assert_eq!(result.unwrap(), Bytes::from(content));
}

#[test]
fn test_decode_invalid_blob() {
// TODO: implement this once decode actually does something
fn test_decode_error_invalid_length() {
let data = EigenDABlobData {
blob: Bytes::from(vec![0; 31]), // one byte short of having a full header
};
let result = data.decode();
assert!(result.is_err());
assert_eq!(result.unwrap_err(), BlobDecodingError::InvalidLength);
}
}
2 changes: 1 addition & 1 deletion crates/eigenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ mod certificate;
pub use certificate::BlobInfo;

mod constant;
pub use constant::BLOB_ENCODING_VERSION;
pub use constant::BLOB_ENCODING_VERSION_0;
6 changes: 3 additions & 3 deletions crates/proof/src/eigenda_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<T: CommsClient + Sync + Send> EigenDABlobProvider for OracleEigenDAProvider
.await
.map_err(OracleProviderError::Preimage)?;

// the fourth because 0x01010000 in the beginnin is metadata
// the fourth because 0x01010000 in the beginning is metadata
let item_slice = cert.as_ref();

// cert should at least contain 32 bytes for header + 4 bytes for commitment type metadata
Expand All @@ -58,7 +58,7 @@ impl<T: CommsClient + Sync + Send> EigenDABlobProvider for OracleEigenDAProvider
// even then, it is not that the entire 80 bytes are used. Some bytes are empty
// for solidity optimization, I remember.
//
// ToDo investigate later to decide a right size
// TODO: investigate later to decide a right size
let mut blob_key = [0u8; 96];

// In eigenDA terminology, length describes the number of field element, size describes
Expand Down Expand Up @@ -87,7 +87,7 @@ impl<T: CommsClient + Sync + Send> EigenDABlobProvider for OracleEigenDAProvider

// if field element is 0, it means the host has identified that the data
// has breached eigenda invariant, i.e cert is valid
if field_element.len() == 0 {
if field_element.is_empty() {
return Err(OracleProviderError::Preimage(PreimageOracleError::Other(
"field elememnt is empty, breached eigenda invariant".into(),
)));
Expand Down
39 changes: 39 additions & 0 deletions op-devnet.docker-compose.yml.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/ops-bedrock/docker-compose.yml b/ops-bedrock/docker-compose.yml
index adcaea8f4..5c5e2e8ee 100644
--- a/ops-bedrock/docker-compose.yml
+++ b/ops-bedrock/docker-compose.yml
@@ -240,22 +240,20 @@ services:
OP_CHALLENGER_NUM_CONFIRMATIONS: 1

da-server:
- image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:devnet
- build:
- context: ../
- dockerfile: ops/docker/op-stack-go/Dockerfile
- target: da-server-target
- command: >
- da-server
- --file.path=/data
- --addr=0.0.0.0
- --port=3100
- --log.level=debug
- --generic-commitment="${ALTDA_GENERIC_DA}"
+ 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"
- volumes:
- - "da_data:/data"
+ - "6969:7300"

sentinel:
image: quarry/sentinel # TODO(10141): We need a public image for this (sentinel is out of repo)

0 comments on commit 303e4b1

Please sign in to comment.