{"id":1469,"date":"2021-03-15T16:00:20","date_gmt":"2021-03-15T16:00:20","guid":{"rendered":"http:\/\/43.153.210.228\/\/?p=1469"},"modified":"2021-03-15T16:00:20","modified_gmt":"2021-03-15T16:00:20","slug":"%e6%95%99%e7%a8%8b%ef%bc%9a%e5%9c%a8%e4%bb%a5%e5%a4%aa%e5%9d%8a%e4%b8%8a%e5%88%9b%e5%bb%ba%e7%a7%81%e9%93%beprivate-chain","status":"publish","type":"post","link":"http:\/\/43.153.210.228\/?p=1469","title":{"rendered":"\u6559\u7a0b\uff1a\u5728\u4ee5\u592a\u574a\u4e0a\u521b\u5efa\u79c1\u94feprivate chain"},"content":{"rendered":"<p>\u6709\u4e24\u79cd\u4ee5\u592a\u574a\u5ba2\u6237\u7aef\u53ef\u4ee5\u9009\u62e9\uff1a <\/p>\n<ul>\n<li>Eth &#8211; C++ implementation\n<li>Geth &#8211; Go implementation<\/li>\n<\/ul>\n<p>\u672c\u6559\u7a0b\u662f\u57fa\u4e8eGeth. \u5b89\u88c5\u6559\u7a0b\u53ef\u4ee5\u5230 frontier gitbook. <\/p>\n<p><strong>\u521b\u5efa\u521b\u4e16\u5757<\/strong> <\/p>\n<p>\u521b\u4e16\u5757\u7684\u6700\u5927\u7279\u70b9\u662f\u7b2c\u4e00\u4e2a\u5757\uff0c\u6240\u4ee5\u6ca1\u6709\u4e0e\u4e4b\u524d\u7684\u5757\u4ea7\u751f\u8054\u7cfb\u3002\u5728\u6bd4\u7279\u5e01\u7cfb\u7edf\u91cc\uff0c\u8fd9\u4e2a\u521b\u4e16\u5757\u662f\u88ab\u5199\u5165\u6e90\u7801\uff0c\u4f46\u5bf9\u4e8e\u4ee5\u592a\u574a\u800c\u8a00\uff0c\u521b\u4e16\u5757\u53ef\u4ee5\u662f\u4efb\u4f55\u4f60\u559c\u6b22\u7684\u4e1c\u897f\u3002\u4f60\u4e5f\u53ef\u4ee5\u628a\u8fd9\u4e2a\u5f53\u6210\u662f\u7cfb\u7edf\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002\u4f46\u662f\u5171\u8bc6\u7b97\u6cd5\u786e\u4fdd\u5176\u5b83\u4eba\u9664\u975e\u7eb3\u5165\u4f60\u7684\u521b\u4e16\u5757\uff0c\u5426\u5219\u662f\u4e0d\u4f1a\u6709\u6548\u7684\u3002\uff08\u4ee5\u540e\u518d\u8be6\u7ec6\u8bf4\uff09 <\/p>\n<p>Great, so how do we make one of these genesis blocks? Well its fairly simple the following JSON is all you really need: <\/p>\n<p>[code]{<br \/>&#8220;nonce&#8221;: &#8220;0xdeadbeefdeadbeef&#8221;,<br \/>&#8220;timestamp&#8221;: &#8220;0x0&#8221;,<br \/>&#8220;parentHash&#8221;: &#8220;0x0000000000000000000000000000000000000000000000000000000000000000&#8221;,<br \/>&#8220;extraData&#8221;: &#8220;0x0&#8221;,<br \/>&#8220;gasLimit&#8221;: &#8220;0x8000000&#8221;,<br \/>&#8220;difficulty&#8221;: &#8220;0x400&#8221;,<br \/>&#8220;mixhash&#8221;: &#8220;0x0000000000000000000000000000000000000000000000000000000000000000&#8221;,<br \/>&#8220;coinbase&#8221;: &#8220;0x3333333333333333333333333333333333333333&#8221;,<br \/>&#8220;alloc&#8221;: {<br \/>}<br \/>}[\/code] <\/p>\n<p>Kudos to <a href=\"https:\/\/github.com\/obscuren\">obscuren<\/a> <\/p>\n<p>\u5728\u672c\u5730\u786c\u76d8\u4e0a\u5b58\u50a8\u8fd9\u4e2a JSON\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a <\/p>\n<p>[code]$ geth &#8211;genesis &#8211;datadir &#8211;networkid 123 &#8211;nodiscover &#8211;maxpeers 0 console[\/code]\u8fd9\u4e2a\u547d\u4ee4\u505a\u4e86\u5982\u4e0b\u51e0\u4e2a\u4e8b\u60c5\uff1a <\/p>\n<ul>\n<li>\u8c03\u7528\u521b\u4e16\u5757JSON\u8fdb\u533a\u5757\u94fe\u91cc\u3002\n<li>\u4f7f\u7528 datadir \u6765\u5b58\u50a8\u76f8\u5173\u6570\u636e\uff0c\u5e76\u4e14\u7ef4\u62a4\u65b0\u521b\u5efa\u7684\u533a\u5757\u53ca\u5176\u5b83\u6570\u636e (declared to prevent you clobbering your main net data, wouldn\u2019t want to overwrite all those blocks you spent time downloading!)\n<li>\u4f7f\u7528\u7f51\u7edcID \u20181\u2019 \u786e\u4fdd\u6211\u4eec\u65e0\u6cd5\u4e0e\u4e3b\u7f51\u7684\u8282\u70b9\u8fdb\u884c\u901a\u8baf\u3002 \u2013 \u201cconnections between nodes are valid only if peers have identical protocol version and network id\u201d\n<li>\u7981\u7528\u540c\u4f34\u53d1\u73b0\u3002\n<li>\u628amaxpeers \u8bbe\u7f6e\u4e3a 0\u7981\u7528\u7f51\u7edc\u3002\n<li>\u4ee5\u63a7\u5236\u53f0\u6a21\u5f0f\u542f\u52a8 geth\u5ba2\u6237\u7aef\uff0c\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u4e0e\u4f60\u7684\u65b0\u533a\u5757\u94fe\u63a5\/\u8282\u70b9\u8fdb\u884c\u901a\u8baf\u3002<\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u6839\u636e testing contracts and transactions \u7684\u6307\u793a\u521b\u5efa\u533a\u5757\u548c\u5e10\u6237\u4e86\u3002\u6211\u8fd9\u91cc\u7684\u533a\u522b\u662f\u7981\u7528\u4e86PRC, \u8868\u73b0\u8bc1\u660e\u7684\u516c\u8ba4\u641c\u96c6\u8fc7\u7a0b( the proof performance metric gathering processes) \uff0cextra verbosity and vmdebu\uff0c\u76ee\u7684\u662f\u7b80\u5355\u5316\u3002 <\/p>\n<p>\u5728\u4e0a\u8ff0\u521b\u4e16\u5757\u91cc\uff0c\u6211\u628a\u96be\u5ea6\u8bbe\u7f6e\u7684\u5f88\u4f4e\uff0c\u8fd9\u6837\u7684\u8bdd\u6211\u7684\u672c\u5730\u7535\u8111\u5c31\u80fd\u591f\u6316\u77ff\uff0c\u5f88\u5bb9\u6613\u83b7\u5f97\u4ee5\u592a\u5e01\u3002 <\/p>\n<p><strong>\u79cd\u5b50\u5e10\u6237 accounts with allocation<\/strong> <\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c31\u6709\u5fc5\u8981\u521b\u5efa\u65b0\u7684\u79cd\u5b50\u5e10\u6237\u4e86\uff08\u4ee5\u4fbf\u5b58\u50a8\u6316\u77ff\u6240\u5f97\u7684\u4ee5\u592a\u5e01\uff09\u3002 \u5f88\u7b80\u5355\uff0c\u5148\u521b\u5efa\u4e00\u4e2a\u65b0\u533a\u5757\u94fe\u548c\u65b0\u5e10\u6237: <\/p>\n<p>[code]$ geth &#8211;genesis &#8211;datadir \/&#8230;\/dapps\/test-genesis\/.ethereum &#8211;networkid 123 &#8211;nodiscover &#8211;maxpeers 0 console<br \/>I0829 13:30:07.340636 3987 database.go:74] Alloted 16MB cache to \/&#8230;\/dapps\/test-genesis\/.ethereum\/blockchain<br \/>I0829 13:30:07.342982 3987 database.go:74] Alloted 16MB cache to \/&#8230;\/dapps\/test-genesis\/.ethereum\/state<br \/>I0829 13:30:07.345055 3987 database.go:74] Alloted 16MB cache to \/&#8230;\/dapps\/test-genesis\/.ethereum\/extra<br \/>I0829 13:30:07.347363 3987 backend.go:291] Protocol Versions: [61 60], Network Id: 12345<br \/>I0829 13:30:07.347738 3987 backend.go:303] Successfully wrote genesis block. New genesis hash = 82b6159155c00fb0b420046012a02257a176ad5dcfce4be4a15da39c166518e2<br \/>I0829 13:30:07.347771 3987 backend.go:328] Blockchain DB Version: 3<br \/>I0829 13:30:07.347866 3987 chain_manager.go:241] Last block (#0) 82b6159155c00fb0b420046012a02257a176ad5dcfce4be4a15da39c166518e2 TD=1024<br \/>I0829 13:30:07.353373 3987 cmd.go:124] Starting Geth\/v1.0.1\/darwin\/go1.4.2<br \/>I0829 13:30:07.353470 3987 server.go:312] Starting Server<br \/>I0829 13:30:07.353610 3987 backend.go:564] Server started<br \/>I0829 13:30:07.353548 3987 server.go:549] Listening on [::]:30310<br \/>I0829 13:30:07.353961 3987 ipc_unix.go:78] IPC service started (\/&#8230;\/dapps\/test-genesis\/.ethereum\/geth.ipc)<br \/>instance: Geth\/v1.0.1\/darwin\/go1.4.2<br \/>datadir: \/&#8230;\/dapps\/test-genesis\/.ethereum<br \/>coinbase: 0x1fb891f92eb557f4d688463d0d7c560552263b5a<br \/>at block: 0 (1970-01-01 01:00:00)<br \/>modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1.0 txpool:1.0 web3:1.0<br \/>&gt; personal.newAccount(&#8220;mypassword&#8221;);<br \/>&#8216;0x1fb891f92eb557f4d688463d0d7c560552263b5a'[\/code] <\/p>\n<p>\u4e0a\u9762\u4ee3\u7801\u7684\u6700\u540e\u4e00\u884c\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684\u5e10\u6237\uff0c\u5176\u5730\u5740\u662f 0x1fb891f92eb557f4d688463d0d7c560552263b5a. <\/p>\n<p>\u521b\u5efa\u5e10\u6237\u540e\uff0c\u7528 <strong><\/strong>\u9000\u51fageth\u5ba2\u6237\u7aef\uff0c\u7136\u540e\u5728\u4f60\u7684datadir\u6587\u4ef6\u5939\u91cc\uff0c\u4fdd\u7559 keystore\/ \u8fd9\u4e2a\u6587\u4ef6\u5939\uff0c\u5176\u4f59\u7684\u5168\u90e8\u5220\u6389\u3002 <\/p>\n<p>[code]$ cd<br \/>$ rm -rf `ls | grep -v keystore`[\/code]\u63a5\u4e0b\u6765\u5c31\u662f\u89c1\u8bc1\u5947\u8ff9\u7684\u65f6\u5019\uff0c\u5237\u65b0\u4f60\u7684\u521b\u4e16\u5757JSON\uff0c\u628a\u4e0b\u9762\u7684\u4ee3\u7801\u52a0\u5165 alloc \u952e: <\/p>\n<p>[code]&#8221;alloc&#8221;: {<br \/>&#8220;&#8221;: {<br \/>&#8220;balance&#8221;: &#8220;10000000000000000000&#8221;<br \/>}<br \/>}[\/code]\u73b0\u5728\u91cd\u65b0\u8fd0\u884cgeth\u547d\u4ee4\u884c\uff0c\u4f7f\u7528\u521a\u624d\u5237\u65b0\u8fc7\u7684 genesis json\u6587\u4ef6\uff0c\u8fd8\u6709\u76f8\u540c\u7684datadir\uff0c\u7136\u540e\u4f60\u4f1a\u53d1\u73b0\u5e10\u6237\u4f59\u989d\u91cc\uff0c\u591a\u4e8610\u4e2a\u4ee5\u592a\u5e01\u51fa\u6765\u3002 <\/p>\n<p>[code]$ geth &#8211;genesis &#8211;datadir \/&#8230;\/dapps\/test-genesis\/.ethereum &#8211;networkid 123 &#8211;nodiscover &#8211;maxpeers 0 console<br \/>I0829 13:30:07.340636 3987 database.go:74] Alloted 16MB cache to \/&#8230;\/dapps\/test-genesis\/.ethereum\/blockchain<br \/>I0829 13:30:07.342982 3987 database.go:74] Alloted 16MB cache to \/&#8230;\/dapps\/test-genesis\/.ethereum\/state<br \/>I0829 13:30:07.345055 3987 database.go:74] Alloted 16MB cache to \/&#8230;\/dapps\/test-genesis\/.ethereum\/extra<br \/>I0829 13:30:07.347363 3987 backend.go:291] Protocol Versions: [61 60], Network Id: 12345<br \/>I0829 13:30:07.347738 3987 backend.go:303] Successfully wrote genesis block. New genesis hash = 82b6159155c00fb0b420046012a02257a176ad5dcfce4be4a15da39c166518e2<br \/>I0829 13:30:07.347771 3987 backend.go:328] Blockchain DB Version: 3<br \/>I0829 13:30:07.347866 3987 chain_manager.go:241] Last block (#0) 82b6159155c00fb0b420046012a02257a176ad5dcfce4be4a15da39c166518e2 TD=1024<br \/>I0829 13:30:07.353373 3987 cmd.go:124] Starting Geth\/v1.0.1\/darwin\/go1.4.2<br \/>I0829 13:30:07.353470 3987 server.go:312] Starting Server<br \/>I0829 13:30:07.353610 3987 backend.go:564] Server started<br \/>I0829 13:30:07.353548 3987 server.go:549] Listening on [::]:30310<br \/>I0829 13:30:07.353961 3987 ipc_unix.go:78] IPC service started (\/&#8230;\/dapps\/test-genesis\/.ethereum\/geth.ipc)<br \/>instance: Geth\/v1.0.1\/darwin\/go1.4.2<br \/>datadir: \/&#8230;\/dapps\/test-genesis\/.ethereum<br \/>coinbase: 0x1fb891f92eb557f4d688463d0d7c560552263b5a<br \/>at block: 0 (1970-01-01 01:00:00)<br \/>modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1.0 txpool:1.0 web3:1.0<br \/>&gt; primary = eth.accounts[0];<br \/>&#8216;0x1fb891f92eb557f4d688463d0d7c560552263b5a&#8217;<br \/>&gt; balance = web3.fromWei(eth.getBalance(primary), &#8220;ether&#8221;);<br \/>&#8217;10&#8242;[\/code]<\/p>\n<p><a href=\"http:\/\/43.153.210.228\/\/wp-content\/uploads\/2021\/03\/sskoo_blockchain___BTC.com27.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"sskoo_blockchain_\u533a\u5757\u94fe_\u6bd4\u7279\u5e01_BTC.com (27)\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline\" border=\"0\" alt=\"sskoo_blockchain_\u533a\u5757\u94fe_\u6bd4\u7279\u5e01_BTC.com (27)\" src=\"http:\/\/43.153.210.228\/\/wp-content\/uploads\/2021\/03\/sskoo_blockchain___BTC.com27_thumb.jpg\" width=\"320\" height=\"565\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e24\u79cd\u4ee5\u592a\u574a\u5ba2\u6237\u7aef\u53ef\u4ee5\u9009\u62e9\uff1a Eth &#8211; C++ implementation Geth &#038;#82 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1469","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/43.153.210.228\/index.php?rest_route=\/wp\/v2\/posts\/1469"}],"collection":[{"href":"http:\/\/43.153.210.228\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/43.153.210.228\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/43.153.210.228\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/43.153.210.228\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1469"}],"version-history":[{"count":1,"href":"http:\/\/43.153.210.228\/index.php?rest_route=\/wp\/v2\/posts\/1469\/revisions"}],"predecessor-version":[{"id":1470,"href":"http:\/\/43.153.210.228\/index.php?rest_route=\/wp\/v2\/posts\/1469\/revisions\/1470"}],"wp:attachment":[{"href":"http:\/\/43.153.210.228\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/43.153.210.228\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1469"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/43.153.210.228\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}