Skip to content

Commit

Permalink
add zetaclientd gen-pre-params command
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 20, 2024
1 parent 3e7855d commit d6afe15
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
45 changes: 45 additions & 0 deletions cmd/zetaclientd/gen_pre_params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"encoding/json"
"fmt"
"os"
"time"

"github.com/binance-chain/tss-lib/ecdsa/keygen"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

func init() {
RootCmd.AddCommand(GenPrePramsCmd)
}

var GenPrePramsCmd = &cobra.Command{
Use: "gen-pre-params",
Short: "Generate pre parameters for TSS",
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := config.Load(rootArgs.zetaCoreHome)
if err != nil {
return err
}

startTime := time.Now()
preParams, err := keygen.GeneratePreParams(time.Second * 300)
if err != nil {
return err
}

file, err := os.OpenFile(cfg.PreParamsPath, os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
return err
}
defer file.Close()
err = json.NewEncoder(file).Encode(preParams)
if err != nil {
return err
}
fmt.Printf("Generated new pre-parameters in %v\n", time.Since(startTime))
return nil
},
}
6 changes: 6 additions & 0 deletions contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ set_sepolia_endpoint() {
jq '.EVMChainConfigs."11155111".Endpoint = "http://eth2:8545"' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json
}

# generate pre-params as early as possible
# to reach keygen height in time
#
# consider caching these on a docker volume
zetaclientd gen-pre-params

# Wait for authorized_keys file to exist (generated by zetacore0)
while [ ! -f ~/.ssh/authorized_keys ]; do
echo "Waiting for authorized_keys file to exist..."
Expand Down

0 comments on commit d6afe15

Please sign in to comment.