Review comments by Dmitriy, part 1
This commit is contained in:
parent
f08a28c101
commit
bdb5eefa7e
|
@ -272,7 +272,10 @@ proc new*(
|
|||
engine = BlockExcEngine.new(repoStore, wallet, network, blockDiscovery, peerStore, pendingBlocks)
|
||||
store = NetworkStore.new(engine, repoStore)
|
||||
prover = if config.prover:
|
||||
some Prover.new(store, config).expect("Unable to create prover.")
|
||||
let
|
||||
backendFactory = BackendFactory()
|
||||
backend = backendFactory.initializeBackend(config).expect("Unable to create prover backend.")
|
||||
some Prover.new(store, backend, config)
|
||||
else:
|
||||
none Prover
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ./proofs/backends
|
||||
import ./proofs/prover
|
||||
import ./proofs/backendfactory
|
||||
|
||||
export circomcompat, prover
|
||||
export circomcompat, prover, backendfactory
|
||||
|
|
|
@ -11,6 +11,9 @@ import ../../conf
|
|||
import ./backends
|
||||
import ./backendutils
|
||||
|
||||
type
|
||||
BackendFactory* = object of RootObj
|
||||
|
||||
proc initializeFromConfig(
|
||||
config: CodexConf,
|
||||
utils: BackendUtils): ?!AnyBackend =
|
||||
|
@ -70,6 +73,7 @@ proc suggestDownloadTool(config: CodexConf) =
|
|||
echo "'./" & tokens.join(" ") & "'"
|
||||
|
||||
proc initializeBackend*(
|
||||
self: BackendFactory,
|
||||
config: CodexConf,
|
||||
utils: BackendUtils = BackendUtils()): ?!AnyBackend =
|
||||
|
||||
|
|
|
@ -92,13 +92,10 @@ proc verify*(
|
|||
proc new*(
|
||||
_: type Prover,
|
||||
store: BlockStore,
|
||||
config: CodexConf): ?!Prover =
|
||||
backend: AnyBackend,
|
||||
config: CodexConf): Prover =
|
||||
|
||||
without backend =? initializeBackend(config), err:
|
||||
error "Failed to initialize backend", msg = err.msg
|
||||
return failure(err)
|
||||
|
||||
success Prover(
|
||||
Prover(
|
||||
store: store,
|
||||
backend: backend,
|
||||
nSamples: config.numProofSamples)
|
||||
|
|
|
@ -36,6 +36,7 @@ suite "Test BackendFactory":
|
|||
let
|
||||
utilsMock = BackendUtilsMock()
|
||||
circuitDir = "testecircuitdir"
|
||||
factory = BackendFactory()
|
||||
|
||||
setup:
|
||||
createDir(circuitDir)
|
||||
|
@ -56,7 +57,7 @@ suite "Test BackendFactory":
|
|||
circomWasm: InputFile("tests/circuits/fixtures/proof_main.wasm"),
|
||||
circomZkey: InputFile("tests/circuits/fixtures/proof_main.zkey")
|
||||
)
|
||||
backend = initializeBackend(config, utilsMock).tryGet
|
||||
backend = factory.initializeBackend(config, utilsMock).tryGet
|
||||
|
||||
check:
|
||||
backend.vkp != nil
|
||||
|
@ -78,7 +79,7 @@ suite "Test BackendFactory":
|
|||
# will be picked up as local files:
|
||||
circuitDir: OutDir("tests/circuits/fixtures")
|
||||
)
|
||||
backend = initializeBackend(config, utilsMock).tryGet
|
||||
backend = factory.initializeBackend(config, utilsMock).tryGet
|
||||
|
||||
check:
|
||||
backend.vkp != nil
|
||||
|
@ -97,8 +98,7 @@ suite "Test BackendFactory":
|
|||
marketplaceAddress: EthAddress.example.some,
|
||||
circuitDir: OutDir(circuitDir)
|
||||
)
|
||||
|
||||
backendResult = initializeBackend(config, utilsMock)
|
||||
backendResult = factory.initializeBackend(config, utilsMock)
|
||||
|
||||
check:
|
||||
backendResult.isErr
|
||||
|
|
|
@ -53,8 +53,12 @@ suite "Test Prover":
|
|||
numProofSamples: samples
|
||||
)
|
||||
|
||||
let
|
||||
backendFactory = BackendFactory()
|
||||
backend = backendFactory.initializeBackend(config).tryGet()
|
||||
|
||||
store = RepoStore.new(repoDs, metaDs)
|
||||
prover = Prover.new(store, config).tryGet()
|
||||
prover = Prover.new(store, backend, config)
|
||||
|
||||
teardown:
|
||||
await repoTmp.destroyDb()
|
||||
|
|
Loading…
Reference in New Issue