mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 13:24:39 +00:00
Deprecate blob lookup sync (#9383)
- Extends https://github.com/sigp/lighthouse/pull/9126 to cover blob lookup sync Lookup sync is only for unfinalized blocks, which will never contains blobs in any network we support. Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>
This commit is contained in:
@@ -9,7 +9,6 @@ use tracing::{Span, debug};
|
||||
use types::{Hash256, Slot};
|
||||
|
||||
pub use blobs_by_range::BlobsByRangeRequestItems;
|
||||
pub use blobs_by_root::{BlobsByRootRequestItems, BlobsByRootSingleBlockRequest};
|
||||
pub use blocks_by_range::BlocksByRangeRequestItems;
|
||||
pub use blocks_by_root::{BlocksByRootRequestItems, BlocksByRootSingleRequest};
|
||||
pub use data_columns_by_range::DataColumnsByRangeRequestItems;
|
||||
@@ -25,7 +24,6 @@ use crate::metrics;
|
||||
use super::{RpcEvent, RpcResponseError, RpcResponseResult};
|
||||
|
||||
mod blobs_by_range;
|
||||
mod blobs_by_root;
|
||||
mod blocks_by_range;
|
||||
mod blocks_by_root;
|
||||
mod data_columns_by_range;
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
use lighthouse_network::rpc::methods::BlobsByRootRequest;
|
||||
use std::sync::Arc;
|
||||
use types::{BlobSidecar, EthSpec, ForkContext, Hash256, data::BlobIdentifier};
|
||||
|
||||
use super::{ActiveRequestItems, LookupVerifyError};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BlobsByRootSingleBlockRequest {
|
||||
pub block_root: Hash256,
|
||||
pub indices: Vec<u64>,
|
||||
}
|
||||
|
||||
impl BlobsByRootSingleBlockRequest {
|
||||
pub fn into_request(self, spec: &ForkContext) -> Result<BlobsByRootRequest, String> {
|
||||
BlobsByRootRequest::new(
|
||||
self.indices
|
||||
.into_iter()
|
||||
.map(|index| BlobIdentifier {
|
||||
block_root: self.block_root,
|
||||
index,
|
||||
})
|
||||
.collect(),
|
||||
spec,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BlobsByRootRequestItems<E: EthSpec> {
|
||||
request: BlobsByRootSingleBlockRequest,
|
||||
items: Vec<Arc<BlobSidecar<E>>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> BlobsByRootRequestItems<E> {
|
||||
pub fn new(request: BlobsByRootSingleBlockRequest) -> Self {
|
||||
Self {
|
||||
request,
|
||||
items: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> ActiveRequestItems for BlobsByRootRequestItems<E> {
|
||||
type Item = Arc<BlobSidecar<E>>;
|
||||
|
||||
/// Appends a chunk to this multi-item request. If all expected chunks are received, this
|
||||
/// method returns `Some`, resolving the request before the stream terminator.
|
||||
/// The active request SHOULD be dropped after `add_response` returns an error
|
||||
fn add(&mut self, blob: Self::Item) -> Result<bool, LookupVerifyError> {
|
||||
let block_root = blob.block_root();
|
||||
if self.request.block_root != block_root {
|
||||
return Err(LookupVerifyError::UnrequestedBlockRoot(block_root));
|
||||
}
|
||||
|
||||
if !blob.verify_blob_sidecar_inclusion_proof() {
|
||||
return Err(LookupVerifyError::InvalidInclusionProof);
|
||||
}
|
||||
|
||||
if !self.request.indices.contains(&blob.index) {
|
||||
return Err(LookupVerifyError::UnrequestedIndex(blob.index));
|
||||
}
|
||||
if self.items.iter().any(|b| b.index == blob.index) {
|
||||
return Err(LookupVerifyError::DuplicatedData(blob.slot(), blob.index));
|
||||
}
|
||||
|
||||
self.items.push(blob);
|
||||
|
||||
Ok(self.items.len() >= self.request.indices.len())
|
||||
}
|
||||
|
||||
fn consume(&mut self) -> Vec<Self::Item> {
|
||||
std::mem::take(&mut self.items)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user