mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-23 16:08:40 +00:00
refactor env
This commit is contained in:
parent
9b87b819f6
commit
b118792cf4
@ -1,6 +1,5 @@
|
|||||||
import std/[hashes, json, strutils, strformat, os, osproc]
|
import std/[hashes, json, strutils, strformat, os, osproc]
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
CircuitEnv* = object
|
CircuitEnv* = object
|
||||||
nimCircuitCli*: string
|
nimCircuitCli*: string
|
||||||
@ -21,14 +20,20 @@ type
|
|||||||
ncells*: int
|
ncells*: int
|
||||||
index*: int
|
index*: int
|
||||||
|
|
||||||
|
proc findCodexProjectDir(): string =
|
||||||
|
## find codex proj dir -- assumes this script is in codex/benchmarks
|
||||||
|
result = currentSourcePath().parentDir.parentDir
|
||||||
|
|
||||||
func default*(tp: typedesc[CircuitEnv]): CircuitEnv =
|
func default*(tp: typedesc[CircuitEnv]): CircuitEnv =
|
||||||
result.nimCircuitCli = "vendor" / "codex-storage-proofs-circuits" / "reference" / "nim" / "proof_input" / "cli"
|
let codexDir = findCodexProjectDir()
|
||||||
result.circuitDirIncludes = "vendor" / "codex-storage-proofs-circuits" / "circuit"
|
result.nimCircuitCli = codexDir / "vendor" / "codex-storage-proofs-circuits" / "reference" / "nim" / "proof_input" / "cli"
|
||||||
result.ptauPath = "benchmarks" / "ceremony" / "powersOfTau28_hez_final_23.ptau"
|
result.circuitDirIncludes = codexDir / "vendor" / "codex-storage-proofs-circuits" / "circuit"
|
||||||
|
result.ptauPath = codexDir / "benchmarks" / "ceremony" / "powersOfTau28_hez_final_23.ptau"
|
||||||
result.ptauUrl = "https://storage.googleapis.com/zkevm/ptau/"
|
result.ptauUrl = "https://storage.googleapis.com/zkevm/ptau/"
|
||||||
result.codexProjDir = ""
|
result.codexProjDir = codexDir
|
||||||
|
|
||||||
template withDir(dir: string, blk: untyped) =
|
template withDir(dir: string, blk: untyped) =
|
||||||
|
## set working dir for duration of blk
|
||||||
let prev = getCurrentDir()
|
let prev = getCurrentDir()
|
||||||
try:
|
try:
|
||||||
setCurrentDir(dir)
|
setCurrentDir(dir)
|
||||||
@ -42,10 +47,6 @@ template runit(cmd: string) =
|
|||||||
echo "STATUS: ", cmdRes
|
echo "STATUS: ", cmdRes
|
||||||
assert cmdRes == 0
|
assert cmdRes == 0
|
||||||
|
|
||||||
proc findCodexProjectDir(): string =
|
|
||||||
## check that the CWD of script is in the codex parent
|
|
||||||
result = currentSourcePath.parentDir()
|
|
||||||
|
|
||||||
proc checkEnv*(env: var CircuitEnv) =
|
proc checkEnv*(env: var CircuitEnv) =
|
||||||
## check that the CWD of script is in the codex parent
|
## check that the CWD of script is in the codex parent
|
||||||
let codexProjDir = findCodexProjectDir()
|
let codexProjDir = findCodexProjectDir()
|
||||||
@ -82,13 +83,8 @@ proc checkEnv*(env: var CircuitEnv) =
|
|||||||
echo "CWD: ", getCurrentDir()
|
echo "CWD: ", getCurrentDir()
|
||||||
assert env.nimCircuitCli.fileExists()
|
assert env.nimCircuitCli.fileExists()
|
||||||
|
|
||||||
env.nimCircuitCli = env.nimCircuitCli.absolutePath()
|
|
||||||
echo "Found NimCircuitCli: ", env.nimCircuitCli
|
echo "Found NimCircuitCli: ", env.nimCircuitCli
|
||||||
|
|
||||||
env.circuitDirIncludes = env.circuitDirIncludes.absolutePath
|
|
||||||
echo "Found Circuit Path: ", env.circuitDirIncludes
|
echo "Found Circuit Path: ", env.circuitDirIncludes
|
||||||
|
|
||||||
env.ptauPath = env.ptauPath.absolutePath
|
|
||||||
echo "Found PTAU file: ", env.ptauPath
|
echo "Found PTAU file: ", env.ptauPath
|
||||||
|
|
||||||
proc downloadPtau*(ptauPath, ptauUrl: string) =
|
proc downloadPtau*(ptauPath, ptauUrl: string) =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user