diff --git a/internal/configs/sharding/pangaea.go b/internal/configs/sharding/pangaea.go index 391856eb0..34537bbac 100644 --- a/internal/configs/sharding/pangaea.go +++ b/internal/configs/sharding/pangaea.go @@ -3,15 +3,8 @@ package shardingconfig import ( "math/big" - "github.com/ethereum/go-ethereum/common" "github.com/harmony-one/harmony/internal/genesis" -) - -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" + "github.com/harmony-one/harmony/internal/params" ) // PangaeaSchedule is the Pangaea sharding configuration schedule. @@ -19,16 +12,34 @@ var PangaeaSchedule pangaeaSchedule type pangaeaSchedule struct{} -func (ps pangaeaSchedule) InstanceForEpoch(epoch *big.Int) Instance { - return pangaeaV0 +const ( + // 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 { - return 150 // 1/3 hour with 8 seconds/block + return pangaeaBlocksPerEpoch } 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 { @@ -36,23 +47,17 @@ func (ps pangaeaSchedule) IsLastBlock(blockNum uint64) bool { } func (ps pangaeaSchedule) EpochLastBlock(epochNum uint64) uint64 { - blocks := ps.BlocksPerEpoch() - return blocks*(epochNum+1) - 1 + return ps.BlocksPerEpoch()*(epochNum+1) - 1 } func (ps pangaeaSchedule) VdfDifficulty() int { - return testnetVdfDifficulty + return pangaeaVdfDifficulty } func (ps pangaeaSchedule) ConsensusRatio() float64 { 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 //RandonnessStartingEpoch returns starting epoch of randonness generation func (ps pangaeaSchedule) RandomnessStartingEpoch() uint64 { @@ -67,3 +72,11 @@ func (pangaeaSchedule) GetNetworkID() NetworkID { func (pangaeaSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} { 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()) diff --git a/internal/params/config.go b/internal/params/config.go index 0f776058d..f108b2fe5 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -50,9 +50,9 @@ var ( PangaeaChainConfig = &ChainConfig{ ChainID: PangaeaChainID, CrossTxEpoch: big.NewInt(0), - CrossLinkEpoch: big.NewInt(3), - StakingEpoch: big.NewInt(3), - PreStakingEpoch: 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), diff --git a/scripts/node.sh b/scripts/node.sh index ef084864a..f2740b991 100755 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -261,8 +261,8 @@ staking) /ip4/54.86.126.90/tcp/9867/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv /ip4/52.40.84.2/tcp/9867/p2p/QmbPVwrqWsTYXq1RxGWcxx9SWaTUCfoo1wA6wmdbduWe29 ) - REL=testnet - network_type=testnet + REL=pangaea + network_type=pangaea dns_zone=os.hmny.io ;; devnet) @@ -271,7 +271,7 @@ devnet) /ip4/54.86.126.90/tcp/9870/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv ) REL=devnet - network_type=pangaea + network_type=devnet dns_zone=pga.hmny.io ;; *)