Synchronization

如何將 pyethapp(python 乙太坊客戶端)與主網同步?

  • April 5, 2018

我剛剛安裝了pyethapp。但是,我無法同步區塊鏈。這是我執行客戶端時得到的結果:

0 ✓ user@host ~ $ pyethapp run

Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt

INFO:app  using data in path=/home/user/.config/pyethapp
INFO:config loading config path=/home/user/.config/pyethapp
INFO:app  omitting reporting of 8893 accounts in genesis 
? ''
: {}
accounts: {keystore_dir: keystore, must_include_coinbase: true}
block:
 ACCOUNT_INITIAL_NONCE: 0
 BLKLIM_FACTOR_DEN: 2
 BLKLIM_FACTOR_NOM: 3
 BLOCK_DIFF_FACTOR: 2048
 BLOCK_REWARD: 5000000000000000000
 DIFF_ADJUSTMENT_CUTOFF: 13
 EXPDIFF_FREE_PERIODS: 2
 EXPDIFF_PERIOD: 100000
 GASLIMIT_ADJMAX_FACTOR: 1024
 GASLIMIT_EMA_FACTOR: 1024
 GENESIS_COINBASE: "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 GENESIS_DIFFICULTY: 131072
 GENESIS_EXTRA_DATA: ''
 GENESIS_GAS_LIMIT: 3141592
 GENESIS_INITIAL_ALLOC: {}
 GENESIS_MIXHASH: "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
   \0"
 GENESIS_NONCE: "\0\0\0\0\0\0\0*"
 GENESIS_PREVHASH: "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
   \0"
 GENESIS_TIMESTAMP: 0
 HOMESTEAD_DIFF_ADJUSTMENT_CUTOFF: 10
 HOMESTEAD_FORK_BLKNUM: 1150000
 MAX_EXTRADATA_LENGTH: 32
 MAX_UNCLES: 2
 MAX_UNCLE_DEPTH: 6
 MIN_DIFF: 131072
 MIN_GAS_LIMIT: 5000
 NEPHEW_REWARD: 156250000000000000
 POW_EPOCH_LENGTH: 30000
 UNCLE_DEPTH_PENALTY_FACTOR: 8
client_version_string: pyethapp/v1.2.1/linux2/py2.7.11
data_dir: !!python/unicode '/home/user/.config/pyethapp'
db: {implementation: LevelDB}
deactivated_services: [pow]
discovery:
 bootstrap_nodes: ['enode://487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a@5.1.83.226:30303',
   'enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303',
   'enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303',
   'enode://2676755dd8477ad3beea32b4e5a144fa10444b70dfa3e05effb0fdfa75683ebd4f75709e1f8126cb5317c5a35cae823d503744e790a3a038ae5dd60f51ee9101@144.76.62.101:30303']
 listen_host: 0.0.0.0
 listen_port: 30303
eth:
 block:
   ACCOUNT_INITIAL_NONCE: 0
   BLKLIM_FACTOR_DEN: 2
   BLKLIM_FACTOR_NOM: 3
   BLOCK_DIFF_FACTOR: 2048
   BLOCK_REWARD: 5000000000000000000
   DIFF_ADJUSTMENT_CUTOFF: 13
   EXPDIFF_FREE_PERIODS: 2
   EXPDIFF_PERIOD: 100000
   GASLIMIT_ADJMAX_FACTOR: 1024
   GASLIMIT_EMA_FACTOR: 1024
   GENESIS_COINBASE: "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
   GENESIS_DIFFICULTY: 17179869184
   GENESIS_EXTRA_DATA: !!binary |
     Ebvo2040e06Mk3wcg3Dkte0zrbPbacvbejjh5Qsbgvo=
   GENESIS_GAS_LIMIT: 5000
   GENESIS_MIXHASH: "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
     \0\0"
   GENESIS_NONCE: "\0\0\0\0\0\0\0B"
   GENESIS_PREVHASH: "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
     \0\0"
   GENESIS_TIMESTAMP: 0
   HOMESTEAD_DIFF_ADJUSTMENT_CUTOFF: 10
   HOMESTEAD_FORK_BLKNUM: 1150000
   MAX_EXTRADATA_LENGTH: 32
   MAX_UNCLES: 2
   MAX_UNCLE_DEPTH: 6
   MIN_DIFF: 131072
   MIN_GAS_LIMIT: 5000
   NEPHEW_REWARD: 156250000000000000
   POW_EPOCH_LENGTH: 30000
   UNCLE_DEPTH_PENALTY_FACTOR: 8
 genesis: /home/user/opt/pyethapp/pyethapp/genesisdata/genesis_frontier.json
 genesis_hash: d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3
 network_id: 1
 pruning: -1
