mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
Merge pull request #226 from XinFinOrg/use-constant-on-forking-param
add v2 testnet forking constant parameter
This commit is contained in:
commit
8b1f77ea01
6 changed files with 55 additions and 39 deletions
|
|
@ -36,6 +36,8 @@ var TIP2019Block = big.NewInt(1)
|
||||||
var TIPSigning = big.NewInt(3000000)
|
var TIPSigning = big.NewInt(3000000)
|
||||||
var TIPRandomize = big.NewInt(3464000)
|
var TIPRandomize = big.NewInt(3464000)
|
||||||
|
|
||||||
|
var TIPV2SwitchBlock = big.NewInt(99999999999)
|
||||||
|
|
||||||
var TIPIncreaseMasternodes = big.NewInt(5000000) // Upgrade MN Count at Block.
|
var TIPIncreaseMasternodes = big.NewInt(5000000) // Upgrade MN Count at Block.
|
||||||
var TIPNoHalvingMNReward = big.NewInt(38383838) // hardfork no halving masternodes reward
|
var TIPNoHalvingMNReward = big.NewInt(38383838) // hardfork no halving masternodes reward
|
||||||
var BlackListHFNumber = uint64(38383838)
|
var BlackListHFNumber = uint64(38383838)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ var TIP2019Block = big.NewInt(1)
|
||||||
var TIPSigning = big.NewInt(225000)
|
var TIPSigning = big.NewInt(225000)
|
||||||
var TIPRandomize = big.NewInt(225000)
|
var TIPRandomize = big.NewInt(225000)
|
||||||
|
|
||||||
|
var TIPV2SwitchBlock = big.NewInt(7074000)
|
||||||
|
|
||||||
var TIPIncreaseMasternodes = big.NewInt(225000) // Upgrade MN Count at Block.
|
var TIPIncreaseMasternodes = big.NewInt(225000) // Upgrade MN Count at Block.
|
||||||
var TIPNoHalvingMNReward = big.NewInt(429987) // hardfork no halving masternodes reward
|
var TIPNoHalvingMNReward = big.NewInt(429987) // hardfork no halving masternodes reward
|
||||||
var BlackListHFNumber = uint64(225000)
|
var BlackListHFNumber = uint64(225000)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func TestIsAuthorisedMNForConsensusV2(t *testing.T) {
|
||||||
func TestIsYourTurnConsensusV2(t *testing.T) {
|
func TestIsYourTurnConsensusV2(t *testing.T) {
|
||||||
// we skip test for v1 since it's hard to make a real genesis block
|
// we skip test for v1 since it's hard to make a real genesis block
|
||||||
blockchain, _, currentBlock, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 900, params.TestXDPoSMockChainConfig, nil)
|
blockchain, _, currentBlock, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 900, params.TestXDPoSMockChainConfig, nil)
|
||||||
minePeriod := params.TestV2Configs[0].MinePeriod
|
minePeriod := params.UnitTestV2Configs[0].MinePeriod
|
||||||
adaptor := blockchain.Engine().(*XDPoS.XDPoS)
|
adaptor := blockchain.Engine().(*XDPoS.XDPoS)
|
||||||
blockNum := 901
|
blockNum := 901
|
||||||
blockCoinBase := "0x111000000000000000000000000000000123"
|
blockCoinBase := "0x111000000000000000000000000000000123"
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ func TestTimeoutPeriodAndThreadholdConfigChange(t *testing.T) {
|
||||||
|
|
||||||
// Timeout handler
|
// Timeout handler
|
||||||
func TestTimeoutMessageHandlerSuccessfullyGenerateTCandSyncInfo(t *testing.T) {
|
func TestTimeoutMessageHandlerSuccessfullyGenerateTCandSyncInfo(t *testing.T) {
|
||||||
params.TestXDPoSMockChainConfig.XDPoS.V2.CurrentConfig = params.TestV2Configs[0]
|
params.TestXDPoSMockChainConfig.XDPoS.V2.CurrentConfig = params.UnitTestV2Configs[0]
|
||||||
blockchain, _, _, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 11, params.TestXDPoSMockChainConfig, nil)
|
blockchain, _, _, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 11, params.TestXDPoSMockChainConfig, nil)
|
||||||
engineV2 := blockchain.Engine().(*XDPoS.XDPoS).EngineV2
|
engineV2 := blockchain.Engine().(*XDPoS.XDPoS).EngineV2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ var (
|
||||||
MinePeriod: 10,
|
MinePeriod: 10,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
TestV2Configs = map[uint64]*V2Config{
|
|
||||||
|
TestnetV2Configs = map[uint64]*V2Config{
|
||||||
Default: {
|
Default: {
|
||||||
SwitchRound: 0,
|
SwitchRound: 0,
|
||||||
CertThreshold: 3,
|
CertThreshold: 3,
|
||||||
|
|
@ -66,22 +67,6 @@ var (
|
||||||
WaitPeriod: 1,
|
WaitPeriod: 1,
|
||||||
MinePeriod: 2,
|
MinePeriod: 2,
|
||||||
},
|
},
|
||||||
10: {
|
|
||||||
SwitchRound: 10,
|
|
||||||
CertThreshold: 5,
|
|
||||||
TimeoutSyncThreshold: 2,
|
|
||||||
TimeoutPeriod: 4,
|
|
||||||
WaitPeriod: 2,
|
|
||||||
MinePeriod: 3,
|
|
||||||
},
|
|
||||||
899: {
|
|
||||||
SwitchRound: 899,
|
|
||||||
CertThreshold: 5,
|
|
||||||
TimeoutSyncThreshold: 4,
|
|
||||||
TimeoutPeriod: 5,
|
|
||||||
WaitPeriod: 2,
|
|
||||||
MinePeriod: 3,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DevnetV2Configs = map[uint64]*V2Config{
|
DevnetV2Configs = map[uint64]*V2Config{
|
||||||
|
|
@ -135,6 +120,33 @@ var (
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnitTestV2Configs = map[uint64]*V2Config{
|
||||||
|
Default: {
|
||||||
|
SwitchRound: 0,
|
||||||
|
CertThreshold: 3,
|
||||||
|
TimeoutSyncThreshold: 2,
|
||||||
|
TimeoutPeriod: 4,
|
||||||
|
WaitPeriod: 1,
|
||||||
|
MinePeriod: 2,
|
||||||
|
},
|
||||||
|
10: {
|
||||||
|
SwitchRound: 10,
|
||||||
|
CertThreshold: 5,
|
||||||
|
TimeoutSyncThreshold: 2,
|
||||||
|
TimeoutPeriod: 4,
|
||||||
|
WaitPeriod: 2,
|
||||||
|
MinePeriod: 3,
|
||||||
|
},
|
||||||
|
899: {
|
||||||
|
SwitchRound: 899,
|
||||||
|
CertThreshold: 5,
|
||||||
|
TimeoutSyncThreshold: 4,
|
||||||
|
TimeoutPeriod: 5,
|
||||||
|
WaitPeriod: 2,
|
||||||
|
MinePeriod: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// XDPoSChain mainnet config
|
// XDPoSChain mainnet config
|
||||||
XDCMainnetChainConfig = &ChainConfig{
|
XDCMainnetChainConfig = &ChainConfig{
|
||||||
ChainId: big.NewInt(50),
|
ChainId: big.NewInt(50),
|
||||||
|
|
@ -152,7 +164,7 @@ var (
|
||||||
Gap: 450,
|
Gap: 450,
|
||||||
FoudationWalletAddr: common.HexToAddress("xdc92a289fe95a85c53b8d0d113cbaef0c1ec98ac65"),
|
FoudationWalletAddr: common.HexToAddress("xdc92a289fe95a85c53b8d0d113cbaef0c1ec98ac65"),
|
||||||
V2: &V2{
|
V2: &V2{
|
||||||
SwitchBlock: big.NewInt(9999999999),
|
SwitchBlock: common.TIPV2SwitchBlock,
|
||||||
CurrentConfig: MainnetV2Configs[0],
|
CurrentConfig: MainnetV2Configs[0],
|
||||||
AllConfigs: MainnetV2Configs,
|
AllConfigs: MainnetV2Configs,
|
||||||
},
|
},
|
||||||
|
|
@ -194,9 +206,9 @@ var (
|
||||||
Gap: 450,
|
Gap: 450,
|
||||||
FoudationWalletAddr: common.HexToAddress("xdc746249c61f5832c5eed53172776b460491bdcd5c"),
|
FoudationWalletAddr: common.HexToAddress("xdc746249c61f5832c5eed53172776b460491bdcd5c"),
|
||||||
V2: &V2{
|
V2: &V2{
|
||||||
SwitchBlock: big.NewInt(900),
|
SwitchBlock: common.TIPV2SwitchBlock,
|
||||||
CurrentConfig: TestV2Configs[0],
|
CurrentConfig: TestnetV2Configs[0],
|
||||||
AllConfigs: TestV2Configs,
|
AllConfigs: TestnetV2Configs,
|
||||||
SkipV2Validation: true,
|
SkipV2Validation: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -219,7 +231,7 @@ var (
|
||||||
Gap: 450,
|
Gap: 450,
|
||||||
FoudationWalletAddr: common.HexToAddress("0x746249c61f5832c5eed53172776b460491bdcd5c"),
|
FoudationWalletAddr: common.HexToAddress("0x746249c61f5832c5eed53172776b460491bdcd5c"),
|
||||||
V2: &V2{
|
V2: &V2{
|
||||||
SwitchBlock: big.NewInt(7074000),
|
SwitchBlock: common.TIPV2SwitchBlock,
|
||||||
CurrentConfig: DevnetV2Configs[0],
|
CurrentConfig: DevnetV2Configs[0],
|
||||||
AllConfigs: DevnetV2Configs,
|
AllConfigs: DevnetV2Configs,
|
||||||
},
|
},
|
||||||
|
|
@ -286,8 +298,8 @@ var (
|
||||||
Reward: 250,
|
Reward: 250,
|
||||||
V2: &V2{
|
V2: &V2{
|
||||||
SwitchBlock: big.NewInt(900),
|
SwitchBlock: big.NewInt(900),
|
||||||
CurrentConfig: TestV2Configs[0],
|
CurrentConfig: UnitTestV2Configs[0],
|
||||||
AllConfigs: TestV2Configs,
|
AllConfigs: UnitTestV2Configs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,37 +83,37 @@ func TestCheckCompatible(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateV2Config(t *testing.T) {
|
func TestUpdateV2Config(t *testing.T) {
|
||||||
TestnetChainConfig.XDPoS.V2.BuildConfigIndex()
|
TestXDPoSMockChainConfig.XDPoS.V2.BuildConfigIndex()
|
||||||
c := TestnetChainConfig.XDPoS.V2.CurrentConfig
|
c := TestXDPoSMockChainConfig.XDPoS.V2.CurrentConfig
|
||||||
assert.Equal(t, 3, c.CertThreshold)
|
assert.Equal(t, 3, c.CertThreshold)
|
||||||
|
|
||||||
TestnetChainConfig.XDPoS.V2.UpdateConfig(10)
|
TestXDPoSMockChainConfig.XDPoS.V2.UpdateConfig(10)
|
||||||
c = TestnetChainConfig.XDPoS.V2.CurrentConfig
|
c = TestXDPoSMockChainConfig.XDPoS.V2.CurrentConfig
|
||||||
assert.Equal(t, 5, c.CertThreshold)
|
assert.Equal(t, 5, c.CertThreshold)
|
||||||
|
|
||||||
TestnetChainConfig.XDPoS.V2.UpdateConfig(899)
|
TestXDPoSMockChainConfig.XDPoS.V2.UpdateConfig(899)
|
||||||
c = TestnetChainConfig.XDPoS.V2.CurrentConfig
|
c = TestXDPoSMockChainConfig.XDPoS.V2.CurrentConfig
|
||||||
assert.Equal(t, 4, c.TimeoutSyncThreshold)
|
assert.Equal(t, 4, c.TimeoutSyncThreshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestV2Config(t *testing.T) {
|
func TestV2Config(t *testing.T) {
|
||||||
TestnetChainConfig.XDPoS.V2.BuildConfigIndex()
|
TestXDPoSMockChainConfig.XDPoS.V2.BuildConfigIndex()
|
||||||
c := TestnetChainConfig.XDPoS.V2.Config(1)
|
c := TestXDPoSMockChainConfig.XDPoS.V2.Config(1)
|
||||||
assert.Equal(t, 3, c.CertThreshold)
|
assert.Equal(t, 3, c.CertThreshold)
|
||||||
|
|
||||||
c = TestnetChainConfig.XDPoS.V2.Config(5)
|
c = TestXDPoSMockChainConfig.XDPoS.V2.Config(5)
|
||||||
assert.Equal(t, 3, c.CertThreshold)
|
assert.Equal(t, 3, c.CertThreshold)
|
||||||
|
|
||||||
c = TestnetChainConfig.XDPoS.V2.Config(10)
|
c = TestXDPoSMockChainConfig.XDPoS.V2.Config(10)
|
||||||
assert.Equal(t, 3, c.CertThreshold)
|
assert.Equal(t, 3, c.CertThreshold)
|
||||||
|
|
||||||
c = TestnetChainConfig.XDPoS.V2.Config(11)
|
c = TestXDPoSMockChainConfig.XDPoS.V2.Config(11)
|
||||||
assert.Equal(t, 5, c.CertThreshold)
|
assert.Equal(t, 5, c.CertThreshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildConfigIndex(t *testing.T) {
|
func TestBuildConfigIndex(t *testing.T) {
|
||||||
TestnetChainConfig.XDPoS.V2.BuildConfigIndex()
|
TestXDPoSMockChainConfig.XDPoS.V2.BuildConfigIndex()
|
||||||
index := TestnetChainConfig.XDPoS.V2.ConfigIndex()
|
index := TestXDPoSMockChainConfig.XDPoS.V2.ConfigIndex()
|
||||||
expected := []uint64{899, 10, 0}
|
expected := []uint64{899, 10, 0}
|
||||||
assert.Equal(t, expected, index)
|
assert.Equal(t, expected, index)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue