Skip to content

Commit 393e63c

Browse files
wemeetagainphilknows
authored andcommitted
chore: add more discovery logs (#6996)
1 parent 76a32dd commit 393e63c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/beacon-node/src/network/peers/discover.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,21 @@ export class PeerDiscovery {
249249
}
250250

251251
// Run a discv5 subnet query to try to discover new peers
252-
if (subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect) {
252+
const shouldRunFindRandomNodeQuery = subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect;
253+
if (shouldRunFindRandomNodeQuery) {
253254
void this.runFindRandomNodeQuery();
254255
}
256+
257+
this.logger.debug("Discover peers outcome", {
258+
peersToConnect,
259+
peersAvailableToDial: cachedENRsToDial.size,
260+
subnetsToDiscover: subnetsToDiscoverPeers.length,
261+
shouldRunFindRandomNodeQuery,
262+
});
255263
}
256264

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

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

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

0 commit comments

Comments
 (0)