This commit is contained in:
Agnish Ghosh 2024-10-02 00:18:00 +05:30
parent 0b9c48cadb
commit 2ecdb078b9
1 changed files with 22 additions and 23 deletions

View File

@ -24,7 +24,7 @@ const
## Allow syncing ~64 blocks/sec (minus request costs) ## Allow syncing ~64 blocks/sec (minus request costs)
blobResponseCost = allowedOpsPerSecondCost(1000) blobResponseCost = allowedOpsPerSecondCost(1000)
## Multiple can exist per block, they are much smaller than blocks ## Multiple can exist per block, they are much smaller than blocks
dataColumnResponseCost = allowedOpsPerSecondCost(250) dataColumnResponseCost = allowedOpsPerSecondCost(4000)
## 1 blob has an equivalent memory of 8 data columns ## 1 blob has an equivalent memory of 8 data columns
type type
@ -478,31 +478,30 @@ p2pProtocol BeaconSync(version = 1,
bytes: seq[byte] bytes: seq[byte]
for i in startIndex..endIndex: for i in startIndex..endIndex:
for j in 0..<MAX_REQUEST_DATA_COLUMNS: for k in reqColumns:
for k in reqColumns: if dag.db.getDataColumnSidecarSZ(blockIds[i].root, ColumnIndex(k), bytes):
if dag.db.getDataColumnSidecarSZ(blockIds[i].root, ColumnIndex(k), bytes): if blockIds[i].slot.epoch >= dag.cfg.DENEB_FORK_EPOCH and
if blockIds[i].slot.epoch >= dag.cfg.DENEB_FORK_EPOCH and not dag.head.executionValid:
not dag.head.executionValid: continue
continue
let uncompressedLen = uncompressedLenFramed(bytes).valueOr: let uncompressedLen = uncompressedLenFramed(bytes).valueOr:
warn "Cannot read data column sidecar size, database, corrupt", warn "Cannot read data column sidecar size, database, corrupt",
bytes = bytes.len(), blck = shortLog(blockIds[i]) bytes = bytes.len(), blck = shortLog(blockIds[i])
continue continue
peer.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1") peer.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1")
peer.network.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1") peer.network.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1")
await response.writeBytesSZ( await response.writeBytesSZ(
uncompressedLen, bytes, uncompressedLen, bytes,
peer.network.forkDigestAtEpoch(blockIds[i].slot.epoch).data) peer.network.forkDigestAtEpoch(blockIds[i].slot.epoch).data)
inc found inc found
var cols: seq[ColumnIndex] var cols: seq[ColumnIndex]
cols.add(k) cols.add(k)
debug "Responded to DataColumnSidecar range request", debug "Responded to DataColumnSidecar range request",
peer, blck = shortLog(blockIds[i]), columns = cols peer, blck = shortLog(blockIds[i]), columns = cols
else: else:
break break
debug "DataColumnSidecar range request done", debug "DataColumnSidecar range request done",
peer, startSlot, count = reqCount, columns = reqColumns, found peer, startSlot, count = reqCount, columns = reqColumns, found