go-ethereum – Resolving Genesis Block Mismatch with Converted Geth Genesis File and Parity

genesisgo-ethereumparity

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).

Best Answer

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

Related Topic