Introduces a start method to prover

This commit is contained in:
benbierens 2024-03-01 11:00:36 +01:00
parent 4d069599c9
commit cfca6b4111
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
3 changed files with 20 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import pkg/stew/shims/net as stewnet
import pkg/datastore
import pkg/ethers except Rng
import pkg/stew/io2
import pkg/questionable
import ./node
import ./conf
@ -66,7 +67,7 @@ proc waitForSync(provider: Provider): Future[void] {.async.} =
inc sleepTime
proc bootstrapInteractions(
s: CodexServer): Future[void] {.async.} =
s: CodexServer): Future[?string] {.async.} =
## bootstrap interactions and return contracts
## using clients, hosts, validators pairings
##
@ -139,6 +140,7 @@ proc bootstrapInteractions(
validator = some ValidatorInteractions.new(clock, validation)
s.codexNode.contracts = (client, host, validator)
return await market.getZkeyHash()
proc start*(s: CodexServer) {.async.} =
trace "Starting codex node", config = $s.config
@ -173,7 +175,11 @@ proc start*(s: CodexServer) {.async.} =
s.codexNode.discovery.updateAnnounceRecord(announceAddrs)
s.codexNode.discovery.updateDhtRecord(s.config.nat, s.config.discoveryPort)
await s.bootstrapInteractions()
let proofCeremonyUrl = await s.bootstrapInteractions()
if prover =? s.codexNode.prover:
prover.start(s.config, proofCeremonyUrl)
await s.codexNode.start()
s.restServer.start()
@ -283,11 +289,13 @@ proc new*(
$config.circomZkey
else: ""
echo "Prover is some!"
some Prover.new(
store,
CircomCompat.init($config.circomR1cs, $config.circomWasm, zkey),
config.numProofSamples)
else:
echo "Prover is none!"
none Prover
codexNode = CodexNodeRef.new(

View File

@ -64,7 +64,7 @@ type
networkId: PeerId
networkStore: NetworkStore
engine: BlockExcEngine
prover: ?Prover
prover*: ?Prover
discovery: Discovery
contracts*: Contracts
clock*: Clock

View File

@ -21,6 +21,7 @@ import ../../merkletree
import ../../stores
import ../../market
import ../../utils/poseidon2digest
import ../../conf
import ../builder
import ../sampler
@ -89,6 +90,14 @@ proc verify*(
self.backend.verify(proof, inputs)
proc start*(
self: Prover,
config: CodexConf,
proofCeremonyUrl: ?string
) =
echo "prover start!"
echo proofCeremonyUrl
proc new*(
_: type Prover,
store: BlockStore,