refactor env

This commit is contained in:
Jaremy Creechley 2024-05-02 15:47:12 +03:00
parent b118792cf4
commit 4aa45dadbd
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 9 additions and 9 deletions

View File

@ -34,7 +34,7 @@ template benchmark(benchmarkName: string, blk: untyped) =
fgGreen, "CPU Time [", benchmarkName, "] ", "avg(", $nn, "): ", elapsedStr, " s"
)
proc runArkCircom(args: CircArgs, files: CircuitFiles) =
proc runArkCircom(args: CircuitArgs, files: CircuitFiles) =
echo "Loading sample proof..."
var
inputData = files.inputs.readFile()
@ -62,12 +62,12 @@ proc runArkCircom(args: CircArgs, files: CircuitFiles) =
verRes = circom.verify(proof, proofInputs).tryGet
echo "verify result: ", verRes
proc runRapidSnark(args: CircArgs, files: CircuitFiles) =
proc runRapidSnark(args: CircuitArgs, files: CircuitFiles) =
# time rapidsnark ${CIRCUIT_MAIN}.zkey witness.wtns proof.json public.json
echo "generating the witness..."
proc runBenchmark(args: CircArgs) =
proc runBenchmark(args: CircuitArgs) =
## execute benchmarks given a set of args
## will create a folder in `benchmarks/circuit_bench_$(args)`
##
@ -88,7 +88,7 @@ proc startBenchmarks*() =
echo "Running benchmark"
# setup()
checkEnv()
var args = CircArgs(
var args = CircuitArgs(
depth: 32, # maximum depth of the slot tree
maxslots: 256, # maximum number of slots
cellsize: 2048, # cell size in bytes

View File

@ -8,7 +8,7 @@ type
ptauUrl*: string
codexProjDir*: string
CircArgs* = object
CircuitArgs* = object
depth*: int
maxslots*: int
cellsize*: int
@ -97,13 +97,13 @@ proc downloadPtau*(ptauPath, ptauUrl: string) =
else:
echo "Found PTAU file at: ", ptauPath
proc getCircuitBenchPath*(args: CircArgs): string =
proc getCircuitBenchPath*(args: CircuitArgs): string =
var an = ""
for f, v in fieldPairs(args):
an &= "_" & f & $v
absolutePath("benchmarks/circuit_bench" & an)
proc generateCircomAndSamples*(args: CircArgs, env: CircuitEnv, name: string) =
proc generateCircomAndSamples*(args: CircuitArgs, env: CircuitEnv, name: string) =
## run nim circuit and sample generator
var cliCmd = env.nimCircuitCli
for f, v in fieldPairs(args):
@ -114,7 +114,7 @@ proc generateCircomAndSamples*(args: CircArgs, env: CircuitEnv, name: string) =
runit fmt"{cliCmd} -v --circom={name}.circom --output=input.json"
proc createCircuit*(
args: CircArgs,
args: CircuitArgs,
env: CircuitEnv,
name = "proof_main",
circBenchDir = getCircuitBenchPath(args),
@ -173,7 +173,7 @@ when isMainModule:
var env = CircuitEnv.default()
checkEnv(env)
let args = CircArgs(
let args = CircuitArgs(
depth: 32, # maximum depth of the slot tree
maxslots: 256, # maximum number of slots
cellsize: 2048, # cell size in bytes