I've tried converting a geth genesis file to the parity format, in order to make a parity node join an already existing geth-backed private blockchain, but I'm getting a "Genesis block mismatch" error:

New peer 0 (protocol: 63, network: 42424242, difficulty: Some(11315973291), latest:4a8e…fcf2, genesis:96d0…b2e1, snapshot:None)
Peer 0 genesis hash mismatch (ours: 31cf…08ea, theirs: 96d0…b2e1)

And on the other side:

Adding p2p peer                          id=1e6033fe00282624 name=Parity/v1.6.8-beta-c...                                            addr=10.0.0.4:43516 peers=3
Ethereum peer connected                  id=1e6033fe00282624 conn=inbound name=Parity/v1.6.8-beta-c396229-20170608/x86_64-linux-gnu/rustc1.17.0
Ethereum handshake failed                id=1e6033fe00282624 conn=inbound err="Genesis block mismatch - 31cf7371d7c8d8ca (!= 96d001c8c6564893)"
Removing p2p peer                        id=1e6033fe00282624 conn=inbound duration=60.389ms  peers=2 req=true  err="disconnect requested"

The original geth genesis file is:

{
  "alloc": {
    "ad94486b5005418dbb46a77eb2fd0c8046bfb858": {
      "balance": "1000000000000000000000000000000"
    }
  },
  "config": {
    "homesteadBlock": 0,
    "chainId": 42424242,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "nonce": "0x0000000000000042",
  "difficulty": "0x6666",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
  "gasLimit": "0x4c4b40"
}

I manually converted this file into parity format (based on these examples https://github.com/5chdn/crossclient-chainspec):

{
    "name": "CrossClient",
    "dataDir": "CrossClient",
    "engine": {
        "Ethash": {
            "params": {
                "gasLimitBoundDivisor": "0x0400",
                "minimumDifficulty": "0x020000",
                "difficultyBoundDivisor": "0x0800",
                "durationLimit": "0x0d",
                "blockReward": "0x4563918244F40000",
                "registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2",
                "homesteadTransition": 0,
                "eip150Transition": 0,
                "eip155Transition": 10,
                "eip160Transition": 10,
                "eip161abcTransition": 10,
                "eip161dTransition": 10
            }
        }
    },
    "params": {
        "accountStartNonce": "0x0",
        "maximumExtraDataSize": "0x20",
        "minGasLimit": "0x1388",
        "networkID" : "0x28757B2"
    },
    "genesis": {
        "seal": {
            "ethereum": {
                "nonce": "0x0000000000000042",
                "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
            }
        },
        "difficulty": "0x6666",
        "author": "0x0000000000000000000000000000000000000000",
        "timestamp": "0x00",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
        "gasLimit": "0x4c4b40"
    },
    "accounts": {
        "ad94486b5005418dbb46a77eb2fd0c8046bfb858": { "balance": "1", "nonce": "0", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }
    }
}

Can anyone see what I did wrong?

Additionally, can anyone tell me exactly how the genesis hash is calculated?

Update I forgot to mention that I've already tried https://github.com/keorn/parity-spec/ to convert between the two formats, but it requires the geth config to have a uint value for "eip150Block", while in my geth config I don't have a value for it so null is assumed (No fork).

I haven't actually looked through your hand-crafted chainspec... But what I'd suggest, to save time in the long run (and to discourage others from doing it by hand), is to use a translation tool to do it for you.

In the README of the repository you link to, under the See also section, there's a link to keorn's translation tool, which will convert Geth -> Parity:

https://github.com/keorn/parity-spec

  • I've already tried that tool. Sorry, forgot to mention it. Updated the question. – André Cruz Jul 21 '17 at 9:59
  • Ah, okay - thanks for the update :-) I'll leave my answer here in case anyone finds it useful in future. – Richard Horrocks Jul 21 '17 at 18:14
up vote 0 down vote accepted

I finally managed to compile a working parity chain specification:

{
  "name": "GethTranslation",
  "engine": {
    "Ethash": {
      "params": {
        "gasLimitBoundDivisor": "0x400",
        "minimumDifficulty": "0x20000",
        "difficultyBoundDivisor": "0x800",
        "durationLimit": "0xd",
        "blockReward": "0x4563918244F40000",
        "registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2",
        "homesteadTransition": 0,
        "eip150Transition": 0,
        "eip155Transition": 0,
        "eip160Transition": 0,
        "eip161abcTransition": 0,
        "eip161dTransition": 0
      }
    }
  },
  "params": {
    "accountStartNonce": "0x0",
    "maximumExtraDataSize": "0x20",
    "minGasLimit": "0x1388",
    "networkID": 42424242,
    "eip98Transition": 9223372036854775807
  },
  "genesis": {
    "seal": {
      "ethereum": {
        "nonce": "0x0000000000000042",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
      }
    },
    "difficulty": "0x6666",
    "author": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
    "gasLimit": "0x4c4b40"
  },
  "accounts": {
    "ad94486b5005418dbb46a77eb2fd0c8046bfb858": {
      "balance": "1000000000000000000000000000000"
    }
  }
}

The differences lie in the "*Transition" elements which specify when (if ever) a fork happened to introduce a certain blockchain change. These need to be synchronized between Geth and Parity and they both have different defaults.

  • Hi André - what did you have to do exactly? Could you write a quick summary above your code snippet? (To save others having to compare it to the first one.) :-) – Richard Horrocks Jul 21 '17 at 18:15
  • 1
    I added a note about the differences. :) – André Cruz Jul 27 '17 at 12:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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