Skip to content

Commit

Permalink
chore: remove unused function in OnlineBlobProvider (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf authored Jan 8, 2025
1 parent 874c7ed commit 3e88447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
]
}
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)
}
}

0 comments on commit 3e88447

Please sign in to comment.