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

chore: remove unused function in OnlineBlobProvider #875

Merged
Show file tree
Hide file tree
Changes from 2 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
44 changes: 3 additions & 41 deletions bin/host/src/blobs.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Contains an online implementation of the `BlobProvider` trait.

use alloy_eips::eip4844::{Blob, BlobTransactionSidecarItem, IndexedBlobHash};
use alloy_eips::eip4844::{BlobTransactionSidecarItem, IndexedBlobHash};
use alloy_rpc_types_beacon::sidecar::{BeaconBlobBundle, BlobData};
use async_trait::async_trait;
use kona_derive::{errors::BlobProviderError, traits::BlobProvider};
use kona_derive::errors::BlobProviderError;
use op_alloy_protocol::BlockInfo;
use reqwest::Client;

Expand Down Expand Up @@ -62,7 +61,7 @@ impl APIGenesisResponse {
}
}

/// An online implementation of the [BlobProvider] trait.
/// An online provider to fetch blob sidecars.
#[derive(Debug, Clone)]
pub struct OnlineBlobProvider {
/// The base url.
Expand Down Expand Up @@ -198,40 +197,3 @@ impl OnlineBlobProvider {
.collect::<Vec<BlobTransactionSidecarItem>>())
}
}

#[async_trait]
impl BlobProvider for OnlineBlobProvider {
type Error = BlobProviderError;

/// Fetches blob sidecars that were confirmed in the specified L1 block with the given indexed
/// hashes. The blobs are validated for their index and hashes using the specified
/// [IndexedBlobHash].
async fn get_blobs(
&mut self,
block_ref: &BlockInfo,
blob_hashes: &[IndexedBlobHash],
) -> Result<Vec<Box<Blob>>, Self::Error> {
// Fetch the blob sidecars for the given block reference and blob hashes.
let sidecars = self.fetch_filtered_sidecars(block_ref, blob_hashes).await?;

// Validate the blob sidecars straight away with the num hashes.
let blobs = sidecars
.into_iter()
.enumerate()
.map(|(i, sidecar)| {
let hash = blob_hashes
.get(i)
.ok_or(BlobProviderError::Backend("Missing blob hash".to_string()))?;
match sidecar.verify_blob(&alloy_eips::eip4844::IndexedBlobHash {
hash: hash.hash,
index: hash.index,
}) {
Ok(_) => Ok(sidecar.blob),
Err(e) => Err(BlobProviderError::Backend(e.to_string())),
}
})
.collect::<Result<Vec<Box<Blob>>, BlobProviderError>>()
.map_err(|e| BlobProviderError::Backend(e.to_string()))?;
Ok(blobs)
}
}
2 changes: 2 additions & 0 deletions rust-toolchain.toml
refcell marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly" # needed so that vscode formats using rustmfmt.toml that uses nightly features
Loading