aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/table.go
Commit message (Collapse)AuthorAgeFilesLines
* p2p/discover: move bond logic from table to transport (#17048)Felix Lange2018-07-031-178/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* all: library changes for swarm-network-rewrite (#16898)Elad2018-06-141-3/+3
| | | | | | | | | | | | This commit adds all changes needed for the merge of swarm-network-rewrite. The changes: - build: increase linter timeout - contracts/ens: export ensNode - log: add Output method and enable fractional seconds in format - metrics: relax test timeout - p2p: reduced some log levels, updates to simulation packages - rpc: increased maxClientSubscriptionBuffer to 20000
* p2p/discover: s/lastPong/bondTime/, update TestUDP_findnodeFelix Lange2018-02-171-3/+3
| | | | | | | I forgot to change the check in udp.go when I changed Table.bond to be based on lastPong instead of node presence in db. Rename lastPong to bondTime and add hasBond so it's clearer what this DB key is used for now.
* p2p/discover: fix out-of-bounds issuePéter Szilágyi2018-02-141-1/+1
|
* p2p, p2p/discover: misc connectivity improvements (#16069)Felix Lange2018-02-121-150/+334
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * p2p: add DialRatio for configuration of inbound vs. dialed connections * p2p: add connection flags to PeerInfo * p2p/netutil: add SameNet, DistinctNetSet * p2p/discover: improve revalidation and seeding This changes node revalidation to be periodic instead of on-demand. This should prevent issues where dead nodes get stuck in closer buckets because no other node will ever come along to replace them. Every 5 seconds (on average), the last node in a random bucket is checked and moved to the front of the bucket if it is still responding. If revalidation fails, the last node is replaced by an entry of the 'replacement list' containing recently-seen nodes. Most close buckets are removed because it's very unlikely we'll ever encounter a node that would fall into any of those buckets. Table seeding is also improved: we now require a few minutes of table membership before considering a node as a potential seed node. This should make it less likely to store short-lived nodes as potential seeds. * p2p/discover: fix nits in UDP transport We would skip sending neighbors replies if there were fewer than maxNeighbors results and CheckRelayIP returned an error for the last one. While here, also resolve a TODO about pong reply tokens.
* build: enable unconvert linter (#15456)ferhat elmas2017-11-111-1/+1
| | | | | | | | | * build: enable unconvert linter - fixes #15453 - update code base for failing cases * cmd/puppeth: replace syscall.Stdin with os.Stdin.Fd() for unconvert linter
* p2p, p2p/discover, p2p/nat: rework logging using context keysFelix Lange2017-02-281-8/+6
|
* all: blidly swap out glog to our log15, logs need reworkPéter Szilágyi2017-02-231-12/+12
|
* all: gofmt -w -sFelix Lange2017-01-061-1/+1
|
* p2p/discover: prevent bonding selfFelix Lange2016-05-031-0/+4
|
* all: Rename crypto.Sha3{,Hash}() to crypto.Keccak256{,Hash}()Ricardo Catalinas Jiménez2016-02-221-3/+3
| | | | As we aren't really using the standarized SHA-3
* p2p, p2p/discover: track bootstrap state in p2p/discoverFelix Lange2015-12-181-37/+68
| | | | | | This change simplifies the dial scheduling logic because it no longer needs to track whether the discovery table has been bootstrapped.
* p2p/discover: support incomplete node URLs, add ResolveFelix Lange2015-12-181-2/+24
|
* node: customizable protocol and service stacksPéter Szilágyi2015-11-271-4/+3
|
* p2p/discover: remove unused lastLookup fieldFelix Lange2015-09-301-6/+1
|
* p2p/discover: fix race involving the seed node iteratorFelix Lange2015-09-301-56/+105
| | | | | | | | | | | | | | | | | | | nodeDB.querySeeds was not safe for concurrent use but could be called concurrenty on multiple goroutines in the following case: - the table was empty - a timed refresh started - a lookup was started and initiated refresh These conditions are unlikely to coincide during normal use, but are much more likely to occur all at once when the user's machine just woke from sleep. The root cause of the issue is that querySeeds reused the same leveldb iterator until it was exhausted. This commit moves the refresh scheduling logic into its own goroutine (so only one refresh is ever active) and changes querySeeds to not use a persistent iterator. The seed node selection is now more random and ignores nodes that have not been contacted in the last 5 days.
* p2p/discover: don't attempt to replace nodes that are being replacedFelix Lange2015-08-191-4/+11
| | | | | | | | PR #1621 changed Table locking so the mutex is not held while a contested node is being pinged. If multiple nodes ping the local node during this time window, multiple ping packets will be sent to the contested node. The changes in this commit prevent multiple packets by tracking whether the node is being replaced.
* p2p/discover: unlock the table during ping replacementFelix Lange2015-08-111-48/+73
| | | | | | Table.mutex was being held while waiting for a reply packet, which effectively made many parts of the whole stack block on that packet, including the net_peerCount RPC call.
* p2p/discover: close Table during testingFelix Lange2015-08-061-1/+3
| | | | Not closing the table used to be fine, but now the table has a database.
* all: fix license headers one more timeFelix Lange2015-07-241-1/+1
| | | | I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
* all: update license headers to distiguish GPL/LGPLFelix Lange2015-07-231-4/+4
| | | | | All code outside of cmd/ is licensed as LGPL. The headers now reflect this by calling the whole work "the go-ethereum library".
* all: update license informationFelix Lange2015-07-071-0/+16
|
* p2p/discover: deflake TestUDP_successfulPingFelix Lange2015-06-101-0/+8
|
* p2p/discover: bond with seed nodes too (runs only if findnode failed)Péter Szilágyi2015-05-271-7/+4
|
* p2p/discovery: fix a cornercase loop if no seeds or bootnodes are knownPéter Szilágyi2015-05-271-5/+9
|
* p2p/discover: force refresh if the table is emptyPéter Szilágyi2015-05-271-13/+41
|
* p2p/discover: permit temporary bond failures for previously known nodesPéter Szilágyi2015-05-271-12/+15
|
* p2p/discover: watch find failures, evacuate on too many, rebond if failedPéter Szilágyi2015-05-271-8/+47
|
* p2p/discover: add ReadRandomNodesFelix Lange2015-05-251-0/+49
|
* p2p/discover: fix #838, evacuate self entries from the node dbPéter Szilágyi2015-05-221-2/+2
|
* p2p/discover: bump maxBondingPingPongs to 16Felix Lange2015-05-141-1/+1
| | | | | This should increase the speed a bit because all findnode results (up to 16) can be verified at the same time.
* p2p/discover: new distance metric based on sha3(id)Felix Lange2015-05-061-24/+30
| | | | | | | The previous metric was pubkey1^pubkey2, as specified in the Kademlia paper. We missed that EC public keys are not uniformly distributed. Using the hash of the public keys addresses that. It also makes it a bit harder to generate node IDs that are close to a particular node.
* p2p/discover: track sha3(ID) in NodeFelix Lange2015-04-301-5/+6
|
* p2p/discover: new endpoint formatFelix Lange2015-04-301-7/+2
| | | | | | This commit changes the discovery protocol to use the new "v4" endpoint format, which allows for separate UDP and TCP ports and makes it possible to discover the UDP address after NAT.
* p2p/discover: fix goroutine leak due to blocking on sync.OncePéter Szilágyi2015-04-281-1/+1
|
* p2p/discover: add node expirer and related testsPéter Szilágyi2015-04-271-0/+2
|
* p2p/discover: parametrize nodedb version, add persistency testsPéter Szilágyi2015-04-271-2/+2
|
* p2p/discover: wrap the pinger to update the node db tooPéter Szilágyi2015-04-271-4/+15
|
* p2p/discover: write the basic tests, catch RLP bugPéter Szilágyi2015-04-271-1/+1
|
* p2p/discovery: fix issues raised in the nodeDb PRPéter Szilágyi2015-04-271-3/+2
|
* cmd/bootnode, eth, p2p, p2p/discover: use a fancier db designPéter Szilágyi2015-04-241-11/+25
|
* cmd/bootnode, eth, p2p, p2p/discover: clean up the seeder and mesh into eth.Péter Szilágyi2015-04-241-13/+10
|
* p2p/discovery: use the seed table for finding nodes, auto drop stale onesPéter Szilágyi2015-04-241-2/+8
|
* cmd, eth, p2p, p2p/discover: init and clean up the seed cachePéter Szilágyi2015-04-241-3/+13
|
* p2p/discover: store nodes in leveldbFelix Lange2015-04-241-1/+2
|
* p2p/discover: remove unused field Node.activeStampFelix Lange2015-04-131-1/+0
|
* p2p/discover: fix off by one error causing buckets to contain duplicatesFelix Lange2015-04-011-1/+1
|
* p2p/discover: implement node bondingFelix Lange2015-04-011-50/+133
| | | | | | | | | | | | | | | | This a fix for an attack vector where the discovery protocol could be used to amplify traffic in a DDOS attack. A malicious actor would send a findnode request with the IP address and UDP port of the target as the source address. The recipient of the findnode packet would then send a neighbors packet (which is 16x the size of findnode) to the victim. Our solution is to require a 'bond' with the sender of findnode. If no bond exists, the findnode packet is not processed. A bond between nodes α and β is created when α replies to a ping from β. This (initial) version of the bonding implementation might still be vulnerable against replay attacks during the expiration time window. We will add stricter source address validation later.
* p2p: server>discover table Self=Node exportedzelig2015-03-151-3/+3
|
* p2p/discover: code review fixesFelix Lange2015-02-131-4/+4
|
* p2p/discover: deflake UDP testsFelix Lange2015-02-091-1/+2
|
* cmd/ethereum, cmd/mist: add flag for discovery bootstrap nodesFelix Lange2015-02-071-2/+2
|
* p2p/discover: add node URL functions, distinguish TCP/UDP portsFelix Lange2015-02-071-193/+4
| | | | | The discovery RPC protocol does not yet distinguish TCP and UDP ports. But it can't hurt to do so in our internal model.
* p2p/discover: add some helper functionsFelix Lange2015-02-061-8/+29
|
* p2p/discover: new package implementing the Node Discovery ProtocolFelix Lange2015-02-061-0/+447