From 3f5b5cee7544c4fedbccffa19b3e3bd03c0e5ef7 Mon Sep 17 00:00:00 2001 From: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:25:47 +0200 Subject: [PATCH] chore(peer-scoring): enhance score trace logs (#1107) --- libp2p/protocols/pubsub/gossipsub/scoring.nim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libp2p/protocols/pubsub/gossipsub/scoring.nim b/libp2p/protocols/pubsub/gossipsub/scoring.nim index edee4d2bc..b5fb99152 100644 --- a/libp2p/protocols/pubsub/gossipsub/scoring.nim +++ b/libp2p/protocols/pubsub/gossipsub/scoring.nim @@ -161,12 +161,13 @@ proc updateScores*(g: GossipSub) = # avoid async trace "p3b", peer, p3b = info.meshFailurePenalty, topic, topicScore topicScore += info.invalidMessageDeliveries * info.invalidMessageDeliveries * topicParams.invalidMessageDeliveriesWeight - trace "p4", p4 = info.invalidMessageDeliveries * info.invalidMessageDeliveries, topic, topicScore - - trace "updated peer topic's scores", peer, topic, info, topicScore + trace "p4", peer, p4 = info.invalidMessageDeliveries * info.invalidMessageDeliveries, topic, topicScore score += topicScore * topicParams.topicWeight + trace "updated peer topic's scores", peer, score, topic, info, topicScore, + topicWeight = topicParams.topicWeight + # Score metrics let agent = peer.getAgent() libp2p_gossipsub_peers_score_firstMessageDeliveries.inc(info.firstMessageDeliveries, labelValues = [agent]) @@ -196,14 +197,18 @@ proc updateScores*(g: GossipSub) = # avoid async stats.topicInfos[topic] = info score += peer.appScore * g.parameters.appSpecificWeight - + trace "appScore", peer, score, appScore = peer.appScore, + appSpecificWeight = g.parameters.appSpecificWeight # The value of the parameter is the square of the counter and is mixed with a negative weight. score += peer.behaviourPenalty * peer.behaviourPenalty * g.parameters.behaviourPenaltyWeight + trace "behaviourPenalty", peer, score, behaviourPenalty = peer.behaviourPenalty, + behaviourPenaltyWeight = g.parameters.behaviourPenaltyWeight let colocationFactor = g.colocationFactor(peer) score += colocationFactor * g.parameters.ipColocationFactorWeight - + trace "colocationFactor", peer, score, colocationFactor, + ipColocationFactorWeight = g.parameters.ipColocationFactorWeight # Score metrics let agent = peer.getAgent() libp2p_gossipsub_peers_score_appScore.inc(peer.appScore, labelValues = [agent])