ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.07k stars 19.95k forks source link

Light client doesn't sync the blockchain on private network #3510

Closed ubunteroz closed 7 years ago

ubunteroz commented 7 years ago

System information

Geth Version: 1.5.6-unstable Git Commit: 3e3edcc46566de81ee3e20d8c016788550a6f4c5 Protocol Versions: [63 62] Network Id: 1 Go Version: go1.7.3 OS: linux GOPATH=/home/surya/go GOROOT=/usr/lib/go-1.7

Expected behaviour

Light client can sync the blockchain on private network

Actual behaviour

Light client doesn't sync the blockchain on private network, while the normal/full node client do.

Steps to reproduce the behaviour

  1. Setup a miner with a custom genesis and datadir $ geth --datadir miner init genesis.json
  2. Setup a light client with the same custom genesis and different datadir $ geth --datadir client --light init genesis.json
  3. Run miner $ geth --datadir miner --networkid 888 --identity miner --lightserv 75 --lightpeers 10 --shh --mine --minerthreads 1 --autodag --etherbase $ETHERBASE --ipcpath geth.ipc
  4. Run light client, add miner as bootnode via it's enode URL
    
    BOOTNODES=enode://1f1e0b2596591468897fd7bc2ba8418516578468b4820ab5cdd0ab4f1b4a9287f4e9a24965ca4e326a8b9297f3adedb330633181f44a3475c57caecb2639f39f@127.0.0.1:30303

$ geth --datadir client --networkid 888 --identity client \ --port 30305 --bootnodes $BOOTNODES --shh --light \ --rpc --rpcaddr 0.0.0.0 --rpcport 8104 \ --ws --wsaddr 0.0.0.0 --wsport 8105 \ --ipcpath geth.ipc


#### Backtrace

[cut] I0104 10:27:22.553847 p2p/discv5/net.go:461] --- (0) pongTimeout for 1f1e0b2596591468@127.0.0.1:30303: verifyinit -> unknown (ok) I0104 10:27:26.389194 p2p/server.go:655] Accepted conn 127.0.0.1:37370 I0104 10:27:26.395136 p2p/server.go:530] <-posthandshake: inbound conn 17b46a67daeef5d3 127.0.0.1:37370 I0104 10:27:26.396118 p2p/server.go:536] <-addpeer: inbound conn 17b46a67daeef5d3 127.0.0.1:37370 I0104 10:27:26.396209 p2p/server.go:739] Added Peer 17b46a67daeef5d3 127.0.0.1:37370 I0104 10:27:26.396453 p2p/peer.go:301] Peer 17b46a67daeef5d3 127.0.0.1:37370: Starting protocol les/1 I0104 10:27:26.396478 p2p/peer.go:301] Peer 17b46a67daeef5d3 127.0.0.1:37370: Starting protocol shh/2 I0104 10:27:26.396619 p2p/peer.go:308] Peer 17b46a67daeef5d3 127.0.0.1:37370: Protocol les/1 error: unwanted connection I0104 10:27:26.396649 p2p/peer.go:177] Peer 17b46a67daeef5d3 127.0.0.1:37370: protocol error: unwanted connection (Subprotocol error) I0104 10:27:26.397044 p2p/server.go:755] Removed Peer 17b46a67daeef5d3 127.0.0.1:37370 (Subprotocol error) I0104 10:27:26.397082 p2p/server.go:552] <-delpeer: Peer 17b46a67daeef5d3 127.0.0.1:37370 ^CI0104 10:27:32.659557 cmd/utils/cmd.go:83] Got interrupt, shutting down... I0104 10:27:32.659611 node/node.go:481] WebSocket endpoint closed: ws://0.0.0.0:8105 I0104 10:27:32.659674 rpc/server.go:239] RPC Server shutdown initiatied I0104 10:27:32.659692 node/node.go:427] HTTP endpoint closed: http://0.0.0.0:8104 I0104 10:27:32.659704 rpc/server.go:239] RPC Server shutdown initiatied I0104 10:27:32.659761 node/node.go:373] IPC endpoint closed: /media/BIGSPACE/manafi/trade/datadir_2_user/geth.ipc I0104 10:27:32.659776 rpc/server.go:239] RPC Server shutdown initiatied I0104 10:27:32.659791 light/lightchain.go:349] Chain manager stopped I0104 10:27:32.659801 les/handler.go:285] Stopping light ethereum protocol handler... I0104 10:27:32.659907 les/handler.go:302] Light ethereum protocol handler stopped I0104 10:27:32.659929 light/txpool.go:324] Transaction pool stopped I0104 10:27:32.860229 ethdb/database.go:176] closed db:/media/BIGSPACE/manafi/trade/datadir_2_user/geth/lightchaindata I0104 10:27:32.860255 whisper/whisperv2/whisper.go:185] Whisper stopped I0104 10:27:32.860314 p2p/nat/nat.go:105] deleting port mapping: tcp 30305 -> 30305 (ethereum p2p) using UPnP or NAT-PMP I0104 10:27:32.860385 p2p/server.go:495] <-quit: spinning down I0104 10:27:32.860429 p2p/discv5/net.go:658] shutting down I0104 10:27:32.860385 p2p/server.go:638] Read error: accept tcp [::]:30305: use of closed network connection I0104 10:27:32.860480 p2p/discv5/udp.go:400] Read error: read udp [::]:30306: use of closed network connection I0104 10:27:32.860504 p2p/server.go:571] ignoring 0 pending tasks at spindown

