plugeth/p2p
Felix Lange 90caa2cabb
p2p: new dial scheduler (#20592)
* p2p: new dial scheduler

This change replaces the peer-to-peer dial scheduler with a new and
improved implementation. The new code is better than the previous
implementation in two key aspects:

- The time between discovery of a node and dialing that node is
  significantly lower in the new version. The old dialState kept
  a buffer of nodes and launched a task to refill it whenever the buffer
  became empty. This worked well with the discovery interface we used to
  have, but doesn't really work with the new iterator-based discovery
  API.

- Selection of static dial candidates (created by Server.AddPeer or
  through static-nodes.json) performs much better for large amounts of
  static peers. Connections to static nodes are now limited like dynanic
  dials and can no longer overstep MaxPeers or the dial ratio.

* p2p/simulations/adapters: adapt to new NodeDialer interface

* p2p: re-add check for self in checkDial

* p2p: remove peersetCh

* p2p: allow static dials when discovery is disabled

* p2p: add test for dialScheduler.removeStatic

* p2p: remove blank line

* p2p: fix documentation of maxDialPeers

* p2p: change "ok" to "added" in static node log

* p2p: improve dialTask docs

Also increase log level for "Can't resolve node"

* p2p: ensure dial resolver is truly nil without discovery

* p2p: add "looking for peers" log message

* p2p: clean up Server.run comments

* p2p: fix maxDialedConns for maxpeers < dialRatio

Always allocate at least one dial slot unless dialing is disabled using
NoDial or MaxPeers == 0. Most importantly, this fixes MaxPeers == 1 to
dedicate the sole slot to dialing instead of listening.

* p2p: fix RemovePeer to disconnect the peer again

Also make RemovePeer synchronous and add a test.

* p2p: remove "Connection set up" log message

* p2p: clean up connection logging

We previously logged outgoing connection failures up to three times.

- in SetupConn() as "Setting up connection failed addr=..."
- in setupConn() with an error-specific message and "id=... addr=..."
- in dial() as "Dial error task=..."

This commit ensures a single log message is emitted per failure and adds
"id=... addr=... conn=..." everywhere (id= omitted when the ID isn't
known yet).

Also avoid printing a log message when a static dial fails but can't be
resolved because discv4 is disabled. The light client hit this case all
the time, increasing the message count to four lines per failed
connection.

* p2p: document that RemovePeer blocks
2020-02-13 11:10:03 +01:00
..
discover p2p/discover: slow down lookups on empty table (#20389) 2019-11-26 12:14:43 +02:00
discv5 p2p/discv5: add deprecation warning and remove unused code (#20367) 2019-11-22 18:02:13 +02:00
dnsdisc p2p/dnsdisc: add enode.Iterator API (#20437) 2019-12-12 11:15:36 +02:00
enode p2p/enode: remove data race in sliceIter (#20421) 2019-12-05 22:16:35 +01:00
enr core/forkid: implement the forkid EIP, announce via ENR (#19738) 2019-07-08 18:53:47 +03:00
nat build: use golangci-lint (#20295) 2019-11-18 10:49:17 +02:00
netutil p2p/netutil: fix staticcheck warning (#20315) 2019-11-19 11:17:41 +02:00
simulations p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
testing all: update author list and licenses 2019-07-22 12:17:27 +03:00
dial_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
dial.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
message_test.go all: fix go vet warnings 2016-04-15 11:17:27 +02:00
message.go p2p: measure subprotocol bandwidth usage 2019-09-27 18:00:25 +03:00
metrics.go dashboard: send current block to the dashboard client (#19762) 2019-11-13 12:13:13 +01:00
peer_error.go p2p: fix some golint warnings (#16577) 2018-05-08 13:08:43 +02:00
peer_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
peer.go p2p: measure subprotocol bandwidth usage 2019-09-27 18:00:25 +03:00
protocol.go cmd/devp2p, p2p: dial using node iterator, discovery crawler (#20132) 2019-10-29 17:08:57 +02:00
rlpx_test.go p2p: remove useless parameter (#19433) 2019-04-10 11:49:02 +03:00
rlpx.go p2p: remove unused code (#20325) 2019-11-19 17:16:08 +01:00
server_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
server.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
util_test.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00
util.go p2p: new dial scheduler (#20592) 2020-02-13 11:10:03 +01:00