Skip to content
Open
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
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ module github.com/dgamingfoundation/dkglib
go 1.12

require (
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/cosmos/cosmos-sdk v0.28.2-0.20190827131926-5aacf454e1b6
github.com/dgamingfoundation/cosmos-utils/client v0.0.0-20191105143510-3ddb0501dfbd
github.com/dgamingfoundation/tendermint v0.27.3
github.com/dgamingfoundation/tendermint v0.27.4-0.20191209175603-06d02b9bd67a
github.com/stumble/gorocksdb v0.0.3 // indirect
github.com/tendermint/go-amino v0.15.1
github.com/tendermint/tendermint v0.32.6
go.dedis.ch/kyber/v3 v3.0.4
)

replace golang.org/x/crypto => github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5

replace github.com/tendermint/tendermint => github.com/dgamingfoundation/tendermint v0.27.4-0.20191113121517-26e7e4991bbf
replace github.com/tendermint/tendermint => ../tendermint

replace github.com/dgamingfoundation/tendermint => ../tendermint
1 change: 1 addition & 0 deletions lib/alias/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (m *DKGData) GetAddrString() string {
}

func (m *DKGData) ValidateBasic() error {
// TODO: at least check the signature.
return nil
}
39 changes: 32 additions & 7 deletions lib/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"github.com/dgamingfoundation/cosmos-utils/client/utils"
"github.com/dgamingfoundation/dkglib/lib/offChain"
"github.com/dgamingfoundation/dkglib/lib/onChain"
"github.com/dgamingfoundation/dkglib/lib/types"
dkg "github.com/dgamingfoundation/dkglib/lib/types"
"github.com/tendermint/go-amino"
tmtypes "github.com/tendermint/tendermint/alias"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/events"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/types"
sdk "github.com/tendermint/tendermint/types"
)

type DKGBasic struct {
Expand Down Expand Up @@ -66,14 +66,22 @@ func NewDKGBasic(
}, nil
}

func (m *DKGBasic) IsReady() bool {
if m == nil {
return false
}

return true
}

type MockFirer struct{}

func (m *MockFirer) FireEvent(event string, data events.EventData) {}

func (m *DKGBasic) HandleOffChainShare(
dkgMsg *dkg.DKGDataMessage,
height int64,
validators *types.ValidatorSet,
validators *sdk.ValidatorSet,
pubKey crypto.PubKey,
) bool {

Expand Down Expand Up @@ -109,7 +117,7 @@ func (m *DKGBasic) HandleOffChainShare(
return false
}

func (m *DKGBasic) runOnChainDKG(validators *types.ValidatorSet, logger log.Logger) bool {
func (m *DKGBasic) runOnChainDKG(validators *sdk.ValidatorSet, logger log.Logger) bool {
err := m.onChain.StartRound(
validators,
m.offChain.GetPrivValidator(),
Expand All @@ -135,7 +143,7 @@ func (m *DKGBasic) runOnChainDKG(validators *types.ValidatorSet, logger log.Logg
}
}

func (m *DKGBasic) CheckDKGTime(height int64, validators *types.ValidatorSet) {
func (m *DKGBasic) CheckDKGTime(height int64, validators *sdk.ValidatorSet) {
m.offChain.CheckDKGTime(height, validators)
}

Expand All @@ -151,6 +159,23 @@ func (m *DKGBasic) MsgQueue() chan *dkg.DKGDataMessage {
return m.offChain.MsgQueue()
}

func (m *DKGBasic) GetLosers() []*tmtypes.Validator {
return append(m.offChain.GetLosers(), m.onChain.GetLosers()...)
func (m *DKGBasic) GetLosers() []*dkg.DKGLoser {
// We only report verifiable on-chain losers.
return m.onChain.GetLosers()
}

func (m *DKGBasic) CheckLoserDuplicateData(loser *types.DKGLoser) bool {
return m.onChain.GetDealer().CheckLoserDuplicateData(loser)
}

func (m *DKGBasic) CheckLoserMissingData(loser *types.DKGLoser) bool {
return m.onChain.GetDealer().CheckLoserMissingData(loser)
}

func (m *DKGBasic) CheckLoserCorruptData(loser *types.DKGLoser) bool {
return m.onChain.GetDealer().CheckLoserCorruptData(loser)
}

func (m *DKGBasic) CheckLoserCorruptJustification(loser *types.DKGLoser) bool {
return m.onChain.GetDealer().CheckLoserCorruptJustification(loser)
}
Loading