Light-Clients

乙太坊輕客戶端同步問題:無效時間戳

  • January 11, 2019

完整節點位於 30303 埠上。輕節點在 30304 埠上。日誌如下。

我啟動了全節點,進行了一些交易,然後啟動了輕節點。

全節點執行如下:

[root .eth]# cat run.sh
#!/usr/bin/env bash
geth --datadir /var/.eth/pn \
 --syncmode 'full' \
 --networkid 4242 \
 --verbosity 5 \
 --rpc --rpcapi db,eth,net,web3,personal,miner,admin \
 --rpcport 8666 --rpcaddr "0.0.0.0" --rpccorsdomain '*' \
 --nodiscover \
 --lightserv 20 \
 --lightpeers 10 \
 --mine \
 > log-fullnode.log 2>&1 &
#  --bootnodes 'enode://b82c69a13668b83c561731d2b7526ac2619b4c445f321937eee778093dbe9c572709df70f0bcd59a9744eee6dd7b1590c0a365e8f0600bd40dc6888a68bfd6fc@127.0.0.1:30310' \

像這樣的輕節點:

[root .eth]# cat run-light.sh
#!/usr/bin/env bash
geth --datadir /var/.eth/pn-light \
 --syncmode 'light' \
 --port=30304 \
 --networkid 4242 \
 --verbosity 9 \
 --nodiscover \
 --rpc --rpcapi db,eth,net,web3,personal,miner,admin \
 --rpcport 8546 --rpcaddr "0.0.0.0" --rpccorsdomain '*' \
 > log-lightnode.log 2>&1 &
#  --bootnodesv5 'enode://b82c69a13668b83c561731d2b7526ac2619b4c445f321937eee778093dbe9c572709df70f0bcd59a9744eee6dd7b1590c0a365e8f0600bd40dc6888a68bfd6fc@127.0.0.1:30310' \
#  --v5disc \

創世紀在這裡:

[root .eth]# cat genesis_poa.json
{
 "config": {
   "chainId": 42,
   "homesteadBlock": 1,
   "eip150Block": 2,
   "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
   "eip155Block": 3,
   "eip158Block": 3,
   "byzantiumBlock": 4,
   "clique": {
     "period": 0,
     "epoch": 30000
   }
 },
 "nonce": "0x0",
 "timestamp": "0x5a00bccf",
 "extraData": "0x000000000000000000000000000000000000000000000000000000000000000055d40a83b8445c004df5964ce4a0e261b599c01a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 "gasLimit": "0x47b760",
 "difficulty": "0x1",
 "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "coinbase": "0x0000000000000000000000000000000000000000",
 "alloc": {
   "55d40a83b8445c004df5964ce4a0e261b599c01a": {
     "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
   },
   "589724c5abf2bce219726477cf0a60fa09321380": {
     "balance": "0x100000000000000000000000000000000000000000000000000000000000000"
   }
 },
 "number": "0x0",
 "gasUsed": "0x0",
 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

可能是什麼問題?

:) 問題是我為節點使用了兩個不同的創世文件。唯一的區別是,在全節點中,我為全節點設置了*“period”: 0 ,但我使用**“period”: 20*初始化了輕節點。這就是為什麼它將時間戳辨識為無效的原因——它沒想到會以如此短的間隔生成塊。所以我只是用我上面提供的創世文件重新初始化了輕節點,它解決了這個問題。

它與全節點連接

DEBUG[01-11|01:50:12.250] Adding p2p peer                          name=Geth/v1.9.0-unstable... addr=127.0.0.1:30303 peers=1
TRACE[01-11|01:50:12.251] connection set up                        id=ffc95673c671c384 addr=127.0.0.1:30303 conn=staticdial inbound=false
TRACE[01-11|01:50:12.251] Dial task done                           task="staticdial ffc95673c671c384 127.0.0.1:30303"
DEBUG[01-11|01:50:12.251] Light Ethereum peer connected            id=ffc95673c671c384 conn=staticdial name=Geth/v1.9.0-unstable-a4af7343/linux-amd64/go1.11.2
TRACE[01-11|01:50:12.253] Registering sync peer                    peer=ffc95673c671c384
DEBUG[01-11|01:50:12.254] Received new announcement                id=ffc95673c671c384 conn=staticdial number=48 hash=985a98…2b96f1 reorg=0
DEBUG[01-11|01:50:12.254] Registered new entry                     enode=ffc95673c671c384
DEBUG[01-11|01:50:12.256] Synchronisation started                  id=ffc95673c671c384 conn=staticdial
INFO [01-11|01:50:12.257] Block synchronisation started
DEBUG[01-11|01:50:12.257] Synchronising with the network           peer=ffc95673c671c384 eth=63 head=985a98…2b96f1 td=97 mode=light
DEBUG[01-11|01:50:12.257] Retrieving remote chain height           peer=ffc95673c671c384

但同步失敗,標頭中的時間戳無效

DEBUG[01-11|01:50:12.289] Invalid header encountered               number=2  hash=862e73…d7686a err="invalid timestamp"
WARN [01-11|01:50:12.289] Rolled back headers                      count=1   header=0->0 fast=0->0 block=0->0
DEBUG[01-11|01:50:12.289] Block body download terminated           err="block body download canceled (requested)"
DEBUG[01-11|01:50:12.289] Fetching batch of headers                id=ffc95673c671c384 conn=staticdial count=192 fromnum=49  skip=0   reverse=false
DEBUG[01-11|01:50:12.290] Header download terminated               peer=ffc95673c671c384
DEBUG[01-11|01:50:12.290] Transaction receipt download terminated  err="receipt download canceled (requested)"
DEBUG[01-11|01:50:12.291] Synchronisation terminated               elapsed=33.583028ms
WARN [01-11|01:50:12.291] Synchronisation failed, dropping peer    peer=ffc95673c671c384 err="retrieved hash chain is invalid"
TRACE[01-11|01:50:12.291] Unregistering sync peer                  peer=ffc95673c671c384

檢查電腦中的時鐘是否正確並與網際網路同步。

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