Skip to content

Commit

Permalink
update configs and paths to store
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkrolevets committed Sep 19, 2023
1 parent 18c0b58 commit 79805c5
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ssv-dkg-tool
# ssv-dkg

### Build

Expand Down
4 changes: 2 additions & 2 deletions cli/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ func GetNetworkFlag(c *cobra.Command) (string, error) {
}

func AddDepositResultStorePathFlag(c *cobra.Command) {
AddPersistentStringFlag(c, depositResultsPath, "", "Path to store deposit result file json", false)
AddPersistentStringFlag(c, depositResultsPath, "./", "Path to store deposit result file json", false)
}

func GetDepositResultStorePathFlag(c *cobra.Command) (string, error) {
return c.Flags().GetString(depositResultsPath)
}

func AddSSVPayloadResultStorePathFlag(c *cobra.Command) {
AddPersistentStringFlag(c, ssvPayloadResultsPath, "", "Path to store ssv contract payload file json", false)
AddPersistentStringFlag(c, ssvPayloadResultsPath, "./", "Path to store ssv contract payload file json", false)
}

func GetSSVPayloadResultStorePathFlag(c *cobra.Command) (string, error) {
Expand Down
14 changes: 7 additions & 7 deletions cli/initiator/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var StartDKG = &cobra.Command{
logger.Fatal(err.Error())
}
if configPath != "" {
viper.AddConfigPath(configPath)
viper.SetConfigFile(configPath)
} else {
viper.AddConfigPath("./config")
}
Expand All @@ -101,17 +101,17 @@ var StartDKG = &cobra.Command{
logger.Fatal("failed to get deposit result path flag value", zap.Error(err))
}
_, err = os.Stat(depositResultsPath)
if !os.IsNotExist(err) {
logger.Fatal("Deposit file at provided path already exist", zap.Error(err))
if os.IsNotExist(err) {
logger.Fatal("Folder to store deposit file does not exist", zap.Error(err))
}
// Check paths for results
ssvPayloadResultsPath := viper.GetString("ssvPayloadResultsPath")
if ssvPayloadResultsPath == "" {
logger.Fatal("failed to get ssv payload path flag value", zap.Error(err))
}
_, err = os.Stat(ssvPayloadResultsPath)
if !os.IsNotExist(err) {
logger.Fatal("SSV payload file at provided path already exist", zap.Error(err))
if os.IsNotExist(err) {
logger.Fatal("Folder to store SSV payload file does not exist", zap.Error(err))
}
// Load operators TODO: add more sources.
operatorFile := viper.GetString("operatorsInfoPath")
Expand Down Expand Up @@ -202,13 +202,13 @@ var StartDKG = &cobra.Command{
}
// Save deposit file
logger.Info("DKG finished. All data is validated. Writing deposit data json to file %s\n", zap.String("path", depositResultsPath))
err = utils.WriteJSON(depositResultsPath, []initiator.DepositDataJson{*depositData})
err = utils.WriteJSON(depositResultsPath+"deposit_"+fmt.Sprint(depositData.PubKey)+".json", []initiator.DepositDataJson{*depositData})
if err != nil {
logger.Warn("Failed writing deposit data file", zap.Error(err))
}

logger.Info("DKG finished. All data is validated. Writing keyshares to file: %s\n", zap.String("path", ssvPayloadResultsPath))
err = utils.WriteJSON(ssvPayloadResultsPath, keyShares)
err = utils.WriteJSON(ssvPayloadResultsPath+"payload_"+fmt.Sprint(depositData.PubKey)+".json", keyShares)
if err != nil {
logger.Warn("Failed writing keyshares file", zap.Error(err))
}
Expand Down
2 changes: 1 addition & 1 deletion cli/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var StartDKGOperator = &cobra.Command{
logger.Fatal(err.Error())
}
if configPath != "" {
viper.AddConfigPath(configPath)
viper.SetConfigFile(configPath)
} else {
viper.AddConfigPath("./config")
}
Expand Down
4 changes: 2 additions & 2 deletions examples/config/initiator.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ owner: "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494"
nonce: 4
fork: "mainnet"
operatorsInfoPath: /data/docker_operators.json
depositResultsPath: /data/deposit.json
ssvPayloadResultsPath: /data/payload.json
depositResultsPath: /data/output/
ssvPayloadResultsPath: /data/output/
initiatorPrivKey: /data/initiator/encrypted_private_key.json
initiatorPrivKeyPassword: /data/initiator/password
4 changes: 2 additions & 2 deletions examples/config/operator1.example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
privKey: ./encrypted_private_key.json
password: ./password
privKey: /data/operator1/encrypted_private_key.json
password: /data/operator1/password
port: 3030
storeShare: true
6 changes: 3 additions & 3 deletions examples/config/operator2.example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
privKey: ./encrypted_private_key.json
password: ./password
port: 3031
privKey: /data/operator2/encrypted_private_key.json
password: /data/operator2/password
port: 3030
storeShare: true
6 changes: 3 additions & 3 deletions examples/config/operator3.example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
privKey: ./encrypted_private_key.json
password: ./password
port: 3032
privKey: /data/operator3/encrypted_private_key.json
password: /data/operator3/password
port: 3030
storeShare: true
6 changes: 3 additions & 3 deletions examples/config/operator4.example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
privKey: ./encrypted_private_key.json
password: ./password
port: 3033
privKey: /data/operator4/encrypted_private_key.json
password: /data/operator4/password
port: 3030
storeShare: true

0 comments on commit 79805c5

Please sign in to comment.