Add stressnet config

* Add stressnet config to main.go
* Add stressnet config internals
pull/2453/head
Daniel Van Der Maden 5 years ago
parent ff0702798f
commit eb8c9bb0f7
  1. 11
      block/factory/factory.go
  2. 2
      cmd/harmony/main.go
  3. 15
      internal/configs/node/config.go
  4. 2
      internal/configs/node/group.go
  5. 1
      internal/configs/sharding/instance.go
  6. 84
      internal/configs/sharding/stress.go
  7. 14
      internal/params/config.go
  8. 2
      internal/wallet/configfile.go
  9. 2
      node/node_genesis.go

@ -45,11 +45,12 @@ func (f *factory) NewHeader(epoch *big.Int) *block.Header {
// Factories corresponding to well-known chain configurations.
var (
ForTest = NewFactory(params.TestChainConfig)
ForTestnet = NewFactory(params.TestnetChainConfig)
ForMainnet = NewFactory(params.MainnetChainConfig)
ForPangaea = NewFactory(params.PangaeaChainConfig)
ForPartner = NewFactory(params.PartnerChainConfig)
ForTest = NewFactory(params.TestChainConfig)
ForTestnet = NewFactory(params.TestnetChainConfig)
ForMainnet = NewFactory(params.MainnetChainConfig)
ForPangaea = NewFactory(params.PangaeaChainConfig)
ForPartner = NewFactory(params.PartnerChainConfig)
ForStressnet = NewFactory(params.StressnetChainConfig)
)
// NewTestHeader creates a new, empty header object for epoch 0 using the test

@ -615,6 +615,8 @@ func main() {
shard.Schedule = shardingconfig.LocalnetSchedule
case nodeconfig.Partner:
shard.Schedule = shardingconfig.PartnerSchedule
case nodeconfig.Stressnet:
shard.Schedule = shardingconfig.StressNetSchedule
case nodeconfig.Devnet:
if *devnetHarmonySize < 0 {
*devnetHarmonySize = *devnetShardSize

@ -51,12 +51,13 @@ type NetworkType string
// Constants for NetworkType
const (
Mainnet = "mainnet"
Testnet = "testnet"
Pangaea = "pangaea"
Partner = "partner"
Devnet = "devnet"
Localnet = "localnet"
Mainnet = "mainnet"
Testnet = "testnet"
Pangaea = "pangaea"
Partner = "partner"
Stressnet = "stressnet"
Devnet = "devnet"
Localnet = "localnet"
)
// Global is the index of the global node configuration
@ -323,6 +324,8 @@ func (t NetworkType) ChainConfig() params.ChainConfig {
return *params.PangaeaChainConfig
case Partner:
return *params.PartnerChainConfig
case Stressnet:
return *params.StressnetChainConfig
case Localnet:
return *params.LocalnetChainConfig
default:

@ -43,6 +43,8 @@ func getNetworkPrefix(shardID ShardID) (netPre string) {
netPre = "hmy/pangaea"
case Partner:
netPre = "hmy/partner"
case Stressnet:
netPre = "hmy/stressnet"
case Devnet:
netPre = "hmy/devnet"
case Localnet:

@ -17,6 +17,7 @@ const (
LocalNet
Pangaea
Partner
StressNet
DevNet
)

@ -0,0 +1,84 @@
package shardingconfig
import (
"math/big"
"github.com/harmony-one/harmony/internal/genesis"
"github.com/harmony-one/harmony/internal/params"
)
// StressNetSchedule is the long-running public stressNet sharding
// configuration schedule.
var StressNetSchedule stressnetSchedule
type stressnetSchedule struct{}
const (
// 10 minutes per epoch (at 8s/block)
stressnetBlocksPerEpoch = 75
stressnetVdfDifficulty = 10000 // This takes about 20s to finish the vdf
// StressNetHTTPPattern is the http pattern for stressnet.
StressNetHTTPPattern = "https://api.s%d.os.hmny.io"
// StressNetWSPattern is the websocket pattern for stressnet.
StressNetWSPattern = "wss://ws.s%d.os.hmny.io"
)
func (stressnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
switch {
case epoch.Cmp(params.StressnetChainConfig.StakingEpoch) >= 0:
return stressnetV1
default: // genesis
return stressnetV0
}
}
func (stressnetSchedule) BlocksPerEpoch() uint64 {
return stressnetBlocksPerEpoch
}
func (ss stressnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
epoch := blockNum / ss.BlocksPerEpoch()
return big.NewInt(int64(epoch))
}
func (ss stressnetSchedule) IsLastBlock(blockNum uint64) bool {
return (blockNum+1)%ss.BlocksPerEpoch() == 0
}
func (ss stressnetSchedule) EpochLastBlock(epochNum uint64) uint64 {
return ss.BlocksPerEpoch()*(epochNum+1) - 1
}
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 {
return mainnetRandomnessStartingEpoch
}
func (ss stressnetSchedule) GetNetworkID() NetworkID {
return StressNet
}
// GetShardingStructure is the sharding structure for stressnet.
func (ss stressnetSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} {
return genShardingStructure(numShard, shardID, StressNetHTTPPattern, StressNetWSPattern)
}
var stressnetReshardingEpoch = []*big.Int{
big.NewInt(0),
params.StressnetChainConfig.StakingEpoch,
}
var stressnetV0 = MustNewInstance(4, 27, 27, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, stressnetReshardingEpoch, StressNetSchedule.BlocksPerEpoch())
var stressnetV1 = MustNewInstance(4, 50, 27, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, stressnetReshardingEpoch, StressNetSchedule.BlocksPerEpoch())

@ -13,6 +13,7 @@ var (
TestnetChainID = big.NewInt(2)
PangaeaChainID = big.NewInt(3)
PartnerChainID = big.NewInt(4)
StressnetChainID = big.NewInt(5)
TestChainID = big.NewInt(99) // not a real network
AllProtocolChangesChainID = big.NewInt(100) // not a real network
)
@ -72,6 +73,19 @@ var (
ReceiptLogEpoch: big.NewInt(0),
}
// StressnetChainConfig contains the chain parameters for the Stress test network.
// All features except for CrossLink are enabled at launch.
StressnetChainConfig = &ChainConfig{
ChainID: StressnetChainID,
CrossTxEpoch: big.NewInt(0),
CrossLinkEpoch: big.NewInt(2),
StakingEpoch: big.NewInt(2),
PreStakingEpoch: big.NewInt(1),
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
ReceiptLogEpoch: big.NewInt(0),
}
// LocalnetChainConfig contains the chain parameters to run for local development.
LocalnetChainConfig = &ChainConfig{
ChainID: TestnetChainID,

@ -60,6 +60,8 @@ func ReadProfile(iniBytes []byte, profile string) (*Profile, error) {
config.ChainID = params.PangaeaChainID.String()
case "partner":
config.ChainID = params.PartnerChainID.String()
case "stressnet":
config.ChainID = params.StressnetChainID.String()
default:
config.ChainID = params.TestnetChainID.String()
}

@ -90,6 +90,8 @@ func (node *Node) SetupGenesisBlock(db ethdb.Database, shardID uint32, myShardSt
chainConfig = *params.PangaeaChainConfig
case nodeconfig.Partner:
chainConfig = *params.PartnerChainConfig
case nodeconfig.Stressnet:
chainConfig = *params.StressnetChainConfig
default: // all other types share testnet config
chainConfig = *params.TestChainConfig
}

Loading…
Cancel
Save