mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-10 21:15:59 +00:00
4e8630791a
* Introduces a start method to prover * Moves backend creation into start method * sets up three paths for backend initialization * Extracts backend initialization to backend-factory * Implements loading backend from cli files or previously downloaded local files * Wires up downloading and unzipping * functional implementation * Fixes testprover.nim * Sets up tests for backendfactory * includes libzip-dev * pulls in updated contracts * removes integration cli tests for r1cs, wasm, and zkey file arguments. * Fixes issue where inner-scope values are lost before returning * sets local proof verification for dist-test images * Adds two traces and bumps nim-ethers * Adds separate path for circuit files * Create circuit dir if not exists * fix: make sure requestStorage is mined * fix: correct place to plug confirm * test: fixing contracts tests * Restores gitmodules * restores nim-datastore reference * Sets up downloader exe * sets up tool skeleton * implements getting of circuit hash * Implements downloader tool * sets up test skeleton * Implements test for cirdl * includes testTools in testAll * Cleanup building.md * cleans up previous downloader implementation * cleans up testbackendfactory * moves start of prover into node.nim * Fills in arguments in example command * Initializes backend in prover constructor * Restores tests * Restores tests for cli instructions * Review comments by Dmitriy, part 1 * Quotes path in download instruction. * replaces curl with chronos http session * Moves cirdl build output to 'build' folder. * Fixes chronicles log output * Add cirdl support to the codex Dockerfile Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> * Add cirdl support to the docker entrypoint Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> * Add cirdl support to the release workflow Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> * Disable verify_circuit flag for releases Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> * Removes backendFactory placeholder type * wip * Replaces zip library with status-im/zippy library (which supports zip and tar) * Updates cirdl to not change circuitdir folder * Switches from zip to tar.gz * Review comments by Dmitriy * updates codex-contracts-eth * Adds testTools to CI * Adds check for access to config.circuitdir * Update fixture circuit zkey * Update matrix to run tools tests on Windows * Adds 'deps' dependency for cirdl * Adjust docker-entrypoint.sh to use CODEX_CIRCUIT_DIR env var * Review comments by Giuliano --------- Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com> Co-authored-by: Adam Uhlíř <adam@uhlir.dev> Co-authored-by: Veaceslav Doina <20563034+veaceslavdoina@users.noreply.github.com>
104 lines
2.7 KiB
Nim
104 lines
2.7 KiB
Nim
import std/sequtils
|
|
import std/sugar
|
|
import std/math
|
|
|
|
import ../../asynctest
|
|
|
|
import pkg/chronos
|
|
import pkg/libp2p/cid
|
|
import pkg/datastore
|
|
|
|
import pkg/codex/merkletree
|
|
import pkg/codex/rng
|
|
import pkg/codex/manifest
|
|
import pkg/codex/chunker
|
|
import pkg/codex/blocktype as bt
|
|
import pkg/codex/slots
|
|
import pkg/codex/stores
|
|
import pkg/codex/conf
|
|
import pkg/confutils/defs
|
|
import pkg/poseidon2/io
|
|
import pkg/codex/utils/poseidon2digest
|
|
|
|
import ./helpers
|
|
import ../helpers
|
|
import ./backends/helpers
|
|
|
|
suite "Test Prover":
|
|
let
|
|
samples = 5
|
|
blockSize = DefaultBlockSize
|
|
cellSize = DefaultCellSize
|
|
repoTmp = TempLevelDb.new()
|
|
metaTmp = TempLevelDb.new()
|
|
challenge = 1234567.toF.toBytes.toArray32
|
|
|
|
var
|
|
store: BlockStore
|
|
prover: Prover
|
|
|
|
setup:
|
|
let
|
|
repoDs = repoTmp.newDb()
|
|
metaDs = metaTmp.newDb()
|
|
config = CodexConf(
|
|
cmd: StartUpCmd.persistence,
|
|
nat: ValidIpAddress.init("127.0.0.1"),
|
|
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
|
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
|
persistenceCmd: PersistenceCmd.prover,
|
|
circomR1cs: InputFile("tests/circuits/fixtures/proof_main.r1cs"),
|
|
circomWasm: InputFile("tests/circuits/fixtures/proof_main.wasm"),
|
|
circomZkey: InputFile("tests/circuits/fixtures/proof_main.zkey"),
|
|
numProofSamples: samples
|
|
)
|
|
backend = config.initializeBackend().tryGet()
|
|
|
|
store = RepoStore.new(repoDs, metaDs)
|
|
prover = Prover.new(store, backend, config.numProofSamples)
|
|
|
|
teardown:
|
|
await repoTmp.destroyDb()
|
|
await metaTmp.destroyDb()
|
|
|
|
test "Should sample and prove a slot":
|
|
let
|
|
(_, _, verifiable) =
|
|
await createVerifiableManifest(
|
|
store,
|
|
8, # number of blocks in the original dataset (before EC)
|
|
5, # ecK
|
|
3, # ecM
|
|
blockSize,
|
|
cellSize)
|
|
|
|
let
|
|
(inputs, proof) = (
|
|
await prover.prove(1, verifiable, challenge)).tryGet
|
|
|
|
check:
|
|
(await prover.verify(proof, inputs)).tryGet == true
|
|
|
|
test "Should generate valid proofs when slots consist of single blocks":
|
|
|
|
# To get single-block slots, we just need to set the number of blocks in
|
|
# the original dataset to be the same as ecK. The total number of blocks
|
|
# after generating random data for parity will be ecK + ecM, which will
|
|
# match the number of slots.
|
|
let
|
|
(_, _, verifiable) =
|
|
await createVerifiableManifest(
|
|
store,
|
|
2, # number of blocks in the original dataset (before EC)
|
|
2, # ecK
|
|
1, # ecM
|
|
blockSize,
|
|
cellSize)
|
|
|
|
let
|
|
(inputs, proof) = (
|
|
await prover.prove(1, verifiable, challenge)).tryGet
|
|
|
|
check:
|
|
(await prover.verify(proof, inputs)).tryGet == true
|