[epoch] support HIP-6 and HIP-8 (#3886)

* HIP-6: increase external voting power to 51%
* HIP-8: increase external slots to 900
* never enable for local net

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3891/head
Leo Chen 3 years ago committed by GitHub
parent 5252dd374f
commit ef81572f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      go.mod
  2. 8
      internal/configs/sharding/mainnet.go
  3. 24
      internal/params/config.go

@ -58,7 +58,7 @@ require (
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/tools v0.0.0-20210106214847-113979e3529a
golang.org/x/tools v0.1.7
google.golang.org/grpc v1.33.2
google.golang.org/protobuf v1.25.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c

@ -53,6 +53,11 @@ type mainnetSchedule struct{}
func (ms mainnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
switch {
case params.MainnetChainConfig.IsHIP6And8Epoch(epoch):
// Decrease internal voting power from 60% to 49%
// Increase external nodes from 800 to 900
// which happens around 10/11/2021 22:00 PDT
return mainnetV3_2
case params.MainnetChainConfig.IsSixtyPercent(epoch):
// Decrease internal voting power from 68% to 60%
// which happens around 1/27/2021 22:00 PDT
@ -194,7 +199,7 @@ func (ms mainnetSchedule) IsSkippedEpoch(shardID uint32, epoch *big.Int) bool {
return false
}
var mainnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(mainnetV0_1Epoch), big.NewInt(mainnetV0_2Epoch), big.NewInt(mainnetV0_3Epoch), big.NewInt(mainnetV0_4Epoch), big.NewInt(mainnetV1Epoch), big.NewInt(mainnetV1_1Epoch), big.NewInt(mainnetV1_2Epoch), big.NewInt(mainnetV1_3Epoch), big.NewInt(mainnetV1_4Epoch), big.NewInt(mainnetV1_5Epoch), big.NewInt(mainnetV2_0Epoch), big.NewInt(mainnetV2_1Epoch), big.NewInt(mainnetV2_2Epoch), params.MainnetChainConfig.TwoSecondsEpoch, params.MainnetChainConfig.SixtyPercentEpoch}
var mainnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(mainnetV0_1Epoch), big.NewInt(mainnetV0_2Epoch), big.NewInt(mainnetV0_3Epoch), big.NewInt(mainnetV0_4Epoch), big.NewInt(mainnetV1Epoch), big.NewInt(mainnetV1_1Epoch), big.NewInt(mainnetV1_2Epoch), big.NewInt(mainnetV1_3Epoch), big.NewInt(mainnetV1_4Epoch), big.NewInt(mainnetV1_5Epoch), big.NewInt(mainnetV2_0Epoch), big.NewInt(mainnetV2_1Epoch), big.NewInt(mainnetV2_2Epoch), params.MainnetChainConfig.TwoSecondsEpoch, params.MainnetChainConfig.SixtyPercentEpoch, params.MainnetChainConfig.HIP6And8Epoch}
var (
mainnetV0 = MustNewInstance(4, 150, 112, numeric.OneDec(), genesis.HarmonyAccounts, genesis.FoundationalNodeAccounts, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpochOld())
@ -213,4 +218,5 @@ var (
mainnetV2_2 = MustNewInstance(4, 250, 90, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpochOld())
mainnetV3 = MustNewInstance(4, 250, 90, numeric.MustNewDecFromStr("0.68"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
mainnetV3_1 = MustNewInstance(4, 250, 50, numeric.MustNewDecFromStr("0.60"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
mainnetV3_2 = MustNewInstance(4, 250, 25, numeric.MustNewDecFromStr("0.49"), genesis.HarmonyAccounts, genesis.FoundationalNodeAccountsV1_5, mainnetReshardingEpoch, MainnetSchedule.BlocksPerEpoch())
)

@ -62,7 +62,8 @@ var (
DataCopyFixEpoch: big.NewInt(689), // Around Wed Sept 15th 2021 with 3.5s block time
IstanbulEpoch: big.NewInt(314),
ReceiptLogEpoch: big.NewInt(101),
SHA3Epoch: EpochTBD, //EpochTBD
SHA3Epoch: EpochTBD, //EpochTBD
HIP6And8Epoch: big.NewInt(725), // Around Mon Oct 11 2021, 19:00 UTC
}
// TestnetChainConfig contains the chain parameters to run a node on the harmony test network.
@ -94,6 +95,7 @@ var (
IstanbulEpoch: big.NewInt(43800),
ReceiptLogEpoch: big.NewInt(0),
SHA3Epoch: EpochTBD, //EpochTBD
HIP6And8Epoch: big.NewInt(74590),
}
// PangaeaChainConfig contains the chain parameters for the Pangaea network.
@ -126,6 +128,7 @@ var (
IstanbulEpoch: big.NewInt(0),
ReceiptLogEpoch: big.NewInt(0),
SHA3Epoch: big.NewInt(0),
HIP6And8Epoch: big.NewInt(0),
}
// PartnerChainConfig contains the chain parameters for the Partner network.
@ -158,6 +161,7 @@ var (
IstanbulEpoch: big.NewInt(0),
ReceiptLogEpoch: big.NewInt(0),
SHA3Epoch: big.NewInt(0),
HIP6And8Epoch: big.NewInt(0),
}
// StressnetChainConfig contains the chain parameters for the Stress test network.
@ -190,6 +194,7 @@ var (
IstanbulEpoch: big.NewInt(0),
ReceiptLogEpoch: big.NewInt(0),
SHA3Epoch: big.NewInt(0),
HIP6And8Epoch: big.NewInt(0),
}
// LocalnetChainConfig contains the chain parameters to run for local development.
@ -221,6 +226,7 @@ var (
IstanbulEpoch: big.NewInt(0),
ReceiptLogEpoch: big.NewInt(0),
SHA3Epoch: big.NewInt(0),
HIP6And8Epoch: EpochTBD, // Never enable it for localnet as localnet has no external validator setup
}
// AllProtocolChanges ...
@ -253,7 +259,8 @@ var (
big.NewInt(0), // DataCopyFixEpoch
big.NewInt(0), // IstanbulEpoch
big.NewInt(0), // ReceiptLogEpoch
big.NewInt(0),
big.NewInt(0), // SHA3Epoch
big.NewInt(0), // HIP6And8Epoch
}
// TestChainConfig ...
@ -286,7 +293,8 @@ var (
big.NewInt(0), // DataCopyFixEpoch
big.NewInt(0), // IstanbulEpoch
big.NewInt(0), // ReceiptLogEpoch
big.NewInt(0),
big.NewInt(0), // SHA3Epoch
big.NewInt(0), // HIP6And8Epoch
}
// TestRules ...
@ -398,6 +406,9 @@ type ChainConfig struct {
// IsSHA3Epoch is the first epoch in supporting SHA3 FIPS-202 standard
SHA3Epoch *big.Int `json:"sha3-epoch,omitempty"`
// IsHIP6And8Epoch is the first epoch to support HIP-6 and HIP-8
HIP6And8Epoch *big.Int `json:"hip6_8-epoch,omitempty"`
}
// String implements the fmt.Stringer interface.
@ -544,6 +555,13 @@ func (c *ChainConfig) IsSHA3(epoch *big.Int) bool {
return isForked(c.SHA3Epoch, epoch)
}
// IsHIP6And8Epoch determines whether it is the epoch to support
// HIP-6: reduce the internal voting power from 60% to 49%
// HIP-8: increase external nodes from 800 to 900
func (c *ChainConfig) IsHIP6And8Epoch(epoch *big.Int) bool {
return isForked(c.HIP6And8Epoch, epoch)
}
// UpdateEthChainIDByShard update the ethChainID based on shard ID.
func UpdateEthChainIDByShard(shardID uint32) {
once.Do(func() {

Loading…
Cancel
Save