diff --git a/codex/erasure/erasure.nim b/codex/erasure/erasure.nim index 14ae98da..939deae3 100644 --- a/codex/erasure/erasure.nim +++ b/codex/erasure/erasure.nim @@ -209,6 +209,9 @@ proc prepareDecodingData( let pos = indexToPos(encoded.steps, idx, step) + if encoded.ecK > pos: + continue + logScope: cid = blk.cid idx = idx @@ -217,7 +220,7 @@ proc prepareDecodingData( empty = blk.isEmpty cids[idx] = blk.cid - if idx >= encoded.rounded and pos >= encoded.ecK: + if idx >= encoded.rounded: trace "Retrieved parity block" shallowCopy(parityData[pos - encoded.ecK], if blk.isEmpty: emptyBlock else: blk.data) parityPieces.inc diff --git a/tests/integration/testecbug.nim b/tests/integration/testecbug.nim index 36c1a3b7..d9128021 100644 --- a/tests/integration/testecbug.nim +++ b/tests/integration/testecbug.nim @@ -1,9 +1,16 @@ from pkg/libp2p import Cid, init + +# import pkg/codex/manifest +import pkg/codex/manifest/coders +import pkg/codex/manifest/manifest + import ../examples import ./marketplacesuite import ./nodeconfigs import ./hardhatconfig +export coders # make Manifest.decode symbol available to codex/manifest + marketplacesuite "EC bug": test "should be able to create storage request and download dataset", @@ -16,15 +23,11 @@ marketplacesuite "EC bug": CodexConfigs.init(nodes=1) # .debug() # uncomment to enable console log output.debug() .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log - .withLogTopics("node", "erasure", "marketplace", ) + .withLogTopics("node", "erasure", "marketplace", "storestream") .some, providers: - CodexConfigs.init(nodes=0) - # .debug() # uncomment to enable console log output - # .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log - # .withLogTopics("node", "marketplace", "sales", "reservations", "node", "proving", "clock") - .some, + CodexConfigs.none, ): let reward = 400.u256 let duration = 10.periods @@ -60,6 +63,10 @@ marketplacesuite "EC bug": let cidFromRequest = Cid.init(request.content.cid).get() let downloaded = await clientApi.downloadBytes(cidFromRequest, local = true) check downloaded.isOk - check downloaded.get.toHex == data + # let manifest = Manifest.new(downloaded.get) + # echo "manifest: ", manifest + echo "orig data length: ", data.len + echo "download length: ", downloaded.get.toHex.len + # check downloaded.get.toHex == data await subscription.unsubscribe()