Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more discovery logs #6996

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/beacon-node/src/network/peers/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,21 @@ export class PeerDiscovery {
}

// Run a discv5 subnet query to try to discover new peers
if (subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect) {
const shouldRunFindRandomNodeQuery = subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect;
if (shouldRunFindRandomNodeQuery) {
void this.runFindRandomNodeQuery();
}

this.logger.debug("Discover peers outcome", {
peersToConnect,
peersAvailableToDial: cachedENRsToDial.size,
subnetsToDiscover: subnetsToDiscoverPeers.length,
shouldRunFindRandomNodeQuery,
});
}

/**
* Request to find peers. First, looked at cached peers in peerStore
* Request discv5 to find peers if there is no query in progress
*/
private async runFindRandomNodeQuery(): Promise<void> {
// Delay the 1st query after starting discv5
Expand Down Expand Up @@ -305,6 +313,7 @@ export class PeerDiscovery {
const attnets = zeroAttnets;
const syncnets = zeroSyncnets;
const status = this.handleDiscoveredPeer(id, multiaddrs[0], attnets, syncnets);
this.logger.debug("Discovered peer via libp2p", {peer: prettyPrintPeerId(id), status});
this.metrics?.discovery.discoveredStatus.inc({status});
};

Expand Down Expand Up @@ -336,6 +345,7 @@ export class PeerDiscovery {
const syncnets = syncnetsBytes ? deserializeEnrSubnets(syncnetsBytes, SYNC_COMMITTEE_SUBNET_COUNT) : zeroSyncnets;

const status = this.handleDiscoveredPeer(peerId, multiaddrTCP, attnets, syncnets);
this.logger.debug("Discovered peer via discv5", {peer: prettyPrintPeerId(peerId), status});
this.metrics?.discovery.discoveredStatus.inc({status});
};

Expand Down
Loading