Skip to content

Commit beb0ce6

Browse files
authored
Make range sync peer loadbalancing PeerDAS-friendly (#6922)
- Re-opens #6864 targeting unstable Range sync and backfill sync still assume that each batch request is done by a single peer. This assumption breaks with PeerDAS, where we request custody columns to N peers. Issues with current unstable: - Peer prioritization counts batch requests per peer. This accounting is broken now, data columns by range request are not accounted - Peer selection for data columns by range ignores the set of peers on a syncing chain, instead draws from the global pool of peers - The implementation is very strict when we have no peers to request from. After PeerDAS this case is very common and we want to be flexible or easy and handle that case better than just hard failing everything. - [x] Upstream peer prioritization to the network context, it knows exactly how many active requests a peer (including columns by range) - [x] Upstream peer selection to the network context, now `block_components_by_range_request` gets a set of peers to choose from instead of a single peer. If it can't find a peer, it returns the error `RpcRequestSendError::NoPeer` - [ ] Range sync and backfill sync handle `RpcRequestSendError::NoPeer` explicitly - [ ] Range sync: leaves the batch in `AwaitingDownload` state and does nothing. **TODO**: we should have some mechanism to fail the chain if it's stale for too long - **EDIT**: Not done in this PR - [x] Backfill sync: pauses the sync until another peer joins - **EDIT**: Same logic as unstable ### TODOs - [ ] Add tests :) - [x] Manually test backfill sync Note: this touches the mainnet path!
1 parent 43c38a6 commit beb0ce6

File tree

12 files changed

+542
-473
lines changed

12 files changed

+542
-473
lines changed

beacon_node/lighthouse_network/src/peer_manager/peerdb.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::discovery::enr::PEERDAS_CUSTODY_GROUP_COUNT_ENR_KEY;
22
use crate::discovery::{peer_id_to_node_id, CombinedKey};
3-
use crate::{metrics, multiaddr::Multiaddr, types::Subnet, Enr, EnrExt, Gossipsub, PeerId};
3+
use crate::{
4+
metrics, multiaddr::Multiaddr, types::Subnet, Enr, EnrExt, Gossipsub, PeerId, SyncInfo,
5+
};
46
use itertools::Itertools;
57
use logging::crit;
68
use peer_info::{ConnectionDirection, PeerConnectionStatus, PeerInfo};
@@ -15,7 +17,7 @@ use std::{
1517
use sync_status::SyncStatus;
1618
use tracing::{debug, error, trace, warn};
1719
use types::data_column_custody_group::compute_subnets_for_node;
18-
use types::{ChainSpec, DataColumnSubnetId, EthSpec};
20+
use types::{ChainSpec, DataColumnSubnetId, Epoch, EthSpec, Hash256, Slot};
1921

2022
pub mod client;
2123
pub mod peer_info;
@@ -735,6 +737,19 @@ impl<E: EthSpec> PeerDB<E> {
735737
},
736738
);
737739

740+
self.update_sync_status(
741+
&peer_id,
742+
SyncStatus::Synced {
743+
// Fill in mock SyncInfo, only for the peer to return `is_synced() == true`.
744+
info: SyncInfo {
745+
head_slot: Slot::new(0),
746+
head_root: Hash256::ZERO,
747+
finalized_epoch: Epoch::new(0),
748+
finalized_root: Hash256::ZERO,
749+
},
750+
},
751+
);
752+
738753
if supernode {
739754
let peer_info = self.peers.get_mut(&peer_id).expect("peer exists");
740755
let all_subnets = (0..spec.data_column_sidecar_subnet_count)

beacon_node/lighthouse_network/src/types/globals.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,20 @@ impl<E: EthSpec> NetworkGlobals<E> {
206206
.collect::<Vec<_>>()
207207
}
208208

209+
/// Returns true if the peer is known and is a custodian of `column_index`
210+
pub fn is_custody_peer_of(&self, column_index: ColumnIndex, peer_id: &PeerId) -> bool {
211+
self.peers
212+
.read()
213+
.peer_info(peer_id)
214+
.map(|info| {
215+
info.is_assigned_to_custody_subnet(&DataColumnSubnetId::from_column_index(
216+
column_index,
217+
&self.spec,
218+
))
219+
})
220+
.unwrap_or(false)
221+
}
222+
209223
/// Returns the TopicConfig to compute the set of Gossip topics for a given fork
210224
pub fn as_topic_config(&self) -> TopicConfig {
211225
TopicConfig {

beacon_node/network/src/network_beacon_processor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ use {
11411141
};
11421142

11431143
#[cfg(test)]
1144-
type TestBeaconChainType<E> =
1144+
pub(crate) type TestBeaconChainType<E> =
11451145
Witness<ManualSlotClock, CachingEth1Backend<E>, E, MemoryStore<E>, MemoryStore<E>>;
11461146

11471147
#[cfg(test)]

0 commit comments

Comments
 (0)