ipc: {ipcpath: /tmp/pyethapp.ipc}
jsonrpc: {corsdomain: '', listen_host: 127.0.0.1, listen_port: 4000}
log_disconnects: false
node: {privkey_hex: 48************************************************************27}
p2p:
 bootstrap_nodes: []
 listen_host: 0.0.0.0
 listen_port: 30303
 max_peers: 10
 min_peers: 5
post_app_start_callback: null
pow: {activated: false, coinbase_hex: null, cpu_pct: 100, mine_empty_blocks: true}

WARNING:accounts  keystore directory does not exist directory=/home/user/.config/pyethapp/keystore
WARNING:accounts  no accounts found 
INFO:app  registering service service=accounts
INFO:db No contrib directory found, so not loading any user services 
INFO:db opening LevelDB path=/home/user/.config/pyethapp/leveldb max_open_files=128 block_cache_size=8388608 write_buffer_size=4194304
INFO:app  registering service service=db
INFO:p2p.discovery  NodeDiscovery init 
INFO:p2p.discovery  starting discovery proto this_enode=enode://afd01fba0c5731191484175421a58f415171ac2e1ded4653ddfd23ff87020490cdb31306e286ba09514a83fc516481f721512a61b85a83f77416d280e63f5308@0.0.0.0:30303
INFO:app  registering service service=discovery
INFO:p2p.peermgr  PeerManager init 
INFO:app  registering service service=peermanager
INFO:eth.chainservice initializing chain 
INFO:eth.chainservice chain at number=0
INFO:app  registering service service=chain
INFO:app  registering service service=jsonrpc
INFO:app  registering service service=ipc
INFO:app  registering service service=console
INFO:app  starting 
INFO:p2p.peermgr  starting peermanager 
INFO:p2p.peermgr  starting listener addr=('0.0.0.0', 30303)
INFO:p2p.discovery  starting discovery 
INFO:p2p.discovery  starting listener host=0.0.0.0 port=30303
INFO:jsonrpc  starting IPCRPCServer ipcpath=/tmp/pyethapp.ipc
INFO:jsonrpc  starting JSONRPCServer port=4000
INFO:p2p.peermgr  waiting for bootstrap 
INFO:p2p.peer received hello client_version=pyethapp/v1.1.1/linux2/py2.7.10 version=55 capabilities=(('eth', 61), ('p2p', 4))
INFO:eth.sync.task  spawning new synctask 
INFO:p2p.peer received hello client_version=Geth/v1.3.5-34b622a2/linux/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
INFO:p2p.peer received hello client_version=Geth/v1.4.1-rc-4b9de756/windows/go1.6.2 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
INFO:p2p.peer received hello client_version=Geth/v1.3.5-3be156fb/linux/go1.4.2 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid genesis hash remote_id=<ETHProtocol <Peer('120.27.121.190', 41303) Geth/v1.3.5-3be156fb>> genesis=5157cbd8975669bdb52c8ba7073bf08fd868946a9f70db197e74097b4342050e
WARNING:protocol  protocol exception, stopping error=wrong genesis block
INFO:p2p.peer received hello client_version=Geth/v1.4.0-unstable/linux/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid network id remote_network_id=104971 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Ged/v1.3.6-66937ae4/linux/go1.6.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid network id remote_network_id=88 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Geth/eth-peer-lon02-2/v1.3.5-34b622a2/linux/go1.6 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61), ('shh', 2))
WARNING:eth.chainservice  invalid network id remote_network_id=996787477 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Gshift/Explorer/v2.5.0-1d1c88f2/linux/go1.6.1 version=4 capabilities=(('shift', 63), ('shift', 62), ('shift', 61))
INFO:p2p.peer received hello client_version=Geth/v1.3.6/windows/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
INFO:p2p.peer received hello client_version=Gshift/v2.5.0-259fd3a2/linux/go1.5.1 version=4 capabilities=(('shift', 63), ('shift', 62), ('shift', 61))
INFO:p2p.peer received hello client_version=Geth/v1.3.5/windows/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:p2p.discovery.kademlia  recv ping from self?! 
WARNING:p2p.discovery.kademlia  recv ping from self?! 
INFO:p2p.peer received hello client_version=Geth/v1.4.1-rc-4b9de756/windows/go1.6.2 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
INFO:p2p.peer received hello client_version=Geth/eth-peer-dal09-6/v1.3.5-34b622a2/linux/go1.6 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61), ('shh', 2))
WARNING:eth.chainservice  invalid network id remote_network_id=996787477 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
Traceback (most recent call last):
 File "/usr/lib/python2.7/site-packages/gevent-1.1.0-py2.7-linux-x86_64.egg/gevent/greenlet.py", line 534, in run
   result = self._run(*self.args, **self.kwargs)
 File "/usr/lib/python2.7/site-packages/devp2p-0.7.2-py2.7.egg/devp2p/peer.py", line 230, in _run_decoded_packets
   self._handle_packet(self.mux.packet_queue.get())  # get_packet blocks
 File "/usr/lib/python2.7/site-packages/devp2p-0.7.2-py2.7.egg/devp2p/peer.py", line 202, in _handle_packet
   cmd_id], protocol=protocol.name, orig_cmd_id=packet.cmd_id)