msacks commented 7 years ago

critical.

ubunteroz commented 7 years ago

Update: Geth version v1.5.7-unstable-b5a100b8/linux/go1.7.4

Normal & client debug stacks: https://gist.github.com/ubunteroz/38548686e097e7f444c7cee5d0cfb396

karalabe commented 7 years ago

@zsfelfoldi Could you please take a look at this?

zsfelfoldi commented 7 years ago

Sorry for missing this issue, I'm currently looking into it. It turned out that there are some minor problems both with the new peer discovery and the les server when running on a private net. I'll make a fix and link the PR here ASAP.

zsfelfoldi commented 7 years ago

https://github.com/ethereum/go-ethereum/pull/3607 fixes the server side issue and also enables adding peers manually. Unfortunately the topic discovery can't help your client finding your server if you don't have your own fixed IP address. Also, it is still a bit unreliable in general, so you might encounter problems even if you're running your server on a fixed IP. So I recommend disabling the topic discovery on the client side (now you can do that with --nodiscover) and adding your server manually with the admin.addPeer("enode://...") command, also on the client side. Once you added the server, the client will remember it next tim and connect automatically. You can also drop the --bootnodes option. (the PR is not merged yet, you can compile my branch until it reaches master)

ubunteroz commented 7 years ago

Thanks, @zsfelfoldi, I will try it out! :smiley:

sekharkumarroy commented 7 years ago

ubunteroz did you get any luck resolving the issue ? I'm facing the same error while connecting to the geth mother node.

ubunteroz commented 7 years ago

Hi @sekharkumarroy, I could get it working by disabling topic discovery (--nodiscover) on both sides (light client and main node) and adding the main node manually with admin.addPeer('enode://...') on the light client side. Also, make sure that both sides had the same genesis block.

sekharkumarroy commented 7 years ago

@ubunteroz Thanks for your reply. I'm able to establish the connectivity between CLI geth and Light server however facing challenges when connecting from an android device to a private light server using the android package (geth.aar). I'm doing experiment in an internet facing AWS server and all the required ports open. Details of the issue can be found here https://github.com/ethereum/go-ethereum/issues/3789

AdwindOne commented 7 years ago

enode://......:@[::]:30303" is no ip ,I want to connect many node on the pravite net ,how can I do ?