|
|
@ -422,6 +422,18 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode { |
|
|
|
curHeader := consensus.ChainReader.CurrentHeader() |
|
|
|
curHeader := consensus.ChainReader.CurrentHeader() |
|
|
|
curEpoch := curHeader.Epoch() |
|
|
|
curEpoch := curHeader.Epoch() |
|
|
|
nextEpoch := new(big.Int).Add(curHeader.Epoch(), common.Big1) |
|
|
|
nextEpoch := new(big.Int).Add(curHeader.Epoch(), common.Big1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Overwrite nextEpoch if the shard state has a epoch number
|
|
|
|
|
|
|
|
if len(curHeader.ShardState()) > 0 { |
|
|
|
|
|
|
|
nextShardState, err := curHeader.GetShardState() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return Syncing |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if nextShardState.Epoch != nil { |
|
|
|
|
|
|
|
nextEpoch = nextShardState.Epoch |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isFirstTimeStaking := consensus.ChainReader.Config().IsStaking(nextEpoch) && |
|
|
|
isFirstTimeStaking := consensus.ChainReader.Config().IsStaking(nextEpoch) && |
|
|
|
len(curHeader.ShardState()) > 0 && |
|
|
|
len(curHeader.ShardState()) > 0 && |
|
|
|
!consensus.ChainReader.Config().IsStaking(curEpoch) |
|
|
|
!consensus.ChainReader.Config().IsStaking(curEpoch) |
|
|
@ -529,9 +541,8 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode { |
|
|
|
Uint32("shard-id", consensus.ShardID). |
|
|
|
Uint32("shard-id", consensus.ShardID). |
|
|
|
Msg("[UpdateConsensusInformation] changing committee") |
|
|
|
Msg("[UpdateConsensusInformation] changing committee") |
|
|
|
|
|
|
|
|
|
|
|
// take care of possible leader change during the curEpoch
|
|
|
|
// take care of possible leader change during the epoch
|
|
|
|
if !shard.Schedule.IsLastBlock(curHeader.Number().Uint64()) && |
|
|
|
if len(curHeader.ShardState()) == 0 && curHeader.Number().Uint64() != 0 { |
|
|
|
curHeader.Number().Uint64() != 0 { |
|
|
|
|
|
|
|
leaderPubKey, err := consensus.getLeaderPubKeyFromCoinbase(curHeader) |
|
|
|
leaderPubKey, err := consensus.getLeaderPubKeyFromCoinbase(curHeader) |
|
|
|
if err != nil || leaderPubKey == nil { |
|
|
|
if err != nil || leaderPubKey == nil { |
|
|
|
consensus.getLogger().Debug().Err(err). |
|
|
|
consensus.getLogger().Debug().Err(err). |
|
|
|