3

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 ?

0

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

| improve this answer | |
  • The old blocks can be retained if the change of configs of genesis file is compatible. – XLeo Nov 9 '17 at 13:10
  • In that case I'm assuming the the 'config' field isn't included into the block hash? – Malone Nov 9 '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 9 '17 at 13:22
  • @XLeo cool, that’s a good find! – Malone Nov 9 '17 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.