Give testnet internal node 70% voting power for stuck epochs (#3521)

pull/3522/head
Rongjian Lan 4 years ago committed by GitHub
parent a9840bb46a
commit 5643dff467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      consensus/quorum/quorum.go
  2. 3
      consensus/votepower/roster.go
  3. 9
      hmy/staking.go

@ -139,11 +139,12 @@ type Registry struct {
Deciders map[string]Decider `json:"quorum-deciders"`
ExternalCount int `json:"external-slot-count"`
MedianStake numeric.Dec `json:"epos-median-stake"`
Epoch int `json:"epoch"`
}
// NewRegistry ..
func NewRegistry(extern int) Registry {
return Registry{map[string]Decider{}, extern, numeric.ZeroDec()}
func NewRegistry(extern int, epoch int) Registry {
return Registry{map[string]Decider{}, extern, numeric.ZeroDec(), epoch}
}
// Transition ..

@ -184,7 +184,8 @@ func Compute(subComm *shard.Committee, epoch *big.Int) (*Roster, error) {
// Testnet incident recovery
// Make harmony nodes having 70% voting power for epoch 73314
if nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Testnet && epoch.Cmp(big.NewInt(73314)) == 0 {
if nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Testnet && epoch.Cmp(big.NewInt(73305)) >= 0 &&
epoch.Cmp(big.NewInt(73330)) <= 0 {
harmonyPercent = numeric.MustNewDecFromStr("0.70")
externalPercent = numeric.MustNewDecFromStr("0.30")
}

@ -66,6 +66,11 @@ func (hmy *Harmony) readAndUpdateRawStakes(
func (hmy *Harmony) getSuperCommittees() (*quorum.Transition, error) {
nowE := hmy.BlockChain.CurrentHeader().Epoch()
if hmy.BlockChain.CurrentHeader().IsLastBlockInEpoch() {
// current epoch is current header epoch + 1 if the header was last block of prev epoch
nowE = new(big.Int).Add(nowE, common.Big1)
}
thenE := new(big.Int).Sub(nowE, common.Big1)
var (
@ -86,8 +91,8 @@ func (hmy *Harmony) getSuperCommittees() (*quorum.Transition, error) {
shard.ExternalSlotsAvailableForEpoch(thenE)
then, now :=
quorum.NewRegistry(stakedSlotsThen),
quorum.NewRegistry(stakedSlotsNow)
quorum.NewRegistry(stakedSlotsThen, int(thenE.Int64())),
quorum.NewRegistry(stakedSlotsNow, int(nowE.Int64()))
rawStakes := []effective.SlotPurchase{}
validatorSpreads := map[common.Address]numeric.Dec{}

Loading…
Cancel
Save