[resharding] add new node resharding/game support

Signed-off-by: Leo Chen <leo@harmony.one>
pull/1224/head
Leo Chen 5 years ago
parent 7d353c4120
commit 4bde201697
  1. 2
      cmd/harmony/main.go
  2. 13
      internal/configs/sharding/instance.go
  3. 8
      internal/configs/sharding/localnet.go
  4. 2
      internal/configs/sharding/mainnet.go
  5. 2
      internal/configs/sharding/testnet.go

@ -416,7 +416,7 @@ func main() {
}
// TODO (leo): use a passing list of accounts here
devnetConfig, err := shardingconfig.NewInstance(
uint32(*devnetNumShards), *devnetShardSize, *devnetHarmonySize, genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts)
uint32(*devnetNumShards), *devnetShardSize, *devnetHarmonySize, genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, nil)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "invalid devnet sharding config: %s",
err)

@ -1,6 +1,8 @@
package shardingconfig
import (
"math/big"
"github.com/harmony-one/harmony/internal/ctxerror"
"github.com/harmony-one/harmony/internal/genesis"
)
@ -11,6 +13,7 @@ type instance struct {
numHarmonyOperatedNodesPerShard int
hmyAccounts []genesis.DeployAccount
fnAccounts []genesis.DeployAccount
reshardingEpoch []*big.Int
}
// NewInstance creates and validates a new sharding configuration based
@ -19,6 +22,7 @@ func NewInstance(
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int,
hmyAccounts []genesis.DeployAccount,
fnAccounts []genesis.DeployAccount,
reshardingEpoch []*big.Int,
) (Instance, error) {
if numShards < 1 {
return nil, ctxerror.New("sharding config must have at least one shard",
@ -45,6 +49,7 @@ func NewInstance(
numHarmonyOperatedNodesPerShard: numHarmonyOperatedNodesPerShard,
hmyAccounts: hmyAccounts,
fnAccounts: fnAccounts,
reshardingEpoch: reshardingEpoch,
}, nil
}
@ -55,9 +60,10 @@ func MustNewInstance(
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int,
hmyAccounts []genesis.DeployAccount,
fnAccounts []genesis.DeployAccount,
reshardingEpoch []*big.Int,
) Instance {
sc, err := NewInstance(
numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, hmyAccounts, fnAccounts)
numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, hmyAccounts, fnAccounts, reshardingEpoch)
if err != nil {
panic(err)
}
@ -107,3 +113,8 @@ func (sc instance) FindAccount(blsPubKey string) (bool, *genesis.DeployAccount)
}
return false, nil
}
// ReshardingEpoch returns the list of epoch number
func (sc instance) ReshardingEpoch() []*big.Int {
return sc.reshardingEpoch
}

@ -23,6 +23,8 @@ func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
}
}
var localnetV0 = MustNewInstance(2, 7, 5, genesis.LocalHarmonyAccounts, genesis.LocalFnAccounts)
var localnetV1 = MustNewInstance(2, 7, 5, genesis.LocalHarmonyAccountsV1, genesis.LocalFnAccountsV1)
var localnetV2 = MustNewInstance(2, 7, 4, genesis.LocalHarmonyAccountsV2, genesis.LocalFnAccountsV2)
var reshardingEpoch = []*big.Int{big.NewInt(10), big.NewInt(20)}
var localnetV0 = MustNewInstance(2, 7, 5, genesis.LocalHarmonyAccounts, genesis.LocalFnAccounts, reshardingEpoch)
var localnetV1 = MustNewInstance(2, 7, 5, genesis.LocalHarmonyAccountsV1, genesis.LocalFnAccountsV1, reshardingEpoch)
var localnetV2 = MustNewInstance(2, 7, 4, genesis.LocalHarmonyAccountsV2, genesis.LocalFnAccountsV2, reshardingEpoch)

@ -22,7 +22,7 @@ func (mainnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
}
}
var mainnetV0 = MustNewInstance(4, 150, 112, genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts)
var mainnetV0 = MustNewInstance(4, 150, 112, genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, nil)
//var mainnetV2 = MustNewInstance(8, 200, 100)
//var mainnet6400 = MustNewInstance(16, 400, 50)

@ -19,4 +19,4 @@ func (testnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
}
}
var testnetV0 = MustNewInstance(2, 150, 150, genesis.TNHarmonyAccounts, genesis.FoundationalNodeAccounts)
var testnetV0 = MustNewInstance(2, 150, 150, genesis.TNHarmonyAccounts, genesis.FoundationalNodeAccounts, nil)

Loading…
Cancel
Save