Skip to content

Commit 7c854c5

Browse files
committed
zkCircuits: fix BaseDir handling
until now, voconed didn't put the files inside VOCONED_DIR now: * `go test ./...` uses ~/.cache/vocdoni/zkCircuits/ * `node` uses ~/.vocdoni/zkCircuits/ * `voconed` uses ~/.voconed/zkCircuits/ and both `node` and `voconed` use `/app/run/zkCircuits` when inside docker
1 parent 0a35fad commit 7c854c5

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

cmd/node/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func main() {
348348

349349
// Overwrite the default path to download the zksnarks circuits artifacts
350350
// using the global datadir as parent folder.
351-
circuit.BaseDir = filepath.Join(globalCfg.DataDir, circuit.BaseDir)
351+
circuit.BaseDir = filepath.Join(globalCfg.DataDir, "zkCircuits")
352352

353353
// Ensure we can have at least 8k open files. This is necessary, since
354354
// many components like IPFS and Tendermint require keeping many active

cmd/voconed/voconed.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/spf13/viper"
1717
"go.vocdoni.io/dvote/api/faucet"
1818
"go.vocdoni.io/dvote/crypto/ethereum"
19+
"go.vocdoni.io/dvote/crypto/zk/circuit"
1920
"go.vocdoni.io/dvote/internal"
2021
"go.vocdoni.io/dvote/log"
2122
"go.vocdoni.io/dvote/vochain/state"
@@ -178,6 +179,10 @@ func main() {
178179

179180
log.Infof("using data directory at %s", config.dir)
180181

182+
// Overwrite the default path to download the zksnarks circuits artifacts
183+
// using the global datadir as parent folder.
184+
circuit.BaseDir = filepath.Join(config.dir, "zkCircuits")
185+
181186
mngKey := ethereum.SignKeys{}
182187
if err := mngKey.AddHexKey(config.keymanager); err != nil {
183188
log.Fatal(err)

crypto/zk/circuit/circuit.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,17 @@ var downloadCircuitsTimeout = time.Minute * 5
1919

2020
// BaseDir is where the artifact cache is expected to be found.
2121
// If the artifacts are not found there, they will be downloaded and stored.
22-
// If unset ("") it will default to ~/.cache/vocdoni/zkCircuits/
22+
//
23+
// Defaults to ~/.cache/vocdoni/zkCircuits/
2324
//
2425
// In any case, the LocalDir path associated with the circuit config will be appended at the end
25-
var BaseDir = ""
26-
27-
func init() {
28-
// if base dir is unset, default to ~/.cache/vocdoni/
29-
if BaseDir == "" {
30-
home, err := os.UserHomeDir()
31-
if err != nil {
32-
panic(err)
33-
}
34-
BaseDir = home + "/.cache/vocdoni/zkCircuits"
26+
var BaseDir = func() string {
27+
home, err := os.UserHomeDir()
28+
if err != nil {
29+
panic(err)
3530
}
36-
}
31+
return filepath.Join(home, ".cache", "vocdoni", "zkCircuits")
32+
}()
3733

3834
// ZkCircuit struct wraps the circuit configuration and contains the file
3935
// content of the circuit artifacts (provingKey, verificationKey and wasm)

dockerfiles/vocone/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
IMAGE_TAG=main
22
# VOCONED_KEYMANAGER=571063b70545d01b8c130bb411b5f0220e06b8db236bb12e77ae478f7078b77b
3+
VOCONED_DIR=/app/run
34
VOCONED_PORT=9090
45
VOCONED_URLPATH=/v2
56
VOCONED_BLOCKPERIOD=5

0 commit comments

Comments
 (0)