Skip to content

Commit

Permalink
Merge branch 'main' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
tak1827 committed Dec 23, 2024
2 parents f10996c + 612da64 commit c51f4b1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
28 changes: 11 additions & 17 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ func LoadChainConfig(db ethdb.Database, genesis *Genesis) (*params.ChainConfig,
// chain config corresponds to the canonical chain.
stored := rawdb.ReadCanonicalHash(db, 0)
if stored != (common.Hash{}) {
builtInConf := params.GetBuiltInChainConfig(stored)
if builtInConf != nil {
return builtInConf, nil
}
storedcfg := rawdb.ReadChainConfig(db, stored)
if storedcfg != nil {
return storedcfg, nil
Expand All @@ -364,24 +368,14 @@ func LoadChainConfig(db ethdb.Database, genesis *Genesis) (*params.ChainConfig,
}

func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
switch {
case g != nil:
return g.Config
case ghash == params.MainnetGenesisHash:
return params.MainnetChainConfig
case ghash == params.HoleskyGenesisHash:
return params.HoleskyChainConfig
case ghash == params.SepoliaGenesisHash:
return params.SepoliaChainConfig
case ghash == params.GoerliGenesisHash:
return params.GoerliChainConfig
case ghash == params.OasysMainnetGenesisHash:
return params.OasysMainnetChainConfig
case ghash == params.OasysTestnetGenesisHash:
return params.OasysTestnetChainConfig
default:
return params.AllEthashProtocolChanges
conf := params.GetBuiltInChainConfig(ghash)
if conf != nil {
return conf
}
if g != nil {
return g.Config // it could be a custom config for QA test, just return
}
return params.AllEthashProtocolChanges
}

// IsVerkle indicates whether the state is already stored in a verkle
Expand Down
19 changes: 19 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,25 @@ var (
TestRules = TestChainConfig.Rules(new(big.Int), false, 0)
)

func GetBuiltInChainConfig(ghash common.Hash) *ChainConfig {
switch ghash {
case MainnetGenesisHash:
return MainnetChainConfig
case HoleskyGenesisHash:
return HoleskyChainConfig
case SepoliaGenesisHash:
return SepoliaChainConfig
case GoerliGenesisHash:
return GoerliChainConfig
case OasysMainnetGenesisHash:
return OasysMainnetChainConfig
case OasysTestnetGenesisHash:
return OasysTestnetChainConfig
default:
return nil
}
}

// NetworkNames are user friendly names to use in the chain spec banner.
var NetworkNames = map[string]string{
MainnetChainConfig.ChainID.String(): "mainnet",
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 7 // Minor version component of the current release
VersionPatch = 2 // Patch version component of the current release
VersionPatch = 3 // Patch version component of the current release
VersionMeta = "testnet0" // Version metadata to append to the version string
)

Expand Down

0 comments on commit c51f4b1

Please sign in to comment.