Fluffy: Improve logging and add offer metrics to status logs. (#2802)
* Set offer processing logs to debug level and add offer counts to state network. * Use metrics instead of int counters and remove from logs. * More logging improvements. Make decoding and validation failures use error log level. * Add protocol_id to metrics.
This commit is contained in:
parent
e038a383c1
commit
8d8f62bf67
|
@ -355,7 +355,7 @@ proc validateContent(
|
||||||
let contentId = contentIdOpt.get()
|
let contentId = contentIdOpt.get()
|
||||||
n.portalProtocol.storeContent(contentKey, contentId, contentItem)
|
n.portalProtocol.storeContent(contentKey, contentId, contentItem)
|
||||||
|
|
||||||
info "Received offered content validated successfully", contentKey
|
debug "Received offered content validated successfully", contentKey
|
||||||
else:
|
else:
|
||||||
error "Received offered content failed validation",
|
error "Received offered content failed validation",
|
||||||
contentKey, error = validation.error
|
contentKey, error = validation.error
|
||||||
|
|
|
@ -705,7 +705,7 @@ proc validateContent(
|
||||||
|
|
||||||
n.portalProtocol.storeContent(contentKey, contentId, contentItem)
|
n.portalProtocol.storeContent(contentKey, contentId, contentItem)
|
||||||
|
|
||||||
info "Received offered content validated successfully", contentKey
|
debug "Received offered content validated successfully", contentKey
|
||||||
else:
|
else:
|
||||||
error "Received offered content failed validation", contentKey
|
error "Received offered content failed validation", contentKey
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -11,6 +11,7 @@ import
|
||||||
results,
|
results,
|
||||||
chronos,
|
chronos,
|
||||||
chronicles,
|
chronicles,
|
||||||
|
metrics,
|
||||||
eth/common/hashes,
|
eth/common/hashes,
|
||||||
eth/p2p/discoveryv5/[protocol, enr],
|
eth/p2p/discoveryv5/[protocol, enr],
|
||||||
../../database/content_db,
|
../../database/content_db,
|
||||||
|
@ -25,6 +26,11 @@ export results, state_content, hashes
|
||||||
logScope:
|
logScope:
|
||||||
topics = "portal_state"
|
topics = "portal_state"
|
||||||
|
|
||||||
|
declareCounter state_network_offers_success,
|
||||||
|
"Portal state network offers successfully validated", labels = ["protocol_id"]
|
||||||
|
declareCounter state_network_offers_failed,
|
||||||
|
"Portal state network offers which failed validation", labels = ["protocol_id"]
|
||||||
|
|
||||||
type StateNetwork* = ref object
|
type StateNetwork* = ref object
|
||||||
portalProtocol*: PortalProtocol
|
portalProtocol*: PortalProtocol
|
||||||
contentQueue*: AsyncQueue[(Opt[NodeId], ContentKeysList, seq[seq[byte]])]
|
contentQueue*: AsyncQueue[(Opt[NodeId], ContentKeysList, seq[seq[byte]])]
|
||||||
|
@ -84,8 +90,7 @@ proc getContent(
|
||||||
|
|
||||||
if maybeLocalContent.isSome():
|
if maybeLocalContent.isSome():
|
||||||
let contentValue = V.decode(maybeLocalContent.get()).valueOr:
|
let contentValue = V.decode(maybeLocalContent.get()).valueOr:
|
||||||
error "Unable to decode state local content value"
|
raiseAssert("Unable to decode state local content value")
|
||||||
return Opt.none(V)
|
|
||||||
|
|
||||||
info "Fetched state local content value"
|
info "Fetched state local content value"
|
||||||
return Opt.some(contentValue)
|
return Opt.some(contentValue)
|
||||||
|
@ -100,11 +105,11 @@ proc getContent(
|
||||||
contentValueBytes = contentLookupResult.content
|
contentValueBytes = contentLookupResult.content
|
||||||
|
|
||||||
let contentValue = V.decode(contentValueBytes).valueOr:
|
let contentValue = V.decode(contentValueBytes).valueOr:
|
||||||
warn "Unable to decode state content value from content lookup"
|
error "Unable to decode state content value from content lookup"
|
||||||
continue
|
continue
|
||||||
|
|
||||||
validateRetrieval(key, contentValue).isOkOr:
|
validateRetrieval(key, contentValue).isOkOr:
|
||||||
warn "Validation of retrieved state content failed"
|
error "Validation of retrieved state content failed"
|
||||||
continue
|
continue
|
||||||
|
|
||||||
info "Fetched valid state content from the network"
|
info "Fetched valid state content from the network"
|
||||||
|
@ -178,7 +183,6 @@ proc processOffer*(
|
||||||
n.portalProtocol.storeContent(
|
n.portalProtocol.storeContent(
|
||||||
contentKeyBytes, contentId, contentValue.toRetrievalValue().encode()
|
contentKeyBytes, contentId, contentValue.toRetrievalValue().encode()
|
||||||
)
|
)
|
||||||
debug "Offered content validated successfully", contentKeyBytes
|
|
||||||
|
|
||||||
await gossipOffer(
|
await gossipOffer(
|
||||||
n.portalProtocol, maybeSrcNodeId, contentKeyBytes, contentValueBytes
|
n.portalProtocol, maybeSrcNodeId, contentKeyBytes, contentValueBytes
|
||||||
|
@ -218,10 +222,13 @@ proc processContentLoop(n: StateNetwork) {.async: (raises: []).} =
|
||||||
srcNodeId, contentKeyBytes, contentBytes, contentKey.contractCodeKey,
|
srcNodeId, contentKeyBytes, contentBytes, contentKey.contractCodeKey,
|
||||||
ContractCodeOffer,
|
ContractCodeOffer,
|
||||||
)
|
)
|
||||||
|
|
||||||
if offerRes.isOk():
|
if offerRes.isOk():
|
||||||
info "Offered content processed successfully", contentKeyBytes
|
state_network_offers_success.inc(labelValues = [$n.portalProtocol.protocolId])
|
||||||
|
debug "Received offered content validated successfully", contentKeyBytes
|
||||||
else:
|
else:
|
||||||
error "Offered content processing failed",
|
state_network_offers_failed.inc(labelValues = [$n.portalProtocol.protocolId])
|
||||||
|
error "Received offered content failed validation",
|
||||||
contentKeyBytes, error = offerRes.error()
|
contentKeyBytes, error = offerRes.error()
|
||||||
except CancelledError:
|
except CancelledError:
|
||||||
trace "processContentLoop canceled"
|
trace "processContentLoop canceled"
|
||||||
|
|
Loading…
Reference in New Issue