fix RawStake of HIP16

pull/4163/head
peekpi 3 years ago committed by Soph
parent f301dca238
commit cbeddf6a0e
  1. 17
      core/blockchain.go

@ -2574,6 +2574,23 @@ func (bc *BlockChain) UpdateValidatorVotingPower(
spread = numeric.NewDecFromBigInt(wrapper.TotalDelegation()).
QuoInt64(int64(len(wrapper.SlotPubKeys)))
}
instance := shard.Schedule.InstanceForEpoch(newEpochSuperCommittee.Epoch)
limitedSlotsCount := 0 // limited slots count for HIP16
slotsLimit := instance.SlotsLimit()
if slotsLimit > 0 {
shardCount := big.NewInt(int64(instance.NumShards()))
shardSlotsCount := make([]int, shardCount.Uint64()) // number slots keys on each shard
for _, pubkey := range wrapper.SlotPubKeys {
shardIndex := new(big.Int).Mod(pubkey.Big(), shardCount).Uint64()
shardSlotsCount[shardIndex] += 1
if shardSlotsCount[shardIndex] > slotsLimit {
continue
}
limitedSlotsCount += 1
}
spread = numeric.NewDecFromBigInt(wrapper.TotalDelegation()).
QuoInt64(int64(limitedSlotsCount))
}
for i := range stats.MetricsPerShard {
stats.MetricsPerShard[i].Vote.RawStake = spread
}

Loading…
Cancel
Save