diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-23 14:13:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-23 14:13:58 +0800 |
commit | 50e7b0fcb7fd78218be68f32f818713e6933a9e8 (patch) | |
tree | fa94e72569a31fb1b22472b62f94697f23d834db /core | |
parent | e909644bdb92ea827c0f5b0a850bce0217d02e08 (diff) | |
download | tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.tar tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.tar.gz tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.tar.bz2 tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.tar.lz tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.tar.xz tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.tar.zst tangerine-consensus-50e7b0fcb7fd78218be68f32f818713e6933a9e8.zip |
core: add round parameter to ProposeCRS method (#244)
Since all DKG set members may ProposeCRS, but only one will get through,
we need to be able to tell which round the CRS is intended for in order
to skip CRS submission of the same round.
Also this commit add check to make sure we have enough master public key
when initializing DKGGroupPublicKey.
Diffstat (limited to 'core')
-rw-r--r-- | core/consensus.go | 4 | ||||
-rw-r--r-- | core/dkg-tsig-protocol.go | 7 | ||||
-rw-r--r-- | core/interfaces.go | 2 | ||||
-rw-r--r-- | core/test/governance.go | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/core/consensus.go b/core/consensus.go index f9b8b37..18294ef 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -540,9 +540,9 @@ func (con *Consensus) runCRS() { con.logger.Error("Failed to run CRS Tsig", "error", err) } else { con.logger.Debug("Calling Governance.ProposeCRS", - "round", con.round, + "round", con.round+1, "crs", crs) - con.gov.ProposeCRS(crs) + con.gov.ProposeCRS(con.round+1, crs) } } } diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go index 1b5f547..bb41931 100644 --- a/core/dkg-tsig-protocol.go +++ b/core/dkg-tsig-protocol.go @@ -37,6 +37,8 @@ var ( "private share not found for specific ID") ErrNotReachThreshold = fmt.Errorf( "threshold not reach") + ErrInvalidThreshold = fmt.Errorf( + "invalid threshold") ErrIncorrectPrivateShareSignature = fmt.Errorf( "incorrect private share signature") ErrMismatchPartialSignatureHash = fmt.Errorf( @@ -352,6 +354,11 @@ func NewDKGGroupPublicKey( mpks []*types.DKGMasterPublicKey, complaints []*types.DKGComplaint, threshold int) ( *DKGGroupPublicKey, error) { + + if len(mpks) < threshold { + return nil, ErrInvalidThreshold + } + // Calculate qualify members. disqualifyIDs := map[types.NodeID]struct{}{} complaintsByID := map[types.NodeID]int{} diff --git a/core/interfaces.go b/core/interfaces.go index 97ab0a3..7b985cf 100644 --- a/core/interfaces.go +++ b/core/interfaces.go @@ -97,7 +97,7 @@ type Governance interface { CRS(round uint64) common.Hash // Propose a CRS of round. - ProposeCRS(signedCRS []byte) + ProposeCRS(round uint64, signedCRS []byte) // NodeSet returns the node set at a given round. // Return the genesis node set if round == 0. diff --git a/core/test/governance.go b/core/test/governance.go index 88aab37..21c04f6 100644 --- a/core/test/governance.go +++ b/core/test/governance.go @@ -120,7 +120,7 @@ func (g *Governance) NotifyRoundHeight(round, height uint64) { } // ProposeCRS propose a CRS. -func (g *Governance) ProposeCRS(signedCRS []byte) { +func (g *Governance) ProposeCRS(round uint64, signedCRS []byte) { g.lock.Lock() defer g.lock.Unlock() crs := crypto.Keccak256Hash(signedCRS) |