Go-Ethereum

Geth不會在私網開始挖礦!

  • December 3, 2018

有人會幫我嗎?幾個小時以來,我一直堅持這一點;該過程+3次,每次刪除datadir內容。Geth 仍然不會開始挖礦!!

規格: Geth 1.8.11,在 macOS X 上

這就是我所做的:

  1. 使用了這個 genesis.json 文件

{
 "difficulty" : "0x20000",
 "extraData"  : "",
 "gasLimit"   : "0x8000000",
 "alloc": {},
 "config": {
       "chainId": 15,
       "homesteadBlock": 0,
       "eip155Block": 0,
       "eip158Block": 0
   }
}

2.用這兩個命令執行geth

初始化私有鏈geth --datadir=/Users/shaikhaalothman/chaindata init /Users/shaikhaalothman/genesis/genesis.json然後啟動 gethgeth --datadir=/Users/shaikhaalothman/chaindata


Last login: Mon Jun 25 22:15:52 on ttys000
Shaikhas-MacBook-Pro:~ shaikhaalothman$ geth --datadir=/Users/shaikhaalothman/chaindata init /Users/shaikhaalothman/genesis/genesis.json
INFO [06-25|22:20:29] Maximum peer count                       ETH=25 LES=0 total=25
INFO [06-25|22:20:29] Allocated cache and file handles         database=/Users/shaikhaalothman/chaindata/geth/chaindata cache=16 handles=16
INFO [06-25|22:20:29] Writing custom genesis block 
INFO [06-25|22:20:29] Persisted trie from memory database      nodes=0 size=0.00B time=11.447µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-25|22:20:29] Successfully wrote genesis state         database=chaindata                                       hash=0613eb…9a64e7
INFO [06-25|22:20:29] Allocated cache and file handles         database=/Users/shaikhaalothman/chaindata/geth/lightchaindata cache=16 handles=16
INFO [06-25|22:20:29] Writing custom genesis block 
INFO [06-25|22:20:29] Persisted trie from memory database      nodes=0 size=0.00B time=4.588µs  gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-25|22:20:29] Successfully wrote genesis state         database=lightchaindata                                       hash=0613eb…9a64e7
Shaikhas-MacBook-Pro:~ shaikhaalothman$ geth --datadir=/Users/shaikhaalothman/chaindata 
INFO [06-25|22:20:39] Maximum peer count                       ETH=25 LES=0 total=25
INFO [06-25|22:20:39] Starting peer-to-peer node               instance=Geth/v1.8.11-stable-dea1ce05/darwin-amd64/go1.10.3
INFO [06-25|22:20:39] Allocated cache and file handles         database=/Users/shaikhaalothman/chaindata/geth/chaindata cache=768 handles=128
INFO [06-25|22:20:39] Initialised chain configuration          config="{ChainID: 15 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Byzantium: <nil> Constantinople: <nil> Engine: unknown}"
INFO [06-25|22:20:39] Disk storage enabled for ethash caches   dir=/Users/shaikhaalothman/chaindata/geth/ethash count=3
INFO [06-25|22:20:39] Disk storage enabled for ethash DAGs     dir=/Users/shaikhaalothman/.ethash               count=2
INFO [06-25|22:20:39] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [06-25|22:20:39] Loaded most recent local header          number=0 hash=0613eb…9a64e7 td=131072
INFO [06-25|22:20:39] Loaded most recent local full block      number=0 hash=0613eb…9a64e7 td=131072
INFO [06-25|22:20:39] Loaded most recent local fast block      number=0 hash=0613eb…9a64e7 td=131072
INFO [06-25|22:20:39] Regenerated local transaction journal    transactions=0 accounts=0
INFO [06-25|22:20:39] Starting P2P networking 
INFO [06-25|22:20:41] UDP listener up                          self=enode://de764357ef765c4cb6fb7aed6e97b895d1f67837ce3764a5dcf138e7f48a5044a81d68d54c18d653a825784bb52e90220ab05f42c176d44cf44b242985bc2118@[::]:30303
INFO [06-25|22:20:41] RLPx listener up                         self=enode://de764357ef765c4cb6fb7aed6e97b895d1f67837ce3764a5dcf138e7f48a5044a81d68d54c18d653a825784bb52e90220ab05f42c176d44cf44b242985bc2118@[::]:30303
INFO [06-25|22:20:41] IPC endpoint opened                      url=/Users/shaikhaalothman/chaindata/geth.ipc
INFO [06-25|22:22:27] Updated mining threads                   threads=1
INFO [06-25|22:22:27] Transaction pool price threshold updated price=18000000000
INFO [06-25|22:22:27] Starting mining operation 
INFO [06-25|22:22:27] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=72.379ms
INFO [06-25|22:23:14] Updated mining threads                   threads=1
INFO [06-25|22:29:59] Updated mining threads                   threads=1
  1. 使用私網ipc文件啟動Mist

