diff --git a/fluffy/network/beacon/beacon_network.nim b/fluffy/network/beacon/beacon_network.nim index 7ad438648..9ee4de945 100644 --- a/fluffy/network/beacon/beacon_network.nim +++ b/fluffy/network/beacon/beacon_network.nim @@ -340,7 +340,10 @@ proc validateContent( n.validateHistoricalSummaries(summariesWithProof) proc validateContent( - n: BeaconNetwork, contentKeys: ContentKeysList, contentItems: seq[seq[byte]] + n: BeaconNetwork, + srcNodeId: Opt[NodeId], + contentKeys: ContentKeysList, + contentItems: seq[seq[byte]], ): Future[bool] {.async: (raises: [CancelledError]).} = # content passed here can have less items then contentKeys, but not more. for i, contentItem in contentItems: @@ -350,16 +353,16 @@ proc validateContent( if validation.isOk(): let contentIdOpt = n.portalProtocol.toContentId(contentKey) if contentIdOpt.isNone(): - error "Received offered content with invalid content key", contentKey + error "Received offered content with invalid content key", srcNodeId, contentKey return false let contentId = contentIdOpt.get() n.portalProtocol.storeContent(contentKey, contentId, contentItem) - debug "Received offered content validated successfully", contentKey + debug "Received offered content validated successfully", srcNodeId, contentKey else: debug "Received offered content failed validation", - contentKey, error = validation.error + srcNodeId, contentKey, error = validation.error return false return true @@ -432,7 +435,7 @@ proc processContentLoop(n: BeaconNetwork) {.async: (raises: []).} = # dropped and not gossiped around. # TODO: Differentiate between failures due to invalid data and failures # due to missing network data for validation. - if await n.validateContent(contentKeys, contentItems): + if await n.validateContent(srcNodeId, contentKeys, contentItems): asyncSpawn n.portalProtocol.randomGossipDiscardPeers( srcNodeId, contentKeys, contentItems ) diff --git a/fluffy/network/history/history_network.nim b/fluffy/network/history/history_network.nim index 5d3046d4d..b975e65d5 100644 --- a/fluffy/network/history/history_network.nim +++ b/fluffy/network/history/history_network.nim @@ -359,7 +359,10 @@ proc new*( ) proc validateContent( - n: HistoryNetwork, contentKeys: ContentKeysList, contentItems: seq[seq[byte]] + n: HistoryNetwork, + srcNodeId: Opt[NodeId], + contentKeys: ContentKeysList, + contentItems: seq[seq[byte]], ): Future[bool] {.async: (raises: [CancelledError]).} = # content passed here can have less items then contentKeys, but not more. for i, contentItem in contentItems: @@ -367,14 +370,15 @@ proc validateContent( let res = await n.validateContent(contentItem, contentKey) if res.isOk(): let contentId = n.portalProtocol.toContentId(contentKey).valueOr: - warn "Received offered content with invalid content key", contentKey + warn "Received offered content with invalid content key", srcNodeId, contentKey return false n.portalProtocol.storeContent(contentKey, contentId, contentItem) - debug "Received offered content validated successfully", contentKey + debug "Received offered content validated successfully", srcNodeId, contentKey else: - debug "Received offered content failed validation", contentKey, error = res.error + debug "Received offered content failed validation", + srcNodeId, contentKey, error = res.error return false return true @@ -388,7 +392,7 @@ proc processContentLoop(n: HistoryNetwork) {.async: (raises: []).} = # dropped and not gossiped around. # TODO: Differentiate between failures due to invalid data and failures # due to missing network data for validation. - if await n.validateContent(contentKeys, contentItems): + if await n.validateContent(srcNodeId, contentKeys, contentItems): asyncSpawn n.portalProtocol.neighborhoodGossipDiscardPeers( srcNodeId, contentKeys, contentItems ) diff --git a/fluffy/network/state/state_network.nim b/fluffy/network/state/state_network.nim index 37afa9f48..da01a7368 100644 --- a/fluffy/network/state/state_network.nim +++ b/fluffy/network/state/state_network.nim @@ -226,11 +226,12 @@ proc processContentLoop(n: StateNetwork) {.async: (raises: []).} = if offerRes.isOk(): state_network_offers_success.inc(labelValues = [$n.portalProtocol.protocolId]) - debug "Received offered content validated successfully", contentKeyBytes + debug "Received offered content validated successfully", + srcNodeId, contentKeyBytes else: state_network_offers_failed.inc(labelValues = [$n.portalProtocol.protocolId]) error "Received offered content failed validation", - contentKeyBytes, error = offerRes.error() + srcNodeId, contentKeyBytes, error = offerRes.error() except CancelledError: trace "processContentLoop canceled"