weird fix

This commit is contained in:
Agnish Ghosh 2024-07-02 03:09:49 +05:30
parent 8e28654a24
commit 3b1f5b48dd
No known key found for this signature in database
GPG Key ID: 7BDDA05D1B25E9F8
2 changed files with 9 additions and 10 deletions

View File

@ -50,6 +50,7 @@ type
pool: PeerPool[A, B]
DENEB_FORK_EPOCH: Epoch
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: uint64
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: uint64
responseTimeout: chronos.Duration
maxHeadAge: uint64
getLocalHeadSlot: GetSlotCallback
@ -186,7 +187,7 @@ proc shouldGetBlobs[A, B](man: SyncManager[A, B], e: Epoch): bool =
proc shouldGetDataColumns[A, B](man: SyncManager[A, B], e: Epoch): bool =
let wallEpoch = man.getLocalWallSlot().epoch
e >= man.DENEB_FORK_EPOCH and
(wallEpoch < man.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUEST or
(wallEpoch < man.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS or
e >= wallEpoch - man.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS)
proc getBlobSidecars[A, B](man: SyncManager[A, B], peer: A,
@ -541,7 +542,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
Opt.none(seq[BlobSidecars])
let shouldGetDataColumns =
if not man.shouldGetBlobs(req.slot.epoch):
if not man.shouldGetDataColumns(req.slot.epoch):
false
else:
var hasColumns = false
@ -556,7 +557,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
let dataColumnData =
if shouldGetDataColumns:
let data_columns = await man.getDataColumnSidecars(peer, req)
if data_columns.isErr:
if data_columns.isErr():
peer.updateScore(PeerScoreNoValues)
man.queue.push(req)
debug "Failed to receive data columns on request",
@ -575,15 +576,14 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
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),
request = req
request = req
return
let groupedDataColumns = groupDataColumns(req, blockData, dataColumnData)
if groupedDataColumns.isErr:
peer.updateScore(PeerScoreNoValues)
man.queue.push(req)
info "Received data columns is inconsistent",
data_columns_map = getShortMap(req, dataColumnData), request = req, msg=groupedDataColumns.error()
# info "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)

View File

@ -137,9 +137,8 @@ proc getShortMap*[T](req: SyncRequest[T],
proc getShortMap*[T](req: SyncRequest[T],
data: openArray[ref DataColumnSidecar]): string =
# Returns all slot numbers in ``data`` as a placement map
var
res = newStringOfCap(req.count * MAX_BLOBS_PER_BLOCK)
cur: uint64 = 0
var res = newStringOfCap(req.count * MAX_BLOBS_PER_BLOCK)
var cur: uint64 = 0
for slot in req.slot..<req.slot+req.count:
if cur >= lenu64(data):
res.add('|')