I am trying to initializing geth node with the following Gensis file content

"nonce": "0x00000000000000042", 
"timestamp": "0x0", 
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
"extraData": "0x0", 
"gasLimit": "0x8000000", 
"difficulty": "0x400", 
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
"coinbase": "0x3333333333333333333333333333333333333333", 
"alloc": { }

and I get error

"Fatal: invalid genesis file: json: cannot unmarshal hex string of odd length into Go struct field Genesis.extraData of type hexutil.Bytes"

But then I understood from this discussion that format of the genesis block has changed to the following

    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    "difficulty": "200000000",
    "gasLimit": "2100000",
    "alloc": {
        "7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
        "f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }

and this works.

But what I am failing to get are

  1. Why the need of such a change?
  2. How is issue related to unmarshalling of hex strings is solved by the new config?
  3. Now that I am not setting the many of the default values how are they getting set and with what values ?
  4. Also it would be great if you could point me to a link which explains the config params in detail.
  • 1
    I hope you will get some answers here.
    – Distic
    Aug 3 '17 at 7:46
  • Ethereum got some protocol changes in the last hard fork, in the mainnet they are activated at a specific block height, but in a private testnet that doesn't make much sense. The genesis file format got updated to have a new section 'config' to specify this type of parameters. You can specify all the parameters that were previously available, when they are absent they are set to a string of 0 bytes.
    – Ismael
    Aug 4 '17 at 3:26
  • Have you tried adding leading zeroes to all of the odd length hex fields? I know that JSON RPC hex formatting says not to do that, but the error message sounds like that to me. (e.g. change "0x400" to "0x0400", but for all odd length hex values that you have) Aug 12 '17 at 2:47

Your Answer

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

Browse other questions tagged or ask your own question.