mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-01 05:37:05 +00:00
initial straightforward merge changes
This commit is contained in:
@@ -45,7 +45,7 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use store::Hash256;
|
||||
use tracing::{debug, error, warn};
|
||||
use types::{BlobSidecar, DataColumnSidecar, EthSpec, SignedBeaconBlock};
|
||||
use types::{EthSpec, SignedBeaconBlock};
|
||||
|
||||
pub mod common;
|
||||
pub mod parent_chain;
|
||||
@@ -77,22 +77,21 @@ const LOOKUP_MAX_DURATION_NO_PEERS_SECS: u64 = 10;
|
||||
/// take at most 2 GB. 200 lookups allow 3 parallel chains of depth 64 (current maximum).
|
||||
const MAX_LOOKUPS: usize = 200;
|
||||
|
||||
/// The values for `Blob`, `DataColumn` and `PartialDataColumn` is the parent root of the column.
|
||||
pub enum BlockComponent<E: EthSpec> {
|
||||
Block(DownloadResult<Arc<SignedBeaconBlock<E>>>),
|
||||
Blob(DownloadResult<Arc<BlobSidecar<E>>>),
|
||||
DataColumn(DownloadResult<Arc<DataColumnSidecar<E>>>),
|
||||
Blob(DownloadResult<Hash256>),
|
||||
DataColumn(DownloadResult<Hash256>),
|
||||
PartialDataColumn(DownloadResult<Hash256>),
|
||||
}
|
||||
|
||||
impl<E: EthSpec> BlockComponent<E> {
|
||||
fn parent_root(&self) -> Hash256 {
|
||||
match self {
|
||||
BlockComponent::Block(block) => block.value.parent_root(),
|
||||
BlockComponent::Blob(blob) => blob.value.block_parent_root(),
|
||||
BlockComponent::DataColumn(column) => match column.value.as_ref() {
|
||||
DataColumnSidecar::Fulu(column) => column.block_parent_root(),
|
||||
// TODO(gloas) we don't have a parent root post gloas, not sure what to do here
|
||||
DataColumnSidecar::Gloas(column) => column.beacon_block_root,
|
||||
},
|
||||
BlockComponent::Blob(parent_root)
|
||||
| BlockComponent::DataColumn(parent_root)
|
||||
| BlockComponent::PartialDataColumn(parent_root) => parent_root.value,
|
||||
}
|
||||
}
|
||||
fn get_type(&self) -> &'static str {
|
||||
@@ -100,6 +99,7 @@ impl<E: EthSpec> BlockComponent<E> {
|
||||
BlockComponent::Block(_) => "block",
|
||||
BlockComponent::Blob(_) => "blob",
|
||||
BlockComponent::DataColumn(_) => "data_column",
|
||||
BlockComponent::PartialDataColumn(_) => "partial_data_column",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,9 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
|
||||
.block_request_state
|
||||
.state
|
||||
.insert_verified_response(block),
|
||||
BlockComponent::Blob(_) | BlockComponent::DataColumn(_) => {
|
||||
BlockComponent::Blob(_)
|
||||
| BlockComponent::DataColumn(_)
|
||||
| BlockComponent::PartialDataColumn(_) => {
|
||||
// For now ignore single blobs and columns, as the blob request state assumes all blobs are
|
||||
// attributed to the same peer = the peer serving the remaining blobs. Ignoring this
|
||||
// block component has a minor effect, causing the node to re-request this blob
|
||||
|
||||
@@ -49,7 +49,6 @@ use crate::sync::block_lookups::{
|
||||
use crate::sync::custody_backfill_sync::CustodyBackFillSync;
|
||||
use crate::sync::network_context::{PeerGroup, RpcResponseResult};
|
||||
use beacon_chain::block_verification_types::AsBlock;
|
||||
use beacon_chain::validator_monitor::timestamp_now;
|
||||
use beacon_chain::{
|
||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainTypes, BlockError, EngineState,
|
||||
};
|
||||
@@ -142,6 +141,14 @@ pub enum SyncMessage<E: EthSpec> {
|
||||
/// A data column with an unknown parent has been received.
|
||||
UnknownParentDataColumn(PeerId, Arc<DataColumnSidecar<E>>),
|
||||
|
||||
/// A partial data column with an unknown parent has been received.
|
||||
UnknownParentPartialDataColumn {
|
||||
peer_id: PeerId,
|
||||
block_root: Hash256,
|
||||
parent_root: Hash256,
|
||||
slot: Slot,
|
||||
},
|
||||
|
||||
/// A peer has sent an attestation that references a block that is unknown. This triggers the
|
||||
/// manager to attempt to find the block matching the unknown hash.
|
||||
UnknownBlockHashFromAttestation(PeerId, Hash256),
|
||||
@@ -851,7 +858,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
BlockComponent::Block(DownloadResult {
|
||||
value: block.block_cloned(),
|
||||
block_root,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
peer_group: PeerGroup::from_single(peer_id),
|
||||
}),
|
||||
);
|
||||
@@ -867,9 +874,9 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
parent_root,
|
||||
blob_slot,
|
||||
BlockComponent::Blob(DownloadResult {
|
||||
value: blob,
|
||||
value: parent_root,
|
||||
block_root,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
peer_group: PeerGroup::from_single(peer_id),
|
||||
}),
|
||||
);
|
||||
@@ -887,9 +894,13 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
parent_root,
|
||||
data_column_slot,
|
||||
BlockComponent::DataColumn(DownloadResult {
|
||||
value: data_column,
|
||||
value: parent_root,
|
||||
block_root,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self
|
||||
.chain
|
||||
.slot_clock
|
||||
.now_duration()
|
||||
.unwrap_or_default(),
|
||||
peer_group: PeerGroup::from_single(peer_id),
|
||||
}),
|
||||
);
|
||||
@@ -900,6 +911,26 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
SyncMessage::UnknownParentPartialDataColumn {
|
||||
peer_id,
|
||||
block_root,
|
||||
parent_root,
|
||||
slot,
|
||||
} => {
|
||||
debug!(%block_root, %parent_root, "Received unknown parent partial column message");
|
||||
self.handle_unknown_parent(
|
||||
peer_id,
|
||||
block_root,
|
||||
parent_root,
|
||||
slot,
|
||||
BlockComponent::PartialDataColumn(DownloadResult {
|
||||
value: parent_root,
|
||||
block_root,
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
peer_group: PeerGroup::from_single(peer_id),
|
||||
}),
|
||||
);
|
||||
}
|
||||
SyncMessage::UnknownBlockHashFromAttestation(peer_id, block_root) => {
|
||||
if !self.notified_unknown_roots.contains(&(peer_id, block_root)) {
|
||||
self.notified_unknown_roots.insert((peer_id, block_root));
|
||||
|
||||
@@ -1703,8 +1703,8 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
};
|
||||
|
||||
let result = columns_by_range_peers_to_request
|
||||
.iter()
|
||||
.filter_map(|(peer_id, _)| {
|
||||
.keys()
|
||||
.filter_map(|peer_id| {
|
||||
self.send_data_columns_by_range_request(
|
||||
*peer_id,
|
||||
request.clone(),
|
||||
|
||||
@@ -2,11 +2,11 @@ use crate::sync::network_context::{
|
||||
DataColumnsByRootRequestId, DataColumnsByRootSingleBlockRequest,
|
||||
};
|
||||
use beacon_chain::BeaconChainTypes;
|
||||
use beacon_chain::validator_monitor::timestamp_now;
|
||||
use fnv::FnvHashMap;
|
||||
use lighthouse_network::PeerId;
|
||||
use lighthouse_network::service::api_types::{CustodyId, DataColumnsByRootRequester};
|
||||
use parking_lot::RwLock;
|
||||
use slot_clock::SlotClock;
|
||||
use std::collections::HashSet;
|
||||
use std::hash::{BuildHasher, RandomState};
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -223,7 +223,10 @@ impl<T: BeaconChainTypes> ActiveCustodyRequest<T> {
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let peer_group = PeerGroup::from_set(peers);
|
||||
let max_seen_timestamp = seen_timestamps.into_iter().max().unwrap_or(timestamp_now());
|
||||
let max_seen_timestamp = seen_timestamps
|
||||
.into_iter()
|
||||
.max()
|
||||
.unwrap_or_else(|| cx.chain.slot_clock.now_duration().unwrap_or_default());
|
||||
return Ok(Some((columns, peer_group, max_seen_timestamp)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::time::Instant;
|
||||
use std::{collections::hash_map::Entry, hash::Hash};
|
||||
|
||||
use beacon_chain::validator_monitor::timestamp_now;
|
||||
use fnv::FnvHashMap;
|
||||
use lighthouse_network::PeerId;
|
||||
use slot_clock::timestamp_now;
|
||||
use strum::IntoStaticStr;
|
||||
use tracing::{Span, debug};
|
||||
use types::{Hash256, Slot};
|
||||
|
||||
Reference in New Issue
Block a user