Merge pull request #104 from Sotatek-SinhVu/hotfix/increase-ms

Hotfix/increase ms
This commit is contained in:
Anil Chinchawale 2019-07-23 07:11:40 -04:00 committed by GitHub
commit b3e8d4fcc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 9 deletions

View file

@ -13,6 +13,7 @@ const (
EpocBlockOpening = 850 EpocBlockOpening = 850
EpocBlockRandomize = 900 EpocBlockRandomize = 900
MaxMasternodes = 18 MaxMasternodes = 18
MaxMasternodesV2 = 54
LimitPenaltyEpoch = 4 LimitPenaltyEpoch = 4
BlocksPerYear = uint64(15768000) BlocksPerYear = uint64(15768000)
LimitThresholdNonceInQueue = 10 LimitThresholdNonceInQueue = 10
@ -25,6 +26,7 @@ const (
var TIP2019Block = big.NewInt(1) var TIP2019Block = big.NewInt(1)
var TIPSigning = big.NewInt(3000000) var TIPSigning = big.NewInt(3000000)
var TIPRandomize = big.NewInt(3464000) var TIPRandomize = big.NewInt(3464000)
var TIPIncreaseMasternodes = big.NewInt(10000000) // example 10 milions
var IsTestnet bool = false var IsTestnet bool = false
var StoreRewardFolder string var StoreRewardFolder string
var RollbackHash Hash var RollbackHash Hash

View file

@ -16,10 +16,11 @@
package validator package validator
import ( import (
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/contracts/validator/contract" "github.com/ethereum/go-ethereum/contracts/validator/contract"
"math/big"
) )
type Validator struct { type Validator struct {

View file

@ -46,7 +46,7 @@ import (
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
"github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"gopkg.in/karalabe/cookiejar.v2/collections/prque" "gopkg.in/karalabe/cookiejar.v2/collections/prque"
) )
@ -1870,8 +1870,19 @@ func (bc *BlockChain) UpdateM1() error {
} }
// update masternodes // update masternodes
log.Info("Updating new set of masternodes") log.Info("Updating new set of masternodes")
if len(ms) > common.MaxMasternodes { // get block header
err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms[:common.MaxMasternodes]) header := bc.CurrentHeader()
var maxMasternodes int
// check if block number is increase ms checkpoint
if bc.chainConfig.IsTIPIncreaseMasternodes(header.Number) {
// using new masterndoes
maxMasternodes = common.MaxMasternodesV2
} else {
// using old masterndoes
maxMasternodes = common.MaxMasternodes
}
if len(ms) > maxMasternodes {
err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms[:maxMasternodes])
} else { } else {
err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms) err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms)
} }

View file

@ -32,8 +32,8 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/consensus/XDPoS" "github.com/ethereum/go-ethereum/consensus/XDPoS"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/contracts" "github.com/ethereum/go-ethereum/contracts"
contractValidator "github.com/ethereum/go-ethereum/contracts/validator/contract" contractValidator "github.com/ethereum/go-ethereum/contracts/validator/contract"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
@ -767,12 +767,18 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
sort.Slice(candidates, func(i, j int) bool { sort.Slice(candidates, func(i, j int) bool {
return candidates[i].Stake.Cmp(candidates[j].Stake) >= 0 return candidates[i].Stake.Cmp(candidates[j].Stake) >= 0
}) })
var maxMasternodes int
if s.b.ChainConfig().IsTIPIncreaseMasternodes(block.Number()) {
maxMasternodes = common.MaxMasternodesV2
} else {
maxMasternodes = common.MaxMasternodes
}
isTopCandidate := false // is candidates in top 150 isTopCandidate := false // is candidates in top 150
status := "" status := ""
for i := 0; i < len(candidates); i++ { for i := 0; i < len(candidates); i++ {
if candidates[i].Address == coinbaseAddress { if candidates[i].Address == coinbaseAddress {
status = statusProposed status = statusProposed
if i < common.MaxMasternodes { if i < maxMasternodes {
isTopCandidate = true isTopCandidate = true
} }
break break

View file

@ -225,6 +225,12 @@ func (c *ChainConfig) IsTIPRandomize(num *big.Int) bool {
return isForked(common.TIPRandomize, num) return isForked(common.TIPRandomize, num)
} }
// IsTIPIncreaseMasternodes using for increase masternodes from 18 to 40
// Time update: 23-07-2019
func (c *ChainConfig) IsTIPIncreaseMasternodes(num *big.Int) bool {
return isForked(common.TIPIncreaseMasternodes, num)
}
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice). // GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
// //
// The returned GasTable's fields shouldn't, under any circumstances, be changed. // The returned GasTable's fields shouldn't, under any circumstances, be changed.