使用命令啟動 Mist/applications/mist.app/contents/macos/mist --rpc /Users/shaikhaalothman/chaindata/geth.ipc


Last login: Mon Jun 25 22:20:14 on ttys000
Shaikhas-MacBook-Pro:~ shaikhaalothman$ /applications/mist.app/contents/macos/mist --rpc /Users/shaikhaalothman/chaindata/geth.ipc
[2018-06-25T22:21:00.528] [INFO] Settings - Running in production mode: true
[2018-06-25T22:21:00.616] [INFO] EthereumNode - undefined 'light' 'light'
[2018-06-25T22:21:00.618] [INFO] EthereumNode - Defaults loaded: geth main light
[2018-06-25T22:21:00.784] [INFO] main - Starting in Mist mode
[2018-06-25T22:21:03.580] [INFO] Db - Loading db: /Users/shaikhaalothman/Library/Application Support/Mist/mist.lokidb
[2018-06-25T22:21:03.691] [INFO] Windows - Creating commonly-used windows
[2018-06-25T22:21:03.693] [INFO] Windows - Create secondary window: loading, owner: notset
[2018-06-25T22:21:07.847] [INFO] updateChecker - Check for update...
[2018-06-25T22:21:12.839] [INFO] Windows - Create primary window: main, owner: notset
[2018-06-25T22:21:12.859] [INFO] Windows - Create primary window: splash, owner: notset
[2018-06-25T22:21:19.141] [INFO] (ui: popupWindow) - Web3 not yet initialized, doing so now with HttpProvider.
[2018-06-25T22:21:19.161] [INFO] updateChecker - App is up-to-date.
[2018-06-25T22:21:19.162] [INFO] (ui: splashscreen) - Web3 already initialized, re-using provider.
[2018-06-25T22:21:19.163] [INFO] (ui: popupWindow) - Web3 already initialized, re-using provider.
[2018-06-25T22:21:19.307] [INFO] (ui: splashscreen) - Meteor starting up...
[2018-06-25T22:21:19.308] [INFO] (ui: popupWindow) - Meteor starting up...
[2018-06-25T22:21:19.309] [INFO] (ui: popupWindow) - Meteor starting up...
[2018-06-25T22:21:20.585] [INFO] ClientBinaryManager - Initializing...
[2018-06-25T22:21:20.586] [INFO] ClientBinaryManager - Checking for new client binaries config from: https://raw.githubusercontent.com/ethereum/mist/master/clientBinaries.json
[2018-06-25T22:21:21.038] [INFO] ClientBinaryManager - No "skippedNodeVersion.json" found.
[2018-06-25T22:21:21.040] [INFO] ClientBinaryManager - Initializing...
[2018-06-25T22:21:21.041] [INFO] ClientBinaryManager - Resolving platform...
[2018-06-25T22:21:21.042] [INFO] ClientBinaryManager - Calculating possible clients...
[2018-06-25T22:21:21.044] [INFO] ClientBinaryManager - 1 possible clients.
[2018-06-25T22:21:21.044] [INFO] ClientBinaryManager - Verifying status of all 1 possible clients...
[2018-06-25T22:21:21.045] [INFO] ClientBinaryManager - Verify Geth status ...
[2018-06-25T22:21:21.891] [INFO] ClientBinaryManager - Checking for Geth sanity check ...
[2018-06-25T22:21:21.892] [INFO] ClientBinaryManager - Checking for Geth sanity check ...
[2018-06-25T22:21:21.892] [INFO] ClientBinaryManager - Checking sanity for Geth ...
[2018-06-25T22:21:21.895] [INFO] ClientBinaryManager - Checking sanity for Geth ...
[2018-06-25T22:21:23.210] [INFO] Sockets/node-ipc - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:23.213] [INFO] Sockets/node-ipc - Connected!
[2018-06-25T22:21:23.214] [INFO] NodeSync - Ethereum node connected, re-start sync
[2018-06-25T22:21:23.215] [INFO] NodeSync - Starting sync loop
[2018-06-25T22:21:23.216] [INFO] Sockets/2 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:23.217] [INFO] Sockets/4 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:23.218] [INFO] main - Connected via IPC to node.
[2018-06-25T22:21:23.233] [INFO] Sockets/2 - Connected!
[2018-06-25T22:21:23.234] [INFO] Sockets/4 - Connected!
[2018-06-25T22:21:23.444] [INFO] (ui: splashscreen) - Network is privatenet
[2018-06-25T22:21:23.445] [INFO] (ui: splashscreen) - Network is privatenet
[2018-06-25T22:21:27.479] [INFO] NodeSync - Sync has been skipped
[2018-06-25T22:21:27.480] [INFO] NodeSync - Sync loop ended
[2018-06-25T22:21:27.481] [INFO] main - Loading Interface at file:///Applications/Mist.app/Contents/Resources/app.asar/interface/index.html
[2018-06-25T22:21:28.710] [INFO] Sockets/3 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:28.711] [INFO] Sockets/3 - Connected!
[2018-06-25T22:21:29.392] [INFO] (ui: mist) - Web3 already initialized, re-using provider.
[2018-06-25T22:21:29.644] [INFO] (ui: mist) - Meteor starting up...
[2018-06-25T22:21:29.658] [INFO] (ui: mist) - Initialise Mist Interface
[2018-06-25T22:21:31.209] [INFO] (ui: mist) - Network is privatenet
[2018-06-25T22:21:33.649] [INFO] (ui: mist) - did-navigate wallet https://wallet.ethereum.org/
[2018-06-25T22:21:33.706] [INFO] Sockets/3 - Disconnecting...
[2018-06-25T22:21:33.969] [INFO] Sockets/3 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:33.970] [INFO] Sockets/3 - Connected!
[2018-06-25T22:21:34.247] [INFO] (ui: mist) - did-navigate browser https://github.com/ethereum/mist/releases
[2018-06-25T22:21:34.249] [INFO] Sockets/3 - Disconnecting...
[2018-06-25T22:21:34.253] [INFO] Sockets/6 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:34.255] [INFO] Sockets/6 - Connected!
[2018-06-25T22:21:34.314] [INFO] Sockets/3 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:34.315] [INFO] Sockets/3 - Connected!
[2018-06-25T22:21:34.505] [INFO] Sockets/5 - Connect to {"path":"/Users/shaikhaalothman/chaindata/geth.ipc"}
[2018-06-25T22:21:34.506] [INFO] Sockets/5 - Connected!
[2018-06-25T22:21:36.584] [INFO] (ui: mist) - did-navigate-in-page wallet https://wallet.ethereum.org/
[2018-06-25T22:21:36.701] [INFO] (ui: mist) - dom-ready wallet https://wallet.ethereum.org/
[2018-06-25T22:21:40.442] [INFO] (ui: mist) - did-stop-loading wallet https://wallet.ethereum.org/
[2018-06-25T22:21:41.252] [INFO] (ui: mist) - dom-ready browser https://github.com/ethereum/mist/releases
[2018-06-25T22:21:42.799] [INFO] (ui: mist) - did-stop-loading browser https://github.com/ethereum/mist/releases
  1. 我執行 geth attach

