Retry custody requests after peer metadata updates (#6975)

Closes https://github.com/sigp/lighthouse/issues/6895

We need sync to retry custody requests when a peer CGC updates. A higher CGC can result in a data column subnet peer count increasing from 0 to 1, allowing requests to happen.


  Add new sync event `SyncMessage::UpdatedPeerCgc`. It's sent by the router when a metadata response updates the known CGC
This commit is contained in:
Lion - dapplion
2025-05-09 05:27:17 -03:00
committed by GitHub
parent 4b9c16fc71
commit a497ec601c
5 changed files with 106 additions and 8 deletions

View File

@@ -73,6 +73,8 @@ pub enum RouterMessage<E: EthSpec> {
PubsubMessage(MessageId, PeerId, PubsubMessage<E>, bool),
/// The peer manager has requested we re-status a peer.
StatusPeer(PeerId),
/// The peer has an updated custody group count from METADATA.
PeerUpdatedCustodyGroupCount(PeerId),
}
impl<T: BeaconChainTypes> Router<T> {
@@ -155,6 +157,10 @@ impl<T: BeaconChainTypes> Router<T> {
RouterMessage::PeerDisconnected(peer_id) => {
self.send_to_sync(SyncMessage::Disconnect(peer_id));
}
// A peer has updated CGC
RouterMessage::PeerUpdatedCustodyGroupCount(peer_id) => {
self.send_to_sync(SyncMessage::UpdatedPeerCgc(peer_id));
}
RouterMessage::RPCRequestReceived {
peer_id,
inbound_request_id,

View File

@@ -485,6 +485,9 @@ impl<T: BeaconChainTypes> NetworkService<T> {
NetworkEvent::PeerDisconnected(peer_id) => {
self.send_to_router(RouterMessage::PeerDisconnected(peer_id));
}
NetworkEvent::PeerUpdatedCustodyGroupCount(peer_id) => {
self.send_to_router(RouterMessage::PeerUpdatedCustodyGroupCount(peer_id));
}
NetworkEvent::RequestReceived {
peer_id,
inbound_request_id,

View File

@@ -106,6 +106,9 @@ pub enum SyncMessage<E: EthSpec> {
head_slot: Option<Slot>,
},
/// Peer manager has received a MetaData of a peer with a new or updated CGC value.
UpdatedPeerCgc(PeerId),
/// A block has been received from the RPC.
RpcBlock {
sync_request_id: SyncRequestId,
@@ -476,6 +479,16 @@ impl<T: BeaconChainTypes> SyncManager<T> {
}
}
fn updated_peer_cgc(&mut self, _peer_id: PeerId) {
// Try to make progress on custody requests that are waiting for peers
for (id, result) in self.network.continue_custody_by_root_requests() {
self.on_custody_by_root_result(id, result);
}
// Attempt to resume range sync too
self.range_sync.resume(&mut self.network);
}
/// Handles RPC errors related to requests that were emitted from the sync manager.
fn inject_error(&mut self, peer_id: PeerId, sync_request_id: SyncRequestId, error: RPCError) {
trace!("Sync manager received a failed RPC");
@@ -748,6 +761,13 @@ impl<T: BeaconChainTypes> SyncManager<T> {
} => {
self.add_peers_force_range_sync(&peers, head_root, head_slot);
}
SyncMessage::UpdatedPeerCgc(peer_id) => {
debug!(
peer_id = ?peer_id,
"Received updated peer CGC message"
);
self.updated_peer_cgc(peer_id);
}
SyncMessage::RpcBlock {
sync_request_id,
peer_id,