diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-08 15:31:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-08 15:31:25 +0800 |
commit | 337b5729c1cea837ac5ee8e1646dca587f52ebbd (patch) | |
tree | 62fcfb7e2586ec2f69323f7c15e53fccb7e20357 | |
parent | 1ea06aaeda901ed8c5bfa0dd8341f232038b4bd9 (diff) | |
download | dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.tar dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.tar.gz dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.tar.bz2 dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.tar.lz dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.tar.xz dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.tar.zst dexon-consensus-337b5729c1cea837ac5ee8e1646dca587f52ebbd.zip |
core: run TSig forever when ForceSync (#554)
-rw-r--r-- | core/configuration-chain.go | 7 | ||||
-rw-r--r-- | core/configuration-chain_test.go | 8 | ||||
-rw-r--r-- | core/consensus.go | 6 |
3 files changed, 12 insertions, 9 deletions
diff --git a/core/configuration-chain.go b/core/configuration-chain.go index fbd504d..4a99d3d 100644 --- a/core/configuration-chain.go +++ b/core/configuration-chain.go @@ -662,7 +662,7 @@ func (cc *configurationChain) untouchTSigHash(hash common.Hash) { } func (cc *configurationChain) runTSig( - round uint64, hash common.Hash) ( + round uint64, hash common.Hash, wait time.Duration) ( crypto.Signature, error) { npks, _, _ := cc.getDKGInfo(round, false) if npks == nil { @@ -687,8 +687,7 @@ func (cc *configurationChain) runTSig( }() timeout := make(chan struct{}, 1) go func() { - // TODO(jimmy-dexon): make timeout configurable. - time.Sleep(5 * time.Second) + time.Sleep(wait) timeout <- struct{}{} cc.tsigReady.Broadcast() }() @@ -714,7 +713,7 @@ func (cc *configurationChain) runTSig( func (cc *configurationChain) runCRSTSig( round uint64, crs common.Hash) ([]byte, error) { - sig, err := cc.runTSig(round, crs) + sig, err := cc.runTSig(round, crs, cc.gov.Configuration(round).LambdaDKG*5) cc.logger.Info("CRS", "nodeID", cc.ID, "round", round+1, diff --git a/core/configuration-chain_test.go b/core/configuration-chain_test.go index c3a8023..61f0906 100644 --- a/core/configuration-chain_test.go +++ b/core/configuration-chain_test.go @@ -331,7 +331,7 @@ func (s *ConfigurationChainTestSuite) TestConfigurationChain() { continue } go func(cc *configurationChain) { - tsig, err := cc.runTSig(round, hash) + tsig, err := cc.runTSig(round, hash, 5*time.Second) // Prevent racing by collecting errors and check in main thread. errs <- err tsigChan <- tsig @@ -547,13 +547,13 @@ func (s *ConfigurationChainTestSuite) TestMultipleTSig() { continue } go func(cc *configurationChain) { - tsig1, err := cc.runTSig(round, hash1) + tsig1, err := cc.runTSig(round, hash1, 5*time.Second) // Prevent racing by collecting errors and check in main thread. errs <- err tsigChan1 <- tsig1 }(cc) go func(cc *configurationChain) { - tsig2, err := cc.runTSig(round, hash2) + tsig2, err := cc.runTSig(round, hash2, 5*time.Second) // Prevent racing by collecting errors and check in main thread. errs <- err tsigChan2 <- tsig2 @@ -604,7 +604,7 @@ func (s *ConfigurationChainTestSuite) TestTSigTimeout() { } qualify++ go func(cc *configurationChain) { - _, err := cc.runTSig(round, hash) + _, err := cc.runTSig(round, hash, 5*time.Second) // Prevent racing by collecting errors and check in main thread. errs <- err }(cc) diff --git a/core/consensus.go b/core/consensus.go index adaf51d..ca7d10f 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -1084,7 +1084,11 @@ func (con *Consensus) generateBlockRandomness(blocks []*types.Block) { "proposer", psig.ProposerID, "block", block) con.network.BroadcastDKGPartialSignature(psig) - sig, err := con.cfgModule.runTSig(block.Position.Round, block.Hash) + sig, err := con.cfgModule.runTSig( + block.Position.Round, + block.Hash, + 60*time.Minute, + ) if err != nil { con.logger.Error("Failed to run Block Tsig", "block", block, |