Change blocks per epoch for testnet. (#3472)

* Add 3s block time and change of block reward

* fixes

* add new blocks per epoch for testnet

* remove unused code

* fix 2s changing logic

* enable 2s at epoch 73000 at testnet
pull/3473/head
Rongjian Lan 4 years ago committed by GitHub
parent d8e509cbd3
commit 60e42232a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/harmony/main.go
  2. 6
      consensus/consensus_service.go
  3. 8
      hmy/staking.go
  4. 8
      internal/chain/reward.go
  5. 8
      internal/configs/sharding/instance.go
  6. 6
      internal/configs/sharding/localnet.go
  7. 28
      internal/configs/sharding/mainnet.go
  8. 4
      internal/configs/sharding/pangaea.go
  9. 4
      internal/configs/sharding/partner.go
  10. 3
      internal/configs/sharding/shardingconfig.go
  11. 4
      internal/configs/sharding/stress.go
  12. 50
      internal/configs/sharding/testnet.go
  13. 28
      internal/params/config.go
  14. 7
      node/node_handler.go
  15. 9
      rpc/blockchain.go
  16. 8
      staking/network/reward.go
  17. 6
      staking/network/reward_test.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)
uint32(dnConfig.NumShards), dnConfig.ShardSize, dnConfig.HmyNodeSize, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, nil, shardingconfig.VLBPE, shardingconfig.VLBPE)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "ERROR invalid devnet sharding config: %s",
err)

@ -307,9 +307,9 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode {
consensus.BlockPeriod = 5 * time.Second
// Enable 3s block time at the threeSecondsEpoch
if consensus.Blockchain.Config().IsThreeSeconds(curEpoch) {
consensus.BlockPeriod = 3 * time.Second
// Enable 2s block time at the twoSecondsEpoch
if consensus.Blockchain.Config().IsTwoSeconds(nextEpoch) {
consensus.BlockPeriod = 2 * time.Second
}
isFirstTimeStaking := consensus.Blockchain.Config().IsStaking(nextEpoch) &&

@ -309,10 +309,10 @@ func (hmy *Harmony) GetValidatorInformation(
computed := availability.ComputeCurrentSigning(
snapshot.Validator, wrapper,
)
beaconChainBlocks := uint64(
hmy.BeaconChain.CurrentBlock().Header().Number().Int64(),
) % shard.Schedule.BlocksPerEpoch()
computed.BlocksLeftInEpoch = shard.Schedule.BlocksPerEpoch() - beaconChainBlocks
lastBlockOfEpoch := shard.Schedule.EpochLastBlock(hmy.BeaconChain.CurrentBlock().Header().Epoch().Uint64())
computed.BlocksLeftInEpoch = lastBlockOfEpoch - hmy.BeaconChain.CurrentBlock().Header().Number().Uint64()
if defaultReply.CurrentlyInCommittee {
defaultReply.Performance = &staking.CurrentEpochPerformance{

@ -157,13 +157,13 @@ func AccumulateRewardsAndCountSigs(
}
}
}
if bc.Config().IsThreeSeconds(header.Epoch()) {
defaultReward = network.ThreeSecondsBaseStakedReward
if bc.Config().IsTwoSeconds(header.Epoch()) {
defaultReward = network.TwoSecondsBaseStakedReward
}
} else {
// Mainnet (other nets):
if bc.Config().IsThreeSeconds(header.Epoch()) {
defaultReward = network.ThreeSecondsBaseStakedReward
if bc.Config().IsTwoSeconds(header.Epoch()) {
defaultReward = network.TwoSecondsBaseStakedReward
} else if bc.Config().IsFiveSeconds(header.Epoch()) {
defaultReward = network.FiveSecondsBaseStakedReward
}

@ -31,6 +31,7 @@ type instance struct {
hmyAccounts []genesis.DeployAccount
fnAccounts []genesis.DeployAccount
reshardingEpoch []*big.Int
blocksPerEpochOld uint64
blocksPerEpoch uint64
}
@ -40,7 +41,7 @@ func NewInstance(
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int, harmonyVotePercent numeric.Dec,
hmyAccounts []genesis.DeployAccount,
fnAccounts []genesis.DeployAccount,
reshardingEpoch []*big.Int, blocksE uint64,
reshardingEpoch []*big.Int, blocksEOld uint64, blocksE uint64,
) (Instance, error) {
if numShards < 1 {
return nil, errors.Errorf(
@ -81,6 +82,7 @@ func NewInstance(
hmyAccounts: hmyAccounts,
fnAccounts: fnAccounts,
reshardingEpoch: reshardingEpoch,
blocksPerEpochOld: blocksEOld,
blocksPerEpoch: blocksE,
}, nil
}
@ -94,11 +96,11 @@ func MustNewInstance(
harmonyVotePercent numeric.Dec,
hmyAccounts []genesis.DeployAccount,
fnAccounts []genesis.DeployAccount,
reshardingEpoch []*big.Int, blocksPerEpoch uint64,
reshardingEpoch []*big.Int, blocksPerEpochOld uint64, blocksPerEpoch uint64,
) Instance {
sc, err := NewInstance(
numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, harmonyVotePercent,
hmyAccounts, fnAccounts, reshardingEpoch, blocksPerEpoch,
hmyAccounts, fnAccounts, reshardingEpoch, blocksPerEpochOld, blocksPerEpoch,
)
if err != nil {
panic(err)

@ -118,7 +118,7 @@ var (
big.NewInt(0), big.NewInt(localnetV1Epoch), params.LocalnetChainConfig.StakingEpoch,
}
// 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())
localnetV1 = MustNewInstance(2, 8, 5, numeric.OneDec(), genesis.LocalHarmonyAccountsV1, genesis.LocalFnAccountsV1, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpoch())
localnetV2 = MustNewInstance(2, 9, 6, numeric.MustNewDecFromStr("0.68"), genesis.LocalHarmonyAccountsV2, genesis.LocalFnAccountsV2, localnetReshardingEpoch, LocalnetSchedule.BlocksPerEpoch())
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())
)

@ -171,18 +171,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())
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())
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())
)

@ -85,5 +85,5 @@ var pangaeaReshardingEpoch = []*big.Int{
params.PangaeaChainConfig.StakingEpoch,
}
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())
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())

@ -87,5 +87,5 @@ var partnerReshardingEpoch = []*big.Int{
params.TestnetChainConfig.StakingEpoch,
}
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())
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())

