mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-17 10:48:28 +00:00
initial straightforward merge changes
This commit is contained in:
@@ -143,6 +143,22 @@ pub static BEACON_PROCESSOR_GOSSIP_DATA_COLUMN_SIDECAR_VERIFIED_TOTAL: LazyLock<
|
||||
"Total number of gossip data column sidecar verified for propagation.",
|
||||
)
|
||||
});
|
||||
pub static BEACON_PROCESSOR_GOSSIP_PARTIAL_DATA_COLUMN_SIDECAR_VERIFIED_TOTAL: LazyLock<
|
||||
Result<IntCounter>,
|
||||
> = LazyLock::new(|| {
|
||||
try_create_int_counter(
|
||||
"beacon_processor_gossip_partial_data_column_verified_total",
|
||||
"Total number of gossip partial data column sidecar verified for propagation.",
|
||||
)
|
||||
});
|
||||
pub static BEACON_PROCESSOR_GOSSIP_PARTIAL_DATA_COLUMN_SIDECAR_MISSING_HEADER_TOTAL: LazyLock<
|
||||
Result<IntCounter>,
|
||||
> = LazyLock::new(|| {
|
||||
try_create_int_counter(
|
||||
"beacon_processor_gossip_partial_data_column_missing_header_total",
|
||||
"Total number of gossip partial data column sidecar received without a (cached) header.",
|
||||
)
|
||||
});
|
||||
// Gossip Exits.
|
||||
pub static BEACON_PROCESSOR_EXIT_VERIFIED_TOTAL: LazyLock<Result<IntCounter>> =
|
||||
LazyLock::new(|| {
|
||||
@@ -601,6 +617,16 @@ pub static BEACON_DATA_COLUMN_GOSSIP_PROPAGATION_VERIFICATION_DELAY_TIME: LazyLo
|
||||
decimal_buckets(-3, -1),
|
||||
)
|
||||
});
|
||||
pub static BEACON_PARTIAL_DATA_COLUMN_GOSSIP_PROPAGATION_VERIFICATION_DELAY_TIME: LazyLock<
|
||||
Result<Histogram>,
|
||||
> = LazyLock::new(|| {
|
||||
try_create_histogram_with_buckets(
|
||||
"beacon_partial_data_column_gossip_propagation_verification_delay_time",
|
||||
"Duration between when the partial data column sidecar is received over gossip and when it is verified for propagation.",
|
||||
// [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5]
|
||||
decimal_buckets(-3, -1),
|
||||
)
|
||||
});
|
||||
pub static BEACON_DATA_COLUMN_GOSSIP_SLOT_START_DELAY_TIME: LazyLock<Result<Histogram>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_histogram_with_buckets(
|
||||
@@ -615,6 +641,28 @@ pub static BEACON_DATA_COLUMN_GOSSIP_SLOT_START_DELAY_TIME: LazyLock<Result<Hist
|
||||
//decimal_buckets(-1,2)
|
||||
)
|
||||
});
|
||||
pub static BEACON_PARTIAL_DATA_COLUMN_GOSSIP_SLOT_START_DELAY_TIME: LazyLock<Result<Histogram>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_histogram_with_buckets(
|
||||
"beacon_partial_data_column_gossip_slot_start_delay_time",
|
||||
"Duration between when the partial data column sidecar is received over gossip and the start of the slot it belongs to.",
|
||||
// Create a custom bucket list for greater granularity in block delay
|
||||
Ok(vec![
|
||||
0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0,
|
||||
6.0, 7.0, 8.0, 9.0, 10.0, 15.0, 20.0,
|
||||
]), // NOTE: Previous values, which we may want to switch back to.
|
||||
// [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50]
|
||||
//decimal_buckets(-1,2)
|
||||
)
|
||||
});
|
||||
pub static BEACON_USEFUL_FULL_COLUMNS_RECEIVED_TOTAL: LazyLock<Result<IntCounterVec>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_counter_vec(
|
||||
"beacon_useful_full_columns_received_total",
|
||||
"Number of useful full columns (any cell being useful) received",
|
||||
&["column_index"],
|
||||
)
|
||||
});
|
||||
|
||||
pub static BEACON_BLOB_DELAY_GOSSIP_VERIFICATION: LazyLock<Result<IntGauge>> = LazyLock::new(
|
||||
|| {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ use lighthouse_network::rpc::methods::{
|
||||
};
|
||||
use lighthouse_network::service::api_types::CustodyBackfillBatchId;
|
||||
use lighthouse_network::{
|
||||
Client, MessageId, NetworkGlobals, PeerId, PubsubMessage,
|
||||
Client, GossipTopic, MessageId, NetworkGlobals, PeerId, PubsubMessage,
|
||||
rpc::{BlocksByRangeRequest, BlocksByRootRequest, LightClientBootstrapRequest, StatusMessage},
|
||||
};
|
||||
use rand::prelude::SliceRandom;
|
||||
@@ -251,6 +251,32 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a new `Work` event for some partial data column sidecar.
|
||||
pub fn send_gossip_partial_data_column_sidecar(
|
||||
self: &Arc<Self>,
|
||||
peer_id: PeerId,
|
||||
column_sidecar: Box<PartialDataColumn<T::EthSpec>>,
|
||||
seen_timestamp: Duration,
|
||||
topic: GossipTopic,
|
||||
) -> Result<(), Error<T::EthSpec>> {
|
||||
let processor = self.clone();
|
||||
let process_fn = async move {
|
||||
processor
|
||||
.process_gossip_partial_data_column_sidecar(
|
||||
peer_id,
|
||||
column_sidecar,
|
||||
seen_timestamp,
|
||||
topic,
|
||||
)
|
||||
.await
|
||||
};
|
||||
|
||||
self.try_send(BeaconWorkEvent {
|
||||
drop_during_sync: false,
|
||||
work: Work::GossipPartialDataColumnSidecar(Box::pin(process_fn)),
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a new `Work` event for some sync committee signature.
|
||||
pub fn send_gossip_sync_signature(
|
||||
self: &Arc<Self>,
|
||||
@@ -463,7 +489,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
processor.process_gossip_execution_payload_bid(
|
||||
message_id,
|
||||
peer_id,
|
||||
*execution_payload_bid,
|
||||
Arc::new(*execution_payload_bid),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -507,12 +533,12 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
processor.process_gossip_proposer_preferences(
|
||||
message_id,
|
||||
peer_id,
|
||||
*proposer_preferences,
|
||||
Arc::new(*proposer_preferences),
|
||||
)
|
||||
};
|
||||
|
||||
self.try_send(BeaconWorkEvent {
|
||||
drop_during_sync: false,
|
||||
drop_during_sync: true,
|
||||
work: Work::GossipProposerPreferences(Box::new(process_fn)),
|
||||
})
|
||||
}
|
||||
@@ -894,14 +920,14 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
|
||||
pub async fn fetch_engine_blobs_and_publish(
|
||||
self: &Arc<Self>,
|
||||
block: Arc<SignedBeaconBlock<T::EthSpec, FullPayload<T::EthSpec>>>,
|
||||
header: Arc<PartialDataColumnHeader<T::EthSpec>>,
|
||||
block_root: Hash256,
|
||||
publish_blobs: bool,
|
||||
) {
|
||||
if self.chain.config.disable_get_blobs {
|
||||
return;
|
||||
}
|
||||
let epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
||||
let epoch = header.slot().epoch(T::EthSpec::slots_per_epoch());
|
||||
let custody_columns = self.chain.sampling_columns_for_epoch(epoch);
|
||||
let self_cloned = self.clone();
|
||||
let publish_fn = move |blobs_or_data_column| {
|
||||
@@ -926,7 +952,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
match fetch_and_process_engine_blobs(
|
||||
self.chain.clone(),
|
||||
block_root,
|
||||
block.clone(),
|
||||
header.clone(),
|
||||
custody_columns,
|
||||
publish_fn,
|
||||
)
|
||||
@@ -970,6 +996,23 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Publish partial columns without eager send
|
||||
if let Some(assembler) = self.chain.data_availability_checker.partial_assembler() {
|
||||
let columns = assembler.get_partials_and_mark_as_local_fetched(block_root, &header);
|
||||
if !columns.is_empty() {
|
||||
debug!(block = %block_root, "Publishing all partials after getBlobs");
|
||||
self.send_network_message(NetworkMessage::PublishPartialColumns {
|
||||
columns: columns
|
||||
.into_iter()
|
||||
.map(|partial| partial.into_inner())
|
||||
.collect(),
|
||||
header,
|
||||
});
|
||||
} else {
|
||||
debug!(block = %block_root, "No partials to publish after getBlobs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to reconstruct all data columns if the conditions checked in
|
||||
|
||||
@@ -218,9 +218,15 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
// Block is valid, we can now attempt fetching blobs from EL using version hashes
|
||||
// derived from kzg commitments from the block, without having to wait for all blobs
|
||||
// to be sent from the peers if we already have them.
|
||||
let publish_blobs = false;
|
||||
self.fetch_engine_blobs_and_publish(signed_beacon_block, block_root, publish_blobs)
|
||||
if let Ok(header) = signed_beacon_block.as_ref().try_into() {
|
||||
let publish_blobs = false;
|
||||
self.fetch_engine_blobs_and_publish(
|
||||
Arc::new(header),
|
||||
block_root,
|
||||
publish_blobs,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ use beacon_chain::test_utils::{
|
||||
use beacon_chain::{BeaconChain, WhenSlotSkipped};
|
||||
use beacon_processor::{work_reprocessing_queue::*, *};
|
||||
use bls::Signature;
|
||||
use fixed_bytes::FixedBytesExtended;
|
||||
use itertools::Itertools;
|
||||
use libp2p::gossipsub::MessageAcceptance;
|
||||
use lighthouse_network::rpc::InboundRequestId;
|
||||
@@ -2125,12 +2124,13 @@ fn make_test_payload_envelope(
|
||||
) -> SignedExecutionPayloadEnvelope<E> {
|
||||
SignedExecutionPayloadEnvelope {
|
||||
message: ExecutionPayloadEnvelope {
|
||||
payload: ExecutionPayloadGloas::default(),
|
||||
payload: ExecutionPayloadGloas {
|
||||
slot_number: slot,
|
||||
..ExecutionPayloadGloas::default()
|
||||
},
|
||||
execution_requests: ExecutionRequests::default(),
|
||||
builder_index: 0,
|
||||
beacon_block_root,
|
||||
slot,
|
||||
state_root: Hash256::zero(),
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
}
|
||||
@@ -2158,7 +2158,7 @@ async fn test_payload_envelopes_by_range() {
|
||||
let envelope = make_test_payload_envelope(Slot::new(slot), root);
|
||||
rig.chain
|
||||
.store
|
||||
.put_payload_envelope(&root, envelope)
|
||||
.put_payload_envelope(&root, &envelope)
|
||||
.unwrap();
|
||||
expected_roots.push(root);
|
||||
}
|
||||
@@ -2208,7 +2208,7 @@ async fn test_payload_envelopes_by_root() {
|
||||
let envelope = make_test_payload_envelope(Slot::new(1), block_root);
|
||||
rig.chain
|
||||
.store
|
||||
.put_payload_envelope(&block_root, envelope)
|
||||
.put_payload_envelope(&block_root, &envelope)
|
||||
.unwrap();
|
||||
|
||||
let roots = RuntimeVariableList::new(vec![block_root], 1).unwrap();
|
||||
@@ -2298,7 +2298,7 @@ async fn test_payload_envelopes_by_range_no_duplicates_with_skip_slots() {
|
||||
let envelope = make_test_payload_envelope(Slot::new(slot), root);
|
||||
rig.chain
|
||||
.store
|
||||
.put_payload_envelope(&root, envelope)
|
||||
.put_payload_envelope(&root, &envelope)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,19 @@ use beacon_processor::{BeaconProcessorSend, DuplicateCache};
|
||||
use futures::prelude::*;
|
||||
use lighthouse_network::rpc::*;
|
||||
use lighthouse_network::{
|
||||
MessageId, NetworkGlobals, PeerId, PubsubMessage, Response,
|
||||
GossipTopic, MessageId, NetworkGlobals, PeerId, PubsubMessage, Response,
|
||||
service::api_types::{AppRequestId, SyncRequestId},
|
||||
};
|
||||
use logging::TimeLatch;
|
||||
use logging::crit;
|
||||
use slot_clock::SlotClock;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::{debug, error, trace, warn};
|
||||
use types::{BlobSidecar, DataColumnSidecar, EthSpec, ForkContext, SignedBeaconBlock};
|
||||
use types::{
|
||||
BlobSidecar, DataColumnSidecar, EthSpec, ForkContext, PartialDataColumn, SignedBeaconBlock,
|
||||
};
|
||||
|
||||
/// Handles messages from the network and routes them to the appropriate service to be handled.
|
||||
pub struct Router<T: BeaconChainTypes> {
|
||||
@@ -69,6 +71,8 @@ pub enum RouterMessage<E: EthSpec> {
|
||||
/// message, the message itself and a bool which indicates if the message should be processed
|
||||
/// by the beacon chain after successful verification.
|
||||
PubsubMessage(MessageId, PeerId, PubsubMessage<E>, bool),
|
||||
/// A partial data column sidecar has been received via gossipsub partial protocol.
|
||||
PartialDataColumnSidecar(PeerId, Box<PartialDataColumn<E>>, GossipTopic),
|
||||
/// The peer manager has requested we re-status a peer.
|
||||
StatusPeer(PeerId),
|
||||
/// The peer has an updated custody group count from METADATA.
|
||||
@@ -180,6 +184,16 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
RouterMessage::PubsubMessage(id, peer_id, gossip, should_process) => {
|
||||
self.handle_gossip(id, peer_id, gossip, should_process);
|
||||
}
|
||||
RouterMessage::PartialDataColumnSidecar(peer_id, column, topic) => self
|
||||
.handle_beacon_processor_send_result(
|
||||
self.network_beacon_processor
|
||||
.send_gossip_partial_data_column_sidecar(
|
||||
peer_id,
|
||||
column,
|
||||
self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
topic,
|
||||
),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +365,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
gossip_message: PubsubMessage<T::EthSpec>,
|
||||
should_process: bool,
|
||||
) {
|
||||
let seen_timestamp = self.chain.slot_clock.now_duration().unwrap_or_default();
|
||||
match gossip_message {
|
||||
PubsubMessage::AggregateAndProofAttestation(aggregate_and_proof) => self
|
||||
.handle_beacon_processor_send_result(
|
||||
@@ -358,7 +373,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
message_id,
|
||||
peer_id,
|
||||
*aggregate_and_proof,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
),
|
||||
PubsubMessage::Attestation(subnet_attestation) => self
|
||||
@@ -369,7 +384,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
subnet_attestation.1,
|
||||
subnet_attestation.0,
|
||||
should_process,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
),
|
||||
PubsubMessage::BeaconBlock(block) => self.handle_beacon_processor_send_result(
|
||||
@@ -378,7 +393,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
self.network_globals.client(&peer_id),
|
||||
block,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
),
|
||||
PubsubMessage::BlobSidecar(data) => {
|
||||
@@ -390,7 +405,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
self.network_globals.client(&peer_id),
|
||||
blob_index,
|
||||
blob_sidecar,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -403,7 +418,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
subnet_id,
|
||||
column_sidecar,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -450,7 +465,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
message_id,
|
||||
peer_id,
|
||||
*contribution_and_proof,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -465,7 +480,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
sync_committtee_msg.1,
|
||||
sync_committtee_msg.0,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -480,7 +495,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
message_id,
|
||||
peer_id,
|
||||
*light_client_finality_update,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -496,7 +511,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
message_id,
|
||||
peer_id,
|
||||
*light_client_optimistic_update,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -516,7 +531,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
message_id,
|
||||
peer_id,
|
||||
signed_execution_payload_envelope,
|
||||
timestamp_now(),
|
||||
seen_timestamp,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -642,7 +657,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
sync_request_id,
|
||||
beacon_block,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -662,7 +677,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
sync_request_id,
|
||||
blob_sidecar,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
});
|
||||
} else {
|
||||
crit!("All blobs by range responses should belong to sync");
|
||||
@@ -699,7 +714,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
sync_request_id,
|
||||
beacon_block,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -733,7 +748,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
sync_request_id,
|
||||
peer_id,
|
||||
blob_sidecar,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -767,7 +782,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
sync_request_id,
|
||||
peer_id,
|
||||
data_column,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -787,7 +802,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id,
|
||||
sync_request_id,
|
||||
data_column,
|
||||
seen_timestamp: timestamp_now(),
|
||||
seen_timestamp: self.chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
});
|
||||
} else {
|
||||
crit!("All data columns by range responses should belong to sync");
|
||||
@@ -855,9 +870,3 @@ impl<E: EthSpec> HandlerNetworkContext<E> {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn timestamp_now() -> Duration {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_else(|_| Duration::from_secs(0))
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ use tokio::time::Sleep;
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
use typenum::Unsigned;
|
||||
use types::{
|
||||
EthSpec, ForkContext, Slot, SubnetId, SyncCommitteeSubscription, SyncSubnetId,
|
||||
ValidatorSubscription,
|
||||
EthSpec, ForkContext, PartialDataColumn, PartialDataColumnHeader, Slot, SubnetId,
|
||||
SyncCommitteeSubscription, SyncSubnetId, ValidatorSubscription,
|
||||
};
|
||||
|
||||
mod tests;
|
||||
@@ -83,6 +83,11 @@ pub enum NetworkMessage<E: EthSpec> {
|
||||
},
|
||||
/// Publish a list of messages to the gossipsub protocol.
|
||||
Publish { messages: Vec<PubsubMessage<E>> },
|
||||
/// Publish partial data column sidecars via the partial gossipsub protocol.
|
||||
PublishPartialColumns {
|
||||
columns: Vec<Arc<PartialDataColumn<E>>>,
|
||||
header: Arc<PartialDataColumnHeader<E>>,
|
||||
},
|
||||
/// Validates a received gossipsub message. This will propagate the message on the network.
|
||||
ValidationResult {
|
||||
/// The peer that sent us the message. We don't send back to this peer.
|
||||
@@ -92,6 +97,13 @@ pub enum NetworkMessage<E: EthSpec> {
|
||||
/// The result of the validation
|
||||
validation_result: MessageAcceptance,
|
||||
},
|
||||
/// Reports validation failure of a partial message.
|
||||
PartialValidationFailure {
|
||||
/// The peer that sent us the message.
|
||||
propagation_source: PeerId,
|
||||
/// The topic of the message.
|
||||
gossip_topic: GossipTopic,
|
||||
},
|
||||
/// Reports a peer to the peer manager for performing an action.
|
||||
ReportPeer {
|
||||
peer_id: PeerId,
|
||||
@@ -540,7 +552,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
let subnet_id = subnet_and_attestation.0;
|
||||
let attestation = &subnet_and_attestation.1;
|
||||
// checks if we have an aggregator for the slot. If so, we should process
|
||||
// the attestation, else we just just propagate the Attestation.
|
||||
// the attestation, else we just propagate the Attestation.
|
||||
let should_process = self.subnet_service.should_process_attestation(
|
||||
Subnet::Attestation(subnet_id),
|
||||
&attestation.data,
|
||||
@@ -560,6 +572,15 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
NetworkEvent::PartialDataColumnSidecar {
|
||||
source,
|
||||
column,
|
||||
topic,
|
||||
} => {
|
||||
self.send_to_router(RouterMessage::PartialDataColumnSidecar(
|
||||
source, column, topic,
|
||||
));
|
||||
}
|
||||
NetworkEvent::NewListenAddr(multiaddr) => {
|
||||
self.network_globals
|
||||
.listen_multiaddrs
|
||||
@@ -640,11 +661,19 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
validation_result,
|
||||
);
|
||||
}
|
||||
NetworkMessage::PartialValidationFailure {
|
||||
propagation_source,
|
||||
gossip_topic,
|
||||
} => {
|
||||
self.libp2p
|
||||
.report_partial_message_validation_failure(propagation_source, gossip_topic);
|
||||
}
|
||||
NetworkMessage::Publish { messages } => {
|
||||
let mut topic_kinds = Vec::new();
|
||||
for message in &messages {
|
||||
if !topic_kinds.contains(&message.kind()) {
|
||||
topic_kinds.push(message.kind());
|
||||
let kind = message.kind();
|
||||
if !topic_kinds.contains(&kind) {
|
||||
topic_kinds.push(kind);
|
||||
}
|
||||
}
|
||||
debug!(
|
||||
@@ -654,6 +683,9 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
);
|
||||
self.libp2p.publish(messages);
|
||||
}
|
||||
NetworkMessage::PublishPartialColumns { columns, header } => {
|
||||
self.libp2p.publish_partial(columns, header);
|
||||
}
|
||||
NetworkMessage::ReportPeer {
|
||||
peer_id,
|
||||
action,
|
||||
|
||||
@@ -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