diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-25 11:48:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 11:48:02 +0800 |
commit | 306d416fc794ddf803a1edc322ad7c7271743c9d (patch) | |
tree | c7ec4507628e268a68cc183e97e34b8bfb1514a6 | |
parent | 3bc4cb2b9bb26c739d7e80daf42509628501758e (diff) | |
download | dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.tar dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.tar.gz dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.tar.bz2 dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.tar.lz dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.tar.xz dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.tar.zst dexon-consensus-306d416fc794ddf803a1edc322ad7c7271743c9d.zip |
core: fix dkg complaint handling (#578)v1.0.0
-rw-r--r-- | core/configuration-chain.go | 12 | ||||
-rw-r--r-- | core/dkg-tsig-protocol.go | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/core/configuration-chain.go b/core/configuration-chain.go index 4e70ff0..3b4cdbb 100644 --- a/core/configuration-chain.go +++ b/core/configuration-chain.go @@ -70,6 +70,7 @@ type configurationChain struct { dkgLock sync.RWMutex dkgSigner map[uint64]*dkgShareSecret npks map[uint64]*typesDKG.NodePublicKeys + complaints []*typesDKG.Complaint dkgResult sync.RWMutex tsig map[common.Hash]*tsigProtocol tsigTouched map[common.Hash]struct{} @@ -321,8 +322,8 @@ func (cc *configurationChain) runDKGPhaseFour() { func (cc *configurationChain) runDKGPhaseFiveAndSix(round uint64, reset uint64) { // Phase 5(T = 2λ): Propose Anti nack complaint. cc.logger.Debug("Calling Governance.DKGComplaints", "round", round) - complaints := cc.gov.DKGComplaints(round) - if err := cc.dkg.processNackComplaints(complaints); err != nil { + cc.complaints = cc.gov.DKGComplaints(round) + if err := cc.dkg.processNackComplaints(cc.complaints); err != nil { cc.logger.Error("Failed to process NackComplaint", "round", round, "reset", reset, @@ -333,9 +334,9 @@ func (cc *configurationChain) runDKGPhaseFiveAndSix(round uint64, reset uint64) // Rebroadcast is done in `processPrivateShare`. } -func (cc *configurationChain) runDKGPhaseSeven(complaints []*typesDKG.Complaint) { +func (cc *configurationChain) runDKGPhaseSeven() { // Phase 7(T = 4λ): Enforce complaints and nack complaints. - cc.dkg.enforceNackComplaints(complaints) + cc.dkg.enforceNackComplaints(cc.complaints) // Enforce complaint is done in `processPrivateShare`. } @@ -425,8 +426,7 @@ func (cc *configurationChain) initDKGPhasesFunc() { return nil }, func(round uint64, reset uint64) error { - complaints := cc.gov.DKGComplaints(round) - cc.runDKGPhaseSeven(complaints) + cc.runDKGPhaseSeven() return nil }, func(round uint64, reset uint64) error { diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go index 8383ad1..d4235a4 100644 --- a/core/dkg-tsig-protocol.go +++ b/core/dkg-tsig-protocol.go @@ -392,6 +392,9 @@ func (d *dkgProtocol) processNackComplaints(complaints []*typesDKG.Complaint) ( func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) { for _, complaint := range complaints { + if d.round != complaint.Round || d.reset != complaint.Reset { + continue + } if !complaint.IsNack() { continue } |