|
|
@ -3,15 +3,8 @@ package shardingconfig |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
|
|
|
"github.com/harmony-one/harmony/internal/genesis" |
|
|
|
"github.com/harmony-one/harmony/internal/genesis" |
|
|
|
) |
|
|
|
"github.com/harmony-one/harmony/internal/params" |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
|
|
// PangaeaHTTPPattern is the http pattern for pangaea.
|
|
|
|
|
|
|
|
PangaeaHTTPPattern = "https://api.s%d.pga.hmny.io" |
|
|
|
|
|
|
|
// PangaeaWSPattern is the websocket pattern for pangaea.
|
|
|
|
|
|
|
|
PangaeaWSPattern = "wss://ws.s%d.pga.hmny.io" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// PangaeaSchedule is the Pangaea sharding configuration schedule.
|
|
|
|
// PangaeaSchedule is the Pangaea sharding configuration schedule.
|
|
|
@ -19,16 +12,34 @@ var PangaeaSchedule pangaeaSchedule |
|
|
|
|
|
|
|
|
|
|
|
type pangaeaSchedule struct{} |
|
|
|
type pangaeaSchedule struct{} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) InstanceForEpoch(epoch *big.Int) Instance { |
|
|
|
const ( |
|
|
|
return pangaeaV0 |
|
|
|
// 10 minutes per epoch (at 8s/block)
|
|
|
|
|
|
|
|
pangaeaBlocksPerEpoch = 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pangaeaVdfDifficulty = 10000 // This takes about 20s to finish the vdf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PangaeaHTTPPattern is the http pattern for pangaea.
|
|
|
|
|
|
|
|
PangaeaHTTPPattern = "https://api.s%d.os.hmny.io" |
|
|
|
|
|
|
|
// PangaeaWSPattern is the websocket pattern for pangaea.
|
|
|
|
|
|
|
|
PangaeaWSPattern = "wss://ws.s%d.os.hmny.io" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (pangaeaSchedule) InstanceForEpoch(epoch *big.Int) Instance { |
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case epoch.Cmp(params.PangaeaChainConfig.StakingEpoch) >= 0: |
|
|
|
|
|
|
|
return pangaeaV1 |
|
|
|
|
|
|
|
default: // genesis
|
|
|
|
|
|
|
|
return pangaeaV0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) BlocksPerEpoch() uint64 { |
|
|
|
func (ps pangaeaSchedule) BlocksPerEpoch() uint64 { |
|
|
|
return 150 // 1/3 hour with 8 seconds/block
|
|
|
|
return pangaeaBlocksPerEpoch |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) CalcEpochNumber(blockNum uint64) *big.Int { |
|
|
|
func (ps pangaeaSchedule) CalcEpochNumber(blockNum uint64) *big.Int { |
|
|
|
return big.NewInt(int64(blockNum / ps.BlocksPerEpoch())) |
|
|
|
epoch := blockNum / ps.BlocksPerEpoch() |
|
|
|
|
|
|
|
return big.NewInt(int64(epoch)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) IsLastBlock(blockNum uint64) bool { |
|
|
|
func (ps pangaeaSchedule) IsLastBlock(blockNum uint64) bool { |
|
|
@ -36,23 +47,17 @@ func (ps pangaeaSchedule) IsLastBlock(blockNum uint64) bool { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) EpochLastBlock(epochNum uint64) uint64 { |
|
|
|
func (ps pangaeaSchedule) EpochLastBlock(epochNum uint64) uint64 { |
|
|
|
blocks := ps.BlocksPerEpoch() |
|
|
|
return ps.BlocksPerEpoch()*(epochNum+1) - 1 |
|
|
|
return blocks*(epochNum+1) - 1 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) VdfDifficulty() int { |
|
|
|
func (ps pangaeaSchedule) VdfDifficulty() int { |
|
|
|
return testnetVdfDifficulty |
|
|
|
return pangaeaVdfDifficulty |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ps pangaeaSchedule) ConsensusRatio() float64 { |
|
|
|
func (ps pangaeaSchedule) ConsensusRatio() float64 { |
|
|
|
return mainnetConsensusRatio |
|
|
|
return mainnetConsensusRatio |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var pangaeaReshardingEpoch = []*big.Int{common.Big0} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pangaeaV0 = MustNewInstance( |
|
|
|
|
|
|
|
2, 50, 40, genesis.PangaeaAccounts, genesis.FoundationalPangaeaAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: remove it after randomness feature turned on mainnet
|
|
|
|
// TODO: remove it after randomness feature turned on mainnet
|
|
|
|
//RandonnessStartingEpoch returns starting epoch of randonness generation
|
|
|
|
//RandonnessStartingEpoch returns starting epoch of randonness generation
|
|
|
|
func (ps pangaeaSchedule) RandomnessStartingEpoch() uint64 { |
|
|
|
func (ps pangaeaSchedule) RandomnessStartingEpoch() uint64 { |
|
|
@ -67,3 +72,11 @@ func (pangaeaSchedule) GetNetworkID() NetworkID { |
|
|
|
func (pangaeaSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} { |
|
|
|
func (pangaeaSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} { |
|
|
|
return genShardingStructure(numShard, shardID, PangaeaHTTPPattern, PangaeaWSPattern) |
|
|
|
return genShardingStructure(numShard, shardID, PangaeaHTTPPattern, PangaeaWSPattern) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pangaeaReshardingEpoch = []*big.Int{ |
|
|
|
|
|
|
|
big.NewInt(0), |
|
|
|
|
|
|
|
params.PangaeaChainConfig.StakingEpoch, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pangaeaV0 = MustNewInstance(4, 25, 25, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch()) |
|
|
|
|
|
|
|
var pangaeaV1 = MustNewInstance(4, 50, 25, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, pangaeaReshardingEpoch, PangaeaSchedule.BlocksPerEpoch()) |
|
|
|