diff options
author | Mission Liao <mission.liao@dexon.org> | 2019-03-17 09:56:23 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-17 09:56:23 +0800 |
commit | 4b40c1b8990d2a371a77018feea32d038163f2ec (patch) | |
tree | b482aee945e1f60c6c9c9efd86c39abe812a353b /core/consensus.go | |
parent | b636901c60aa666c6c6b532d06e78b529537d315 (diff) | |
download | dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.tar dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.tar.gz dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.tar.bz2 dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.tar.lz dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.tar.xz dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.tar.zst dexon-consensus-4b40c1b8990d2a371a77018feea32d038163f2ec.zip |
dkg: add reset field (#492)
* Add Reset fields to DKG types
* Fix crypto part after adding Reset field
* Prohibit DKG messages with different resetCount
* Add TODO
* Add reset parameter to dkgProtocol constructor
* Add TODO
* Fix inconsist hash to prepare CRS
* Add reset parameter when runnning DKG
* Fix test for utils.RoundEvent
* Add dummy test to prohibit DKG messages with unexpected reset count
* Fix test.App
Diffstat (limited to 'core/consensus.go')
-rw-r--r-- | core/consensus.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/consensus.go b/core/consensus.go index 8529e40..e0a6753 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -740,7 +740,7 @@ func (con *Consensus) prepare( con.logger.Info("Selected as DKG set", "round", nextRound) nextConfig := utils.GetConfigWithPanic(con.gov, nextRound, con.logger) - con.cfgModule.registerDKG(nextRound, utils.GetDKGThreshold( + con.cfgModule.registerDKG(nextRound, e.Reset, utils.GetDKGThreshold( nextConfig)) con.event.RegisterHeight(e.NextDKGPreparationHeight(), func(uint64) { @@ -749,7 +749,7 @@ func (con *Consensus) prepare( defer con.dkgReady.L.Unlock() con.dkgRunning = 0 }() - con.runDKG(nextRound, nextConfig) + con.runDKG(nextRound, e.Reset, nextConfig) }) }) }) @@ -805,7 +805,7 @@ func (con *Consensus) Run() { } // runDKG starts running DKG protocol. -func (con *Consensus) runDKG(round uint64, config *types.Config) { +func (con *Consensus) runDKG(round, reset uint64, config *types.Config) { con.dkgReady.L.Lock() defer con.dkgReady.L.Unlock() if con.dkgRunning != 0 { @@ -819,7 +819,7 @@ func (con *Consensus) runDKG(round uint64, config *types.Config) { con.dkgReady.Broadcast() con.dkgRunning = 2 }() - if err := con.cfgModule.runDKG(round); err != nil { + if err := con.cfgModule.runDKG(round, reset); err != nil { con.logger.Error("Failed to runDKG", "error", err) } }() @@ -841,8 +841,7 @@ func (con *Consensus) runCRS(round uint64, hash common.Hash) { "hash", psig.Hash) con.network.BroadcastDKGPartialSignature(psig) con.logger.Debug("Calling Governance.CRS", "round", round) - crs, err := con.cfgModule.runCRSTSig( - round, utils.GetCRSWithPanic(con.gov, round, con.logger)) + crs, err := con.cfgModule.runCRSTSig(round, hash) if err != nil { con.logger.Error("Failed to run CRS Tsig", "error", err) } else { |