mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Remove DataAvailabilityView trait from ChildComponents (#5421)
* Remove DataAvailabilityView trait from ChildComponents * PR reviews * Update beacon_node/network/src/sync/block_lookups/common.rs Co-authored-by: realbigsean <seananderson33@GMAIL.com> * Merge branch 'unstable' of https://github.com/sigp/lighthouse into child_components_independent
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use super::child_components::ChildComponents;
|
||||
use super::state_lru_cache::DietAvailabilityPendingExecutedBlock;
|
||||
use crate::blob_verification::KzgVerifiedBlob;
|
||||
use crate::block_verification_types::AsBlock;
|
||||
@@ -195,14 +194,6 @@ impl_availability_view!(
|
||||
verified_blobs
|
||||
);
|
||||
|
||||
impl_availability_view!(
|
||||
ChildComponents,
|
||||
Arc<SignedBeaconBlock<E>>,
|
||||
Arc<BlobSidecar<E>>,
|
||||
downloaded_block,
|
||||
downloaded_blobs
|
||||
);
|
||||
|
||||
pub trait GetCommitments<E: EthSpec> {
|
||||
fn get_commitments(&self) -> KzgCommitments<E>;
|
||||
}
|
||||
@@ -381,23 +372,6 @@ pub mod tests {
|
||||
(block.into(), blobs, invalid_blobs)
|
||||
}
|
||||
|
||||
type ChildComponentsSetup<E> = (
|
||||
Arc<SignedBeaconBlock<E>>,
|
||||
FixedVector<Option<Arc<BlobSidecar<E>>>, <E as EthSpec>::MaxBlobsPerBlock>,
|
||||
FixedVector<Option<Arc<BlobSidecar<E>>>, <E as EthSpec>::MaxBlobsPerBlock>,
|
||||
);
|
||||
|
||||
pub fn setup_child_components(
|
||||
block: SignedBeaconBlock<E>,
|
||||
valid_blobs: FixedVector<Option<Arc<BlobSidecar<E>>>, <E as EthSpec>::MaxBlobsPerBlock>,
|
||||
invalid_blobs: FixedVector<Option<Arc<BlobSidecar<E>>>, <E as EthSpec>::MaxBlobsPerBlock>,
|
||||
) -> ChildComponentsSetup<E> {
|
||||
let blobs = FixedVector::from(valid_blobs.into_iter().cloned().collect::<Vec<_>>());
|
||||
let invalid_blobs =
|
||||
FixedVector::from(invalid_blobs.into_iter().cloned().collect::<Vec<_>>());
|
||||
(Arc::new(block), blobs, invalid_blobs)
|
||||
}
|
||||
|
||||
pub fn assert_cache_consistent<V: AvailabilityView<E>>(cache: V) {
|
||||
if let Some(cached_block) = cache.get_cached_block() {
|
||||
let cached_block_commitments = cached_block.get_commitments();
|
||||
@@ -530,11 +504,4 @@ pub mod tests {
|
||||
verified_blobs,
|
||||
setup_pending_components
|
||||
);
|
||||
generate_tests!(
|
||||
child_component_tests,
|
||||
ChildComponents::<E>,
|
||||
downloaded_block,
|
||||
downloaded_blobs,
|
||||
setup_child_components
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::block_verification_types::RpcBlock;
|
||||
use crate::data_availability_checker::AvailabilityView;
|
||||
use bls::Hash256;
|
||||
use std::sync::Arc;
|
||||
use types::blob_sidecar::FixedBlobSidecarList;
|
||||
use types::{EthSpec, SignedBeaconBlock};
|
||||
use types::{BlobSidecar, EthSpec, SignedBeaconBlock};
|
||||
|
||||
/// For requests triggered by an `UnknownBlockParent` or `UnknownBlobParent`, this struct
|
||||
/// is used to cache components as they are sent to the network service. We can't use the
|
||||
@@ -48,6 +47,22 @@ impl<E: EthSpec> ChildComponents<E> {
|
||||
cache
|
||||
}
|
||||
|
||||
pub fn merge_block(&mut self, block: Arc<SignedBeaconBlock<E>>) {
|
||||
self.downloaded_block = Some(block);
|
||||
}
|
||||
|
||||
pub fn merge_blob(&mut self, blob: Arc<BlobSidecar<E>>) {
|
||||
if let Some(blob_ref) = self.downloaded_blobs.get_mut(blob.index as usize) {
|
||||
*blob_ref = Some(blob);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn merge_blobs(&mut self, blobs: FixedBlobSidecarList<E>) {
|
||||
for blob in blobs.iter().flatten() {
|
||||
self.merge_blob(blob.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_blobs(&mut self) {
|
||||
self.downloaded_blobs = FixedBlobSidecarList::default();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user