Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
Format dc4bc + code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyWh1te committed Dec 16, 2022
1 parent 617c4f5 commit 7a391fa
Show file tree
Hide file tree
Showing 42 changed files with 97 additions and 87 deletions.
3 changes: 2 additions & 1 deletion airgapped/airgapped.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (
"github.com/corestario/kyber"
"github.com/corestario/kyber/encrypt/ecies"
vss "github.com/corestario/kyber/share/vss/rabin"
"github.com/syndtr/goleveldb/leveldb"

client "github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/dkg"
"github.com/lidofinance/dc4bc/fsm/fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines/dkg_proposal_fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines/signature_proposal_fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines/signing_proposal_fsm"
"github.com/lidofinance/dc4bc/fsm/types/requests"
"github.com/syndtr/goleveldb/leveldb"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion airgapped/airgapped_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/require"

client "github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/fsm/fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines/dkg_proposal_fsm"
Expand All @@ -18,7 +20,6 @@ import (
"github.com/lidofinance/dc4bc/fsm/types/requests"
"github.com/lidofinance/dc4bc/fsm/types/responses"
"github.com/lidofinance/dc4bc/storage"
"github.com/stretchr/testify/require"
)

const (
Expand Down
1 change: 1 addition & 0 deletions airgapped/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/corestario/kyber/pairing"
"github.com/corestario/kyber/sign/bls"
"github.com/corestario/kyber/sign/tbls"

client "github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/fsm/state_machines/signing_proposal_fsm"
"github.com/lidofinance/dc4bc/fsm/types/requests"
Expand Down
1 change: 1 addition & 0 deletions airgapped/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/corestario/kyber"
dkgPedersen "github.com/corestario/kyber/share/dkg/pedersen"

client "github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/dkg"
"github.com/lidofinance/dc4bc/fsm/state_machines/dkg_proposal_fsm"
Expand Down
3 changes: 2 additions & 1 deletion airgapped/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (

bls12381 "github.com/corestario/kyber/pairing/bls12381"

client "github.com/lidofinance/dc4bc/client/types"
"github.com/syndtr/goleveldb/leveldb"
"github.com/tyler-smith/go-bip39"
"golang.org/x/crypto/pbkdf2"

client "github.com/lidofinance/dc4bc/client/types"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion airgapped/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"os"
"testing"

client "github.com/lidofinance/dc4bc/client/types"
"github.com/stretchr/testify/require"

client "github.com/lidofinance/dc4bc/client/types"
)

func TestMachine_DropOperationsLog(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion airgapped/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"strings"

"github.com/lidofinance/dc4bc/dkg"
"github.com/syndtr/goleveldb/leveldb/util"

"github.com/lidofinance/dc4bc/dkg"
)

const (
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/censync/go-dto"
"github.com/censync/go-validator"
"github.com/labstack/echo/v4"

. "github.com/lidofinance/dc4bc/client/api/dto"
cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
req "github.com/lidofinance/dc4bc/client/api/http_api/requests"
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"

"github.com/labstack/echo/v4"

. "github.com/lidofinance/dc4bc/client/api/dto"
cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
req "github.com/lidofinance/dc4bc/client/api/http_api/requests"
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"

"github.com/labstack/echo/v4"

cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
)

Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"

"github.com/labstack/echo/v4"

. "github.com/lidofinance/dc4bc/client/api/dto"
cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
req "github.com/lidofinance/dc4bc/client/api/http_api/requests"
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/labstack/echo/v4"

. "github.com/lidofinance/dc4bc/client/api/dto"
cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
req "github.com/lidofinance/dc4bc/client/api/http_api/requests"
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/google/uuid"

"github.com/labstack/echo/v4"

. "github.com/lidofinance/dc4bc/client/api/dto"
cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
req "github.com/lidofinance/dc4bc/client/api/http_api/requests"
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/labstack/echo/v4"

. "github.com/lidofinance/dc4bc/client/api/dto"
cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
req "github.com/lidofinance/dc4bc/client/api/http_api/requests"
Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/handlers/username.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"

"github.com/labstack/echo/v4"

cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
)

Expand Down
4 changes: 2 additions & 2 deletions client/api/http_api/http_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package http_api
import (
"context"

"github.com/labstack/echo/v4"
echo_middleware "github.com/labstack/echo/v4/middleware"
"github.com/lidofinance/dc4bc/client/services"

"github.com/labstack/echo/v4"
"github.com/lidofinance/dc4bc/client/api/http_api/router"
"github.com/lidofinance/dc4bc/client/config"
"github.com/lidofinance/dc4bc/client/services"
"github.com/lidofinance/dc4bc/client/services/node"
)

Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

. "github.com/labstack/echo/v4"

cs "github.com/lidofinance/dc4bc/client/api/http_api/context_service"
)

