From 00fe07a608ee76506e6634e6918b3b8e69a22865 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 29 Oct 2024 11:11:48 +0100 Subject: [PATCH] Restores testcircomcompat and testsampler. --- codex/merkletree/merkletree.nim | 1 - codex/slots/proofs/prover.nim | 4 ++++ codex/utils/poseidon2digest.nim | 2 +- tests/codex/slots/backends/testcircomcompat.nim | 1 + tests/codex/slots/sampler/testsampler.nim | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/codex/merkletree/merkletree.nim b/codex/merkletree/merkletree.nim index 9b972e88..fab6476d 100644 --- a/codex/merkletree/merkletree.nim +++ b/codex/merkletree/merkletree.nim @@ -121,7 +121,6 @@ func reconstructRoot*[H, K](proof: MerkleProof[H, K], leaf: H): ?!H = func verify*[H, K](proof: MerkleProof[H, K], leaf: H, root: H): ?!bool = success bool(root == ? proof.reconstructRoot(leaf)) -# TODO: replace with implementation in poseidon library plz proc merkleTreeWorker*[H, K]( self: MerkleTree[H, K], xs: seq[H], diff --git a/codex/slots/proofs/prover.nim b/codex/slots/proofs/prover.nim index 956270c2..ab1ed687 100644 --- a/codex/slots/proofs/prover.nim +++ b/codex/slots/proofs/prover.nim @@ -66,6 +66,10 @@ proc prove*( error "Unable to create slots builder", err = err.msg return failure(err) + if err =? (await builder.init()).errorOption: + error "Failed to initialize builder", err = err.msg + return failure(err) + without sampler =? AnySampler.new(slotIdx, self.store, builder), err: error "Unable to create data sampler", err = err.msg return failure(err) diff --git a/codex/utils/poseidon2digest.nim b/codex/utils/poseidon2digest.nim index efc9acfe..3960ca0c 100644 --- a/codex/utils/poseidon2digest.nim +++ b/codex/utils/poseidon2digest.nim @@ -55,7 +55,7 @@ proc digestTree*( return failure err leaves.add(digest) index += chunkSize - await sleepAsync(1.micros) # cooperative scheduling + await sleepAsync(1.nanos) # cooperative scheduling return await Poseidon2Tree.init(leaves) proc digest*( diff --git a/tests/codex/slots/backends/testcircomcompat.nim b/tests/codex/slots/backends/testcircomcompat.nim index 99097afd..d8cb1021 100644 --- a/tests/codex/slots/backends/testcircomcompat.nim +++ b/tests/codex/slots/backends/testcircomcompat.nim @@ -99,6 +99,7 @@ suite "Test Circom Compat Backend": cellSize) builder = Poseidon2Builder.new(store, verifiable).tryGet + (await builder.init()).tryGet() sampler = Poseidon2Sampler.new(slotId, store, builder).tryGet circom = CircomCompat.init(r1cs, wasm, zkey) diff --git a/tests/codex/slots/sampler/testsampler.nim b/tests/codex/slots/sampler/testsampler.nim index 01855c27..d98af204 100644 --- a/tests/codex/slots/sampler/testsampler.nim +++ b/tests/codex/slots/sampler/testsampler.nim @@ -111,6 +111,7 @@ suite "Test Sampler": # create sampler builder = Poseidon2Builder.new(store, verifiable).tryGet + (await builder.init()).tryGet() teardown: await store.close()