diff --git a/codex/manifest/manifest.nim b/codex/manifest/manifest.nim index abfd5b4cb..5966feb30 100644 --- a/codex/manifest/manifest.nim +++ b/codex/manifest/manifest.nim @@ -322,7 +322,7 @@ func new*( protected: true, ecK: manifest.ecK, ecM: manifest.ecM, - originalTreeCid: manifest.treeCid, + originalTreeCid: manifest.originalTreeCid, originalDatasetSize: manifest.originalDatasetSize, protectedStrategy: manifest.protectedStrategy, verifiable: true, diff --git a/codex/node.nim b/codex/node.nim index 15ca1466c..f2bcb2897 100644 --- a/codex/node.nim +++ b/codex/node.nim @@ -257,7 +257,10 @@ proc streamEntireDataset( leoDecoderProvider, self.taskpool) without _ =? (await erasure.decode(manifest)), error: - trace "Unable to erasure decode manifest", manifestCid, exc = error.msg + error "Unable to erasure decode manifest", manifestCid, exc = error.msg + return failure(error) + + return success() # -------------------------------------------------------------------------- # FIXME this is a HACK so that the node does not crash during the workshop. # We should NOT catch Defect. diff --git a/tests/codex/testerasure.nim b/tests/codex/testerasure.nim index b92f4ae33..84f4b1c3c 100644 --- a/tests/codex/testerasure.nim +++ b/tests/codex/testerasure.nim @@ -17,6 +17,7 @@ import pkg/taskpools import ../asynctest import ./helpers +import ./examples suite "Erasure encode/decode": const BlockSize = 1024'nb @@ -232,3 +233,22 @@ suite "Erasure encode/decode": let encoded = await encode(buffers, parity) discard (await erasure.decode(encoded)).tryGet() + + test "Should handle verifiable manifests": + const + buffers = 20 + parity = 10 + + let + encoded = await encode(buffers, parity) + slotCids = collect(newSeq): + for i in 0.. //_.log + .withLogTopics("node", "erasure", "marketplace", ) + .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, + ): + let reward = 400.u256 + let duration = 10.periods + let collateral = 200.u256 + let expiry = 5.periods + let data = await RandomChunker.example(blocks=8) + let client = clients()[0] + let clientApi = client.client + + let cid = clientApi.upload(data).get + + var requestId = none RequestId + proc onStorageRequested(event: StorageRequested) {.raises:[].} = + requestId = event.requestId.some + + let subscription = await marketplace.subscribe(StorageRequested, onStorageRequested) + + # client requests storage but requires multiple slots to host the content + let id = await clientApi.requestStorage( + cid, + duration=duration, + reward=reward, + expiry=expiry, + collateral=collateral, + nodes=3, + tolerance=1 + ) + + check eventually(requestId.isSome, timeout=expiry.int * 1000) + + let request = await marketplace.getRequest(requestId.get) + let cidFromRequest = Cid.init(request.content.cid).get() + let downloaded = await clientApi.downloadBytes(cidFromRequest, local = true) + check downloaded.isOk + check downloaded.get.toHex == data.toHex + + await subscription.unsubscribe() diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index de854ecb0..b1f81ef40 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -6,5 +6,6 @@ import ./integration/testpurchasing import ./integration/testblockexpiration import ./integration/testmarketplace import ./integration/testproofs +import ./integration/testecbug {.warning[UnusedImport]:off.} diff --git a/vendor/nim-leopard b/vendor/nim-leopard index 1a6f2ab72..895ff24ca 160000 --- a/vendor/nim-leopard +++ b/vendor/nim-leopard @@ -1 +1 @@ -Subproject commit 1a6f2ab7252426a6ac01482a68b75d0c3b134cf0 +Subproject commit 895ff24ca6615d577acfb11811cdd5465f596c97