Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/rand"
"os"
"path/filepath"
"slices"
"strings"
"testing"

Expand Down Expand Up @@ -313,11 +314,5 @@ func TestDefinitionPeers(t *testing.T) {
}

func isAnyVersion(version string, list ...string) bool {
for _, v := range list {
if version == v {
return true
}
}

return false
return slices.Contains(list, version)
}
9 changes: 2 additions & 7 deletions cluster/manifest/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package manifest_test

import (
"math/rand"
"slices"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -28,13 +29,7 @@ const (
)

func isAnyVersion(version string, list ...string) bool {
for _, v := range list {
if version == v {
return true
}
}

return false
return slices.Contains(list, version)
}

func TestDuplicateENRs(t *testing.T) {
Expand Down
13 changes: 5 additions & 8 deletions cluster/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

package cluster

import "testing"
import (
"slices"
"testing"
)

const (
currentVersion = v1_10
Expand Down Expand Up @@ -40,13 +43,7 @@ var supportedVersions = map[string]bool{
}

func isAnyVersion(version string, versions ...string) bool {
for _, v := range versions {
if version == v {
return true
}
}

return false
return slices.Contains(versions, version)
}

func isV1x3(version string) bool {
Expand Down
9 changes: 2 additions & 7 deletions cmd/createcluster_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -1104,11 +1105,5 @@ func newObolAPIHandler(ctx context.Context, t *testing.T, result chan<- struct{}
}

func isAnyVersion(version string, versions ...string) bool {
for _, v := range versions {
if version == v {
return true
}
}

return false
return slices.Contains(versions, version)
}
15 changes: 13 additions & 2 deletions cmd/createdkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func newCreateDKGCmd(runFunc func(context.Context, createDKGConfig) error) *cobr
}

if config.Publish {
mustMarkFlagRequired(cmd, "operator-addresses")
cmd.MarkFlagsOneRequired("operator-addresses", "operator-enrs")
} else {
mustMarkFlagRequired(cmd, "operator-enrs")
}
Expand Down Expand Up @@ -334,6 +334,10 @@ func generateLaunchpadLink(configHash []byte, network string) string {
return "https://" + networkLink + "launchpad.obol.org/dv#" + fmt.Sprintf("%#x", configHash)
}

func generateAPILink(configHash []byte) string {
return "https://api.obol.tech/dv/" + fmt.Sprintf("%#x", configHash)
}

func publishPartialDefinition(ctx context.Context, conf createDKGConfig, privKey *k1.PrivateKey, def cluster.Definition) error {
apiClient, err := obolapi.New(conf.PublishAddress, obolapi.WithTimeout(10*time.Second))
if err != nil {
Expand All @@ -358,7 +362,14 @@ func publishPartialDefinition(ctx context.Context, conf createDKGConfig, privKey
}

log.Info(ctx, "Cluster Invitation Prepared")
log.Info(ctx, "Direct the Node Operators to: "+generateLaunchpadLink(def.ConfigHash, conf.Network)+" to review the cluster configuration and begin the distributed key generation ceremony.")

if len(conf.OperatorENRs) == 0 {
log.Info(ctx, "Direct the Node Operators to: "+generateLaunchpadLink(def.ConfigHash, conf.Network)+" to review the cluster configuration and begin the distributed key generation ceremony.")
} else {
log.Info(ctx, "Distributed Key Generation configuration created. Run one of the following commands from the directories where the associated .charon/charon-enr-private-key(s) that match these ENRs are: "+
"(Without docker): `charon dkg --definition-file="+generateAPILink(def.ConfigHash)+"` "+
"(With docker): `docker run --rm --it -v \"$(pwd):/opt/charon/.charon\" obolnetwork/charon:latest dkg --definition-file="+generateAPILink(def.ConfigHash)+"`")
}

return nil
}
2 changes: 1 addition & 1 deletion dkg/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func Run(ctx context.Context, conf Config) (err error) {

// This DKG only supports a few specific config versions.
if def.Version != "v1.6.0" && def.Version != "v1.7.0" && def.Version != "v1.8.0" && def.Version != "v1.9.0" && def.Version != "v1.10.0" {
return errors.New("only v1.6.0, v1.7.0 and v1.8.0 cluster definition versions supported")
return errors.New("only v1.6.0 and newer cluster definition versions supported")
}

if err := validateKeymanagerFlags(ctx, conf.KeymanagerAddr, conf.KeymanagerAuthToken); err != nil {
Expand Down
Loading