diff options
-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, |