sync queue

This commit is contained in:
Agnish Ghosh 2024-07-02 22:37:09 +05:30
parent ad64b22485
commit d292e94560
No known key found for this signature in database
GPG Key ID: 7BDDA05D1B25E9F8
2 changed files with 34 additions and 34 deletions

View File

@ -558,7 +558,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
if shouldGetDataColumns:
let data_columns = await man.getDataColumnSidecars(peer, req)
if data_columns.isErr():
peer.updateScore(PeerScoreNoValues)
# peer.updateScore(PeerScoreNoValues)
man.queue.push(req)
debug "Failed to receive data columns on request",
request = req, err = data_columns.error
@ -572,7 +572,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
let slots = mapIt(dataColumnData, it[].signed_block_header.message.slot)
let uniqueSlots = foldl(slots, combine(a, b), @[slots[0]])
if not(checkResponse(req, uniqueSlots)):
peer.updateScore(PeerScoreBadResponse)
# peer.updateScore(PeerScoreBadResponse)
man.queue.push(req)
warn "Received data columns sequence is not in requested range",
data_columns_count = len(dataColumnData), data_columns_map = getShortMap(req, dataColumnData),
@ -580,13 +580,13 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
return
let groupedDataColumns = groupDataColumns(req, blockData, dataColumnData)
if groupedDataColumns.isErr():
peer.updateScore(PeerScoreNoValues)
# peer.updateScore(PeerScoreNoValues)
man.queue.push(req)
# warn "Received data columns is inconsistent",
# data_columns_map = getShortMap(req, dataColumnData), request = req, msg=groupedDataColumns.error()
return
if (let checkRes = groupedDataColumns.get.checkDataColumns(); checkRes.isErr):
peer.updateScore(PeerScoreBadResponse)
# peer.updateScore(PeerScoreBadResponse)
man.queue.push(req)
warn "Received data columns is invalid",
data_columns_count = len(dataColumnData),

View File

@ -727,42 +727,42 @@ proc push*[T](sq: SyncQueue[T], sr: SyncRequest[T],
# Nim versions, remove workaround and move `res` into for loop
res: Result[void, VerifierError]
var i=0
for blk, blb in sq.blocks(item):
res = await sq.blockVerifier(blk[], blb, Opt.none(DataColumnSidecars), maybeFinalized)
inc(i)
# var i=0
# for blk, blb in sq.blocks(item):
# res = await sq.blockVerifier(blk[], blb, Opt.none(DataColumnSidecars), maybeFinalized)
# inc(i)
if res.isOk():
goodBlock = some(blk[].slot)
else:
case res.error()
of VerifierError.MissingParent:
missingParentSlot = some(blk[].slot)
break
of VerifierError.Duplicate:
# Keep going, happens naturally
discard
of VerifierError.UnviableFork:
# Keep going so as to register other unviable blocks with the
# quarantine
if unviableBlock.isNone:
# Remember the first unviable block, so we can log it
unviableBlock = some((blk[].root, blk[].slot))
# if res.isOk():
# goodBlock = some(blk[].slot)
# else:
# case res.error()
# of VerifierError.MissingParent:
# missingParentSlot = some(blk[].slot)
# break
# of VerifierError.Duplicate:
# # Keep going, happens naturally
# discard
# of VerifierError.UnviableFork:
# # Keep going so as to register other unviable blocks with the
# # quarantine
# if unviableBlock.isNone:
# # Remember the first unviable block, so we can log it
# unviableBlock = some((blk[].root, blk[].slot))
of VerifierError.Invalid:
hasInvalidBlock = true
# of VerifierError.Invalid:
# hasInvalidBlock = true
let req = item.request
notice "Received invalid sequence of blocks", request = req,
blocks_count = len(item.data),
blocks_map = getShortMap(req, item.data)
req.item.updateScore(PeerScoreBadValues)
break
# let req = item.request
# notice "Received invalid sequence of blocks", request = req,
# blocks_count = len(item.data),
# blocks_map = getShortMap(req, item.data)
# req.item.updateScore(PeerScoreBadValues)
# break
var counter = 0
for blk, col in sq.das_blocks(item):
res = await sq.blockVerifier(blk[], Opt.none(BlobSidecars), col, maybeFinalized)
inc i
inc counter
if res.isOk:
goodBlock = some(blk[].slot)
@ -788,7 +788,7 @@ proc push*[T](sq: SyncQueue[T], sr: SyncRequest[T],
notice "Received invalid sequence of blocks", request = req,
blocks_count = len(item.data),
blocks_map = getShortMap(req, item.data)
req.item.updateScore(PeerScoreBadValues)
# req.item.updateScore(PeerScoreBadValues)
# When errors happen while processing blocks, we retry the same request
# with, hopefully, a different peer