Rotate external leaders on non-beacon chains.

pull/4383/head
frozen 2 years ago committed by Casey Gardiner
parent adab3d6d29
commit f6e5b84232
  1. 10
      consensus/consensus_v2.go
  2. 1
      consensus/quorum/quorum.go
  3. 16
      consensus/view_change.go

@ -714,7 +714,15 @@ func (consensus *Consensus) rotateLeader(epoch *big.Int) {
}
}
// Passed all checks, we can change leader.
wasFound, next := consensus.Decider.NthNextHmy(shard.Schedule.InstanceForEpoch(epoch), leader, 1)
var (
wasFound bool
next *bls.PublicKeyWrapper
)
if consensus.ShardID == shard.BeaconChainShardID {
wasFound, next = consensus.Decider.NthNextHmy(shard.Schedule.InstanceForEpoch(epoch), leader, 1)
} else {
wasFound, next = consensus.Decider.NthNext(leader, 1)
}
if !wasFound {
utils.Logger().Error().Msg("Failed to get next leader")
return

@ -75,6 +75,7 @@ type ParticipantTracker interface {
Participants() multibls.PublicKeys
IndexOf(bls.SerializedPublicKey) int
ParticipantsCount() int64
NthNext(*bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
NthNextHmy(shardingconfig.Instance, *bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
NthNextHmyExt(shardingconfig.Instance, *bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
FirstParticipant(shardingconfig.Instance) *bls.PublicKeyWrapper

@ -202,11 +202,17 @@ func (consensus *Consensus) getNextLeaderKey(viewID uint64) *bls.PublicKeyWrappe
// FIXME: rotate leader on harmony nodes only before fully externalization
var wasFound bool
var next *bls.PublicKeyWrapper
if blockchain != nil && blockchain.Config().IsAllowlistEpoch(epoch) {
wasFound, next = consensus.Decider.NthNextHmyExt(
shard.Schedule.InstanceForEpoch(epoch),
lastLeaderPubKey,
gap)
if consensus.Blockchain().Config().IsLeaderRotation(epoch) {
if consensus.ShardID == shard.BeaconChainShardID {
wasFound, next = consensus.Decider.NthNextHmy(
shard.Schedule.InstanceForEpoch(epoch),
lastLeaderPubKey,
gap)
} else {
wasFound, next = consensus.Decider.NthNext(
lastLeaderPubKey,
gap)
}
} else {
wasFound, next = consensus.Decider.NthNextHmy(
shard.Schedule.InstanceForEpoch(epoch),

Loading…
Cancel
Save