KeyError: 6
<Greenlet at 0x7f61de03f870: <bound method Peer._run_decoded_packets of <Peer('120.25.154.157', 19999) >>> failed with KeyError

INFO:p2p.peer received hello client_version=Geth/v1.3.5/windows/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
INFO:p2p.peer received hello client_version=Ged/v1.3.6-66937ae4/linux/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid network id remote_network_id=88 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Gshift/Explorer/v2.5.0-1d1c88f2/linux/go1.6.1 version=4 capabilities=(('shift', 63), ('shift', 62), ('shift', 61))
INFO:p2p.peer received hello client_version=Geth/v1.3.6/linux/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid network id remote_network_id=2 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Geth/v1.3.5/linux/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
INFO:p2p.peer received hello client_version=Geth/v1.3.6/linux/go1.5.1 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid network id remote_network_id=2 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Geth/v1.3.5-4f8c7bfd/linux/go1.6.2 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))
WARNING:eth.chainservice  invalid network id remote_network_id=9895630 expected_network_id=1
WARNING:protocol  protocol exception, stopping error=wrong network_id
INFO:p2p.peer received hello client_version=Geth/v1.3.5-34b622a2/linux/go1.6 version=4 capabilities=(('eth', 63), ('eth', 62), ('eth', 61))

這是我從控制台得到的:

^C
Hit [ENTER], to launch console; [Ctrl+C] again to quit! [3s]




Entering Console
Tip:
 use `lastlog(n)` to see n lines of log-output. [default 10] 
 use `lasterr(n)` to see n lines of stderr.
 use `help(eth)` for help on accessing the live chain.


Python 2.7.11 (default, Mar 31 2016, 06:18:34) 
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: help(eth)


In [2]: eth.pending
Out[2]: <Block(#1 fec20c0d)>

In [3]: help(eth)


In [4]: eth.latest
Out[4]: <CachedBlock(#0 d4e56740)>

In [5]: lastlog(15)


In [6]: lasterr(15)


In [7]: 

如何將 pyethapp(python 乙太坊客戶端)與主網同步?


更新,我只是想,我可能必須添加一個引導節點。由於我已經在 localhost 上執行了 parity、geth 和 eth,因此我將它們添加為帶有 的引導節點-b,但是我收到以下錯誤:

Traceback (most recent call last):
 File "/usr/lib/python2.7/site-packages/gevent-1.1.0-py2.7-linux-x86_64.egg/gevent/greenlet.py", line 534, in run
   result = self._run(*self.args, **self.kwargs)
 File "/usr/lib/python2.7/site-packages/devp2p-0.7.2-py2.7.egg/devp2p/peer.py", line 266, in _run_ingress_message
   self.mux.add_message(imsg)
 File "/usr/lib/python2.7/site-packages/devp2p-0.7.2-py2.7.egg/devp2p/muxsession.py", line 51, in _add_message_during_handshake
   rest = session.decode_authentication(msg)
 File "/usr/lib/python2.7/site-packages/devp2p-0.7.2-py2.7.egg/devp2p/rlpxcipher.py", line 224, in decode_authentication
   (size, sig, initiator_pubkey, nonce, version) = self.decode_auth_eip8(ciphertext)
 File "/usr/lib/python2.7/site-packages/devp2p-0.7.2-py2.7.egg/devp2p/rlpxcipher.py", line 261, in decode_auth_eip8
   assert len(ciphertext) >= size
AssertionError
<Peer('127.0.0.1', 37178) > failed with AssertionError

這是一個錯誤嗎?

答案是耐心。pyethapp 與其說是生產就緒節點,不如說是概念驗證實現。

我不得不等待幾個小時,直到我注意到客戶端開始同步主網路。幾天來,它的同步速度非常緩慢,而且我的磁碟上只有前一百萬個塊。繼續等待其餘的。

TL;DR pyethapp 有效,但如果你想在主網上工作,請準備一些時間。

萬一有人像我一樣現在(問題發布兩年後)發現了這一點:在嘗試修復在主網上執行 pyethapp 的各種問題後,我從 wiki 仔細查看了這個頁面。這意味著 pyethapp 目前無法在主網上執行,或者至少在 2017 年 3 月沒有。

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