@@ -190,6 +190,11 @@ var (
190190 Usage : "Exits after block synchronisation completes" ,
191191 Category : flags .EthCategory ,
192192 }
193+ GenesisFlag = & cli.StringFlag {
194+ Name : "genesis" ,
195+ Usage : "Load genesis block and configuration from file at this path." ,
196+ Category : flags .EthCategory ,
197+ }
193198
194199 // Dump command options.
195200 IterativeOutputFlag = & cli.BoolFlag {
@@ -1593,7 +1598,7 @@ func setRequiredBlocks(ctx *cli.Context, cfg *ethconfig.Config) {
15931598// SetEthConfig applies eth-related command line flags to the config.
15941599func SetEthConfig (ctx * cli.Context , stack * node.Node , cfg * ethconfig.Config ) {
15951600 // Avoid conflicting network flags, don't allow network id override on preset networks
1596- flags .CheckExclusive (ctx , MainnetFlag , DeveloperFlag , SepoliaFlag , HoleskyFlag , HoodiFlag , NetworkIdFlag )
1601+ flags .CheckExclusive (ctx , MainnetFlag , DeveloperFlag , SepoliaFlag , HoleskyFlag , HoodiFlag , NetworkIdFlag , GenesisFlag )
15971602 flags .CheckExclusive (ctx , DeveloperFlag , ExternalSignerFlag ) // Can't use both ephemeral unlocked and external signer
15981603
15991604 // Set configurations from CLI flags
@@ -1873,6 +1878,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18731878 if ! ctx .IsSet (MinerGasPriceFlag .Name ) {
18741879 cfg .Miner .GasPrice = big .NewInt (1 )
18751880 }
1881+ case ctx .String (GenesisFlag .Name ) != "" :
1882+ f , err := os .Open (ctx .String (GenesisFlag .Name ))
1883+ if err != nil {
1884+ Fatalf ("Failed to read genesis file: %v" , err )
1885+ }
1886+ defer f .Close ()
1887+
1888+ genesis := new (core.Genesis )
1889+ if err := json .NewDecoder (f ).Decode (genesis ); err != nil {
1890+ Fatalf ("Invalid genesis file: %v" , err )
1891+ }
1892+ cfg .Genesis = genesis
18761893 default :
18771894 if cfg .NetworkId == 1 {
18781895 SetDNSDiscoveryDefaults (cfg , params .MainnetGenesisHash )
0 commit comments