mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
xin-203 fix wrong config hash and update v2 params on mainnet (#109)
* fix wrong config hash and update v2 params on mainnet * update config and all the test * hard code binary into code * add default config for testing * update test timestamp
This commit is contained in:
parent
90395f5423
commit
833f70bdb7
8 changed files with 236 additions and 238 deletions
|
|
@ -52,7 +52,7 @@ func TestConsoleWelcome(t *testing.T) {
|
||||||
XDC.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
XDC.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
||||||
XDC.SetTemplateFunc("gover", runtime.Version)
|
XDC.SetTemplateFunc("gover", runtime.Version)
|
||||||
XDC.SetTemplateFunc("XDCver", func() string { return params.Version })
|
XDC.SetTemplateFunc("XDCver", func() string { return params.Version })
|
||||||
XDC.SetTemplateFunc("niltime", func() string { return time.Unix(1544771829, 0).Format(time.RFC1123) })
|
XDC.SetTemplateFunc("niltime", func() string { return time.Unix(1559211559, 0).Format(time.RFC1123) })
|
||||||
XDC.SetTemplateFunc("apis", func() string { return ipcAPIs })
|
XDC.SetTemplateFunc("apis", func() string { return ipcAPIs })
|
||||||
|
|
||||||
// Verify the actual welcome message to the required template
|
// Verify the actual welcome message to the required template
|
||||||
|
|
@ -137,7 +137,7 @@ func testAttachWelcome(t *testing.T, XDC *testXDC, endpoint, apis string) {
|
||||||
attach.SetTemplateFunc("gover", runtime.Version)
|
attach.SetTemplateFunc("gover", runtime.Version)
|
||||||
attach.SetTemplateFunc("XDCver", func() string { return params.Version })
|
attach.SetTemplateFunc("XDCver", func() string { return params.Version })
|
||||||
attach.SetTemplateFunc("etherbase", func() string { return XDC.Etherbase })
|
attach.SetTemplateFunc("etherbase", func() string { return XDC.Etherbase })
|
||||||
attach.SetTemplateFunc("niltime", func() string { return time.Unix(1544771829, 0).Format(time.RFC1123) })
|
attach.SetTemplateFunc("niltime", func() string { return time.Unix(1559211559, 0).Format(time.RFC1123) })
|
||||||
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
||||||
attach.SetTemplateFunc("datadir", func() string { return XDC.Datadir })
|
attach.SetTemplateFunc("datadir", func() string { return XDC.Datadir })
|
||||||
attach.SetTemplateFunc("apis", func() string { return apis })
|
attach.SetTemplateFunc("apis", func() string { return apis })
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,14 @@ func New(config *params.XDPoSConfig, db ethdb.Database) *XDPoS {
|
||||||
config.Epoch = utils.EpochLength
|
config.Epoch = utils.EpochLength
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For testing and testing project, default to mainnet config
|
||||||
|
if config.V2 == nil {
|
||||||
|
config.V2 = params.XDPoSV2Config
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("xdc config loading", "config", config)
|
||||||
|
|
||||||
waitPeriodCh := make(chan int)
|
waitPeriodCh := make(chan int)
|
||||||
// TODO: This shall be configurable or replaced
|
|
||||||
config.V2 = params.DevnetXDPoSV2Config
|
|
||||||
|
|
||||||
// Allocate the snapshot caches and create the engine
|
// Allocate the snapshot caches and create the engine
|
||||||
signingTxsCache, _ := lru.New(utils.BlockSignersCacheLimit)
|
signingTxsCache, _ := lru.New(utils.BlockSignersCacheLimit)
|
||||||
|
|
|
||||||
|
|
@ -188,10 +188,11 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
|
||||||
}
|
}
|
||||||
return newcfg, stored, err
|
return newcfg, stored, err
|
||||||
}
|
}
|
||||||
// Special case: don't change the existing config of a non-mainnet chain if no new
|
|
||||||
|
// Special case: don't change the existing config of a non-xinfin chain if no new
|
||||||
// config is supplied. These chains would get AllProtocolChanges (and a compat error)
|
// config is supplied. These chains would get AllProtocolChanges (and a compat error)
|
||||||
// if we just continued here.
|
// if we just continued here.
|
||||||
if genesis == nil && stored != params.MainnetGenesisHash {
|
if genesis == nil && newcfg == params.AllEthashProtocolChanges {
|
||||||
return storedcfg, stored, nil
|
return storedcfg, stored, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,12 +212,19 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
|
||||||
func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
|
func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
|
||||||
switch {
|
switch {
|
||||||
case g != nil:
|
case g != nil:
|
||||||
|
log.Info("[configOrDefault] load orignal config", "hash", ghash)
|
||||||
return g.Config
|
return g.Config
|
||||||
case ghash == params.MainnetGenesisHash:
|
case ghash == params.XDCMainnetGenesisHash:
|
||||||
|
log.Info("[configOrDefault] load mainnetconfig")
|
||||||
return params.XDCMainnetChainConfig
|
return params.XDCMainnetChainConfig
|
||||||
case ghash == params.TestnetGenesisHash:
|
case ghash == params.TestnetGenesisHash:
|
||||||
|
log.Info("[configOrDefault] load TestnetChainConfig")
|
||||||
return params.TestnetChainConfig
|
return params.TestnetChainConfig
|
||||||
|
case ghash == params.DevnetGenesisHash:
|
||||||
|
log.Info("[configOrDefault] load DevnetChainConfig")
|
||||||
|
return params.DevnetChainConfig
|
||||||
default:
|
default:
|
||||||
|
log.Info("[configOrDefault] load AllEthashProtocolChanges", "hash", ghash)
|
||||||
return params.AllEthashProtocolChanges
|
return params.AllEthashProtocolChanges
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -312,26 +320,31 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big
|
||||||
|
|
||||||
// DefaultGenesisBlock returns the Ethereum main net genesis block.
|
// DefaultGenesisBlock returns the Ethereum main net genesis block.
|
||||||
func DefaultGenesisBlock() *Genesis {
|
func DefaultGenesisBlock() *Genesis {
|
||||||
|
config := params.XDCMainnetChainConfig
|
||||||
|
config.XDPoS.V2 = nil
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
Config: params.XDCMainnetChainConfig,
|
Config: config,
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000001b82c4bf317fcafe3d77e8b444c82715d216afe845b7bd987fa22c9bac89b71f0ded03f6e150ba31ad670b2b166684657ffff95f4810380ae7381e9bce41231d5dd8cdd7499e418b648c00af75d184a2f9aba09a6fa4a46fb1a6a3919b027d9cac5aa6890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
ExtraData: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000025c65b4b379ac37cf78357c4915f73677022eaffc7d49d0a2cf198deebd6ce581af465944ec8b2bbcfccdea1006a5cfa7d9484b5b293b46964c265c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
GasLimit: 4700000,
|
GasLimit: 4700000,
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: big.NewInt(1),
|
||||||
Alloc: DecodeMainnet(),
|
Alloc: DecodeAllocJson(XDCAllocData),
|
||||||
Timestamp: 1544771829,
|
Timestamp: 1559211559,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
|
// DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
|
||||||
func DefaultTestnetGenesisBlock() *Genesis {
|
func DefaultTestnetGenesisBlock() *Genesis {
|
||||||
|
config := params.TestnetChainConfig
|
||||||
|
config.XDPoS.V2 = nil
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
Config: params.TestnetChainConfig,
|
Config: params.TestnetChainConfig,
|
||||||
Nonce: 66,
|
Nonce: 0,
|
||||||
ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"),
|
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000003ea0a3555f9b1de983572bff6444aeb1899ec58c4f7900282f3d371d585ab1361205b0940ab1789c942a5885a8844ee5587c8ac5e371fc39ffe618960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
GasLimit: 16777216,
|
GasLimit: 4700000,
|
||||||
Difficulty: big.NewInt(1048576),
|
Difficulty: big.NewInt(1),
|
||||||
Alloc: decodePrealloc(testnetAllocData),
|
Alloc: DecodeAllocJson(XDCTestAllocData),
|
||||||
|
Timestamp: 1560417871,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,8 +399,8 @@ func decodePrealloc(data string) GenesisAlloc {
|
||||||
return ga
|
return ga
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecodeMainnet() GenesisAlloc {
|
func DecodeAllocJson(s string) GenesisAlloc {
|
||||||
mainnetAlloc := GenesisAlloc{}
|
alloc := GenesisAlloc{}
|
||||||
json.Unmarshal([]byte(XDCAllocData), &mainnetAlloc)
|
json.Unmarshal([]byte(s), &alloc)
|
||||||
return mainnetAlloc
|
return alloc
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -17,14 +17,15 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/ethash"
|
"github.com/XinFinOrg/XDPoSChain/consensus/ethash"
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/vm"
|
"github.com/XinFinOrg/XDPoSChain/core/vm"
|
||||||
|
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/common"
|
||||||
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
||||||
"github.com/XinFinOrg/XDPoSChain/params"
|
"github.com/XinFinOrg/XDPoSChain/params"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -29,15 +29,20 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
XDCMainnetGenesisHash = common.HexToHash("9326145f8a2c8c00bbe13afc7d7f3d9c868b5ef39d89f2f4e9390e9720298624") // XDC Mainnet genesis hash to enforce below configs on
|
XDCMainnetGenesisHash = common.HexToHash("4a9d748bd78a8d0385b67788c2435dcdb914f98a96250b68863a1f8b7642d6b1") // XDC Mainnet genesis hash to enforce below configs on
|
||||||
MainnetGenesisHash = common.HexToHash("8d13370621558f4ed0da587934473c0404729f28b0ff1d50e5fdd840457a2f17") // Mainnet genesis hash to enforce below configs on
|
MainnetGenesisHash = common.HexToHash("8d13370621558f4ed0da587934473c0404729f28b0ff1d50e5fdd840457a2f17") // Mainnet genesis hash to enforce below configs on
|
||||||
TestnetGenesisHash = common.HexToHash("dffc8ae3b45965404b4fd73ce7f0e13e822ac0fc23ce7e95b42bc5f1e57023a5") // Testnet genesis hash to enforce below configs on
|
TestnetGenesisHash = common.HexToHash("bdea512b4f12ff1135ec92c00dc047ffb93890c2ea1aa0eefe9b013d80640075") // Testnet genesis hash to enforce below configs on
|
||||||
|
DevnetGenesisHash = common.HexToHash("ab6fd3cb7d1a489e03250c7d14c2d6d819a6a528d6380b31e8410951964ef423") // Devnet genesis hash to enforce below configs on
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
XDPoSV2Config = &V2{
|
XDPoSV2Config = &V2{
|
||||||
TimeoutPeriod: 50,
|
SwitchBlock: big.NewInt(9999999999),
|
||||||
CertThreshold: common.MaxMasternodesV2*2/3 + 1,
|
CertThreshold: common.MaxMasternodesV2*2/3 + 1,
|
||||||
|
TimeoutSyncThreshold: 3,
|
||||||
|
TimeoutPeriod: 60,
|
||||||
|
WaitPeriod: 10,
|
||||||
|
MinePeriod: 10,
|
||||||
}
|
}
|
||||||
TestXDPoSV2Config = &V2{
|
TestXDPoSV2Config = &V2{
|
||||||
SwitchBlock: big.NewInt(900),
|
SwitchBlock: big.NewInt(900),
|
||||||
|
|
@ -59,7 +64,7 @@ var (
|
||||||
|
|
||||||
// XDPoSChain mainnet config
|
// XDPoSChain mainnet config
|
||||||
XDCMainnetChainConfig = &ChainConfig{
|
XDCMainnetChainConfig = &ChainConfig{
|
||||||
ChainId: big.NewInt(88),
|
ChainId: big.NewInt(50),
|
||||||
HomesteadBlock: big.NewInt(1),
|
HomesteadBlock: big.NewInt(1),
|
||||||
EIP150Block: big.NewInt(2),
|
EIP150Block: big.NewInt(2),
|
||||||
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
|
@ -69,10 +74,10 @@ var (
|
||||||
XDPoS: &XDPoSConfig{
|
XDPoS: &XDPoSConfig{
|
||||||
Period: 2,
|
Period: 2,
|
||||||
Epoch: 900,
|
Epoch: 900,
|
||||||
Reward: 250,
|
Reward: 5000,
|
||||||
RewardCheckpoint: 900,
|
RewardCheckpoint: 900,
|
||||||
Gap: 5,
|
Gap: 450,
|
||||||
FoudationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068"),
|
FoudationWalletAddr: common.HexToAddress("xdc92a289fe95a85c53b8d0d113cbaef0c1ec98ac65"),
|
||||||
V2: XDPoSV2Config,
|
V2: XDPoSV2Config,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -94,17 +99,45 @@ var (
|
||||||
|
|
||||||
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
|
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
|
||||||
TestnetChainConfig = &ChainConfig{
|
TestnetChainConfig = &ChainConfig{
|
||||||
ChainId: big.NewInt(3),
|
ChainId: big.NewInt(51),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: big.NewInt(1),
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(2),
|
||||||
EIP150Hash: common.HexToHash("0x62e0fde86e34c263e250fbcd5ca4598ba8ca10a1d166c8526bb127e10b313311"),
|
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
EIP155Block: big.NewInt(10),
|
EIP155Block: big.NewInt(3),
|
||||||
EIP158Block: big.NewInt(10),
|
EIP158Block: big.NewInt(3),
|
||||||
ByzantiumBlock: big.NewInt(1700000),
|
ByzantiumBlock: big.NewInt(4),
|
||||||
ConstantinopleBlock: nil,
|
ConstantinopleBlock: nil,
|
||||||
Ethash: new(EthashConfig),
|
XDPoS: &XDPoSConfig{
|
||||||
|
Period: 2,
|
||||||
|
Epoch: 900,
|
||||||
|
Reward: 5000,
|
||||||
|
RewardCheckpoint: 900,
|
||||||
|
Gap: 450,
|
||||||
|
FoudationWalletAddr: common.HexToAddress("xdc746249c61f5832c5eed53172776b460491bdcd5c"),
|
||||||
|
V2: TestXDPoSV2Config,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
|
||||||
|
DevnetChainConfig = &ChainConfig{
|
||||||
|
ChainId: big.NewInt(551),
|
||||||
|
HomesteadBlock: big.NewInt(1),
|
||||||
|
EIP150Block: big.NewInt(2),
|
||||||
|
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
EIP155Block: big.NewInt(3),
|
||||||
|
EIP158Block: big.NewInt(3),
|
||||||
|
ByzantiumBlock: big.NewInt(4),
|
||||||
|
XDPoS: &XDPoSConfig{
|
||||||
|
Period: 2,
|
||||||
|
Epoch: 900,
|
||||||
|
Reward: 5000,
|
||||||
|
RewardCheckpoint: 900,
|
||||||
|
Gap: 450,
|
||||||
|
FoudationWalletAddr: common.HexToAddress("0x746249c61f5832c5eed53172776b460491bdcd5c"),
|
||||||
|
V2: DevnetXDPoSV2Config,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
|
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue