Fix: ProofInputSample data is cell bytes instead of block bytes

This commit is contained in:
benbierens 2024-01-16 09:35:45 +01:00 committed by Dmitriy Ryajov
parent 901d816f56
commit 70541921c4
2 changed files with 18 additions and 2 deletions

View File

@ -127,6 +127,13 @@ func numBlockCells*(self: SlotsBuilder): Natural =
(self.manifest.blockSize div self.cellSize).Natural
func cellSize*(self: SlotsBuilder): NBytes =
## Cell size.
##
self.cellSize
func numSlotCells*(self: SlotsBuilder): Natural =
## Number of cells per slot.
##

View File

@ -69,7 +69,14 @@ proc new*(
blockStore: blockStore,
builder: builder)
proc getProofs*(
proc getCell*(self: DataSampler, blkBytes: seq[byte], blkCellIdx: uint64): Cell =
let
cellSize = self.builder.cellSize.uint64
dataStart = (cellSize * blkCellIdx)
dataEnd = dataStart + cellSize
return blkBytes[dataStart ..< dataEnd]
proc getProofInput*(
self: DataSampler,
entropy: ProofChallenge,
nSamples: Natural): Future[?!ProofInput] {.async.} =
@ -126,7 +133,9 @@ proc getProofs*(
error "Failed to get proof from block tree", err = err.msg
return failure(err)
Sample(data: bytes, proof: blockProof)
let cellData = self.getCell(bytes, blkCellIdx)
Sample(data: cellData, proof: blockProof)
success ProofInput(
entropy: entropy,