我跑了geth attach /Users/shaikhaalothman/chaindata/geth.ipc ,然後設置miner.setEtherbase("f8ddc84985c88e209a9f345bd6e87e9373cf386c"),並通過以下方式開始挖礦miner.start(1);


Last login: Mon Jun 25 22:20:53 on ttys001
Shaikhas-MacBook-Pro:~ shaikhaalothman$ geth attach /Users/shaikhaalothman/chaindata/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.11-stable-dea1ce05/darwin-amd64/go1.10.3
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> miner.setEtherbase("f8ddc84985c88e209a9f345bd6e87e9373cf386c")
true
> miner.start(1);
null
> miner.start(1);
null
> miner.start(1);
null
> 

我不知道出了什麼問題。如果您有任何想法…您的意見將不勝感激

我相信您正在嘗試創建一個私有鏈(ID 為 15),但只為它初始化文件。然後你啟動 Mist,它會啟動一個生產 geth 節點,而不是連接到在你的私有鏈上執行的節點。在初始化和啟動 Mist 之間,可能有另一個命令來使用您的創世塊和您可以連接您的 Mist 客戶端的初始化文件來啟動一個私有挖礦節點。

當我建立自己的私有乙太坊網路時,我使用了以下 github 儲存庫:https ://github.com/vertigobr/ethereum

這對我了解正確設置的要求有很大幫助。還有一篇文章解釋了一切。你可以在這裡找到它:https ://medium.com/@andrenit/buildind-an-ethereum-playground-with-docker-part-1-introduction-80be173aaa7a

如果我對該主題的理解是正確的,您可能需要在該專用網路上執行任何節點/礦工之前啟動“bootnode”。我也遇到礦工不工作的問題,原因是它無法連接到任何對等方。就我而言,問題在於引導節點的 URL。正確設置它可以修復錯誤並使探勘/部署智能合約成為可能。

我希望這會有所幫助!即使答案不正確,我分享的那篇文章也是一個很好的起點。(我不是作者,我只是分享。)

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