mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Add DataColumnSidecar gossip topic and message handling (#6147)
* Add `DataColumnSidecar` gossip topic and verification (#5050 and #5783). * Remove gossip verification changes (#5783). * Merge branch 'unstable' into data-column-gossip # Conflicts: # beacon_node/beacon_chain/src/data_column_verification.rs # beacon_node/beacon_chain/src/lib.rs * Add gossip cache timeout for data columns. Rename data column metrics for consistency. * Remove usage of `unimplemented!` and address review comments. * Remove unnused `GossipDataColumnError` variants and address review comments. * Merge branch 'unstable' into data-column-gossip * Update Cargo.lock * Arc `ChainSpec` in discovery to avoid performance regression when needing to clone it repeatedly.
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
//! The subnet predicate used for searching for a particular subnet.
|
||||
use super::*;
|
||||
use crate::types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield};
|
||||
use itertools::Itertools;
|
||||
use slog::trace;
|
||||
use std::ops::Deref;
|
||||
use types::{ChainSpec, DataColumnSubnetId};
|
||||
|
||||
/// Returns the predicate for a given subnet.
|
||||
pub fn subnet_predicate<E>(subnets: Vec<Subnet>, log: &slog::Logger) -> impl Fn(&Enr) -> bool + Send
|
||||
pub fn subnet_predicate<E>(
|
||||
subnets: Vec<Subnet>,
|
||||
log: &slog::Logger,
|
||||
spec: Arc<ChainSpec>,
|
||||
) -> impl Fn(&Enr) -> bool + Send
|
||||
where
|
||||
E: EthSpec,
|
||||
{
|
||||
@@ -19,10 +25,13 @@ where
|
||||
};
|
||||
|
||||
// Pre-fork/fork-boundary enrs may not contain a syncnets field.
|
||||
// Don't return early here
|
||||
// Don't return early here.
|
||||
let sync_committee_bitfield: Result<EnrSyncCommitteeBitfield<E>, _> =
|
||||
enr.sync_committee_bitfield::<E>();
|
||||
|
||||
// TODO(das): compute from enr
|
||||
let custody_subnet_count = spec.custody_requirement;
|
||||
|
||||
let predicate = subnets.iter().any(|subnet| match subnet {
|
||||
Subnet::Attestation(s) => attestation_bitfield
|
||||
.get(*s.deref() as usize)
|
||||
@@ -30,6 +39,14 @@ where
|
||||
Subnet::SyncCommittee(s) => sync_committee_bitfield
|
||||
.as_ref()
|
||||
.map_or(false, |b| b.get(*s.deref() as usize).unwrap_or(false)),
|
||||
Subnet::DataColumn(s) => {
|
||||
let mut subnets = DataColumnSubnetId::compute_custody_subnets::<E>(
|
||||
enr.node_id().raw().into(),
|
||||
custody_subnet_count,
|
||||
&spec,
|
||||
);
|
||||
subnets.contains(s)
|
||||
}
|
||||
});
|
||||
|
||||
if !predicate {
|
||||
|
||||
Reference in New Issue
Block a user