mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
upgrade increase masternodes
This commit is contained in:
parent
fed1401642
commit
3180921a7f
5 changed files with 35 additions and 9 deletions
|
|
@ -13,6 +13,7 @@ const (
|
|||
EpocBlockOpening = 850
|
||||
EpocBlockRandomize = 900
|
||||
MaxMasternodes = 18
|
||||
MaxMasternodesV2 = 54
|
||||
LimitPenaltyEpoch = 4
|
||||
BlocksPerYear = uint64(15768000)
|
||||
LimitThresholdNonceInQueue = 10
|
||||
|
|
@ -25,6 +26,7 @@ const (
|
|||
var TIP2019Block = big.NewInt(1)
|
||||
var TIPSigning = big.NewInt(3000000)
|
||||
var TIPRandomize = big.NewInt(3464000)
|
||||
var TIPIncreaseMasternodes = big.NewInt(10000000) // example 10 milions
|
||||
var IsTestnet bool = false
|
||||
var StoreRewardFolder string
|
||||
var RollbackHash Hash
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@
|
|||
package validator
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/contracts/validator/contract"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
type Validator struct {
|
||||
|
|
@ -52,7 +53,7 @@ func DeployValidator(transactOpts *bind.TransactOpts, contractBackend bind.Contr
|
|||
// 150 masternodes
|
||||
// Candidate Delay Withdraw 30 days = 1296000 blocks
|
||||
// Voter Delay Withdraw 10 days = 432000 blocks
|
||||
validatorAddr, _, _, err := contract.DeployXDCValidator(transactOpts, contractBackend, validatorAddress, caps, ownerAddress, minDeposit, minVoterCap, big.NewInt(18), big.NewInt(1296000), big.NewInt(432000))
|
||||
validatorAddr, _, _, err := contract.DeployXDCValidator(transactOpts, contractBackend, validatorAddress, caps, ownerAddress, minDeposit, minVoterCap, big.NewInt(54), big.NewInt(1296000), big.NewInt(432000))
|
||||
if err != nil {
|
||||
return validatorAddr, nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
||||
)
|
||||
|
||||
|
|
@ -1870,8 +1870,19 @@ func (bc *BlockChain) UpdateM1() error {
|
|||
}
|
||||
// update masternodes
|
||||
log.Info("Updating new set of masternodes")
|
||||
// get block header
|
||||
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) > common.MaxMasternodes {
|
||||
err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms[:common.MaxMasternodes])
|
||||
err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms[:maxMasternodes])
|
||||
} else {
|
||||
err = engine.UpdateMasternodes(bc, bc.CurrentHeader(), ms)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"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/ethash"
|
||||
"github.com/ethereum/go-ethereum/contracts"
|
||||
contractValidator "github.com/ethereum/go-ethereum/contracts/validator/contract"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
|
|
@ -747,7 +747,7 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
|||
opts := new(bind.CallOpts)
|
||||
var (
|
||||
candidateAddresses []common.Address
|
||||
candidates []XDPoS.Masternode
|
||||
candidates []XDPoS.Masternode
|
||||
)
|
||||
|
||||
candidateAddresses, err = validator.GetCandidates(opts)
|
||||
|
|
@ -767,12 +767,18 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
|||
sort.Slice(candidates, func(i, j int) bool {
|
||||
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
|
||||
status := ""
|
||||
for i := 0; i < len(candidates); i++ {
|
||||
if candidates[i].Address == coinbaseAddress {
|
||||
status = statusProposed
|
||||
if i < common.MaxMasternodes {
|
||||
if i < maxMasternodes {
|
||||
isTopCandidate = true
|
||||
}
|
||||
break
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ var (
|
|||
//
|
||||
// This configuration is intentionally not using keyed fields to force anyone
|
||||
// adding flags to the config to also have to set these fields.
|
||||
AllXDPoSProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &XDPoSConfig{Period: 0, Epoch: 30000}}
|
||||
AllXDPoSProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &XDPoSConfig{Period: 0, Epoch: 30000}}
|
||||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
|
||||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, nil}
|
||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||
|
|
@ -121,7 +121,7 @@ type ChainConfig struct {
|
|||
// Various consensus engines
|
||||
Ethash *EthashConfig `json:"ethash,omitempty"`
|
||||
Clique *CliqueConfig `json:"clique,omitempty"`
|
||||
XDPoS *XDPoSConfig `json:"XDPoS,omitempty"`
|
||||
XDPoS *XDPoSConfig `json:"XDPoS,omitempty"`
|
||||
}
|
||||
|
||||
// EthashConfig is the consensus engine configs for proof-of-work based sealing.
|
||||
|
|
@ -225,6 +225,12 @@ func (c *ChainConfig) IsTIPRandomize(num *big.Int) bool {
|
|||
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).
|
||||
//
|
||||
// The returned GasTable's fields shouldn't, under any circumstances, be changed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue