Adjust some portal wire and history network (error) logging (#2965)
This commit is contained in:
parent
473da69043
commit
7112a19d6c
|
@ -142,11 +142,12 @@ proc getVerifiedBlockHeader*(
|
||||||
for i in 0 ..< (1 + n.contentRequestRetries):
|
for i in 0 ..< (1 + n.contentRequestRetries):
|
||||||
let
|
let
|
||||||
headerContent = (await n.portalProtocol.contentLookup(contentKey, contentId)).valueOr:
|
headerContent = (await n.portalProtocol.contentLookup(contentKey, contentId)).valueOr:
|
||||||
warn "Failed fetching block header with proof from the network"
|
debug "Failed fetching block header with proof from the network"
|
||||||
return Opt.none(Header)
|
return Opt.none(Header)
|
||||||
|
|
||||||
header = validateCanonicalHeaderBytes(headerContent.content, id, n.accumulator).valueOr:
|
header = validateCanonicalHeaderBytes(headerContent.content, id, n.accumulator).valueOr:
|
||||||
warn "Validation of block header failed", error = error
|
warn "Validation of block header failed",
|
||||||
|
error = error, node = headerContent.receivedFrom.record.toURI()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
debug "Fetched valid block header from the network"
|
debug "Fetched valid block header from the network"
|
||||||
|
@ -186,11 +187,12 @@ proc getBlockBody*(
|
||||||
for i in 0 ..< (1 + n.contentRequestRetries):
|
for i in 0 ..< (1 + n.contentRequestRetries):
|
||||||
let
|
let
|
||||||
bodyContent = (await n.portalProtocol.contentLookup(contentKey, contentId)).valueOr:
|
bodyContent = (await n.portalProtocol.contentLookup(contentKey, contentId)).valueOr:
|
||||||
warn "Failed fetching block body from the network"
|
debug "Failed fetching block body from the network"
|
||||||
return Opt.none(BlockBody)
|
return Opt.none(BlockBody)
|
||||||
|
|
||||||
body = validateBlockBodyBytes(bodyContent.content, header).valueOr:
|
body = validateBlockBodyBytes(bodyContent.content, header).valueOr:
|
||||||
warn "Validation of block body failed", error
|
warn "Validation of block body failed",
|
||||||
|
error, node = bodyContent.receivedFrom.record.toURI()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
debug "Fetched block body from the network"
|
debug "Fetched block body from the network"
|
||||||
|
@ -217,7 +219,7 @@ proc getBlock*(
|
||||||
# also the original type into the network.
|
# also the original type into the network.
|
||||||
let
|
let
|
||||||
header = (await n.getVerifiedBlockHeader(id)).valueOr:
|
header = (await n.getVerifiedBlockHeader(id)).valueOr:
|
||||||
warn "Failed to get header when getting block", id
|
debug "Failed to get header when getting block", id
|
||||||
return Opt.none(Block)
|
return Opt.none(Block)
|
||||||
hash =
|
hash =
|
||||||
when id is Hash32:
|
when id is Hash32:
|
||||||
|
@ -225,7 +227,7 @@ proc getBlock*(
|
||||||
else:
|
else:
|
||||||
header.rlpHash()
|
header.rlpHash()
|
||||||
body = (await n.getBlockBody(hash, header)).valueOr:
|
body = (await n.getBlockBody(hash, header)).valueOr:
|
||||||
warn "Failed to get body when getting block", hash
|
debug "Failed to get body when getting block", hash
|
||||||
return Opt.none(Block)
|
return Opt.none(Block)
|
||||||
|
|
||||||
Opt.some((header, body))
|
Opt.some((header, body))
|
||||||
|
@ -261,10 +263,11 @@ proc getReceipts*(
|
||||||
for i in 0 ..< (1 + n.contentRequestRetries):
|
for i in 0 ..< (1 + n.contentRequestRetries):
|
||||||
let
|
let
|
||||||
receiptsContent = (await n.portalProtocol.contentLookup(contentKey, contentId)).valueOr:
|
receiptsContent = (await n.portalProtocol.contentLookup(contentKey, contentId)).valueOr:
|
||||||
warn "Failed fetching receipts from the network"
|
debug "Failed fetching receipts from the network"
|
||||||
return Opt.none(seq[Receipt])
|
return Opt.none(seq[Receipt])
|
||||||
receipts = validateReceiptsBytes(receiptsContent.content, header.receiptsRoot).valueOr:
|
receipts = validateReceiptsBytes(receiptsContent.content, header.receiptsRoot).valueOr:
|
||||||
warn "Validation of receipts failed", error
|
warn "Validation of receipts failed",
|
||||||
|
error, node = receiptsContent.receivedFrom.record.toURI()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
debug "Fetched receipts from the network"
|
debug "Fetched receipts from the network"
|
||||||
|
|
|
@ -205,6 +205,7 @@ type
|
||||||
ContentLookupResult* = object
|
ContentLookupResult* = object
|
||||||
content*: seq[byte]
|
content*: seq[byte]
|
||||||
utpTransfer*: bool
|
utpTransfer*: bool
|
||||||
|
receivedFrom*: Node
|
||||||
# List of nodes which do not have requested content, and for which
|
# List of nodes which do not have requested content, and for which
|
||||||
# content is in their range
|
# content is in their range
|
||||||
nodesInterestedInContent*: seq[Node]
|
nodesInterestedInContent*: seq[Node]
|
||||||
|
@ -238,11 +239,13 @@ func init*(
|
||||||
T: type ContentLookupResult,
|
T: type ContentLookupResult,
|
||||||
content: seq[byte],
|
content: seq[byte],
|
||||||
utpTransfer: bool,
|
utpTransfer: bool,
|
||||||
|
receivedFrom: Node,
|
||||||
nodesInterestedInContent: seq[Node],
|
nodesInterestedInContent: seq[Node],
|
||||||
): T =
|
): T =
|
||||||
ContentLookupResult(
|
ContentLookupResult(
|
||||||
content: content,
|
content: content,
|
||||||
utpTransfer: utpTransfer,
|
utpTransfer: utpTransfer,
|
||||||
|
receivedFrom: receivedFrom,
|
||||||
nodesInterestedInContent: nodesInterestedInContent,
|
nodesInterestedInContent: nodesInterestedInContent,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -890,7 +893,8 @@ proc offer(
|
||||||
if m.contentKeys.len() != contentKeysLen:
|
if m.contentKeys.len() != contentKeysLen:
|
||||||
# TODO:
|
# TODO:
|
||||||
# When there is such system, the peer should get scored negatively here.
|
# When there is such system, the peer should get scored negatively here.
|
||||||
error "Accepted content key bitlist has invalid size"
|
error "Accepted content key bitlist has invalid size",
|
||||||
|
bitListLen = m.contentKeys.len(), contentKeysLen
|
||||||
return err("Accepted content key bitlist has invalid size")
|
return err("Accepted content key bitlist has invalid size")
|
||||||
|
|
||||||
let acceptedKeysAmount = m.contentKeys.countOnes()
|
let acceptedKeysAmount = m.contentKeys.countOnes()
|
||||||
|
@ -1232,7 +1236,7 @@ proc contentLookup*(
|
||||||
)
|
)
|
||||||
return Opt.some(
|
return Opt.some(
|
||||||
ContentLookupResult.init(
|
ContentLookupResult.init(
|
||||||
content.content, content.utpTransfer, nodesWithoutContent
|
content.content, content.utpTransfer, content.src, nodesWithoutContent
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue