aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover
Commit message (Collapse)AuthorAgeFilesLines
* crypto: use go-ethereum secp256k1 package to avoid symbol conflict (#374)Wei-Ning Huang2019-04-181-1/+1
|
* Revert "p2p/discover: increase IP address limits (#60)"Wei-Ning Huang2019-04-091-3/+2
| | | | This reverts commit 3ca44e556bd9561b0c6c64c7d3a4f95726c78be8.
* p2p/discover: fix peer discovery (#248)Wei-Ning Huang2019-04-091-0/+2
| | | | | | | | | | The refactor in 4cd90e02e23ecf2bb11bcb4bba4fea2ae164ef74 introduced livness checks for nodes. However, the change in 86ec742f975d825f42dd69ebf17b0adaa66542c0 did not properly set the initial liveness check value for verified node. For verified node we should set livenessCheck to 1 initially. Without this change, the node entry will not be properly send to other nodes and the network would be broken.
* p2p/discover: increase IP address limits (#60)Sonic2019-04-091-2/+3
|
* dex: redesign p2p network topologySonic2019-04-093-15/+15
| | | | | | | | | | - Let p2p server support direct connection and group connection. - Introduce node meta table to maintain IP of all nodes in node set, in memory and let nodes in the network can sync this table. - Let peerSet able to manage direct connections to notary set and dkg set. The mechanism to refresh the network topology when configuration round change is not done yet.
* Change import go github.com/dexon-foundation/dexonWei-Ning Huang2019-04-097-25/+25
|
* p2p/discover: bump failure counter only if no nodes were provided (#19362)Felix Lange2019-04-081-1/+1
| | | | | | | | This resolves a minor issue where neighbors responses containing less than 16 nodes would bump the failure counter, removing the node. One situation where this can happen is a private deployment where the total number of extant nodes is less than 16. Issue found by @jsying.
* p2p/discover: improve table addition code (#18974)Felix Lange2019-01-314-62/+175
| | | | | | | | | | | | | This change clears up confusion around the two ways in which nodes can be added to the table. When a neighbors packet is received as a reply to findnode, the nodes contained in the reply are added as 'seen' entries if sufficient space is available. When a ping is received and the endpoint verification has taken place, the remote node is added as a 'verified' entry or moved to the front of the bucket if present. This also updates the node's IP address and port if they have changed.
* p2p/discover, p2p/enode: rework endpoint proof handling, packet logging (#18963)Felix Lange2019-01-306-191/+310
| | | | | | | | | | | | | | | | This change resolves multiple issues around handling of endpoint proofs. The proof is now done separately for each IP and completing the proof requires a matching ping hash. Also remove waitping because it's equivalent to sleep. waitping was slightly more efficient, but that may cause issues with findnode if packets are reordered and the remote end sees findnode before pong. Logging of received packets was hitherto done after handling the packet, which meant that sent replies were logged before the packet that generated them. This change splits up packet handling into 'preverify' and 'handle'. The error from 'preverify' is logged, but 'handle' happens after the message is logged. This fixes the order. Packet logs now contain the node ID.
* core: better side-chain importingMartin Holst Swende2018-11-201-1/+1
|
* p2p, p2p/discover: add signed ENR generation (#17753)Felix Lange2018-10-125-75/+104
| | | | | | | | | | | | | | | This PR adds enode.LocalNode and integrates it into the p2p subsystem. This new object is the keeper of the local node record. For now, a new version of the record is produced every time the client restarts. We'll make it smarter to avoid that in the future. There are a couple of other changes in this commit: discovery now waits for all of its goroutines at shutdown and the p2p server now closes the node database after discovery has shut down. This fixes a leveldb crash in tests. p2p server startup is faster because it doesn't need to wait for the external IP query anymore.
* all: new p2p node representation (#17643)Felix Lange2018-09-259-1981/+681
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Package p2p/enode provides a generalized representation of p2p nodes which can contain arbitrary information in key/value pairs. It is also the new home for the node database. The "v4" identity scheme is also moved here from p2p/enr to remove the dependency on Ethereum crypto from that package. Record signature handling is changed significantly. The identity scheme registry is removed and acceptable schemes must be passed to any method that needs identity. This means records must now be validated explicitly after decoding. The enode API is designed to make signature handling easy and safe: most APIs around the codebase work with enode.Node, which is a wrapper around a valid record. Going from enr.Record to enode.Node requires a valid signature. * p2p/discover: port to p2p/enode This ports the discovery code to the new node representation in p2p/enode. The wire protocol is unchanged, this can be considered a refactoring change. The Kademlia table can now deal with nodes using an arbitrary identity scheme. This requires a few incompatible API changes: - Table.Lookup is not available anymore. It used to take a public key as argument because v4 protocol requires one. Its replacement is LookupRandom. - Table.Resolve takes *enode.Node instead of NodeID. This is also for v4 protocol compatibility because nodes cannot be looked up by ID alone. - Types Node and NodeID are gone. Further commits in the series will be fixes all over the the codebase to deal with those removals. * p2p: port to p2p/enode and discovery changes This adapts package p2p to the changes in p2p/discover. All uses of discover.Node and discover.NodeID are replaced by their equivalents from p2p/enode. New API is added to retrieve the enode.Node instance of a peer. The behavior of Server.Self with discovery disabled is improved. It now tries much harder to report a working IP address, falling back to 127.0.0.1 if no suitable address can be determined through other means. These changes were needed for tests of other packages later in the series. * p2p/simulations, p2p/testing: port to p2p/enode No surprises here, mostly replacements of discover.Node, discover.NodeID with their new equivalents. The 'interesting' API changes are: - testing.ProtocolSession tracks complete nodes, not just their IDs. - adapters.NodeConfig has a new method to create a complete node. These changes were needed to make swarm tests work. Note that the NodeID change makes the code incompatible with old simulation snapshots. * whisper/whisperv5, whisper/whisperv6: port to p2p/enode This port was easy because whisper uses []byte for node IDs and URL strings in the API. * eth: port to p2p/enode Again, easy to port because eth uses strings for node IDs and doesn't care about node information in any way. * les: port to p2p/enode Apart from replacing discover.NodeID with enode.ID, most changes are in the server pool code. It now deals with complete nodes instead of (Pubkey, IP, Port) triples. The database format is unchanged for now, but we should probably change it to use the node database later. * node: port to p2p/enode This change simply replaces discover.Node and discover.NodeID with their new equivalents. * swarm/network: port to p2p/enode Swarm has its own node address representation, BzzAddr, containing both an overlay address (the hash of a secp256k1 public key) and an underlay address (enode:// URL). There are no changes to the BzzAddr format in this commit, but certain operations such as creating a BzzAddr from a node ID are now impossible because node IDs aren't public keys anymore. Most swarm-related changes in the series remove uses of NewAddrFromNodeID, replacing it with NewAddr which takes a complete node as argument. ToOverlayAddr is removed because we can just use the node ID directly.
* all: simplify s[:] to s where s is a slice (#17673)Emil2018-09-151-1/+1
|
* p2p, swarm, trie: avoid copying slices in loops (#17265)Oleg Kovalov2018-08-071-4/+4
|
* p2p/discover: move bond logic from table to transport (#17048)Felix Lange2018-07-036-245/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: fix some golint warnings (#16577)kiel barry2018-05-081-10/+10
|
* build: enable goimports and varcheck linters (#16446)thomasmodeneis2018-04-181-1/+0
|
* p2p/discover: s/lastPong/bondTime/, update TestUDP_findnodeFelix Lange2018-02-175-25/+26
| | | | | | | 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: validate bond against lastpong, not db presencePéter Szilágyi2018-02-161-1/+1
|
* p2p/discover: fix out-of-bounds issuePéter Szilágyi2018-02-141-1/+1
|
* p2p, p2p/discover: misc connectivity improvements (#16069)Felix Lange2018-02-125-249/+519
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* p2p, p2p/discover, p2p/discv5: implement UDP port sharing (#15200)Felföldi Zsolt2018-01-222-25/+22
| | | | | | | | | | | | | | | This commit affects p2p/discv5 "topic discovery" by running it on the same UDP port where the old discovery works. This is realized by giving an "unhandled" packet channel to the old v4 discovery packet handler where all invalid packets are sent. These packets are then processed by v5. v5 packets are always invalid when interpreted by v4 and vice versa. This is ensured by adding one to the first byte of the packet hash in v5 packets. DiscoveryV5Bootnodes is also changed to point to new bootnodes that are implementing the changed packet format with modified hash. Existing and new v5 bootnodes are both running on different ports ATM.
* p2p/discover: fix leaked goroutine in data expirationferhat elmas2017-12-181-3/+3
|
* 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: add network simulation framework (#14982)Lewis Marshall2017-09-252-0/+70
| | | | | | This commit introduces a network simulation framework which can be used to run simulated networks of devp2p nodes. The intention is to use this for testing protocols, performing benchmarks and visualising emergent network behaviour.
* discover: Changed Logging from Debug to Info (#14485)Ali Hajimirza2017-05-201-1/+1
|
* cmd/geth: add --config file flag (#13875)Felix Lange2017-04-121-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * p2p/discover, p2p/discv5: add marshaling methods to Node * p2p/netutil: make Netlist decodable from TOML * common/math: encode nil HexOrDecimal256 as 0x0 * cmd/geth: add --config file flag * cmd/geth: add missing license header * eth: prettify Config again, fix tests * eth: use gasprice.Config instead of duplicating its fields * eth/gasprice: hide nil default from dumpconfig output * cmd/geth: hide genesis block in dumpconfig output * node: make tests compile * console: fix tests * cmd/geth: make TOML keys look exactly like Go struct fields * p2p: use discovery by default This makes the zero Config slightly more useful. It also fixes package node tests because Node detects reuse of the datadir through the NodeDatabase. * cmd/geth: make ethstats URL settable through config file * cmd/faucet: fix configuration * cmd/geth: dedup attach tests * eth: add comment for DefaultConfig * eth: pass downloader.SyncMode in Config This removes the FastSync, LightSync flags in favour of a more general SyncMode flag. * cmd/utils: remove jitvm flags * cmd/utils: make mutually exclusive flag error prettier It now reads: Fatal: flags --dev, --testnet can't be used at the same time * p2p: fix typo * node: add DefaultConfig, use it for geth * mobile: add missing NoDiscovery option * cmd/utils: drop MakeNode This exposed a couple of places that needed to be updated to use node.DefaultConfig. * node: fix typo * eth: make fast sync the default mode * cmd/utils: remove IPCApiFlag (unused) * node: remove default IPC path Set it in the frontends instead. * cmd/geth: add --syncmode * cmd/utils: make --ipcdisable and --ipcpath mutually exclusive * cmd/utils: don't enable WS, HTTP when setting addr * cmd/utils: fix --identity
* p2p, p2p/discover, p2p/nat: rework logging using context keysFelix Lange2017-02-285-44/+42
|
* all: blidly swap out glog to our log15, logs need reworkPéter Szilágyi2017-02-234-39/+35
|
* p2p: remove trailing newlines from log messagesPéter Szilágyi2017-02-231-3/+3
|
* crypto: add btcec fallback for sign/recover without cgo (#3680)Felix Lange2017-02-181-1/+1
| | | | | | | | | | | * vendor: add github.com/btcsuite/btcd/btcec * crypto: add btcec fallback for sign/recover without cgo This commit adds a non-cgo fallback implementation of secp256k1 operations. * crypto, core/vm: remove wrappers for sha256, ripemd160
* all: fix spelling errorsPéter Szilágyi2017-01-071-1/+1
|
* all: fix issues reported by honnef.co/go/simple/cmd/gosimpleFelix Lange2017-01-072-5/+2
|
* all: gofmt -w -sFelix Lange2017-01-063-16/+16
|
* p2p/discover, p2p/discv5: use flexible comparison for IPsPéter Szilágyi2016-12-151-1/+1
|
* p2p, p2p/discover, p2p/discv5: add IP network restriction featureFelix Lange2016-11-232-11/+16
| | | | | | The p2p packages can now be configured to restrict all communication to a certain subset of IP networks. This feature is meant to be used for private networks.
* p2p/discover, p2p/discv5: prevent relay of invalid IPs and low portsFelix Lange2016-11-233-7/+21
| | | | | | | | | | | | | | | | | | | | | The discovery DHT contains a number of hosts with LAN and loopback IPs. These get relayed because some implementations do not perform any checks on the IP. go-ethereum already prevented relay in most cases because it verifies that the host actually exists before adding it to the local table. But this verification causes other issues. We have received several reports where people's VPSs got shut down by hosting providers because sending packets to random LAN hosts is indistinguishable from a slow port scan. The new check prevents sending random packets to LAN by discarding LAN IPs sent by Internet hosts (and loopback IPs from LAN and Internet hosts). The new check also blacklists almost all currently registered special-purpose networks assigned by IANA to avoid inciting random responses from services in the LAN. As another precaution against abuse of the DHT, ports below 1024 are now considered invalid.
* p2p/discover, p2p/discv5: use netutil.IsTemporaryErrorFelix Lange2016-11-234-124/+1
|
* mobile: initial wrappers for mobile supportPéter Szilágyi2016-11-141-2/+2
|
* ethdb, p2p/discover: replace "alloted" with "allotted" (#2785)villesundell2016-07-121-1/+1
|
* p2p/discover: prevent bonding selfFelix Lange2016-05-031-0/+4
|
* all: fix go vet warningsFelix Lange2016-04-151-1/+1
|
* Merge pull request #2242 from jimenezrick/upstream-cryptoJeffrey Wilcke2016-02-246-13/+13
|\ | | | | Closes #2241: Use Keccak-256 from golang.org/x/crypto/sha3 and mention explicitly
| * all: Rename crypto.Sha3{,Hash}() to crypto.Keccak256{,Hash}()Ricardo Catalinas Jiménez2016-02-226-13/+13
| | | | | | | | As we aren't really using the standarized SHA-3
* | p2p/discover: emphasize warning, add 10 min cooldownPéter Szilágyi2016-02-242-18/+39
| |
* | psp/discovery: NTP sanity check clock drift in case of expirationsPéter Szilágyi2016-02-242-4/+128
|/
* p2p/discover: EIP-8 changesFelix Lange2016-02-192-1/+122
|
* p2p/discover: fix Windows-specific issue for larger-than-buffer packetsFelix Lange2016-01-234-7/+124
| | | | | | | | | | On Windows, UDPConn.ReadFrom returns an error for packets larger than the receive buffer. The error is not marked temporary, causing our loop to exit when the first oversized packet arrived. The fix is to treat this particular error as temporary. Fixes: #1579, #2087 Updates: #2082
* p2p/discover: attempt to deflake TestUDP_responseTimeoutsFelix Lange2015-12-181-1/+2
| | | | | The test expected the timeout to fire after a matcher for the response was added, but the timeout is random and fired sooner sometimes.
* p2p, p2p/discover: track bootstrap state in p2p/discoverFelix Lange2015-12-183-45/+92
| | | | | | 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-187-54/+158
|
* crypto, crypto/ecies, crypto/secp256k1: libsecp256k1 scalar multGustav Simonsson2015-11-301-1/+1
| | | | thanks to Felix Lange (fjl) for help with design & impl
* node: customizable protocol and service stacksPéter Szilágyi2015-11-274-13/+20
|
* p2p/discover: ignore packet version numbersFelix Lange2015-09-302-5/+0
| | | | The strict matching can get in the way of protocol upgrades.
* p2p/discover: remove unused lastLookup fieldFelix Lange2015-09-301-6/+1
|
* p2p/discover: fix race involving the seed node iteratorFelix Lange2015-09-305-172/+198
| | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #1694 from obscuren/hide-fdtrackJeffrey Wilcke2015-08-201-3/+0
|\ | | | | fdtrack: hide message
| * Revert "fdtrack: temporary hack for tracking file descriptor usage"Jeffrey Wilcke2015-08-201-3/+0
| | | | | | | | This reverts commit 5c949d3b3ba81ea0563575b19a7b148aeac4bf61.
* | p2p/discover: don't attempt to replace nodes that are being replacedFelix Lange2015-08-192-4/+15
| | | | | | | | | | | | | | | | 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: continue reading after temporary errorsFelix Lange2015-08-191-1/+11
|/ | | | Might solve #1579
* p2p/discover: fix UDP reply packet timeout handlingFelix Lange2015-08-112-31/+120
| | | | | | | | | | | | If the timeout fired (even just nanoseconds) before the deadline of the next pending reply, the timer was not rescheduled. The timer would've been rescheduled anyway once the next packet was sent, but there were cases where no next packet could ever be sent due to the locking issue fixed in the previous commit. As timing-related bugs go, this issue had been present for a long time and I could never reproduce it. The test added in this commit did reproduce the issue on about one out of 15 runs.
* p2p/discover: unlock the table during ping replacementFelix Lange2015-08-113-52/+77
| | | | | | 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-062-4/+8
| | | | Not closing the table used to be fine, but now the table has a database.
* fdtrack: temporary hack for tracking file descriptor usageFelix Lange2015-08-041-0/+3
| | | | | Package fdtrack logs statistics about open file descriptors. This should help identify the source of #1549.
* all: fix license headers one more timeFelix Lange2015-07-248-8/+8
| | | | I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
* all: update license headers to distiguish GPL/LGPLFelix Lange2015-07-238-32/+32
| | | | | 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-078-0/+128
|
* p2p/discover: use separate rand.Source instances in testsFelix Lange2015-06-102-15/+19
| | | | rand.Source isn't safe for concurrent use.
* p2p/discover: deflake TestUDP_successfulPingFelix Lange2015-06-102-33/+30
|
* 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 support for counting findnode failuresPéter Szilágyi2015-05-272-3/+25
|
* p2p/discover: add ReadRandomNodesFelix Lange2015-05-252-1/+83
|
* p2p/discover: fix #838, evacuate self entries from the node dbPéter Szilágyi2015-05-223-25/+99
|
* p2p/discover: fix database presistency test folderPéter Szilágyi2015-05-221-3/+3
|
* p2p/discover: limit open files for node databaseFelix Lange2015-05-141-2/+3
|
* 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: fix out-of-bounds slicing for chunked neighbors packetsFelix Lange2015-05-142-32/+49
| | | | | The code assumed that Table.closest always returns at least 13 nodes. This is not true for small tables (e.g. during bootstrap).
* fix test.subtly2015-05-141-1/+1
|
* Manual send of multiple neighbours packets. Test receiving multiple ↵subtly2015-05-142-3/+19
| | | | neighbours packets.
* UDP Interop. Limit datagrams to 1280bytes.subtly2015-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't have a UDP which specifies any messages that will be 4KB. Aside from being implemented for months and a necessity for encryption and piggy-backing packets, 1280bytes is ideal, and, means this TODO can be completed! Why 1280 bytes? * It's less than the default MTU for most WAN/LAN networks. That means fewer fragmented datagrams (esp on well-connected networks). * Fragmented datagrams and dropped packets suck and add latency while OS waits for a dropped fragment to never arrive (blocking readLoop()) * Most of our packets are < 1280 bytes. * 1280 bytes is minimum datagram size and MTU for IPv6 -- on IPv6, a datagram < 1280bytes will *never* be fragmented. UDP datagrams are dropped. A lot! And fragmented datagrams are worse. If a datagram has a 30% chance of being dropped, then a fragmented datagram has a 60% chance of being dropped. More importantly, we have signed packets and can't do anything with a packet unless we receive the entire datagram because the signature can't be verified. The same is true when we have encrypted packets. So the solution here to picking an ideal buffer size for receiving datagrams is a number under 1400bytes. And the lower-bound value for IPv6 of 1280 bytes make's it a non-decision. On IPv4 most ISPs and 3g/4g/let networks have an MTU just over 1400 -- and *never* over 1500. Never -- that means packets over 1500 (in reality: ~1450) bytes are fragmented. And probably dropped a lot. Just to prove the point, here are pings sending non-fragmented packets over wifi/ISP, and a second set of pings via cell-phone tethering. It's important to note that, if *any* router between my system and the EC2 node has a lower MTU, the message would not go through: On wifi w/normal ISP: localhost:Debug $ ping -D -s 1450 52.6.250.242 PING 52.6.250.242 (52.6.250.242): 1450 data bytes 1458 bytes from 52.6.250.242: icmp_seq=0 ttl=42 time=104.831 ms 1458 bytes from 52.6.250.242: icmp_seq=1 ttl=42 time=119.004 ms ^C --- 52.6.250.242 ping statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 104.831/111.918/119.004/7.087 ms localhost:Debug $ ping -D -s 1480 52.6.250.242 PING 52.6.250.242 (52.6.250.242): 1480 data bytes ping: sendto: Message too long ping: sendto: Message too long Request timeout for icmp_seq 0 ping: sendto: Message too long Request timeout for icmp_seq 1 Tethering to O2: localhost:Debug $ ping -D -s 1480 52.6.250.242 PING 52.6.250.242 (52.6.250.242): 1480 data bytes ping: sendto: Message too long ping: sendto: Message too long Request timeout for icmp_seq 0 ^C --- 52.6.250.242 ping statistics --- 2 packets transmitted, 0 packets received, 100.0% packet loss localhost:Debug $ ping -D -s 1450 52.6.250.242 PING 52.6.250.242 (52.6.250.242): 1450 data bytes 1458 bytes from 52.6.250.242: icmp_seq=0 ttl=42 time=107.844 ms 1458 bytes from 52.6.250.242: icmp_seq=1 ttl=42 time=105.127 ms 1458 bytes from 52.6.250.242: icmp_seq=2 ttl=42 time=120.483 ms 1458 bytes from 52.6.250.242: icmp_seq=3 ttl=42 time=102.136 ms
* removed redundant newlines in import blockBas van Kervel2015-05-121-1/+1
|
* replaced several path.* with filepath.* which is platform independentBas van Kervel2015-05-121-2/+2
|
* p2p/discover: bump packet timeouts to 500msFelix Lange2015-05-071-2/+2
|
* p2p/discover: new distance metric based on sha3(id)Felix Lange2015-05-066-106/+354
| | | | | | | 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-308-99/+166
|
* p2p, p2p/discover: protocol version 4Felix Lange2015-04-301-1/+1
|
* p2p/discover: new endpoint formatFelix Lange2015-04-307-119/+150
| | | | | | 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 api issues caused by leveldb updatePéter Szilágyi2015-04-281-4/+6
|
* p2p/discover: fix goroutine leak due to blocking on sync.OncePéter Szilágyi2015-04-282-13/+24
|
* p2p/discover: add node expirer and related testsPéter Szilágyi2015-04-273-4/+116
|
* p2p/discover: parametrize nodedb version, add persistency testsPéter Szilágyi2015-04-273-11/+62
|
* p2p/discover: drop a superfluous warningPéter Szilágyi2015-04-271-1/+1
|
* p2p/discover: wrap the pinger to update the node db tooPéter Szilágyi2015-04-271-4/+15
|
* p2p/discover: use iterator based seeding, drop old protocol testPéter Szilágyi2015-04-272-45/+118
|
* p2p/discover: write the basic tests, catch RLP bugPéter Szilágyi2015-04-273-8/+150
|
* p2p/discovery: fix issues raised in the nodeDb PRPéter Szilágyi2015-04-272-36/+32
|
* cmd/bootnode, eth, p2p, p2p/discover: use a fancier db designPéter Szilágyi2015-04-246-156/+273
|
* cmd/bootnode, eth, p2p, p2p/discover: clean up the seeder and mesh into eth.Péter Szilágyi2015-04-246-137/+154
|
* p2p/discovery: fix broken tests due to API updatePéter Szilágyi2015-04-242-4/+4
|
* p2p/discovery: use the seed table for finding nodes, auto drop stale onesPéter Szilágyi2015-04-242-5/+38
|
* cmd, eth, p2p, p2p/discover: init and clean up the seed cachePéter Szilágyi2015-04-243-7/+21
|
* p2p/discover: store nodes in leveldbFelix Lange2015-04-242-13/+73
|
* p2p/discover: use rlp.DecodeBytesFelix Lange2015-04-171-1/+1
|
* p2p/discover: improve timer handling for reply timeoutsFelix Lange2015-04-141-2/+3
|
* p2p/discover: remove unused field Node.activeStampFelix Lange2015-04-132-16/+0
|
* p2p/discover: don't log packet contentFelix Lange2015-04-101-3/+4
|
* p2p/discover: make packet processing less concurrentFelix Lange2015-04-101-6/+4
|
* Updated loggingobscuren2015-04-071-10/+9
|
* p2p/discover: fix off by one error causing buckets to contain duplicatesFelix Lange2015-04-012-1/+43
|
* p2p/discover: implement node bondingFelix Lange2015-04-015-383/+649
| | | | | | | | | | | | | | | | 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/discover: add version number to ping packetFelix Lange2015-04-011-0/+8
| | | | | | The primary motivation for doing this right now is that old PoC 8 nodes and newer PoC 9 nodes keep discovering each other, causing handshake failures.
* %#x => %xobscuren2015-03-201-2/+2
|
* p2p: server>discover table Self=Node exportedzelig2015-03-151-3/+3
|
* p2p/discover: add NodeID.PubkeyFelix Lange2015-03-042-0/+33
|
* p2p/discover: fix pending replies iterationFelix Lange2015-02-171-1/+2
| | | | | | Range expressions capture the length of the slice once before the first iteration. A range expression cannot be used here since the loop modifies the slice variable (including length changes).
* p2p/discover: fix race in ListenUDPFelix Lange2015-02-131-24/+17
| | | | | udp.Table was assigned after the readLoop started, so packets could arrive and be processed before the Table was there.
* p2p/discover: map listening port using configured mechanismFelix Lange2015-02-132-13/+24
|
* p2p/discover: code review fixesFelix Lange2015-02-133-7/+9
|
* p2p/discover: deflake UDP testsFelix Lange2015-02-094-59/+123
|
* 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-076-321/+527
| | | | | 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-064-20/+41
|
* p2p/discover: new package implementing the Node Discovery ProtocolFelix Lange2015-02-064-0/+1428