From 31e02bf76c4ce38e139ba29f17961f6b17851d8a Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Mon, 16 Dec 2024 22:32:10 -0500 Subject: [PATCH] fix: issues after rebase --- bin/host/src/extended_fetcher/mod.rs | 54 ++++++++++++++-------------- bin/host/src/preimage.rs | 8 ++--- crates/proof/src/hint.rs | 4 +-- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/bin/host/src/extended_fetcher/mod.rs b/bin/host/src/extended_fetcher/mod.rs index 493d4ea..618dcf3 100644 --- a/bin/host/src/extended_fetcher/mod.rs +++ b/bin/host/src/extended_fetcher/mod.rs @@ -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; @@ -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(()) } diff --git a/bin/host/src/preimage.rs b/bin/host/src/preimage.rs index 90719df..ebb73c4 100644 --- a/bin/host/src/preimage.rs +++ b/bin/host/src/preimage.rs @@ -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 where @@ -36,7 +36,7 @@ impl OnlinePreimageFetcher 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>>) -> Self { Self { inner: fetcher } } @@ -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 where @@ -99,7 +99,7 @@ impl OnlineHintRouter 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>>) -> Self { Self { inner: fetcher } } diff --git a/crates/proof/src/hint.rs b/crates/proof/src/hint.rs index 78ecf8b..8644557 100644 --- a/crates/proof/src/hint.rs +++ b/crates/proof/src/hint.rs @@ -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 ` `, where `` is a string that +/// A [ExtendedHint] is parsed in the format ` `, where `` is a string that /// represents the type of hint, and `` is the data associated with the hint (bytes /// encoded as hex UTF-8). #[derive(Debug, Clone, PartialEq, Eq)] @@ -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) }