Fixed the slots limit calculation.

pull/4163/head
peekpi 3 years ago committed by Soph
parent e93bb38abf
commit e2df509af2
  1. 6
      internal/configs/sharding/instance.go
  2. 2
      internal/configs/sharding/mainnet.go
  3. 2
      internal/configs/sharding/testnet.go

@ -66,6 +66,9 @@ func NewInstance(
numNodesPerShard,
)
}
if slotsLimit < 0 {
return nil, errors.Errorf("SlotsLimit cannot be negative %d", slotsLimit)
}
if harmonyVotePercent.LT(numeric.ZeroDec()) ||
harmonyVotePercent.GT(numeric.OneDec()) {
return nil, errors.Errorf("" +
@ -92,12 +95,13 @@ func NewInstance(
// It is intended to be used for static initialization.
func MustNewInstance(
numShards uint32,
numNodesPerShard, numHarmonyOperatedNodesPerShard, slotsLimit int,
numNodesPerShard, numHarmonyOperatedNodesPerShard int, slotsLimitPercent float32,
harmonyVotePercent numeric.Dec,
hmyAccounts []genesis.DeployAccount,
fnAccounts []genesis.DeployAccount,
reshardingEpoch []*big.Int, blocksPerEpoch uint64,
) Instance {
slotsLimit := int(float32(numNodesPerShard-numHarmonyOperatedNodesPerShard) * slotsLimitPercent)
sc, err := NewInstance(
numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, slotsLimit, harmonyVotePercent,
hmyAccounts, fnAccounts, reshardingEpoch, blocksPerEpoch,

@ -221,5 +221,5 @@ var (
mainnetV3 = MustNewInstance(4, 250, 90, 0, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
mainnetV3_1 = MustNewInstance(4, 250, 50, 0, numeric.MustNewDecFromStr("0.60"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
mainnetV3_2 = MustNewInstance(4, 250, 25, 0, numeric.MustNewDecFromStr("0.49"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
mainnetV3_3 = MustNewInstance(4, 250, 25, 250*6/100, numeric.MustNewDecFromStr("0.49"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
mainnetV3_3 = MustNewInstance(4, 250, 25, 0.06, numeric.MustNewDecFromStr("0.49"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
)

@ -121,4 +121,4 @@ var testnetV1 = MustNewInstance(4, 20, 15, 0, numeric.MustNewDecFromStr("0.90"),
var testnetV2 = MustNewInstance(4, 30, 8, 0, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld())
var testnetV3 = MustNewInstance(4, 30, 8, 0, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())
var testnetV3_1 = MustNewInstance(4, 30, 8, 0, numeric.MustNewDecFromStr("0.60"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())
var testnetV3_2 = MustNewInstance(4, 30, 8, 30*6/100, numeric.MustNewDecFromStr("0.60"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())
var testnetV3_2 = MustNewInstance(4, 30, 8, 0.06, numeric.MustNewDecFromStr("0.60"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())

Loading…
Cancel
Save