mirror of https://github.com/status-im/op-geth.git
cmd, params: only set default fork configs for test and mainnet
This commit is contained in:
parent
8639b0fae9
commit
f0dbec0c93
|
@ -116,19 +116,19 @@ func TestDAOInitOldPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{}, nil, false)
|
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{}, nil, false)
|
||||||
}
|
}
|
||||||
func TestDAODefaultOldPrivnet(t *testing.T) {
|
func TestDAODefaultOldPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true)
|
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, false}}, nil, false)
|
||||||
}
|
}
|
||||||
func TestDAOSupportOldPrivnet(t *testing.T) {
|
func TestDAOSupportOldPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true)
|
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}}, nil, true)
|
||||||
}
|
}
|
||||||
func TestDAOOpposeOldPrivnet(t *testing.T) {
|
func TestDAOOpposeOldPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false)
|
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}}, nil, false)
|
||||||
}
|
}
|
||||||
func TestDAOSwitchToSupportOldPrivnet(t *testing.T) {
|
func TestDAOSwitchToSupportOldPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true)
|
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, nil, true)
|
||||||
}
|
}
|
||||||
func TestDAOSwitchToOpposeOldPrivnet(t *testing.T) {
|
func TestDAOSwitchToOpposeOldPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false)
|
testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, nil, false)
|
||||||
}
|
}
|
||||||
func TestDAOInitNoForkPrivnet(t *testing.T) {
|
func TestDAOInitNoForkPrivnet(t *testing.T) {
|
||||||
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false)
|
testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false)
|
||||||
|
|
|
@ -781,34 +781,43 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainConfi
|
||||||
Fatalf("Could not make chain configuration: %v", err)
|
Fatalf("Could not make chain configuration: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set any missing fields due to them being unset or system upgrade
|
// Check whether we are allowed to set default config params or not:
|
||||||
if config.HomesteadBlock == nil {
|
// - If no genesis is set, we're running either mainnet or testnet (private nets use `geth init`)
|
||||||
if ctx.GlobalBool(TestNetFlag.Name) {
|
// - If a genesis is already set, ensure we have a configuration for it (mainnet or testnet)
|
||||||
config.HomesteadBlock = params.TestNetHomesteadBlock
|
defaults := genesis == nil ||
|
||||||
} else {
|
(genesis.Hash() == params.MainNetGenesisHash && !ctx.GlobalBool(TestNetFlag.Name)) ||
|
||||||
config.HomesteadBlock = params.MainNetHomesteadBlock
|
(genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name))
|
||||||
|
|
||||||
|
// Set any missing chainConfig fields due to them being unset or system upgrade
|
||||||
|
if defaults {
|
||||||
|
if config.HomesteadBlock == nil {
|
||||||
|
if ctx.GlobalBool(TestNetFlag.Name) {
|
||||||
|
config.HomesteadBlock = params.TestNetHomesteadBlock
|
||||||
|
} else {
|
||||||
|
config.HomesteadBlock = params.MainNetHomesteadBlock
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if config.DAOForkBlock == nil {
|
||||||
if config.DAOForkBlock == nil {
|
if ctx.GlobalBool(TestNetFlag.Name) {
|
||||||
if ctx.GlobalBool(TestNetFlag.Name) {
|
config.DAOForkBlock = params.TestNetDAOForkBlock
|
||||||
config.DAOForkBlock = params.TestNetDAOForkBlock
|
} else {
|
||||||
} else {
|
config.DAOForkBlock = params.MainNetDAOForkBlock
|
||||||
config.DAOForkBlock = params.MainNetDAOForkBlock
|
}
|
||||||
|
config.DAOForkSupport = true
|
||||||
}
|
}
|
||||||
config.DAOForkSupport = true
|
if config.HomesteadGasRepriceBlock == nil {
|
||||||
}
|
if ctx.GlobalBool(TestNetFlag.Name) {
|
||||||
if config.HomesteadGasRepriceBlock == nil {
|
config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock
|
||||||
if ctx.GlobalBool(TestNetFlag.Name) {
|
} else {
|
||||||
config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock
|
config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock
|
||||||
} else {
|
}
|
||||||
config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock
|
|
||||||
}
|
}
|
||||||
}
|
if config.HomesteadGasRepriceHash == (common.Hash{}) {
|
||||||
if config.HomesteadGasRepriceHash == (common.Hash{}) {
|
if ctx.GlobalBool(TestNetFlag.Name) {
|
||||||
if ctx.GlobalBool(TestNetFlag.Name) {
|
config.HomesteadGasRepriceHash = params.TestNetHomesteadGasRepriceHash
|
||||||
config.HomesteadGasRepriceHash = params.TestNetHomesteadGasRepriceHash
|
} else {
|
||||||
} else {
|
config.HomesteadGasRepriceHash = params.MainNetHomesteadGasRepriceHash
|
||||||
config.HomesteadGasRepriceHash = params.MainNetHomesteadGasRepriceHash
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Force override any existing configs if explicitly requested
|
// Force override any existing configs if explicitly requested
|
||||||
|
|
|
@ -253,7 +253,7 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare
|
||||||
}
|
}
|
||||||
if config.HomesteadGasRepriceBlock != nil && config.HomesteadGasRepriceBlock.Cmp(header.Number) == 0 {
|
if config.HomesteadGasRepriceBlock != nil && config.HomesteadGasRepriceBlock.Cmp(header.Number) == 0 {
|
||||||
if config.HomesteadGasRepriceHash != (common.Hash{}) && config.HomesteadGasRepriceHash != header.Hash() {
|
if config.HomesteadGasRepriceHash != (common.Hash{}) && config.HomesteadGasRepriceHash != header.Hash() {
|
||||||
return ValidationError("Homestead gas reprice fork hash mismatch: have 0x%x, want 0x%x", header.Hash(), config.HomesteadGasRepriceBlock)
|
return ValidationError("Homestead gas reprice fork hash mismatch: have 0x%x, want 0x%x", header.Hash(), config.HomesteadGasRepriceHash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -23,6 +23,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
TestNetGenesisHash = common.HexToHash("0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303") // Testnet genesis hash to enforce below configs on
|
||||||
|
MainNetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
|
||||||
|
|
||||||
TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block
|
TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block
|
||||||
MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block
|
MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue