mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Merge branch 'some-blob-reprocessing-work' of https://github.com/realbigsean/lighthouse into some-blob-reprocessing-work
This commit is contained in:
@@ -86,6 +86,20 @@ impl<T: EthSpec> PendingComponents<T> {
|
|||||||
None
|
None
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_missing_blob_info(&self) -> MissingBlobInfo<T> {
|
||||||
|
let block_opt = self
|
||||||
|
.executed_block
|
||||||
|
.as_ref()
|
||||||
|
.map(|block| block.block.block.clone());
|
||||||
|
let blobs = self
|
||||||
|
.verified_blobs
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(i, maybe_blob)| maybe_blob.as_ref().map(|_| i))
|
||||||
|
.collect::<HashSet<_>>();
|
||||||
|
(block_opt, blobs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@@ -197,6 +211,22 @@ impl<T: BeaconChainTypes> OverflowStore<T> {
|
|||||||
Ok(disk_keys)
|
Ok(disk_keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn load_block(
|
||||||
|
&self,
|
||||||
|
block_root: &Hash256,
|
||||||
|
) -> Result<Option<AvailabilityPendingExecutedBlock<T::EthSpec>>, AvailabilityCheckError> {
|
||||||
|
let key = OverflowKey::from_block_root(*block_root);
|
||||||
|
|
||||||
|
self.0
|
||||||
|
.hot_db
|
||||||
|
.get_bytes(DBColumn::OverflowLRUCache.as_str(), &key.as_ssz_bytes())?
|
||||||
|
.map(|block_bytes| {
|
||||||
|
AvailabilityPendingExecutedBlock::from_ssz_bytes(block_bytes.as_slice())
|
||||||
|
})
|
||||||
|
.transpose()
|
||||||
|
.map_err(|e| e.into())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load_blob(
|
pub fn load_blob(
|
||||||
&self,
|
&self,
|
||||||
blob_id: &BlobIdentifier,
|
blob_id: &BlobIdentifier,
|
||||||
@@ -244,12 +274,6 @@ impl<T: BeaconChainTypes> Critical<T> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_block(&self, block_root: &Hash256) -> bool {
|
|
||||||
self.in_memory
|
|
||||||
.peek(block_root)
|
|
||||||
.map_or(false, |cache| cache.executed_block.is_some())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This only checks for the blobs in memory
|
/// This only checks for the blobs in memory
|
||||||
pub fn peek_blob(
|
pub fn peek_blob(
|
||||||
&self,
|
&self,
|
||||||
@@ -331,27 +355,38 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_block(&self, block_root: &Hash256) -> bool {
|
pub fn has_block(&self, block_root: &Hash256) -> bool {
|
||||||
self.critical.read().has_block(block_root)
|
let read_lock = self.critical.read();
|
||||||
}
|
if read_lock
|
||||||
pub fn get_missing_blob_info(&self, block_root: Hash256) -> MissingBlobInfo<T::EthSpec> {
|
|
||||||
self.critical
|
|
||||||
.read()
|
|
||||||
.in_memory
|
.in_memory
|
||||||
.peek(&block_root)
|
.peek(block_root)
|
||||||
.map(|cache| {
|
.map_or(false, |cache| cache.executed_block.is_some())
|
||||||
let block_opt = cache
|
{
|
||||||
.executed_block
|
true
|
||||||
.as_ref()
|
} else if read_lock.store_keys.contains(block_root) {
|
||||||
.map(|block| block.block.block.clone());
|
drop(read_lock);
|
||||||
let blobs = cache
|
// If there's some kind of error reading from the store, we should just return false
|
||||||
.verified_blobs
|
self.overflow_store
|
||||||
.iter()
|
.load_block(block_root)
|
||||||
.enumerate()
|
.map_or(false, |maybe_block| maybe_block.is_some())
|
||||||
.filter_map(|(i, maybe_blob)| maybe_blob.as_ref().map(|_| i))
|
} else {
|
||||||
.collect::<HashSet<_>>();
|
false
|
||||||
(block_opt, blobs)
|
}
|
||||||
})
|
}
|
||||||
.unwrap_or_default()
|
|
||||||
|
pub fn get_missing_blob_info(&self, block_root: Hash256) -> MissingBlobInfo<T::EthSpec> {
|
||||||
|
let read_lock = self.critical.read();
|
||||||
|
if let Some(cache) = read_lock.in_memory.peek(&block_root) {
|
||||||
|
cache.get_missing_blob_info()
|
||||||
|
} else if read_lock.store_keys.contains(&block_root) {
|
||||||
|
drop(read_lock);
|
||||||
|
// return default if there's an error reading from the store
|
||||||
|
match self.overflow_store.get_pending_components(block_root) {
|
||||||
|
Ok(Some(pending_components)) => pending_components.get_missing_blob_info(),
|
||||||
|
_ => Default::default(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peek_blob(
|
pub fn peek_blob(
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
self.log,
|
self.log,
|
||||||
"Sending BlobsByRoot Request";
|
"Sending parent BlobsByRoot Request";
|
||||||
"method" => "BlobsByRoot",
|
"method" => "BlobsByRoot",
|
||||||
"count" => request.blob_ids.len(),
|
"count" => request.blob_ids.len(),
|
||||||
"peer" => %peer_id
|
"peer" => %peer_id
|
||||||
|
|||||||
Reference in New Issue
Block a user