Skip to content

Commit

Permalink
cmd: wire dkg command
Browse files Browse the repository at this point in the history
  • Loading branch information
corverroos committed May 5, 2022
1 parent c815250 commit eb45a38
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/obolnetwork/charon/app"
"github.com/obolnetwork/charon/app/errors"
"github.com/obolnetwork/charon/dkg"
)

const (
Expand All @@ -46,13 +47,14 @@ func New() *cobra.Command {
newRunCmd(app.Run),
newBootnodeCmd(RunBootnode),
newCreateClusterCmd(runCreateCluster),
newDKGCmd(dkg.Run),
)
}

func newRootCmd(cmds ...*cobra.Command) *cobra.Command {
root := &cobra.Command{
Use: "charon",
Short: "Charon - The Ethereum DVT middleware client",
Short: "Charon - Proof of Stake Ethereum Distributed Validator Client",
Long: `Charon enables the operation of Ethereum validators in a fault tolerant manner by splitting the validating keys across a group of trusted parties using threshold cryptography.`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return initializeConfig(cmd)
Expand Down
52 changes: 52 additions & 0 deletions cmd/dkg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright © 2022 Obol Labs Inc.
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.

package cmd

import (
"context"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/obolnetwork/charon/dkg"
)

func newDKGCmd(runFunc func(context.Context, dkg.Config) error) *cobra.Command {
var config dkg.Config

cmd := &cobra.Command{
Use: "dkg",
Short: "Create distributed validator key shares by participating in a DKG ceremony",
Long: `Participate in a distributed key generation ceremony for a specific cluster definition that creates
distributed validator key shares and a final cluster lock configuration. Note that all other cluster operators should run
this command at the same time.`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return runFunc(cmd.Context(), config)
},
}

bindDataDirFlag(cmd.Flags(), &config.DataDir)
bindDefDirFlag(cmd.Flags(), &config.DefFile)
bindP2PFlags(cmd.Flags(), &config.P2P)
bindLogFlags(cmd.Flags(), &config.Log)

return cmd
}

func bindDefDirFlag(flags *pflag.FlagSet, dataDir *string) {
flags.StringVar(dataDir, "definition-file", ".charon/cluster_definition.json", "The path to the cluster definition file.")
}

0 comments on commit eb45a38

Please sign in to comment.