Bandaid for failing erasure coding (#855)

This commit is contained in:
Tomasz Bekas 2024-07-03 16:44:00 +02:00 committed by GitHub
parent fbf1b51f57
commit 3ae73197c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 2 deletions

View File

@ -114,7 +114,14 @@ proc proxySpawnEncodeTask(
args: EncodeTaskArgs, args: EncodeTaskArgs,
data: ref seq[seq[byte]] data: ref seq[seq[byte]]
): Flowvar[EncodeTaskResult] = ): Flowvar[EncodeTaskResult] =
tp.spawn encodeTask(args, data[]) # FIXME Uncomment the code below after addressing an issue:
# https://github.com/codex-storage/nim-codex/issues/854
# tp.spawn encodeTask(args, data[])
let fv = EncodeTaskResult.newFlowVar
fv.readyWith(encodeTask(args, data[]))
return fv
proc proxySpawnDecodeTask( proc proxySpawnDecodeTask(
tp: Taskpool, tp: Taskpool,
@ -122,7 +129,14 @@ proc proxySpawnDecodeTask(
data: ref seq[seq[byte]], data: ref seq[seq[byte]],
parity: ref seq[seq[byte]] parity: ref seq[seq[byte]]
): Flowvar[DecodeTaskResult] = ): Flowvar[DecodeTaskResult] =
tp.spawn decodeTask(args, data[], parity[]) # FIXME Uncomment the code below after addressing an issue:
# https://github.com/codex-storage/nim-codex/issues/854
# tp.spawn decodeTask(args, data[], parity[])
let fv = DecodeTaskResult.newFlowVar
fv.readyWith(decodeTask(args, data[], parity[]))
return fv
proc awaitResult[T](signal: ThreadSignalPtr, handle: Flowvar[T]): Future[?!T] {.async.} = proc awaitResult[T](signal: ThreadSignalPtr, handle: Flowvar[T]): Future[?!T] {.async.} =
await wait(signal) await wait(signal)

View File

@ -252,3 +252,22 @@ suite "Erasure encode/decode":
decoded.treeCid == manifest.treeCid decoded.treeCid == manifest.treeCid
decoded.treeCid == verifiable.originalTreeCid decoded.treeCid == verifiable.originalTreeCid
decoded.blocksCount == verifiable.originalBlocksCount decoded.blocksCount == verifiable.originalBlocksCount
for i in 1..5:
test "Should encode/decode using various parameters " & $i & "/5":
let
blockSize = rng.sample(@[1, 2, 4, 8, 16, 32, 64].mapIt(it.KiBs))
datasetSize = 1.MiBs
ecK = 10.Natural
ecM = 10.Natural
let
chunker = RandomChunker.new(rng, size = datasetSize, chunkSize = blockSize)
manifest = await storeDataGetManifest(store, chunker)
encoded = (await erasure.encode(manifest, ecK, ecM)).tryGet()
decoded = (await erasure.decode(encoded)).tryGet()
check:
decoded.treeCid == manifest.treeCid
decoded.treeCid == encoded.originalTreeCid
decoded.blocksCount == encoded.originalBlocksCount