diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 729c7176f..450746cc5 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.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) diff --git a/internal/configs/sharding/instance.go b/internal/configs/sharding/instance.go index dcd896d64..6fe672e4a 100644 --- a/internal/configs/sharding/instance.go +++ b/internal/configs/sharding/instance.go @@ -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 +} diff --git a/internal/configs/sharding/localnet.go b/internal/configs/sharding/localnet.go index 4bb0304df..ae97a5a8a 100644 --- a/internal/configs/sharding/localnet.go +++ b/internal/configs/sharding/localnet.go @@ -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) diff --git a/internal/configs/sharding/mainnet.go b/internal/configs/sharding/mainnet.go index 6c3247b4f..bf3fac2f1 100644 --- a/internal/configs/sharding/mainnet.go +++ b/internal/configs/sharding/mainnet.go @@ -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) diff --git a/internal/configs/sharding/testnet.go b/internal/configs/sharding/testnet.go index 2210a7017..532fea229 100644 --- a/internal/configs/sharding/testnet.go +++ b/internal/configs/sharding/testnet.go @@ -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)