Can't convert valid geth genesis file
Closed this issue · 4 comments
The following file is a valid geth genesis file but cannot be converted:
{
"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"
}
The error is:
thread 'main' panicked at 'Invalid JSON file.: Syntax(Message("missing field `chainId`"), 12, 3)', src/libcore/result.rs:859
If I remove the "config" part I'm able to convert, however, when I try to use the chain specification to connect a parity node to an existent geth-powered blockchain I get:
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)
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 field name for Geth is chainId
, not chainID
Well, geth handles that file just fine. Nevertheless I changed the case of that attribute and now parity-spec is complaining about a missing "eip150Block":
thread 'main' panicked at 'Invalid JSON file.: Syntax(Message("missing field `eip150Block`"), 12, 7)', src/libcore/result.rs:859
I'm not sure what to put here since geth has a nil default for this value which means "No Fork". If I put a "null" in the genesis file parity-spec complains with:
thread 'main' panicked at 'Invalid JSON file.: Syntax(Message("invalid type: unit value, expected u64"), 10, 27)', src/libcore/result.rs:859
Ok, made eip150 optional. Will add zeros too, if they are missing in Geth spec.
Thanks, I've updated the code.
Now wherever I run I get this warning:
warning: field is never used: `eip158Block`
--> src/main.rs:27:2
|
27 | eip158Block: u64,
| ^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
I suppose it's fine. However, it still complains about a missing "eip160Block" block:
thread 'main' panicked at 'Invalid JSON file.: Syntax(Message("missing field `eip160Block`"), 12, 7)', src/libcore/result.rs:859
And I can't find any reference to "eip160Block" on go-ethereum source code.