@@ -769,17 +769,17 @@ func SetupNetwork(ctx *cli.Context) {
769769}
770770
771771// MustMakeChainConfig reads the chain configuration from the database in ctx.Datadir.
772- func MustMakeChainConfig (ctx * cli.Context ) * core .ChainConfig {
772+ func MustMakeChainConfig (ctx * cli.Context ) * params .ChainConfig {
773773 db := MakeChainDatabase (ctx )
774774 defer db .Close ()
775775
776776 return MustMakeChainConfigFromDb (ctx , db )
777777}
778778
779779// MustMakeChainConfigFromDb reads the chain configuration from the given database.
780- func MustMakeChainConfigFromDb (ctx * cli.Context , db ethdb.Database ) * core .ChainConfig {
780+ func MustMakeChainConfigFromDb (ctx * cli.Context , db ethdb.Database ) * params .ChainConfig {
781781 // If the chain is already initialized, use any existing chain configs
782- config := new (core .ChainConfig )
782+ config := new (params .ChainConfig )
783783
784784 genesis := core .GetBlock (db , core .GetCanonicalHash (db , 0 ))
785785 if genesis != nil {
@@ -793,6 +793,9 @@ func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainC
793793 Fatalf ("Could not make chain configuration: %v" , err )
794794 }
795795 }
796+ if config .ChainId == nil {
797+ config .ChainId = new (big.Int )
798+ }
796799 // Set any missing fields due to them being unset or system upgrade
797800 if config .HomesteadBlock == nil {
798801 if ctx .GlobalBool (TestNetFlag .Name ) {
@@ -809,11 +812,39 @@ func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainC
809812 }
810813 config .DAOForkSupport = true
811814 }
812- if config .HomesteadGasRepriceBlock == nil {
815+ if config .EIP150Block == nil {
816+ if ctx .GlobalBool (TestNetFlag .Name ) {
817+ config .EIP150Block = params .TestNetHomesteadGasRepriceBlock
818+ } else {
819+ config .EIP150Block = params .MainNetHomesteadGasRepriceBlock
820+ }
821+ }
822+ if config .EIP150Hash == (common.Hash {}) {
823+ if ctx .GlobalBool (TestNetFlag .Name ) {
824+ config .EIP150Hash = params .TestNetHomesteadGasRepriceHash
825+ } else {
826+ config .EIP150Hash = params .MainNetHomesteadGasRepriceHash
827+ }
828+ }
829+ if config .EIP155Block == nil {
830+ if ctx .GlobalBool (TestNetFlag .Name ) {
831+ config .EIP150Block = params .TestNetSpuriousDragon
832+ } else {
833+ config .EIP155Block = params .MainNetSpuriousDragon
834+ }
835+ }
836+ if config .EIP158Block == nil {
837+ if ctx .GlobalBool (TestNetFlag .Name ) {
838+ config .EIP158Block = params .TestNetSpuriousDragon
839+ } else {
840+ config .EIP158Block = params .MainNetSpuriousDragon
841+ }
842+ }
843+ if config .ChainId .BitLen () == 0 {
813844 if ctx .GlobalBool (TestNetFlag .Name ) {
814- config .HomesteadGasRepriceBlock = params .TestNetHomesteadGasRepriceBlock
845+ config .ChainId = params .TestNetChainID
815846 } else {
816- config .HomesteadGasRepriceBlock = params .MainNetHomesteadGasRepriceBlock
847+ config .ChainId = params .MainNetChainID
817848 }
818849 }
819850 // Force override any existing configs if explicitly requested
0 commit comments