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