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

fix(IndexedBlobHash): Change index to u64 #846

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ where
let timestamp = u64::from_be_bytes(timestamp_data_bytes);

let partial_block_ref = BlockInfo { timestamp, ..Default::default() };
let indexed_hash = IndexedBlobHash { index: index as usize, hash };
let indexed_hash = IndexedBlobHash { index, hash };

// Fetch the blob sidecar from the blob provider.
let mut sidecars = self
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/providers/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl BeaconClient for OnlineBeaconClient {
let mut sidecars = Vec::with_capacity(hashes.len());
hashes.iter().for_each(|hash| {
if let Some(sidecar) =
raw_response.data.iter().find(|sidecar| sidecar.index == hash.index as u64)
raw_response.data.iter().find(|sidecar| sidecar.index == hash.index)
{
sidecars.push(sidecar.clone());
}
Expand Down
10 changes: 5 additions & 5 deletions bin/host/src/providers/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ impl<B: BeaconClient> OnlineBlobProvider<B> {
let sidecars = self.fetch_sidecars(slot, blob_hashes).await?;

// Filter blob sidecars that match the indicies in the specified list.
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index).collect::<Vec<usize>>();
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index).collect::<Vec<u64>>();
let filtered = sidecars
.into_iter()
.filter(|s| blob_hash_indicies.contains(&(s.index as usize)))
.filter(|s| blob_hash_indicies.contains(&s.index))
.collect::<Vec<_>>();

// Validate the correct number of blob sidecars were retrieved.
Expand Down Expand Up @@ -158,7 +158,7 @@ where
.ok_or(BlobProviderError::Backend("Missing blob hash".to_string()))?;
match sidecar.verify_blob(&alloy_eips::eip4844::IndexedBlobHash {
hash: hash.hash,
index: hash.index as u64,
index: hash.index,
}) {
Ok(_) => Ok(sidecar.blob),
Err(e) => Err(BlobProviderError::Backend(e.to_string())),
Expand Down Expand Up @@ -253,7 +253,7 @@ impl<B: BeaconClient, F: BlobSidecarProvider> OnlineBlobProviderWithFallback<B,
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index).collect::<Vec<_>>();
let filtered = sidecars
.into_iter()
.filter(|s| blob_hash_indicies.contains(&(s.index as usize)))
.filter(|s| blob_hash_indicies.contains(&s.index))
.collect::<Vec<_>>();

// Validate the correct number of blob sidecars were retrieved.
Expand Down Expand Up @@ -314,7 +314,7 @@ where
))?;
match sidecar.verify_blob(&alloy_eips::eip4844::IndexedBlobHash {
hash: hash.hash,
index: hash.index as u64,
index: hash.index,
}) {
Ok(_) => Ok(sidecar.blob),
Err(e) => Err(BlobProviderError::Backend(e.to_string())),
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/sources/blob_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy_primitives::B256;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IndexedBlobHash {
/// The index of the blob
pub index: usize,
pub index: u64,
/// The hash of the blob
pub hash: B256,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/sources/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
continue;
};
for blob in blob_hashes {
let indexed = IndexedBlobHash { hash: blob, index: number as usize };
let indexed = IndexedBlobHash { hash: blob, index: number };
hashes.push(indexed);
data.push(BlobData::default());
number += 1;
Expand Down