code: func initGenesis(ctx *cli.Context) error {
  	// Make sure we have a valid genesis JSON
  	genesisPath := ctx.Args().First()
  	if len(genesisPath) == 0 {
  		utils.Fatalf("Must supply path to genesis JSON file")
  	}
  	file, err := os.Open(genesisPath)
  	if err != nil {
  		utils.Fatalf("Failed to read genesis file: %v", err)
  	}
  	defer file.Close()
  
  	genesis := new(core.Genesis)
  	if err := json.NewDecoder(file).Decode(genesis); err != nil {
  		utils.Fatalf("invalid genesis file: %v", err)
  	}
  	// Open an initialise both full and light databases
  	stack := makeFullNode(ctx)
  	defer stack.Close()
  
  	for _, name := range []string{"chaindata", "lightchaindata"} {
  		chaindb, err := stack.OpenDatabase(name, 0, 0, "")
  		if err != nil {
  			utils.Fatalf("Failed to open database: %v", err)
  		}
  		_, hash, err := core.SetupGenesisBlock(chaindb, genesis)
  		if err != nil {
  			utils.Fatalf("Failed to write genesis block: %v", err)
  		}
  		chaindb.Close()
  		log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
  	}
  	return nil
  }
docs: // initGenesis will initialise the given JSON format genesis file and writes it as
  // the zero'd block (i.e. genesis) or will fail hard if it can't succeed.