mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 22:13:12 +00:00
* Setting up testfixture for proof datasampler * Sets up calculating number of cells in a slot * Sets up tests for bitwise modulo * Implements cell index collection * setting up slot blocks module * Implements getting treeCID from slot * implements getting slot blocks by index * Implements out-of-range check for slot index * cleanup * Sets up getting sample from block * Implements selecting a cell sample from a block * Implements building a minitree for block cells * Adds method to get dataset block index from slot block index * It's running * splits up indexing * almost there * Fixes test. Implementation is now functional * Refactoring to object-oriented * Cleanup * Lining up output type with updated reference code. * setting up * Updates expected samples * Updates proof checking test to match new format * move builder to own dir * move sampler to own dir * fix paths * various changes to add support for the sampler * wip sampler implementation * don't use upraises * wip sampler integration * misc * move tests around * Various fixes to select correct slot and block index * removing old tests * cleanup * misc fix tests that work with correct cell indices * remove unused file * fixup logging * add logscope * truncate entropy to 31 bytes, otherwise it might be > than mod * forwar getCidAndProof to local store * misc * Adds missing test for initial-proving state * reverting back to correct slot/block indexing * fix tests for revert * misc * misc --------- Co-authored-by: benbierens <thatbenbierens@gmail.com>
65 lines
1.5 KiB
Nim
65 lines
1.5 KiB
Nim
import std/sequtils
|
|
|
|
import pkg/chronos
|
|
import pkg/questionable/results
|
|
import pkg/asynctest
|
|
import pkg/codex/chunker
|
|
import pkg/codex/blocktype as bt
|
|
import pkg/codex/manifest
|
|
import pkg/poseidon2
|
|
|
|
import pkg/codex/slots
|
|
import pkg/codex/merkletree
|
|
|
|
import ./helpers
|
|
import ./examples
|
|
|
|
checksuite "Manifest":
|
|
let
|
|
manifest = Manifest.new(
|
|
treeCid = Cid.example,
|
|
blockSize = 1.MiBs,
|
|
datasetSize = 100.MiBs
|
|
)
|
|
|
|
protectedManifest = Manifest.new(
|
|
manifest = manifest,
|
|
treeCid = Cid.example,
|
|
datasetSize = 200.MiBs,
|
|
eck = 2,
|
|
ecM = 2
|
|
)
|
|
|
|
leaves = [
|
|
0.toF.Poseidon2Hash,
|
|
1.toF.Poseidon2Hash,
|
|
2.toF.Poseidon2Hash,
|
|
3.toF.Poseidon2Hash]
|
|
|
|
slotLeavesCids = leaves.toSlotCids().tryGet
|
|
|
|
tree = Poseidon2Tree.init(leaves).tryGet
|
|
verifyCid = tree.root.tryGet.toVerifyCid().tryGet
|
|
|
|
verifiableManifest = Manifest.new(
|
|
manifest = protectedManifest,
|
|
verifyRoot = verifyCid,
|
|
slotRoots = slotLeavesCids
|
|
).tryGet()
|
|
|
|
proc encodeDecode(manifest: Manifest): Manifest =
|
|
let e = manifest.encode().tryGet()
|
|
Manifest.decode(e).tryGet()
|
|
|
|
test "Should encode/decode to/from base manifest":
|
|
check:
|
|
encodeDecode(manifest) == manifest
|
|
|
|
test "Should encode/decode to/from protected manifest":
|
|
check:
|
|
encodeDecode(protectedManifest) == protectedManifest
|
|
|
|
test "Should encode/decode to/from verifiable manifest":
|
|
check:
|
|
encodeDecode(verifiableManifest) == verifiableManifest
|