@ -16,9 +16,6 @@ import (
type Schedule interface {
InstanceForEpoch(epoch *big.Int) Instance
// BlocksPerEpoch returns the number of blocks per each Epoch
BlocksPerEpoch() uint64
// CalcEpochNumber returns the epoch number based on the block number
CalcEpochNumber(blockNum uint64) *big.Int

@ -87,5 +87,5 @@ var stressnetReshardingEpoch = []*big.Int{
params.StressnetChainConfig.StakingEpoch,
}
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())
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())

@ -18,6 +18,9 @@ const (
// ~304 sec epochs for P2 of open staking
testnetBlocksPerEpoch = 38
// 4.5 hours per epoch (given 2s block time)
testnetBlocksPerEpochV2 = 8192
testnetVdfDifficulty = 10000 // This takes about 20s to finish the vdf
// TestNetHTTPPattern is the http pattern for testnet.
@ -30,6 +33,8 @@ const (
func (ts testnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
switch {
case params.TestnetChainConfig.IsTwoSeconds(epoch):
return testnetV3
case epoch.Cmp(big.NewInt(testnetV2Epoch)) >= 0:
return testnetV2
case epoch.Cmp(params.TestnetChainConfig.StakingEpoch) >= 0:
@ -39,21 +44,48 @@ func (ts testnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
}
}
func (ts testnetSchedule) BlocksPerEpoch() uint64 {
func (ts testnetSchedule) BlocksPerEpochOld() uint64 {
return testnetBlocksPerEpoch
}
func (ts testnetSchedule) BlocksPerEpoch() uint64 {
return testnetBlocksPerEpochV2
}
func (ts testnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
epoch := blockNum / ts.BlocksPerEpoch()
return big.NewInt(int64(epoch))
firstBlock2s := params.TestnetChainConfig.TwoSecondsEpoch.Uint64() * ts.BlocksPerEpochOld()
switch {
case blockNum >= firstBlock2s:
return big.NewInt(int64((blockNum-firstBlock2s)/ts.BlocksPerEpoch() + params.TestnetChainConfig.TwoSecondsEpoch.Uint64()))
default: // genesis
oldEpoch := blockNum / ts.BlocksPerEpochOld()
return big.NewInt(int64(oldEpoch))
}
}
func (ts testnetSchedule) IsLastBlock(blockNum uint64) bool {
return (blockNum+1)%ts.BlocksPerEpoch() == 0
firstBlock2s := params.TestnetChainConfig.TwoSecondsEpoch.Uint64() * ts.BlocksPerEpochOld()
switch {
case blockNum >= firstBlock2s:
return ((blockNum-firstBlock2s)%ts.BlocksPerEpoch() == ts.BlocksPerEpoch()-1)
default: // genesis
return (blockNum+1)%ts.BlocksPerEpochOld() == 0
}
}
func (ts testnetSchedule) EpochLastBlock(epochNum uint64) uint64 {
return ts.BlocksPerEpoch()*(epochNum+1) - 1
firstBlock2s := params.TestnetChainConfig.TwoSecondsEpoch.Uint64() * ts.BlocksPerEpochOld()
switch {
case params.TestnetChainConfig.IsTwoSeconds(big.NewInt(int64(epochNum))):
return firstBlock2s - 1 + ts.BlocksPerEpoch()*(epochNum-params.TestnetChainConfig.TwoSecondsEpoch.Uint64()+1)
default: // genesis
return ts.BlocksPerEpochOld()*(epochNum+1) - 1
}
}
func (ts testnetSchedule) VdfDifficulty() int {
@ -88,8 +120,10 @@ func (ts testnetSchedule) IsSkippedEpoch(shardID uint32, epoch *big.Int) bool {
var testnetReshardingEpoch = []*big.Int{
big.NewInt(0),
params.TestnetChainConfig.StakingEpoch,
params.TestnetChainConfig.TwoSecondsEpoch,
}
var testnetV0 = MustNewInstance(4, 16, 15, numeric.OneDec(), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())
var testnetV1 = MustNewInstance(4, 20, 15, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())
var testnetV2 = MustNewInstance(4, 30, 8, numeric.MustNewDecFromStr("0.90"), genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch, TestnetSchedule.BlocksPerEpoch())
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())

@ -32,7 +32,7 @@ var (
PreStakingEpoch: big.NewInt(185),
QuickUnlockEpoch: big.NewInt(191),
FiveSecondsEpoch: big.NewInt(230),
ThreeSecondsEpoch: big.NewInt(10000), // TBD
TwoSecondsEpoch: big.NewInt(10000), // TBD
RedelegationEpoch: big.NewInt(290),
EIP155Epoch: big.NewInt(28),
S3Epoch: big.NewInt(28),
@ -49,7 +49,7 @@ var (
PreStakingEpoch: big.NewInt(1),
QuickUnlockEpoch: big.NewInt(0),
FiveSecondsEpoch: big.NewInt(16500),
ThreeSecondsEpoch: big.NewInt(70000),
TwoSecondsEpoch: big.NewInt(73000),
RedelegationEpoch: big.NewInt(36500),
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
@ -67,7 +67,7 @@ var (
PreStakingEpoch: big.NewInt(1),
QuickUnlockEpoch: big.NewInt(0),
FiveSecondsEpoch: big.NewInt(0),
ThreeSecondsEpoch: big.NewInt(0),
TwoSecondsEpoch: big.NewInt(0),
RedelegationEpoch: big.NewInt(0),
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
@ -85,7 +85,7 @@ var (
PreStakingEpoch: big.NewInt(1),
QuickUnlockEpoch: big.NewInt(0),
FiveSecondsEpoch: big.NewInt(0),
ThreeSecondsEpoch: big.NewInt(0),
TwoSecondsEpoch: big.NewInt(0),
RedelegationEpoch: big.NewInt(0),
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
@ -103,7 +103,7 @@ var (
PreStakingEpoch: big.NewInt(1),
QuickUnlockEpoch: big.NewInt(0),
FiveSecondsEpoch: big.NewInt(0),
ThreeSecondsEpoch: big.NewInt(0),
TwoSecondsEpoch: big.NewInt(0),
RedelegationEpoch: big.NewInt(0),
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
@ -120,7 +120,7 @@ var (
PreStakingEpoch: big.NewInt(0),
QuickUnlockEpoch: big.NewInt(0),
FiveSecondsEpoch: big.NewInt(0),
ThreeSecondsEpoch: big.NewInt(0),
TwoSecondsEpoch: big.NewInt(0),
RedelegationEpoch: big.NewInt(0),
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
@ -139,7 +139,7 @@ var (
big.NewInt(0), // PreStakingEpoch
big.NewInt(0), // QuickUnlockEpoch
big.NewInt(0), // FiveSecondsEpoch
big.NewInt(0), // ThreeSecondsEpoch
big.NewInt(0), // TwoSecondsEpoch
big.NewInt(0), // RedelegationEpoch
big.NewInt(0), // EIP155Epoch
big.NewInt(0), // S3Epoch
@ -158,7 +158,7 @@ var (
big.NewInt(0), // PreStakingEpoch
big.NewInt(0), // QuickUnlockEpoch
big.NewInt(0), // FiveSecondsEpoch
big.NewInt(0), // ThreeSecondsEpoch
big.NewInt(0), // TwoSecondsEpoch
big.NewInt(0), // RedelegationEpoch
big.NewInt(0), // EIP155Epoch
big.NewInt(0), // S3Epoch
@ -212,9 +212,9 @@ type ChainConfig struct {
// and block rewards adjusted to 17.5 ONE/block
FiveSecondsEpoch *big.Int `json:"five-seconds-epoch,omitempty"`
// ThreeSecondsEpoch is the epoch when block time is reduced to 3 seconds
// and block rewards adjusted to 10.5 ONE/block
ThreeSecondsEpoch *big.Int `json:"three-seconds-epoch,omitempty"`
// TwoSecondsEpoch is the epoch when block time is reduced to 2 seconds
// and block rewards adjusted to 7 ONE/block
TwoSecondsEpoch *big.Int `json:"two-seconds-epoch,omitempty"`
// RedelegationEpoch is the epoch when redelegation is supported and undelegation locking time
// is restored to 7 epoch
@ -280,9 +280,9 @@ func (c *ChainConfig) IsFiveSeconds(epoch *big.Int) bool {
return isForked(c.FiveSecondsEpoch, epoch)
}
// IsThreeSeconds determines whether it is the epoch to change to 3 seconds block time
func (c *ChainConfig) IsThreeSeconds(epoch *big.Int) bool {
return isForked(c.ThreeSecondsEpoch, epoch)
// IsTwoSeconds determines whether it is the epoch to change to 3 seconds block time
func (c *ChainConfig) IsTwoSeconds(epoch *big.Int) bool {
return isForked(c.TwoSecondsEpoch, epoch)
}
// IsRedelegation determines whether it is the epoch to support redelegation

@ -384,10 +384,9 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block) error {
computed := availability.ComputeCurrentSigning(
snapshot.Validator, wrapper,
)
beaconChainBlocks := uint64(
node.Beaconchain().CurrentBlock().Header().Number().Int64(),
) % shard.Schedule.BlocksPerEpoch()
computed.BlocksLeftInEpoch = shard.Schedule.BlocksPerEpoch() - beaconChainBlocks
lastBlockOfEpoch := shard.Schedule.EpochLastBlock(node.Beaconchain().CurrentBlock().Header().Epoch().Uint64())
computed.BlocksLeftInEpoch = lastBlockOfEpoch - node.Beaconchain().CurrentBlock().Header().Number().Uint64()
if err != nil && computed.IsBelowThreshold {
url := h.Availability.OnDroppedBelowThreshold

@ -24,10 +24,6 @@ const (
initSupply = int64(12600000000)
)
var (
blocksPeriod = shard.Schedule.BlocksPerEpoch()
)
// PublicBlockchainService provides an API to access the Harmony blockchain.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicBlockchainService struct {
@ -376,8 +372,9 @@ func (s *PublicBlockchainService) GetSignedBlocks(
totalSigned := uint64(0)
lastBlock := uint64(0)
blockHeight := s.hmy.CurrentBlock().Number().Uint64()
if blockHeight >= blocksPeriod {
lastBlock = blockHeight - blocksPeriod + 1
instance := shard.Schedule.InstanceForEpoch(s.hmy.CurrentBlock().Epoch())
if blockHeight >= instance.BlocksPerEpoch() {
lastBlock = blockHeight - instance.BlocksPerEpoch() + 1
}
for i := lastBlock; i <= blockHeight; i++ {
signed, err := s.IsBlockSigner(ctx, BlockNumber(i), address)

@ -25,10 +25,10 @@ var (
FiveSecondsBaseStakedReward = numeric.NewDecFromBigInt(new(big.Int).Mul(
big.NewInt(17.5*denominations.Nano), big.NewInt(denominations.Nano),
))
// ThreeSecondsBaseStakedReward is the flat-rate block reward after epoch 360.
// 10.5 ONE per block
ThreeSecondsBaseStakedReward = numeric.NewDecFromBigInt(new(big.Int).Mul(
big.NewInt(10.5*denominations.Nano), big.NewInt(denominations.Nano),
// TwoSecondsBaseStakedReward is the flat-rate block reward after epoch 360.
// 7 ONE per block
TwoSecondsBaseStakedReward = numeric.NewDecFromBigInt(new(big.Int).Mul(
big.NewInt(7*denominations.Nano), big.NewInt(denominations.Nano),
))
// BlockRewardStakedCase is the baseline block reward in staked case -
totalTokens = numeric.NewDecFromBigInt(

@ -15,10 +15,10 @@ func TestFiveSecondsBaseStakedReward(t *testing.T) {
)
}
expectedNewReward = BaseStakedReward.Mul(numeric.MustNewDecFromStr("3")).Quo(numeric.MustNewDecFromStr("8"))
if !expectedNewReward.Equal(ThreeSecondsBaseStakedReward) {
expectedNewReward = BaseStakedReward.Mul(numeric.MustNewDecFromStr("2")).Quo(numeric.MustNewDecFromStr("8"))
if !expectedNewReward.Equal(TwoSecondsBaseStakedReward) {
t.Errorf(
"Expected: %s, Got: %s", ThreeSecondsBaseStakedReward.String(), expectedNewReward.String(),
"Expected: %s, Got: %s", TwoSecondsBaseStakedReward.String(), expectedNewReward.String(),
)
}
}

Loading…
Cancel
Save