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()
|
||||
n.portalProtocol.storeContent(contentKey, contentId, contentItem)
|
||||
|
||||
info "Received offered content validated successfully", contentKey
|
||||
debug "Received offered content validated successfully", contentKey
|
||||
else:
|
||||
error "Received offered content failed validation",
|
||||
contentKey, error = validation.error
|
||||
|
|
|
@ -705,7 +705,7 @@ proc validateContent(
|
|||
|
||||
n.portalProtocol.storeContent(contentKey, contentId, contentItem)
|
||||
|
||||
info "Received offered content validated successfully", contentKey
|
||||
debug "Received offered content validated successfully", contentKey
|
||||
else:
|
||||
error "Received offered content failed validation", contentKey
|
||||
return false
|
||||
|
|
|
@ -11,6 +11,7 @@ import
|
|||
results,
|
||||
chronos,
|
||||
chronicles,
|
||||
metrics,
|
||||
eth/common/hashes,
|
||||
eth/p2p/discoveryv5/[protocol, enr],
|
||||
../../database/content_db,
|
||||
|
@ -25,6 +26,11 @@ export results, state_content, hashes
|
|||
logScope:
|
||||
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
|
||||
portalProtocol*: PortalProtocol
|
||||
contentQueue*: AsyncQueue[(Opt[NodeId], ContentKeysList, seq[seq[byte]])]
|
||||
|
@ -84,8 +90,7 @@ proc getContent(
|
|||
|
||||
if maybeLocalContent.isSome():
|
||||
let contentValue = V.decode(maybeLocalContent.get()).valueOr:
|
||||
error "Unable to decode state local content value"
|
||||
return Opt.none(V)
|
||||
raiseAssert("Unable to decode state local content value")
|
||||
|
||||
info "Fetched state local content value"
|
||||
return Opt.some(contentValue)
|
||||
|
@ -100,11 +105,11 @@ proc getContent(
|
|||
contentValueBytes = contentLookupResult.content
|
||||
|
||||
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
|
||||
|
||||
validateRetrieval(key, contentValue).isOkOr:
|
||||
warn "Validation of retrieved state content failed"
|
||||
error "Validation of retrieved state content failed"
|
||||
continue
|
||||
|
||||
info "Fetched valid state content from the network"
|
||||
|
@ -178,7 +183,6 @@ proc processOffer*(
|
|||
n.portalProtocol.storeContent(
|
||||
contentKeyBytes, contentId, contentValue.toRetrievalValue().encode()
|
||||
)
|
||||
debug "Offered content validated successfully", contentKeyBytes
|
||||
|
||||
await gossipOffer(
|
||||
n.portalProtocol, maybeSrcNodeId, contentKeyBytes, contentValueBytes
|
||||
|
@ -218,10 +222,13 @@ proc processContentLoop(n: StateNetwork) {.async: (raises: []).} =
|
|||
srcNodeId, contentKeyBytes, contentBytes, contentKey.contractCodeKey,
|
||||
ContractCodeOffer,
|
||||
)
|
||||
|
||||
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:
|
||||
error "Offered content processing failed",
|
||||
state_network_offers_failed.inc(labelValues = [$n.portalProtocol.protocolId])
|
||||
error "Received offered content failed validation",
|
||||
contentKeyBytes, error = offerRes.error()
|
||||
except CancelledError:
|
||||
trace "processContentLoop canceled"
|
||||
|
|
Loading…
Reference in New Issue