mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 21:34:46 +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:
@@ -8,7 +8,7 @@ use crate::sync::block_lookups::{
|
||||
use crate::sync::manager::{BlockProcessType, Id, SingleLookupReqId};
|
||||
use crate::sync::network_context::SyncNetworkContext;
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::data_availability_checker::{AvailabilityView, ChildComponents};
|
||||
use beacon_chain::data_availability_checker::ChildComponents;
|
||||
use beacon_chain::{get_block_root, BeaconChainTypes};
|
||||
use lighthouse_network::rpc::methods::BlobsByRootRequest;
|
||||
use lighthouse_network::rpc::BlocksByRootRequest;
|
||||
@@ -17,7 +17,7 @@ use std::ops::IndexMut;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use types::blob_sidecar::{BlobIdentifier, FixedBlobSidecarList};
|
||||
use types::{BlobSidecar, ChainSpec, EthSpec, Hash256, SignedBeaconBlock};
|
||||
use types::{BlobSidecar, ChainSpec, Hash256, SignedBeaconBlock};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ResponseType {
|
||||
@@ -371,27 +371,35 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlobRequestState<L,
|
||||
|
||||
fn verify_response_inner(
|
||||
&mut self,
|
||||
_expected_block_root: Hash256,
|
||||
expected_block_root: Hash256,
|
||||
blob: Option<Self::ResponseType>,
|
||||
peer_id: PeerId,
|
||||
) -> Result<Option<FixedBlobSidecarList<T::EthSpec>>, LookupVerifyError> {
|
||||
match blob {
|
||||
Some(blob) => {
|
||||
let received_id = blob.id();
|
||||
if !self.requested_ids.contains(&received_id) {
|
||||
self.state.register_failure_downloading();
|
||||
Err(LookupVerifyError::UnrequestedBlobId(received_id))
|
||||
} else {
|
||||
// State should remain downloading until we receive the stream terminator.
|
||||
self.requested_ids.remove(&received_id);
|
||||
let blob_index = blob.index;
|
||||
|
||||
if blob_index >= T::EthSpec::max_blobs_per_block() as u64 {
|
||||
return Err(LookupVerifyError::InvalidIndex(blob.index));
|
||||
}
|
||||
*self.blob_download_queue.index_mut(blob_index as usize) = Some(blob);
|
||||
Ok(None)
|
||||
if !self.requested_ids.contains(&received_id) {
|
||||
Err(LookupVerifyError::UnrequestedBlobId(received_id))
|
||||
} else if !blob.verify_blob_sidecar_inclusion_proof().unwrap_or(false) {
|
||||
Err(LookupVerifyError::InvalidInclusionProof)
|
||||
} else if blob.block_root() != expected_block_root {
|
||||
Err(LookupVerifyError::UnrequestedHeader)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
.map_err(|e| {
|
||||
self.state.register_failure_downloading();
|
||||
e
|
||||
})?;
|
||||
|
||||
// State should remain downloading until we receive the stream terminator.
|
||||
self.requested_ids.remove(&received_id);
|
||||
|
||||
// The inclusion proof check above ensures `blob.index` is < MAX_BLOBS_PER_BLOCK
|
||||
let blob_index = blob.index;
|
||||
*self.blob_download_queue.index_mut(blob_index as usize) = Some(blob);
|
||||
Ok(None)
|
||||
}
|
||||
None => {
|
||||
self.state.state = State::Processing { peer_id };
|
||||
|
||||
Reference in New Issue
Block a user