Skip to content

Commit

Permalink
Merge pull request #158 from ssvlabs/unstable
Browse files Browse the repository at this point in the history
DKG v3.0.0
  • Loading branch information
MatusKysel authored Nov 19, 2024
2 parents 62ef8b3 + a00890a commit 3cf2e91
Show file tree
Hide file tree
Showing 1,584 changed files with 46,492 additions and 6,889 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.23"

- name: Build
run: go build -v ./...

- name: Test
run: go test ./... -timeout 3600s
run: go run gotest.tools/gotestsum@latest --format pkgname -- -timeout=7200s ./...

- name: Critic
run: go install -v github.com/go-critic/go-critic/cmd/gocritic@latest && gocritic check ./...
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
bin/
.vscode/
examples/*/output/*
integration_test/output

######## Node
# Logs
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use golang base image
FROM golang:1.20-alpine3.18 as build
FROM golang:1.23.0-alpine3.20 AS build

WORKDIR /ssv-dkg

Expand Down Expand Up @@ -27,11 +27,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
./cmd/ssv-dkg

# Final stage
FROM alpine:3.18
FROM alpine:3.20
WORKDIR /ssv-dkg

# Install openssl
RUN apk add --no-cache openssl
RUN apk add --no-cache openssl
RUN apk add --no-cache ca-certificates && update-ca-certificates

# Copy the built binary and entry-point script from the previous stage/build context
COPY --from=build /bin/ssv-dkg /bin/ssv-dkg
Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ build:
# Recipe to run tests
test:
@echo "running tests"
go run gotest.tools/gotestsum@latest --format testname
go run gotest.tools/gotestsum@latest --format pkgname --jsonfile test-output.log -- -timeout=3600s ./...

# Recipe to build the Docker image
docker-build-image:
Expand All @@ -40,16 +40,36 @@ docker-build-image:

docker-demo-operators:
@echo "Running operators in docker demo"
docker-compose up --build operator1 operator2 operator3 operator4 operator5 operator6 operator7 operator8
docker-compose up --build operator1 operator2 operator3 operator4 operator5 operator6 operator7 operator8 operator9 operator10 operator11 operator12 operator13

docker-demo-initiator:
@echo "Running initiator in docker demo"
docker-compose up --build initiator

docker-demo-generate-resign-msg:
@echo "Running generate re-sign message in docker demo"
docker-compose up --build generate-resign-msg

docker-demo-resign:
@echo "Running re-sign ceremony in docker demo"
docker-compose up --build resign

docker-demo-generate-reshare-msg:
@echo "Running generate re-share message in docker demo"
docker-compose up --build generate-reshare-msg

docker-demo-reshare:
@echo "Running re-share ceremony in docker demo"
docker-compose up --build reshare

docker-demo-ping:
@echo "Running ping operators in docker demo"
docker-compose up --build ping

docker-demo-ethnode:
@echo "Running ethereum node in docker demo"
docker-compose up --build ethnode

docker-operator:
@echo "Running operator docker, make sure to update ./examples/operator1/congig/config.yaml"
docker run \
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [DKG](#dkg)
- [DKG tool by SSV](#dkg-tool-by-ssv)
- [Overview](#overview)
- [Minimum requirements](#minimum-requirements)
- [Initiator Quick start](#initiator-quick-start)
- [Check operators health](#healthcheck)
- [Obtaining Operators data](#obtaining-operators-data)
Expand Down Expand Up @@ -56,6 +57,26 @@ In order for the DKG protocol to execute successfully:
For details on how to run the tool as an Operator, please head over [to this section containing the related instructions](#operator-quick-start).
Similarly, head over to [this other section](#initiator-quick-start) for instructions on how to launch the tool as the Initiator of the DKG ceremony.

## Minimum requirements

The tool is heavily reliant on cryptography, therefore computational power has a major impact on its performance.

The minimum requirement is an AWS t3.medium or equivalent machine dedicated to run DKG (https://aws.amazon.com/ec2/instance-types/).

The recommend requirement is an AWS t3.large or higher tier machine.

Please note: computational demands are raising depending on amount validators being created at once.

Minimum docker resource allocations:

```
deploy:
resources:
limits:
cpus: "1"
memory: 500M
```

## Initiator Quick start

### Obtaining Operators data
Expand Down
14 changes: 11 additions & 3 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ import (
"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/bloxapp/ssv-dkg/cli/initiator"
"github.com/bloxapp/ssv-dkg/cli/operator"
"github.com/bloxapp/ssv-dkg/cli/verify"
"github.com/ssvlabs/ssv-dkg/cli/initiator"
"github.com/ssvlabs/ssv-dkg/cli/operator"
"github.com/ssvlabs/ssv-dkg/cli/verify"
)

func init() {
RootCmd.AddCommand(initiator.StartDKG)
RootCmd.AddCommand(operator.StartDKGOperator)
RootCmd.AddCommand(initiator.HealthCheck)
RootCmd.AddCommand(verify.Verify)
RootCmd.AddCommand(initiator.GenerateResignMsg)
RootCmd.AddCommand(initiator.StartResigning)
RootCmd.AddCommand(initiator.GenerateReshareMsg)
RootCmd.AddCommand(initiator.StartReshare)
}

// RootCmd represents the root command of DKG-tool CLI
Expand All @@ -32,6 +36,10 @@ func Execute(appName, version string) {
RootCmd.Version = version
initiator.HealthCheck.Version = version
initiator.StartDKG.Version = version
initiator.GenerateResignMsg.Version = version
initiator.StartResigning.Version = version
initiator.GenerateReshareMsg.Version = version
initiator.StartReshare.Version = version
operator.StartDKGOperator.Version = version
if err := RootCmd.Execute(); err != nil {
log.Fatal("failed to execute root command", zap.Error(err))
Expand Down
110 changes: 110 additions & 0 deletions cli/flags/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package flags

import (
"fmt"
"path/filepath"

"github.com/spf13/cobra"
"github.com/spf13/viper"

cli_utils "github.com/ssvlabs/ssv-dkg/cli/utils"
)

// Flag names.
const (
logLevel = "logLevel"
logFormat = "logFormat"
logLevelFormat = "logLevelFormat"
logFilePath = "logFilePath"
configPath = "configPath"
outputPath = "outputPath"
)

// global base flags
var (
ConfigPath string
OutputPath string
LogLevel string
LogFormat string
LogLevelFormat string
LogFilePath string
)

func SetBaseFlags(cmd *cobra.Command) {
OutputPathFlag(cmd)
ConfigPathFlag(cmd)
LogLevelFlag(cmd)
LogFormatFlag(cmd)
LogLevelFormatFlag(cmd)
LogFilePathFlag(cmd)
}

// BindFlags binds flags to yaml config parameters
func BindBaseFlags(cmd *cobra.Command) error {
if err := viper.BindPFlag("outputPath", cmd.PersistentFlags().Lookup("outputPath")); err != nil {
return err
}
if err := viper.BindPFlag("configPath", cmd.PersistentFlags().Lookup("configPath")); err != nil {
return err
}
if err := viper.BindPFlag("logLevel", cmd.PersistentFlags().Lookup("logLevel")); err != nil {
return err
}
if err := viper.BindPFlag("logFormat", cmd.PersistentFlags().Lookup("logFormat")); err != nil {
return err
}
if err := viper.BindPFlag("logLevelFormat", cmd.PersistentFlags().Lookup("logLevelFormat")); err != nil {
return err
}
if err := viper.BindPFlag("logFilePath", cmd.PersistentFlags().Lookup("logFilePath")); err != nil {
return err
}
OutputPath = viper.GetString("outputPath")
if OutputPath != "" {
OutputPath = filepath.Clean(OutputPath)
}
if !filepath.IsLocal(OutputPath) {
return fmt.Errorf("😥 wrong OutputPath flag, should be local")
}
if err := cli_utils.CreateDirIfNotExist(OutputPath); err != nil {
return err
}
LogLevel = viper.GetString("logLevel")
LogFormat = viper.GetString("logFormat")
LogLevelFormat = viper.GetString("logLevelFormat")
LogFilePath = viper.GetString("logFilePath")
if !filepath.IsLocal(LogFilePath) {
return fmt.Errorf("😥 wrong logFilePath flag, should be local")
}
return nil
}

// LogLevelFlag logger's log level flag to the command
func LogLevelFlag(c *cobra.Command) {
AddPersistentStringFlag(c, logLevel, "debug", "Defines logger's log level", false)
}

// LogFormatFlag logger's logger's encoding flag to the command
func LogFormatFlag(c *cobra.Command) {
AddPersistentStringFlag(c, logFormat, "json", "Defines logger's encoding, valid values are 'json' (default) and 'console'", false)
}

// LogLevelFormatFlag logger's level format flag to the command
func LogLevelFormatFlag(c *cobra.Command) {
AddPersistentStringFlag(c, logLevelFormat, "capitalColor", "Defines logger's level format, valid values are 'capitalColor' (default), 'capital' or 'lowercase'", false)
}

// LogFilePathFlag file path to write logs into
func LogFilePathFlag(c *cobra.Command) {
AddPersistentStringFlag(c, logFilePath, "debug.log", "Defines a file path to write logs into", false)
}

// ConfigPathFlag config path flag to the command
func ConfigPathFlag(c *cobra.Command) {
AddPersistentStringFlag(c, configPath, "", "Path to config file", false)
}

// OutputPathFlag sets the path to store resulting files
func OutputPathFlag(c *cobra.Command) {
AddPersistentStringFlag(c, outputPath, "./output", "Path to store results", false)
}
Loading

0 comments on commit 3cf2e91

Please sign in to comment.