Expand Down
1 change: 1 addition & 0 deletions client/api/http_api/router/default_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package router

import (
"github.com/labstack/echo/v4"

"github.com/lidofinance/dc4bc/client/api/http_api/handlers"
"github.com/lidofinance/dc4bc/client/services"
"github.com/lidofinance/dc4bc/client/services/node"
Expand Down
3 changes: 2 additions & 1 deletion client/modules/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"encoding/json"
"fmt"

"github.com/lidofinance/dc4bc/client/repositories/operation"
"github.com/syndtr/goleveldb/leveldb"

"github.com/lidofinance/dc4bc/client/repositories/operation"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion client/repositories/operation/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/lidofinance/dc4bc/client/modules/state"
"github.com/lidofinance/dc4bc/client/types"
"github.com/stretchr/testify/require"
)

func TestPutOperation(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion client/services/fsmservice/fsmservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/lidofinance/dc4bc/client/api/dto"
"github.com/lidofinance/dc4bc/mocks/clientMocks"
"github.com/lidofinance/dc4bc/mocks/storageMocks"
"github.com/stretchr/testify/require"
)

func TestClient_ResetState(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions client/services/node/adapt_dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

"github.com/google/uuid"

"github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/fsm/fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines/dkg_proposal_fsm"
Expand Down
11 changes: 5 additions & 6 deletions client/services/node/node_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ import (
"github.com/corestario/kyber/pairing"
"github.com/corestario/kyber/pairing/bls12381"
"github.com/corestario/kyber/sign/tbls"
"github.com/lidofinance/dc4bc/dkg"

"github.com/lidofinance/dc4bc/client/services/fsmservice"
"github.com/lidofinance/dc4bc/client/services/operation"
"github.com/lidofinance/dc4bc/client/services/signature"

"github.com/google/uuid"

"github.com/lidofinance/dc4bc/client/api/dto"
"github.com/lidofinance/dc4bc/client/config"
"github.com/lidofinance/dc4bc/client/modules/keystore"
"github.com/lidofinance/dc4bc/client/modules/logger"
"github.com/lidofinance/dc4bc/client/modules/state"
"github.com/lidofinance/dc4bc/client/services"
"github.com/lidofinance/dc4bc/client/services/fsmservice"
"github.com/lidofinance/dc4bc/client/services/operation"
"github.com/lidofinance/dc4bc/client/services/signature"
"github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/dkg"
"github.com/lidofinance/dc4bc/fsm/fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines"
dpf "github.com/lidofinance/dc4bc/fsm/state_machines/dkg_proposal_fsm"
Expand Down
9 changes: 4 additions & 5 deletions client/services/node/node_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/lidofinance/dc4bc/mocks/serviceMocks"
"github.com/stretchr/testify/require"

"github.com/lidofinance/dc4bc/client/config"
"github.com/lidofinance/dc4bc/client/modules/keystore"
Expand All @@ -17,12 +18,10 @@ import (
"github.com/lidofinance/dc4bc/fsm/state_machines"
spf "github.com/lidofinance/dc4bc/fsm/state_machines/signature_proposal_fsm"
"github.com/lidofinance/dc4bc/fsm/types/requests"
"github.com/lidofinance/dc4bc/storage"

"github.com/golang/mock/gomock"
"github.com/lidofinance/dc4bc/mocks/clientMocks"
"github.com/lidofinance/dc4bc/mocks/serviceMocks"
"github.com/lidofinance/dc4bc/mocks/storageMocks"
"github.com/stretchr/testify/require"
"github.com/lidofinance/dc4bc/storage"
)

func TestClient_ProcessMessage(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/airgapped/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"syscall"
"time"

"github.com/lidofinance/dc4bc/airgapped"
client "github.com/lidofinance/dc4bc/client/types"
"github.com/syndtr/goleveldb/leveldb"
"golang.org/x/crypto/ssh/terminal"

"github.com/lidofinance/dc4bc/airgapped"
client "github.com/lidofinance/dc4bc/client/types"
)

func init() {
Expand Down
12 changes: 5 additions & 7 deletions cmd/dc4bc_cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,20 @@ import (
"time"

"github.com/corestario/kyber/pairing/bls12381"
"github.com/lidofinance/dc4bc/dkg"
fsmtypes "github.com/lidofinance/dc4bc/fsm/types"
"github.com/lidofinance/dc4bc/pkg/utils"
"github.com/fatih/color"
"github.com/spf13/cobra"

httprequests "github.com/lidofinance/dc4bc/client/api/http_api/requests"
httpresponses "github.com/lidofinance/dc4bc/client/api/http_api/responses"

"github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/dkg"
"github.com/lidofinance/dc4bc/fsm/fsm"
"github.com/lidofinance/dc4bc/fsm/state_machines"
spf "github.com/lidofinance/dc4bc/fsm/state_machines/signature_proposal_fsm"
fsmtypes "github.com/lidofinance/dc4bc/fsm/types"
"github.com/lidofinance/dc4bc/fsm/types/requests"
"github.com/lidofinance/dc4bc/fsm/types/responses"

"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/lidofinance/dc4bc/pkg/utils"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions cmd/dc4bc_d/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"os/signal"
"syscall"

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

"github.com/lidofinance/dc4bc/client/api/http_api"
apiconfig "github.com/lidofinance/dc4bc/client/config"
"github.com/lidofinance/dc4bc/client/modules/keystore"
"github.com/lidofinance/dc4bc/client/services"
"github.com/lidofinance/dc4bc/client/services/node"

apiconfig "github.com/lidofinance/dc4bc/client/config"
"github.com/lidofinance/dc4bc/fsm/config"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions cmd/dkg_reinitializer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/lidofinance/dc4bc/pkg/utils"
"io/ioutil"
"log"
"os"

"github.com/lidofinance/dc4bc/client/services/node"
"github.com/lidofinance/dc4bc/pkg/utils"
"github.com/spf13/cobra"

"github.com/lidofinance/dc4bc/client/services/node"
"github.com/lidofinance/dc4bc/client/types"
"github.com/lidofinance/dc4bc/storage"
"github.com/spf13/cobra"
)

const (
Expand Down
18 changes: 10 additions & 8 deletions fsm/types/requests/dkg_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ type DKGProposalMasterKeyConfirmationRequest struct {
}

// States: "state_dkg_pub_keys_await_confirmations"
// "state_dkg_commits_sending_await_confirmations"
// "state_dkg_deals_await_confirmations"
// "state_dkg_responses_await_confirmations"
// "state_dkg_master_key_await_confirmations"
//
// "state_dkg_commits_sending_await_confirmations"
// "state_dkg_deals_await_confirmations"
// "state_dkg_responses_await_confirmations"
// "state_dkg_master_key_await_confirmations"
//
// Events: "event_dkg_pub_key_confirm_canceled_by_error",
// "event_dkg_commit_confirm_canceled_by_error"
// "event_dkg_deal_confirm_canceled_by_error"
// "event_dkg_response_confirm_canceled_by_error"
// "event_dkg_master_key_confirm_canceled_by_error"
//
// "event_dkg_commit_confirm_canceled_by_error"
// "event_dkg_deal_confirm_canceled_by_error"
// "event_dkg_response_confirm_canceled_by_error"
// "event_dkg_master_key_confirm_canceled_by_error"
type DKGProposalConfirmationErrorRequest struct {
ParticipantId int
Error *FSMError
Expand Down
3 changes: 2 additions & 1 deletion fsm/types/requests/signature_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type SignatureProposalParticipantsEntry struct {

// States: "__idle"
// Events: "event_sig_proposal_confirm_by_participant"
// "event_sig_proposal_decline_by_participant"
//
// "event_sig_proposal_decline_by_participant"
type SignatureProposalParticipantRequest struct {
ParticipantId int
CreatedAt time.Time
Expand Down
Loading

0 comments on commit 7a391fa

Please sign in to comment.