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,6 +575,9 @@ proc onProve(
|
||||||
|
|
||||||
trace "Received proof challenge"
|
trace "Received proof challenge"
|
||||||
|
|
||||||
|
if prover =? self.prover:
|
||||||
|
trace "Prover enabled"
|
||||||
|
|
||||||
without cid =? Cid.init(cidStr).mapFailure, err:
|
without cid =? Cid.init(cidStr).mapFailure, err:
|
||||||
error "Unable to parse Cid", cid, err = err.msg
|
error "Unable to parse Cid", cid, err = err.msg
|
||||||
return failure(err)
|
return failure(err)
|
||||||
|
@ -579,12 +586,8 @@ proc onProve(
|
||||||
error "Unable to fetch manifest for cid", err = err.msg
|
error "Unable to fetch manifest for cid", err = err.msg
|
||||||
return failure(err)
|
return failure(err)
|
||||||
|
|
||||||
without builder =? Poseidon2Builder.new(self.blockStore, manifest), err:
|
without proof =? await prover.prove(slotIdx, manifest, challenge), err:
|
||||||
error "Unable to create slots builder", err = err.msg
|
error "Unable to generate proof", 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)
|
return failure(err)
|
||||||
|
|
||||||
without proofInput =? await sampler.getProofInput(challenge, nSamples = 3), err:
|
without proofInput =? await sampler.getProofInput(challenge, nSamples = 3), err:
|
||||||
|
@ -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