Go-Ethereum

使用具有奇偶校驗的轉換 geth 創世文件的創世塊不匹配

  • July 27, 2017

我嘗試將 geth 創世文件轉換為奇偶校驗格式,以使奇偶校驗節點加入已經存在的 geth 支持的私有區塊鏈,但我收到“創世區塊不匹配”錯誤:

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"

原始的geth genesis文件是:

{
 "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"
}

我手動將此文件轉換為奇偶校驗格式(基於這些範例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 } } } }
   }
}

誰能看到我做錯了什麼?

另外,誰能告訴我創世雜湊是如何計算的?

更新 我忘了提到我已經嘗試過https://github.com/keorn/parity-spec/在兩種格式之間進行轉換,但它要求 geth 配置具有“eip150Block”的 uint 值,而在我的 geth 配置我沒有它的值,因此假定為 null(無叉)。

我終於設法編譯了一個有效的奇偶校驗鏈規範:

{
 "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"
   }
 }
}

不同之處在於“*Transition”元素,它指定何時(如果有的話)分叉碰巧引入了某個區塊鏈更改。這些需要在 Geth 和 Parity 之間同步,並且它們都有不同的預設值。

我實際上並沒有看過你手工製作的鏈規範……但我建議,從長遠來看,為了節省時間(並阻止其他人手工做),是使用翻譯工具來做為你。

在您連結到的儲存庫的 README 中,在See also部分下,有一個指向 keorn 的翻譯工具的連結,它將轉換 Geth -> Parity:

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

引用自:https://ethereum.stackexchange.com/questions/21687