diff --git a/codex/codex.nim b/codex/codex.nim index e1ca98fa..37f11f7e 100644 --- a/codex/codex.nim +++ b/codex/codex.nim @@ -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( diff --git a/codex/node.nim b/codex/node.nim index b8466943..9ec19f99 100644 --- a/codex/node.nim +++ b/codex/node.nim @@ -64,7 +64,7 @@ type networkId: PeerId networkStore: NetworkStore engine: BlockExcEngine - prover: ?Prover + prover*: ?Prover discovery: Discovery contracts*: Contracts clock*: Clock diff --git a/codex/slots/proofs/prover.nim b/codex/slots/proofs/prover.nim index 9077c478..34fef2c5 100644 --- a/codex/slots/proofs/prover.nim +++ b/codex/slots/proofs/prover.nim @@ -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,