created different consensysratio for localnet/mainnet

use different consensus ratio for localnet
pull/1281/head
coolcottontail 5 years ago
parent 7f9721598c
commit 46f292be25
  1. 3
      api/service/syncing/syncing.go
  2. 5
      internal/configs/sharding/fixedschedule.go
  3. 6
      internal/configs/sharding/localnet.go
  4. 6
      internal/configs/sharding/mainnet.go
  5. 3
      internal/configs/sharding/shardingconfig.go
  6. 5
      internal/configs/sharding/testnet.go

@ -25,7 +25,6 @@ import (
// Constants for syncing.
const (
ConsensusRatio = float64(0.66)
SleepTimeAfterNonConsensusBlockHashes = time.Second * 30
TimesToFail = 5 // Downloadblocks service retry limit
RegistrationNumber = 3
@ -318,7 +317,7 @@ func (sc *SyncConfig) GetBlockHashesConsensusAndCleanUp() bool {
Int("maxFirstID", maxFirstID).
Int("maxCount", maxCount).
Msg("[SYNC] block consensus hashes")
if float64(maxCount) >= ConsensusRatio*float64(len(sc.peers)) {
if float64(maxCount) >= core.ShardingSchedule.ConsensusRatio()*float64(len(sc.peers)) {
sc.cleanUpPeers(maxFirstID)
return true
}

@ -36,6 +36,11 @@ func (s fixedSchedule) VdfDifficulty() int {
return mainnetVdfDifficulty
}
// ConsensusRatio ratio of new nodes vs consensus total nodes
func (s fixedSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
// NewFixedSchedule returns a sharding configuration schedule that uses the
// given config instance for all epochs. Useful for testing.
func NewFixedSchedule(instance Instance) Schedule {

@ -20,6 +20,7 @@ const (
twoOne = 5
localnetVdfDifficulty = 5000 // This takes about 10s to finish the vdf
localnetConsensusRatio = float64(0.1)
)
func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
@ -63,6 +64,11 @@ func (ls localnetSchedule) VdfDifficulty() int {
return localnetVdfDifficulty
}
// ConsensusRatio ratio of new nodes vs consensus total nodes
func (ls localnetSchedule) ConsensusRatio() float64 {
return localnetConsensusRatio
}
var localnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(localnetV1Epoch), big.NewInt(localnetV2Epoch)}
var localnetV0 = MustNewInstance(2, 7, 5, genesis.LocalHarmonyAccounts, genesis.LocalFnAccounts, localnetReshardingEpoch)

@ -13,6 +13,7 @@ const (
mainnetV2Epoch = 5
mainnetVdfDifficulty = 50000 // This takes about 100s to finish the vdf
mainnetConsensusRatio = float64(0.66)
)
// MainnetSchedule is the mainnet sharding configuration schedule.
@ -63,6 +64,11 @@ func (ms mainnetSchedule) VdfDifficulty() int {
return mainnetVdfDifficulty
}
// ConsensusRatio ratio of new nodes vs consensus total nodes
func (ms mainnetSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
var mainnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(mainnetV1Epoch)}
var mainnetV0 = MustNewInstance(4, 150, 112, genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, mainnetReshardingEpoch)
var mainnetV1 = MustNewInstance(4, 152, 112, genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1, mainnetReshardingEpoch)

@ -24,6 +24,9 @@ type Schedule interface {
// VDFDifficulty returns number of iterations for VDF calculation
VdfDifficulty() int
// ConsensusRatio ratio of new nodes vs consensus total nodes
ConsensusRatio() float64
}
// Instance is one sharding configuration instance.

@ -64,6 +64,11 @@ func (ts testnetSchedule) VdfDifficulty() int {
return testnetVdfDifficulty
}
// ConsensusRatio ratio of new nodes vs consensus total nodes
func (ts testnetSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
var testnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(testnetV1Epoch), big.NewInt(testnetV2Epoch)}
var testnetV0 = MustNewInstance(2, 150, 150, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch)

Loading…
Cancel
Save