mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-21 23:08:23 +00:00
parent blob lookups
This commit is contained in:
@@ -26,6 +26,7 @@ use crate::beacon_processor::{ChainSegmentProcessId, WorkEvent};
|
||||
use crate::metrics;
|
||||
use crate::sync::block_lookups::single_block_lookup::LookupVerifyError;
|
||||
|
||||
mod hg5e3wdtrfqa;
|
||||
mod parent_lookup;
|
||||
mod single_block_lookup;
|
||||
#[cfg(test)]
|
||||
@@ -201,6 +202,23 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn search_current_unknown_blob_parent(
|
||||
&mut self,
|
||||
blob: Arc<BlobSidecar<T::EthSpec>>,
|
||||
peer_id: PeerId,
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
let block_root = blob.block_root;
|
||||
self.search_block_with(
|
||||
|request| {
|
||||
let _ = request.add_blob(blob.clone());
|
||||
},
|
||||
block_root,
|
||||
peer_id,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
||||
/// If a block is attempted to be processed but we do not know its parent, this function is
|
||||
/// called in order to find the block's parent.
|
||||
pub fn search_parent(
|
||||
|
||||
@@ -101,6 +101,36 @@ impl<const MAX_ATTEMPTS: u8, T: BeaconChainTypes> SingleBlockLookup<MAX_ATTEMPTS
|
||||
None
|
||||
}
|
||||
|
||||
pub fn add_blob(
|
||||
&mut self,
|
||||
blob: Arc<BlobSidecar<T::EthSpec>>,
|
||||
) -> Result<LookupDownloadStatus<T::EthSpec>, LookupVerifyError> {
|
||||
let block_root = blob.block_root;
|
||||
|
||||
if let Some(blob_opt) = self.downloaded_blobs.get_mut(blob.index as usize) {
|
||||
//TODO(sean) should we log a warn if there is already a downloaded blob?
|
||||
*blob_opt = Some(blob.clone());
|
||||
|
||||
if let Some(block) = self.downloaded_block.as_ref() {
|
||||
match self.da_checker.wrap_block(
|
||||
block_root,
|
||||
block.clone(),
|
||||
self.downloaded_blobs.clone(),
|
||||
) {
|
||||
Ok(wrapper) => Ok(LookupDownloadStatus::Process(wrapper)),
|
||||
Err(AvailabilityCheckError::MissingBlobs) => {
|
||||
Ok(LookupDownloadStatus::SearchBlock(block_root))
|
||||
}
|
||||
Err(_e) => Err(LookupVerifyError::AvailabilityCheck),
|
||||
}
|
||||
} else {
|
||||
Ok(LookupDownloadStatus::SearchBlock(block_root))
|
||||
}
|
||||
} else {
|
||||
return Err(LookupVerifyError::InvalidIndex(blob.index));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_blobs(
|
||||
&mut self,
|
||||
block_root: Hash256,
|
||||
|
||||
Reference in New Issue
Block a user