Skip to content

Commit

Permalink
fix: issues after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Dec 17, 2024
1 parent 497f433 commit 31e02bf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
54 changes: 26 additions & 28 deletions bin/host/src/extended_fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::eigenda_blobs::OnlineEigenDABlobProvider;
use alloy_primitives::{keccak256, B256};
use alloy_provider::ReqwestProvider;
use anyhow::{anyhow, Result};
use eigenda_proof::hint::{ExtendedHint, ExtendedHintType};
use hokulea_proof::hint::{ExtendedHint, ExtendedHintType};
use kona_host::{blobs::OnlineBlobProvider, fetcher::Fetcher, kv::KeyValueStore};
use kona_preimage::{PreimageKey, PreimageKeyType};
use std::sync::Arc;
Expand Down Expand Up @@ -124,34 +124,32 @@ where
let (hint_type, hint_data) = hint.split();
trace!(target: "fetcher", "Fetching hint: {hint_type} {hint_data}");

match hint_type {
ExtendedHintType::AltDACommitment => {
let cert = hint_data;
info!(target: "fetcher", "Fetching AltDACommitment cert: {:?}", cert);
// Fetch the blob sidecar from the blob provider.
let eigenda_blob = self
.eigenda_blob_provider
.fetch_eigenda_blob(&cert)
.await
.map_err(|e| anyhow!("Failed to fetch eigenda blob: {e}"))?;

info!(target: "fetcher", "eigenda_blob len {}", eigenda_blob.len());
// Acquire a lock on the key-value store and set the preimages.
let mut kv_write_lock = self.kv_store.write().await;

// Set the preimage for the blob commitment.
kv_write_lock.set(
PreimageKey::new(*keccak256(cert), PreimageKeyType::GlobalGeneric).into(),
eigenda_blob.to_vec(),
)?;
}
// We can't do this because fetcher.prefetch is private.
// TODO: do we want to change the Fetcher api to make this possible?
// ExtendedHintType::Original(hint_type) => {
// self.fetcher.prefetch(hint_type, hint_data).await?;
// }
_ => (),
if hint_type == ExtendedHintType::AltDACommitment {
let cert = hint_data;
info!(target: "fetcher", "Fetching AltDACommitment cert: {:?}", cert);
// Fetch the blob sidecar from the blob provider.
let eigenda_blob = self
.eigenda_blob_provider
.fetch_eigenda_blob(&cert)
.await
.map_err(|e| anyhow!("Failed to fetch eigenda blob: {e}"))?;

info!(target: "fetcher", "eigenda_blob len {}", eigenda_blob.len());
// Acquire a lock on the key-value store and set the preimages.
let mut kv_write_lock = self.kv_store.write().await;

// Set the preimage for the blob commitment.
kv_write_lock.set(
PreimageKey::new(*keccak256(cert), PreimageKeyType::GlobalGeneric).into(),
eigenda_blob.to_vec(),
)?;
}
// We don't match against the other enum case because fetcher.prefetch is private,
// so we can't make the below code compile.
// TODO: do we want to change the Fetcher api to make this possible?
// ExtendedHintType::Original(hint_type) => {
// self.fetcher.prefetch(hint_type, hint_data).await?;
// }

Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions bin/host/src/preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kona_preimage::{
use std::sync::Arc;
use tokio::sync::RwLock;

/// A [Fetcher]-backed implementation of the [PreimageFetcher] trait.
/// A [ExtendedFetcher]-backed implementation of the [PreimageFetcher] trait.
#[derive(Debug)]
pub struct OnlinePreimageFetcher<KV>
where
Expand All @@ -36,7 +36,7 @@ impl<KV> OnlinePreimageFetcher<KV>
where
KV: KeyValueStore + ?Sized,
{
/// Create a new [OnlinePreimageFetcher] from the given [Fetcher].
/// Create a new [OnlinePreimageFetcher] from the given [ExtendedFetcher].
pub const fn new(fetcher: Arc<RwLock<ExtendedFetcher<KV>>>) -> Self {
Self { inner: fetcher }
}
Expand Down Expand Up @@ -74,7 +74,7 @@ where
}
}

/// A [Fetcher]-backed implementation of the [HintRouter] trait.
/// A [ExtendedFetcher]-backed implementation of the [HintRouter] trait.
#[derive(Debug)]
pub struct OnlineHintRouter<KV>
where
Expand All @@ -99,7 +99,7 @@ impl<KV> OnlineHintRouter<KV>
where
KV: KeyValueStore + ?Sized,
{
/// Create a new [OnlineHintRouter] from the given [Fetcher].
/// Create a new [OnlineHintRouter] from the given [ExtendedFetcher].
pub const fn new(fetcher: Arc<RwLock<ExtendedFetcher<KV>>>) -> Self {
Self { inner: fetcher }
}
Expand Down
4 changes: 2 additions & 2 deletions crates/proof/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloy_primitives::{hex, Bytes};
use core::fmt::Display;
use kona_proof::{errors::HintParsingError, HintType};

/// A [Hint] is parsed in the format `<hint_type> <hint_data>`, where `<hint_type>` is a string that
/// A [ExtendedHint] is parsed in the format `<hint_type> <hint_data>`, where `<hint_type>` is a string that
/// represents the type of hint, and `<hint_data>` is the data associated with the hint (bytes
/// encoded as hex UTF-8).
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -42,7 +42,7 @@ impl ExtendedHint {
})
}

/// Splits the [Hint] into its components.
/// Splits the [ExtendedHint] into its components.
pub fn split(self) -> (ExtendedHintType, Bytes) {
(self.hint_type, self.hint_data)
}
Expand Down

0 comments on commit 31e02bf

Please sign in to comment.