diff --git a/cmd/zetaclientd/gen_pre_params.go b/cmd/zetaclientd/gen_pre_params.go new file mode 100644 index 0000000000..c797a9f206 --- /dev/null +++ b/cmd/zetaclientd/gen_pre_params.go @@ -0,0 +1,40 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "time" + + "github.com/binance-chain/tss-lib/ecdsa/keygen" + "github.com/spf13/cobra" +) + +func init() { + RootCmd.AddCommand(GenPrePramsCmd) +} + +var GenPrePramsCmd = &cobra.Command{ + Use: "gen-pre-params ", + Short: "Generate pre parameters for TSS", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + startTime := time.Now() + preParams, err := keygen.GeneratePreParams(time.Second * 300) + if err != nil { + return err + } + + file, err := os.OpenFile(args[0], 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 + }, +} diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index 170746968d..d7fd1d7dde 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -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 ~/preParams.json + # Wait for authorized_keys file to exist (generated by zetacore0) while [ ! -f ~/.ssh/authorized_keys ]; do echo "Waiting for authorized_keys file to exist..."