4

I have created a private network by Geth follow this tutorial on github. Now I want to add “byzantiumBlock:1000” to config block of genesis.json.

Will I get a new network and lose all blocks of my old network after I execute the command geth init path/to/genesis.json ?

Malone
  • 1,590
  • 12
  • 23
XLeo
  • 71
  • 2

1 Answers1

1

If you want to change the genesis block, then you'll be changing the block hash. With this you'll render the rest of the blockchain invalid.

UPDATE: However there are field in the genesis block that do not contribute to the block hash and thus would not require the following

A new genesis block will require a new chain being built. On MacOS, the get init <path to genesis> command locks the /Users/[user]/Library/Ethereum/geth/chaindata folder by default. This would be shared by different nodes if you didn't explicitly specify a different datadir.

What is the datadir? - It's a data directory for the databases and keystore associated with a node, in other words, a location where to create the blockchain.

Example:

geth --datadir <path_of_data_directory> init <path_of_genesis_file>

An example value of the <path_of_data_directory> could be Library/Ethereum/aCoolDataDirectoryName. Then within that directory you'll have the following:

contents of new datadir

By specifying a different datadir, you'll be able to keep your old blockchain but create a new one with your new config.

Sources:

Command Line Options
Related Question

Malone
  • 1,590
  • 12
  • 23
  • The old blocks can be retained if the change of configs of genesis file is compatible. – XLeo Nov 09 '17 at 13:10
  • In that case I'm assuming the the 'config' field isn't included into the block hash? – Malone Nov 09 '17 at 13:14
  • 2
    Yes, it is not included into the block hash, see SetupGenesisBlock method in core\genesis.go, there is a CheckCompatible logic at bottom of the method. – XLeo Nov 09 '17 at 13:22
  • @XLeo cool, that’s a good find! – Malone Nov 09 '17 at 13:24