chore(peer-scoring): enhance score trace logs (#1107)

This commit is contained in:
Ivan FB 2024-06-03 12:25:47 +02:00 committed by GitHub
parent 8a4e8a00a2
commit 3f5b5cee75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 5 deletions

View File

@ -161,12 +161,13 @@ proc updateScores*(g: GossipSub) = # avoid async
trace "p3b", peer, p3b = info.meshFailurePenalty, topic, topicScore trace "p3b", peer, p3b = info.meshFailurePenalty, topic, topicScore
topicScore += info.invalidMessageDeliveries * info.invalidMessageDeliveries * topicParams.invalidMessageDeliveriesWeight topicScore += info.invalidMessageDeliveries * info.invalidMessageDeliveries * topicParams.invalidMessageDeliveriesWeight
trace "p4", p4 = info.invalidMessageDeliveries * info.invalidMessageDeliveries, topic, topicScore trace "p4", peer, p4 = info.invalidMessageDeliveries * info.invalidMessageDeliveries, topic, topicScore
trace "updated peer topic's scores", peer, topic, info, topicScore
score += topicScore * topicParams.topicWeight score += topicScore * topicParams.topicWeight
trace "updated peer topic's scores", peer, score, topic, info, topicScore,
topicWeight = topicParams.topicWeight
# Score metrics # Score metrics
let agent = peer.getAgent() let agent = peer.getAgent()
libp2p_gossipsub_peers_score_firstMessageDeliveries.inc(info.firstMessageDeliveries, labelValues = [agent]) libp2p_gossipsub_peers_score_firstMessageDeliveries.inc(info.firstMessageDeliveries, labelValues = [agent])
@ -196,14 +197,18 @@ proc updateScores*(g: GossipSub) = # avoid async
stats.topicInfos[topic] = info stats.topicInfos[topic] = info
score += peer.appScore * g.parameters.appSpecificWeight 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. # 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 score += peer.behaviourPenalty * peer.behaviourPenalty * g.parameters.behaviourPenaltyWeight
trace "behaviourPenalty", peer, score, behaviourPenalty = peer.behaviourPenalty,
behaviourPenaltyWeight = g.parameters.behaviourPenaltyWeight
let colocationFactor = g.colocationFactor(peer) let colocationFactor = g.colocationFactor(peer)
score += colocationFactor * g.parameters.ipColocationFactorWeight score += colocationFactor * g.parameters.ipColocationFactorWeight
trace "colocationFactor", peer, score, colocationFactor,
ipColocationFactorWeight = g.parameters.ipColocationFactorWeight
# Score metrics # Score metrics
let agent = peer.getAgent() let agent = peer.getAgent()
libp2p_gossipsub_peers_score_appScore.inc(peer.appScore, labelValues = [agent]) libp2p_gossipsub_peers_score_appScore.inc(peer.appScore, labelValues = [agent])