Legacy ibft should be used if qibftBlock is not defined in genesis

This commit is contained in:
Jitendra Bhurat 2020-05-28 16:15:34 -04:00
parent 8044d33d40
commit 89fac8995a
3 changed files with 10 additions and 11 deletions

View File

@ -327,13 +327,15 @@ func (sb *backend) Close() error {
// IsQIBFTConsensus returns whether qbft consensus should be used
func (sb *backend) IsQIBFTConsensus() bool {
if sb.qibftConsensusEnabled {
return true
}
// If it is a new network then by default use qibft consensus
if sb.config.QibftBlock == nil || sb.config.QibftBlock.Uint64() == 0 {
// If qibftBlock is not defined in genesis, then use legacy ibft
if sb.config.QibftBlock == nil {
return false
}
if sb.qibftConsensusEnabled || sb.config.QibftBlock.Uint64() == 0{
return true
}
if sb.chain != nil && sb.chain.CurrentHeader().Number.Cmp(sb.config.QibftBlock) >= 0 {
return true
}

View File

@ -39,8 +39,9 @@ func (c *core) Stop() error {
c.stopTimer()
c.unsubscribeEvents()
// Make sure the handler goroutine exits
c.handlerWg.Wait()
// Not waiting for handlerWg to stop, as it was blocking legacy IBFT consensus to stop
// and new events will be handled by qibft consensus
// c.handlerWg.Wait()
return nil
}

View File

@ -283,11 +283,7 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo
config.Istanbul.ProposerPolicy = istanbul.ProposerPolicy(chainConfig.Istanbul.ProposerPolicy)
config.Istanbul.Ceil2Nby3Block = chainConfig.Istanbul.Ceil2Nby3Block
config.Istanbul.AllowedFutureBlockTime = config.AllowedFutureBlockTime
config.Istanbul.QibftBlock = chainConfig.Istanbul.QibftBlock
if chainConfig.Istanbul.QibftBlock == nil {
config.Istanbul.QibftBlock = big.NewInt(0)
}
return istanbulBackend.New(&config.Istanbul, ctx.NodeKey(), db)
}