Maintain peers across all data column subnets (#7915)

Closes:
- #7865
- #7855

Changes extracted from earlier PR #7876

This PR fixes two main things with a few other improvements mentioned below:
- Prevent Lighthouse from repeatedly sending `DataColumnByRoot` requests to an unsynced peer, causing lookup sync to get stuck
- Allows Lighthouse to send discovery requests if there isn't enough **synced** peers in the required sampling subnets - this fixes the stuck sync scenario where there isn't enough usable peers in sampling subnet but no discovery is attempted.


  - Make peer discovery queries if custody subnet peer count drops below the minimum threshold
- Update peer pruning logic to prioritise uniform distribution across all data column subnets and avoid pruning sampling peers if the count is below the target threshold (2)
- Check sync status when making discovery requests, to make sure we don't ignore requests if there isn't enough synced peers in the required sampling subnets
- Optimise some of the `PeerDB` functions checking custody peers
- Only send lookup requests to peers that are synced or advanced
This commit is contained in:
Jimmy Chen
2025-09-04 15:36:20 +10:00
committed by GitHub
parent 76adedff27
commit c2a92f1a8c
6 changed files with 974 additions and 336 deletions

View File

@@ -1223,7 +1223,7 @@ impl<E: EthSpec> Discovery<E> {
#[cfg(test)]
mod tests {
use super::*;
use crate::rpc::methods::{MetaData, MetaDataV2};
use crate::rpc::methods::{MetaData, MetaDataV3};
use libp2p::identity::secp256k1;
use types::{BitVector, MinimalEthSpec, SubnetId};
@@ -1248,10 +1248,11 @@ mod tests {
.unwrap();
let globals = NetworkGlobals::new(
enr,
MetaData::V2(MetaDataV2 {
MetaData::V3(MetaDataV3 {
seq_number: 0,
attnets: Default::default(),
syncnets: Default::default(),
custody_group_count: spec.custody_requirement,
}),
vec![],
false,