erigon-pulse/p2p
Felix Lange c73b654fd1 p2p/discover: move bond logic from table to transport (#17048)
* p2p/discover: move bond logic from table to transport

This commit moves node endpoint verification (bonding) from the table to
the UDP transport implementation. Previously, adding a node to the table
entailed pinging the node if needed. With this change, the ping-back
logic is embedded in the packet handler at a lower level.

It is easy to verify that the basic protocol is unchanged: we still
require a valid pong reply from the node before findnode is accepted.

The node database tracked the time of last ping sent to the node and
time of last valid pong received from the node. Node endpoints are
considered verified when a valid pong is received and the time of last
pong was called 'bond time'. The time of last ping sent was unused. In
this commit, the last ping database entry is repurposed to mean last
ping _received_. This entry is now used to track whether the node needs
to be pinged back.

The other big change is how nodes are added to the table. We used to add
nodes in Table.bond, which ran when a remote node pinged us or when we
encountered the node in a neighbors reply. The transport now adds to the
table directly after the endpoint is verified through ping. To ensure
that the Table can't be filled just by pinging the node repeatedly, we
retain the isInitDone check. During init, only nodes from neighbors
replies are added.

* p2p/discover: reduce findnode failure counter on success

* p2p/discover: remove unused parameter of loadSeedNodes

* p2p/discover: improve ping-back check and comments

* p2p/discover: add neighbors reply nodes always, not just during init
2018-07-03 16:24:12 +03:00
..
discover p2p/discover: move bond logic from table to transport (#17048) 2018-07-03 16:24:12 +03:00
discv5 p2p/discv5: add egress/ingress traffic metrics to discv5 udp transport (#16369) 2018-05-29 13:46:09 +02:00
enr p2p/enr: updates for discovery v4 compatibility (#16679) 2018-05-17 15:11:27 +02:00
nat p2p/nat: delete port mapping before adding (#15222) 2017-10-06 13:39:47 +02:00
netutil p2p, p2p/discover: misc connectivity improvements (#16069) 2018-02-12 14:36:09 +02:00
protocols swarm: network rewrite merge 2018-06-21 21:10:31 +02:00
simulations swarm: network rewrite merge 2018-06-21 21:10:31 +02:00
testing swarm: network rewrite merge 2018-06-21 21:10:31 +02:00
dial_test.go p2p: when peer is removed remove it also from dial history (#16060) 2018-02-21 15:03:26 +01:00
dial.go p2p: when peer is removed remove it also from dial history (#16060) 2018-02-21 15:03:26 +01:00
message_test.go all: fix go vet warnings 2016-04-15 11:17:27 +02:00
message.go p2p: fix some golint warnings (#16577) 2018-05-08 13:08:43 +02:00
metrics.go swarm: network rewrite merge 2018-06-21 21:10:31 +02:00
peer_error.go p2p: fix some golint warnings (#16577) 2018-05-08 13:08:43 +02:00
peer_test.go p2p, p2p/discover, p2p/nat: rework logging using context keys 2017-02-28 10:20:29 +01:00
peer.go swarm: network rewrite merge 2018-06-21 21:10:31 +02:00
protocol.go eth, p2p, rpc/api: polish protocol info gathering 2015-10-28 12:44:15 +02:00
rlpx_test.go all: library changes for swarm-network-rewrite (#16898) 2018-06-14 11:21:17 +02:00
rlpx.go crypto: replace ToECDSAPub with error-checking func UnmarshalPubkey (#16932) 2018-06-12 15:26:08 +02:00
server_test.go p2p/simulations: various stability fixes (#15198) 2017-12-01 12:49:04 +01:00
server.go all: library changes for swarm-network-rewrite (#16898) 2018-06-14 11:21:17 +02:00