diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index a6a0cbfc7..4917d3013 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -444,7 +444,7 @@ func nodeconfigSetShardSchedule(config harmonyConfig) { } devnetConfig, err := shardingconfig.NewInstance( - uint32(dnConfig.NumShards), dnConfig.ShardSize, dnConfig.HmyNodeSize, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, nil, shardingconfig.VLBPE, shardingconfig.VLBPE) + uint32(dnConfig.NumShards), dnConfig.ShardSize, dnConfig.HmyNodeSize, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, nil, shardingconfig.VLBPE) if err != nil { _, _ = fmt.Fprintf(os.Stderr, "ERROR invalid devnet sharding config: %s", err) diff --git a/core/blockchain.go b/core/blockchain.go index 2b00539b5..dce8fda34 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -293,15 +293,6 @@ func IsEpochBlock(block *types.Block) bool { return shard.Schedule.IsLastBlock(block.NumberU64() - 1) } -// EpochFirstBlock returns the block number of the first block of an epoch. -// TODO: instead of using fixed epoch schedules, determine the first block by epoch changes. -func EpochFirstBlock(epoch *big.Int) *big.Int { - if epoch.Cmp(big.NewInt(GenesisEpoch)) == 0 { - return big.NewInt(GenesisEpoch) - } - return big.NewInt(int64(shard.Schedule.EpochLastBlock(epoch.Uint64()-1) + 1)) -} - func (bc *BlockChain) getProcInterrupt() bool { return atomic.LoadInt32(&bc.procInterrupt) == 1 } diff --git a/internal/configs/sharding/fixedschedule.go b/internal/configs/sharding/fixedschedule.go index 477a8a514..d5fa9b8d9 100644 --- a/internal/configs/sharding/fixedschedule.go +++ b/internal/configs/sharding/fixedschedule.go @@ -41,11 +41,6 @@ func (s fixedSchedule) VdfDifficulty() int { return mainnetVdfDifficulty } -// ConsensusRatio ratio of new nodes vs consensus total nodes -func (s fixedSchedule) ConsensusRatio() float64 { - return mainnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (s fixedSchedule) RandomnessStartingEpoch() uint64 { diff --git a/internal/configs/sharding/instance.go b/internal/configs/sharding/instance.go index a1454cd36..7601c2899 100644 --- a/internal/configs/sharding/instance.go +++ b/internal/configs/sharding/instance.go @@ -31,7 +31,6 @@ type instance struct { hmyAccounts []genesis.DeployAccount fnAccounts []genesis.DeployAccount reshardingEpoch []*big.Int - blocksPerEpochOld uint64 blocksPerEpoch uint64 } @@ -41,7 +40,7 @@ func NewInstance( numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int, harmonyVotePercent numeric.Dec, hmyAccounts []genesis.DeployAccount, fnAccounts []genesis.DeployAccount, - reshardingEpoch []*big.Int, blocksEOld uint64, blocksE uint64, + reshardingEpoch []*big.Int, blocksE uint64, ) (Instance, error) { if numShards < 1 { return nil, errors.Errorf( @@ -82,7 +81,6 @@ func NewInstance( hmyAccounts: hmyAccounts, fnAccounts: fnAccounts, reshardingEpoch: reshardingEpoch, - blocksPerEpochOld: blocksEOld, blocksPerEpoch: blocksE, }, nil } @@ -96,11 +94,11 @@ func MustNewInstance( harmonyVotePercent numeric.Dec, hmyAccounts []genesis.DeployAccount, fnAccounts []genesis.DeployAccount, - reshardingEpoch []*big.Int, blocksPerEpochOld uint64, blocksPerEpoch uint64, + reshardingEpoch []*big.Int, blocksPerEpoch uint64, ) Instance { sc, err := NewInstance( numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, harmonyVotePercent, - hmyAccounts, fnAccounts, reshardingEpoch, blocksPerEpochOld, blocksPerEpoch, + hmyAccounts, fnAccounts, reshardingEpoch, blocksPerEpoch, ) if err != nil { panic(err) diff --git a/internal/configs/sharding/localnet.go b/internal/configs/sharding/localnet.go index 208cd64f9..5f853cc76 100644 --- a/internal/configs/sharding/localnet.go +++ b/internal/configs/sharding/localnet.go @@ -19,18 +19,20 @@ type localnetSchedule struct{} const ( localnetV1Epoch = 1 - localnetEpochBlock1 = 10 - localnetBlocksPerEpoch = 5 + localnetEpochBlock1 = 10 + localnetBlocksPerEpoch = 5 + localnetBlocksPerEpochV2 = 10 - localnetVdfDifficulty = 5000 // This takes about 10s to finish the vdf - localnetConsensusRatio = float64(0.1) + localnetVdfDifficulty = 5000 // This takes about 10s to finish the vdf localnetRandomnessStartingEpoch = 0 ) func (ls localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance { switch { - case epoch.Cmp(params.LocalnetChainConfig.StakingEpoch) >= 0: + case params.LocalnetChainConfig.IsTwoSeconds(epoch): + return localnetV3 + case params.LocalnetChainConfig.IsStaking(epoch): return localnetV2 case epoch.Cmp(big.NewInt(localnetV1Epoch)) >= 0: return localnetV1 @@ -39,39 +41,63 @@ func (ls localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance { } } -func (ls localnetSchedule) BlocksPerEpoch() uint64 { +func (ls localnetSchedule) BlocksPerEpochOld() uint64 { return localnetBlocksPerEpoch } +func (ls localnetSchedule) BlocksPerEpoch() uint64 { + return localnetBlocksPerEpochV2 +} func (ls localnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int { - blocks := ls.BlocksPerEpoch() + blocks := ls.BlocksPerEpochOld() + var oldEpochNumber uint64 switch { case blockNum >= localnetEpochBlock1: - return big.NewInt(int64((blockNum-localnetEpochBlock1)/blocks) + 1) + oldEpochNumber = uint64((blockNum-localnetEpochBlock1)/blocks) + 1 default: - return big.NewInt(0) + oldEpochNumber = 0 + } + + firstBlock2s := params.LocalnetChainConfig.TwoSecondsEpoch.Uint64()*ls.BlocksPerEpochOld() + 5 + switch { + case oldEpochNumber >= params.LocalnetChainConfig.TwoSecondsEpoch.Uint64(): + return big.NewInt(int64((blockNum-firstBlock2s)/ls.BlocksPerEpoch() + params.LocalnetChainConfig.TwoSecondsEpoch.Uint64())) + default: // genesis + return big.NewInt(int64(oldEpochNumber)) } } func (ls localnetSchedule) IsLastBlock(blockNum uint64) bool { - blocks := ls.BlocksPerEpoch() + blocks := ls.BlocksPerEpochOld() switch { case blockNum < localnetEpochBlock1-1: return false case blockNum == localnetEpochBlock1-1: return true default: - return ((blockNum-localnetEpochBlock1)%blocks == blocks-1) + firstBlock2s := params.LocalnetChainConfig.TwoSecondsEpoch.Uint64()*ls.BlocksPerEpochOld() + 5 + switch { + case blockNum >= firstBlock2s: + return ((blockNum-firstBlock2s)%ls.BlocksPerEpoch() == ls.BlocksPerEpoch()-1) + default: // genesis + return ((blockNum-localnetEpochBlock1)%blocks == blocks-1) + } } } func (ls localnetSchedule) EpochLastBlock(epochNum uint64) uint64 { - blocks := ls.BlocksPerEpoch() + blocks := ls.BlocksPerEpochOld() switch { case epochNum == 0: return localnetEpochBlock1 - 1 default: - return localnetEpochBlock1 - 1 + blocks*epochNum + firstBlock2s := params.LocalnetChainConfig.TwoSecondsEpoch.Uint64()*ls.BlocksPerEpochOld() + 5 + switch { + case params.LocalnetChainConfig.IsTwoSeconds(big.NewInt(int64(epochNum))): + return firstBlock2s - 1 + ls.BlocksPerEpoch()*(epochNum-params.LocalnetChainConfig.TwoSecondsEpoch.Uint64()+1) + default: // genesis + return localnetEpochBlock1 - 1 + blocks*epochNum + } } } @@ -79,11 +105,6 @@ func (ls localnetSchedule) VdfDifficulty() int { return localnetVdfDifficulty } -// ConsensusRatio ratio of new nodes vs consensus total nodes -func (ls localnetSchedule) ConsensusRatio() float64 { - return localnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (ls localnetSchedule) RandomnessStartingEpoch() uint64 { @@ -115,10 +136,11 @@ func (ls localnetSchedule) IsSkippedEpoch(shardID uint32, epoch *big.Int) bool { var ( localnetReshardingEpoch = []*big.Int{ - big.NewInt(0), big.NewInt(localnetV1Epoch), params.LocalnetChainConfig.StakingEpoch, + big.NewInt(0), big.NewInt(localnetV1Epoch), params.LocalnetChainConfig.StakingEpoch, params.LocalnetChainConfig.TwoSecondsEpoch, } // Number of shards, how many slots on each , how many slots owned by Harmony - localnetV0 = MustNewInstance(2, 7, 5, numeric.OneDec(), genesis.LocalHarmonyAccounts, genesis.LocalFnAccounts, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpoch(), LocalnetSchedule.BlocksPerEpoch()) - localnetV1 = MustNewInstance(2, 8, 5, numeric.OneDec(), genesis.LocalHarmonyAccountsV1, genesis.LocalFnAccountsV1, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpoch(), LocalnetSchedule.BlocksPerEpoch()) - localnetV2 = MustNewInstance(2, 9, 6, numeric.MustNewDecFromStr("0.68"), genesis.LocalHarmonyAccountsV2, genesis.LocalFnAccountsV2, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpoch(), LocalnetSchedule.BlocksPerEpoch()) + localnetV0 = MustNewInstance(2, 7, 5, numeric.OneDec(), genesis.LocalHarmonyAccounts, genesis.LocalFnAccounts, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpochOld()) + localnetV1 = MustNewInstance(2, 8, 5, numeric.OneDec(), genesis.LocalHarmonyAccountsV1, genesis.LocalFnAccountsV1, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpochOld()) + localnetV2 = MustNewInstance(2, 9, 6, numeric.MustNewDecFromStr("0.68"), genesis.LocalHarmonyAccountsV2, genesis.LocalFnAccountsV2, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpochOld()) + localnetV3 = MustNewInstance(2, 9, 6, numeric.MustNewDecFromStr("0.68"), genesis.LocalHarmonyAccountsV2, genesis.LocalFnAccountsV2, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpoch()) ) diff --git a/internal/configs/sharding/mainnet.go b/internal/configs/sharding/mainnet.go index bb94c5cd5..ed4e13efd 100644 --- a/internal/configs/sharding/mainnet.go +++ b/internal/configs/sharding/mainnet.go @@ -12,8 +12,7 @@ const ( mainnetEpochBlock1 = 344064 // 21 * 2^14 blocksPerEpoch = 16384 // 2^14 - mainnetVdfDifficulty = 50000 // This takes about 100s to finish the vdf - mainnetConsensusRatio = float64(0.1) + mainnetVdfDifficulty = 50000 // This takes about 100s to finish the vdf // TODO: remove it after randomness feature turned on mainnet mainnetRandomnessStartingEpoch = 100000 @@ -136,11 +135,6 @@ func (ms mainnetSchedule) VdfDifficulty() int { return mainnetVdfDifficulty } -// ConsensusRatio ratio of new nodes vs consensus total nodes -func (ms mainnetSchedule) ConsensusRatio() float64 { - return mainnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (ms mainnetSchedule) RandomnessStartingEpoch() uint64 { @@ -171,18 +165,18 @@ func (ms mainnetSchedule) IsSkippedEpoch(shardID uint32, epoch *big.Int) bool { var mainnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(mainnetV0_1Epoch), big.NewInt(mainnetV0_2Epoch), big.NewInt(mainnetV0_3Epoch), big.NewInt(mainnetV0_4Epoch), big.NewInt(mainnetV1Epoch), big.NewInt(mainnetV1_1Epoch), big.NewInt(mainnetV1_2Epoch), big.NewInt(mainnetV1_3Epoch), big.NewInt(mainnetV1_4Epoch), big.NewInt(mainnetV1_5Epoch), big.NewInt(mainnetV2_0Epoch), big.NewInt(mainnetV2_1Epoch), big.NewInt(mainnetV2_2Epoch)} var ( - mainnetV0 = MustNewInstance(4, 150, 112, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV0_1 = MustNewInstance(4, 152, 112, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_1, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV0_2 = MustNewInstance(4, 200, 148, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_2, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV0_3 = MustNewInstance(4, 210, 148, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_3, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV0_4 = MustNewInstance(4, 216, 148, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_4, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV1 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV1_1 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_1, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV1_2 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_2, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV1_3 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_3, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV1_4 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_4, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV1_5 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV2_0 = MustNewInstance(4, 250, 170, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV2_1 = MustNewInstance(4, 250, 130, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) - mainnetV2_2 = MustNewInstance(4, 250, 90, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch(), MainnetSchedule.BlocksPerEpoch()) + mainnetV0 = MustNewInstance(4, 150, 112, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV0_1 = MustNewInstance(4, 152, 112, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_1, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV0_2 = MustNewInstance(4, 200, 148, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_2, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV0_3 = MustNewInstance(4, 210, 148, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_3, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV0_4 = MustNewInstance(4, 216, 148, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV0_4, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV1 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV1_1 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_1, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV1_2 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_2, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV1_3 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_3, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV1_4 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_4, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV1_5 = MustNewInstance(4, 250, 170, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV2_0 = MustNewInstance(4, 250, 170, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV2_1 = MustNewInstance(4, 250, 130, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) + mainnetV2_2 = MustNewInstance(4, 250, 90, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch()) ) diff --git a/internal/configs/sharding/pangaea.go b/internal/configs/sharding/pangaea.go index 30d5fed89..baa2a8b81 100644 --- a/internal/configs/sharding/pangaea.go +++ b/internal/configs/sharding/pangaea.go @@ -56,10 +56,6 @@ func (ps pangaeaSchedule) VdfDifficulty() int { return pangaeaVdfDifficulty } -func (ps pangaeaSchedule) ConsensusRatio() float64 { - return mainnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (ps pangaeaSchedule) RandomnessStartingEpoch() uint64 { @@ -85,5 +81,5 @@ var pangaeaReshardingEpoch = []*big.Int{ params.PangaeaChainConfig.StakingEpoch, } -var pangaeaV0 = MustNewInstance(4, 30, 30, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch(), PangaeaSchedule.BlocksPerEpoch()) -var pangaeaV1 = MustNewInstance(4, 110, 30, numeric.MustNewDecFromStr("0.68"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch(), PangaeaSchedule.BlocksPerEpoch()) +var pangaeaV0 = MustNewInstance(4, 30, 30, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch()) +var pangaeaV1 = MustNewInstance(4, 110, 30, numeric.MustNewDecFromStr("0.68"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch()) diff --git a/internal/configs/sharding/partner.go b/internal/configs/sharding/partner.go index 5c351a2c3..9ff31f413 100644 --- a/internal/configs/sharding/partner.go +++ b/internal/configs/sharding/partner.go @@ -57,11 +57,6 @@ func (ps partnerSchedule) VdfDifficulty() int { return partnerVdfDifficulty } -// ConsensusRatio ratio of new nodes vs consensus total nodes -func (ps partnerSchedule) ConsensusRatio() float64 { - return mainnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (ps partnerSchedule) RandomnessStartingEpoch() uint64 { @@ -87,5 +82,5 @@ var partnerReshardingEpoch = []*big.Int{ params.TestnetChainConfig.StakingEpoch, } -var partnerV0 = MustNewInstance(2, 15, 15, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, partnerReshardingEpoch, PartnerSchedule.BlocksPerEpoch(), PartnerSchedule.BlocksPerEpoch()) -var partnerV1 = MustNewInstance(2, 30, 15, numeric.MustNewDecFromStr("0.68"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, partnerReshardingEpoch, PartnerSchedule.BlocksPerEpoch(), PartnerSchedule.BlocksPerEpoch()) +var partnerV0 = MustNewInstance(2, 15, 15, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, partnerReshardingEpoch, PartnerSchedule.BlocksPerEpoch()) +var partnerV1 = MustNewInstance(2, 30, 15, numeric.MustNewDecFromStr("0.68"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, partnerReshardingEpoch, PartnerSchedule.BlocksPerEpoch()) diff --git a/internal/configs/sharding/shardingconfig.go b/internal/configs/sharding/shardingconfig.go index 87e839f81..e18095e2f 100644 --- a/internal/configs/sharding/shardingconfig.go +++ b/internal/configs/sharding/shardingconfig.go @@ -20,17 +20,16 @@ type Schedule interface { CalcEpochNumber(blockNum uint64) *big.Int // IsLastBlock check if the block is the last block in the epoch + // NOTE: This method is very critical for the epoch transition logic and other checks. IsLastBlock(blockNum uint64) bool // EpochLastBlock returns the last block number of an epoch + // NOTE: This method id important for a few rpcs and validator APR calculation EpochLastBlock(epochNum uint64) uint64 // VDFDifficulty returns number of iterations for VDF calculation VdfDifficulty() int - // ConsensusRatio ratio of new nodes vs consensus total nodes - ConsensusRatio() float64 - // TODO: remove it after randomness feature turned on mainnet //RandomnessStartingEpoch returns starting epoch of randonness generation RandomnessStartingEpoch() uint64 diff --git a/internal/configs/sharding/stress.go b/internal/configs/sharding/stress.go index 436e5b604..6a45d2ff8 100644 --- a/internal/configs/sharding/stress.go +++ b/internal/configs/sharding/stress.go @@ -57,11 +57,6 @@ func (ss stressnetSchedule) VdfDifficulty() int { return stressnetVdfDifficulty } -// ConsensusRatio ratio of new nodes vs consensus total nodes -func (ss stressnetSchedule) ConsensusRatio() float64 { - return mainnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (ss stressnetSchedule) RandomnessStartingEpoch() uint64 { @@ -87,5 +82,5 @@ var stressnetReshardingEpoch = []*big.Int{ params.StressnetChainConfig.StakingEpoch, } -var stressnetV0 = MustNewInstance(2, 10, 10, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, stressnetReshardingEpoch, StressNetSchedule.BlocksPerEpoch(), StressNetSchedule.BlocksPerEpoch()) -var stressnetV1 = MustNewInstance(2, 30, 10, numeric.MustNewDecFromStr("0.9"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, stressnetReshardingEpoch, StressNetSchedule.BlocksPerEpoch(), StressNetSchedule.BlocksPerEpoch()) +var stressnetV0 = MustNewInstance(2, 10, 10, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, stressnetReshardingEpoch, StressNetSchedule.BlocksPerEpoch()) +var stressnetV1 = MustNewInstance(2, 30, 10, numeric.MustNewDecFromStr("0.9"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, stressnetReshardingEpoch, StressNetSchedule.BlocksPerEpoch()) diff --git a/internal/configs/sharding/testnet.go b/internal/configs/sharding/testnet.go index 8bb1d1a11..607894e00 100644 --- a/internal/configs/sharding/testnet.go +++ b/internal/configs/sharding/testnet.go @@ -92,11 +92,6 @@ func (ts testnetSchedule) VdfDifficulty() int { return testnetVdfDifficulty } -// ConsensusRatio ratio of new nodes vs consensus total nodes -func (ts testnetSchedule) ConsensusRatio() float64 { - return mainnetConsensusRatio -} - // TODO: remove it after randomness feature turned on mainnet //RandonnessStartingEpoch returns starting epoch of randonness generation func (ts testnetSchedule) RandomnessStartingEpoch() uint64 { @@ -123,7 +118,7 @@ var testnetReshardingEpoch = []*big.Int{ params.TestnetChainConfig.TwoSecondsEpoch, } -var testnetV0 = MustNewInstance(4, 16, 15, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld(), TestnetSchedule.BlocksPerEpoch()) -var testnetV1 = MustNewInstance(4, 20, 15, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld(), TestnetSchedule.BlocksPerEpoch()) -var testnetV2 = MustNewInstance(4, 30, 8, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld(), TestnetSchedule.BlocksPerEpoch()) -var testnetV3 = MustNewInstance(4, 30, 8, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld(), TestnetSchedule.BlocksPerEpoch()) +var testnetV0 = MustNewInstance(4, 16, 15, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld()) +var testnetV1 = MustNewInstance(4, 20, 15, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld()) +var testnetV2 = MustNewInstance(4, 30, 8, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpochOld()) +var testnetV3 = MustNewInstance(4, 30, 8, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch()) diff --git a/internal/params/config.go b/internal/params/config.go index ae5b096f7..cb84fbb21 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -120,7 +120,7 @@ var ( PreStakingEpoch: big.NewInt(0), QuickUnlockEpoch: big.NewInt(0), FiveSecondsEpoch: big.NewInt(0), - TwoSecondsEpoch: big.NewInt(0), + TwoSecondsEpoch: big.NewInt(3), RedelegationEpoch: big.NewInt(0), EIP155Epoch: big.NewInt(0), S3Epoch: big.NewInt(0),