add prover

This commit is contained in:
Dmitriy Ryajov 2024-01-29 14:59:20 -06:00
parent 23c170ce46
commit 5e234e7604
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 17 additions and 12 deletions

View File

@ -64,6 +64,7 @@ type
blockStore: BlockStore
engine: BlockExcEngine
erasure: Erasure
prover: ?Prover
discovery: Discovery
contracts*: Contracts
clock*: Clock
@ -86,6 +87,9 @@ func engine*(self: CodexNodeRef): BlockExcEngine =
func erasure*(self: CodexNodeRef): Erasure =
return self.erasure
func prover*(self: CodexNodeRef): ?Prover =
return self.prover
func discovery*(self: CodexNodeRef): Discovery =
return self.discovery
@ -571,21 +575,20 @@ proc onProve(
trace "Received proof challenge"
without cid =? Cid.init(cidStr).mapFailure, err:
error "Unable to parse Cid", cid, err = err.msg
return failure(err)
if prover =? self.prover:
trace "Prover enabled"
without manifest =? await self.fetchManifest(cid), err:
error "Unable to fetch manifest for cid", err = err.msg
return failure(err)
without cid =? Cid.init(cidStr).mapFailure, err:
error "Unable to parse Cid", cid, err = err.msg
return failure(err)
without builder =? Poseidon2Builder.new(self.blockStore, manifest), err:
error "Unable to create slots builder", err = err.msg
return failure(err)
without manifest =? await self.fetchManifest(cid), err:
error "Unable to fetch manifest for cid", err = err.msg
return failure(err)
without sampler =? Poseidon2Sampler.new(slotIdx, self.blockStore, builder), err:
error "Unable to create data sampler", err = err.msg
return failure(err)
without proof =? await prover.prove(slotIdx, manifest, challenge), err:
error "Unable to generate proof", err = err.msg
return failure(err)
without proofInput =? await sampler.getProofInput(challenge, nSamples = 3), err:
error "Unable to get proof input for slot", err = err.msg
@ -707,6 +710,7 @@ proc new*(
store: BlockStore,
engine: BlockExcEngine,
erasure: Erasure,
prover = Prover.none,
discovery: Discovery,
contracts = Contracts.default): CodexNodeRef =
## Create new instance of a Codex self, call `start` to run it
@ -717,5 +721,6 @@ proc new*(
blockStore: store,
engine: engine,
erasure: erasure,
prover: prover,
discovery: discovery,
contracts: contracts)