Commit Graph

603 Commits

Author SHA1 Message Date
ferhat elmas
86f6568f66 build: enable unconvert linter (#15456)
* build: enable unconvert linter

 - fixes #15453
 - update code base for failing cases

* cmd/puppeth: replace syscall.Stdin with os.Stdin.Fd() for unconvert linter
2017-11-10 19:06:45 +02:00
Darrel Herbst
d54e3539d4 p2p/nat: delete port mapping before adding (#15222)
Fixes #1024
2017-10-06 13:39:47 +02:00
Péter Szilágyi
2ee885958b p2p: snappy encoding for devp2p (version bump to 5) (#15106)
* p2p: snappy encoding for devp2p (version bump to 5)

* p2p: remove lazy decompression, enforce 16MB limit
2017-09-26 16:54:49 +03:00
Lewis Marshall
9feec51e2d p2p: add network simulation framework (#14982)
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.
2017-09-25 10:08:07 +02:00
Martin Holst Swende
dc92779c0a p2p: change ping ticker to timer (#15071)
Using a Timer over Ticker seems to be a lot better, though I cannot fully
account for why that it behaves so (since Ticker should be more bursty, but not
necessarily more active over time, but that may depend on how long window it
uses to decide on when to tick next)
2017-09-04 09:24:52 +02:00
Ali Hajimirza
33b158e0ed discover: Changed Logging from Debug to Info (#14485) 2017-05-20 13:10:59 +02:00
Felix Lange
30d706c35e cmd/geth: add --config file flag (#13875)
* 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
2017-04-12 17:27:23 +03:00
Péter Szilágyi
04fcae207d p2p: if no nodes are connected, attempt dialing bootnodes (#13874) 2017-04-10 18:33:41 +02:00
Felix Lange
96ae35e2ac p2p, p2p/discover, p2p/nat: rework logging using context keys 2017-02-28 10:20:29 +01:00
Felix Lange
d0eba23af3 all: disable log message colors outside of geth
Also tweak behaviour so colors are only enabled when stderr is a terminal.
2017-02-27 15:33:12 +01:00
Péter Szilágyi
d4fd06c3dc
all: blidly swap out glog to our log15, logs need rework 2017-02-23 12:16:44 +02:00
Péter Szilágyi
189dee26c6
p2p: remove trailing newlines from log messages 2017-02-23 12:00:04 +02:00
Felix Lange
9b0af51386 crypto: add btcec fallback for sign/recover without cgo (#3680)
* 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
2017-02-18 09:24:12 +01:00
Felix Lange
b9b3efb09f all: fix ineffectual assignments and remove uses of crypto.Sha3
go get github.com/gordonklaus/ineffassign
ineffassign .
2017-01-09 16:24:42 +01:00
Péter Szilágyi
18c77744ff
all: fix spelling errors 2017-01-06 19:44:35 +02:00
Felix Lange
13e3b2f433 logger, pow/dagger, pow/ezp: delete dead code 2017-01-06 18:18:07 +01:00
Felix Lange
f2da6581ba all: fix issues reported by honnef.co/go/simple/cmd/gosimple 2017-01-06 18:18:07 +01:00
Felix Lange
35a7dcb162 all: gofmt -w -s 2017-01-06 15:52:03 +01:00
Péter Szilágyi
21fd9f037e
p2p/nat: fix a bytes based net.IP comparison 2016-12-15 16:28:31 +02:00
Péter Szilágyi
2573094df2
p2p/discover, p2p/discv5: use flexible comparison for IPs 2016-12-14 18:40:49 +02:00
Zsolt Felfoldi
a6d3bf6fc3 p2p/discv5: search and lookup improvement 2016-12-08 13:38:15 +01:00
Felix Lange
a47341cf96 p2p, p2p/discover, p2p/discv5: add IP network restriction feature
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.
2016-11-22 22:21:18 +01:00
Felix Lange
a98d1d67d6 p2p/discover, p2p/discv5: prevent relay of invalid IPs and low ports
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.
2016-11-22 22:21:18 +01:00
Felix Lange
ba2884f343 p2p/discover, p2p/discv5: use netutil.IsTemporaryError 2016-11-22 22:21:15 +01:00
Felix Lange
1d80155d5e p2p/netutil: new package for network utilities
The new package contains three things for now:

- IP network list parsing and matching
- The WSAEMSGSIZE workaround, which is duplicated in p2p/discover and
  p2p/discv5.
2016-11-22 22:20:38 +01:00
Péter Szilágyi
b61f48e5aa
cmd, mobile, node, p2p: surface the discovery V5 bootnodes 2016-11-14 18:00:14 +02:00
Péter Szilágyi
178da7c6a9
mobile: initial wrappers for mobile support 2016-11-14 17:56:58 +02:00
Zsolt Felfoldi
1f70b279ba p2p/discv5: added new bootnodes 2016-11-14 13:22:19 +01:00
Zsolt Felfoldi
e33e57684f p2p/discv5: fixed bootnode connect issues 2016-11-14 13:22:19 +01:00
Zsolt Felfoldi
09baeec0da discv5: fixed state machine lockup bug 2016-11-11 03:10:46 +01:00
Felix Lange
b8bd9a71c8 all: update license information 2016-11-09 02:51:34 +01:00
Felix Lange
0f19cbc6e5 p2p/discv5: fix build with Go 1.5, delete package testimg 2016-11-09 02:18:48 +01:00
Zsolt Felfoldi
49da42983a p2p/discv5: added new topic discovery package 2016-11-09 02:12:53 +01:00
Felix Lange
44bc2e80dd Merge pull request #2914 from fjl/node-coinhabit
cmd/utils, node: make datadir reusable for bzzd
2016-09-29 14:24:37 +02:00
ken10100147
afecb93e2e p2p/nat: fix parameter order for AddMapping 2016-09-28 12:11:58 +02:00
Felix Lange
f5c432bcab p2p/nat: delay auto discovery until first use
Port mapper auto discovery used to run immediately after parsing the
--nat flag, giving it a slight performance boost. But this is becoming
inconvenient because we create node.Node for all geth operations
including account management and bare chain interaction. Delay
autodiscovery until the first use instead, which avoids any network
interaction until the node is actually started.
2016-09-16 11:06:52 +02:00
Felix Lange
b8ba80bff7 Merge pull request #2740 from Firescar96/removepeer
node, p2p, internal: Add ability to remove peers via admin interface
2016-07-29 12:34:28 +02:00
Firescar96
4c3da0f2e1 node, p2p, internal: Add ability to remove peers via admin interface 2016-07-14 18:51:41 -04:00
villesundell
c7442ef0d2 ethdb, p2p/discover: replace "alloted" with "allotted" (#2785) 2016-07-12 11:42:47 +02:00
Felix Lange
542b839ec7 node, p2p: move network config out of Server
This silences a go vet message about copying p2p.Server in package node.
2016-05-18 12:19:04 +02:00
Felix Lange
8110671960 p2p/discover: prevent bonding self 2016-05-02 18:50:16 +02:00
Felix Lange
32bb280179 p2p: improve readability of dial task scheduling code 2016-05-02 18:50:15 +02:00
Felix Lange
6fdd0893c3 all: fix go vet warnings 2016-04-15 11:17:27 +02:00
Felix Lange
659c0cb9e8 p2p: enable EIP-8 handshake sending
With the Ethereum Homestead fork is now behind us, we can
assume that everyone runs an EIP-8 capable client.
2016-04-03 23:10:11 +02:00
Péter Szilágyi
64c8e2f2ca p2p/nat: fix #2291, NAT discovery did't abort on failure 2016-03-14 17:08:15 +02:00
Jeffrey Wilcke
483feb0d3f Merge pull request #2242 from jimenezrick/upstream-crypto
Closes #2241: Use Keccak-256 from golang.org/x/crypto/sha3 and mention explicitly
2016-02-24 12:57:57 +01:00
Péter Szilágyi
ac954f48bd p2p/discover: emphasize warning, add 10 min cooldown 2016-02-24 12:16:28 +02:00
Péter Szilágyi
b1908f6a16 psp/discovery: NTP sanity check clock drift in case of expirations 2016-02-24 12:14:15 +02:00
Ricardo Catalinas Jiménez
436fc8d76a all: Rename crypto.Sha3{,Hash}() to crypto.Keccak256{,Hash}()
As we aren't really using the standarized SHA-3
2016-02-21 22:34:34 +00:00
Felix Lange
7d8155714b p2p: EIP-8 changes 2016-02-19 11:14:48 +01:00
Felix Lange
ee1debda53 p2p/discover: EIP-8 changes 2016-02-19 11:14:42 +01:00
Felix Lange
2871781f64 p2p/discover: fix Windows-specific issue for larger-than-buffer packets
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
2016-01-22 23:44:25 +01:00
Felix Lange
b3f1f4c673 p2p/discover: attempt to deflake TestUDP_responseTimeouts
The test expected the timeout to fire after a matcher for the response
was added, but the timeout is random and fired sooner sometimes.
2015-12-17 23:44:56 +01:00
Felix Lange
6c41e675ec p2p: resolve incomplete dial targets
This change makes it possible to add peers without providing their IP
address. The endpoint of the target node is resolved using the discovery
protocol.
2015-12-17 23:39:49 +01:00
Felix Lange
04c6369a09 p2p, p2p/discover: track bootstrap state in p2p/discover
This change simplifies the dial scheduling logic because it
no longer needs to track whether the discovery table has been
bootstrapped.
2015-12-17 23:38:54 +01:00
Felix Lange
d1f507b7f1 p2p/discover: support incomplete node URLs, add Resolve 2015-12-17 23:38:54 +01:00
Péter Szilágyi
abb53644c6 p2p: always allow dynamic dials if network not disabled 2015-12-03 11:45:35 +02:00
Gustav Simonsson
c8ad64f33c crypto, crypto/ecies, crypto/secp256k1: libsecp256k1 scalar mult
thanks to Felix Lange (fjl) for help with design & impl
2015-11-30 13:43:32 +01:00
Péter Szilágyi
9e1d9bff3b node: customizable protocol and service stacks 2015-11-27 11:06:12 +02:00
Jeffrey Wilcke
e165c2d23c Merge pull request #1934 from karalabe/polish-protocol-infos
eth, p2p, rpc/api: polish protocol info gathering
2015-11-04 11:59:31 +01:00
Felix Lange
f570b68ed1 p2p/nat: add docs for discover 2015-10-29 22:54:44 +01:00
Felix Lange
bf11a47f22 Godeps: upgrade github.com/huin/goupnp to 90f71cb5 2015-10-29 22:53:59 +01:00
Péter Szilágyi
e46ab3bdcd eth, p2p, rpc/api: polish protocol info gathering 2015-10-28 12:44:15 +02:00
Felix Lange
32dda97602 p2p/discover: ignore packet version numbers
The strict matching can get in the way of protocol upgrades.
2015-09-30 16:23:03 +02:00
Felix Lange
631bf36102 p2p/discover: remove unused lastLookup field 2015-09-30 16:23:03 +02:00
Felix Lange
b4374436f3 p2p/discover: fix race involving the seed node iterator
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.
2015-09-30 16:23:03 +02:00
Péter Szilágyi
c51e153b5c eth, metrics, p2p: prepare metrics and net packets to eth/62 2015-08-21 10:30:57 +03:00
Jeffrey Wilcke
e2d44814a5 Merge pull request #1694 from obscuren/hide-fdtrack
fdtrack: hide message
2015-08-19 13:50:54 -07:00
Jeffrey Wilcke
269c5c7107 Revert "fdtrack: temporary hack for tracking file descriptor usage"
This reverts commit 5c949d3b3b.
2015-08-19 21:46:01 +02:00
Felix Lange
dd54fef898 p2p/discover: don't attempt to replace nodes that are being replaced
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.
2015-08-19 14:57:16 +02:00
Felix Lange
edccc7ae34 p2p: continue listening after temporary errors 2015-08-19 14:39:04 +02:00
Felix Lange
7d5ff770e2 p2p/discover: continue reading after temporary errors
Might solve #1579
2015-08-19 14:38:55 +02:00
Felix Lange
a89cfe92cc Merge pull request #1470 from ebuchman/encHandshake
p2p: validate recovered ephemeral pubkey
2015-08-13 11:59:27 +02:00
Felix Lange
0d10d5a0a5 p2p: fix value of DiscSubprotocolError
We had the wrong value (12) since forever.
2015-08-12 14:15:54 +02:00
Felix Lange
590c99a98f p2p/discover: fix UDP reply packet timeout handling
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.
2015-08-11 11:42:17 +02:00
Felix Lange
01ed3fa1a9 p2p/discover: unlock the table during ping replacement
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.
2015-08-11 11:42:17 +02:00
Felix Lange
6ee908848c p2p/nat: disable UPnP test on windows 2015-08-06 17:18:59 +02:00
Felix Lange
b23b4dbd79 p2p/discover: close Table during testing
Not closing the table used to be fine, but now the table has a database.
2015-08-06 12:27:59 +02:00
Felix Lange
5c949d3b3b fdtrack: temporary hack for tracking file descriptor usage
Package fdtrack logs statistics about open file descriptors.
This should help identify the source of #1549.
2015-08-04 03:10:27 +02:00
Felix Lange
bfbcfbe4a9 all: fix license headers one more time
I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
2015-07-23 18:35:11 +02:00
Felix Lange
3f047be5aa all: update license headers to distiguish GPL/LGPL
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
2015-07-22 18:51:45 +02:00
Ethan Buchman
37efd08b42 p2p: validate recovered ephemeral pubkey against checksum in decodeAuthMsg 2015-07-14 03:06:44 +00:00
Felix Lange
bdae4fd573 all: add some godoc synopsis comments 2015-07-07 14:12:45 +02:00
Felix Lange
ea54283b30 all: update license information 2015-07-07 14:12:44 +02:00
Péter Szilágyi
01fe972113 cmd, core, eth, metrics, p2p: require enabling metrics 2015-06-30 00:51:46 +02:00
Péter Szilágyi
216fc267fa p2p: fix local/remote cap/protocol mixup 2015-06-26 20:45:13 +03:00
Péter Szilágyi
d84638bd31 p2p: support protocol version negotiation 2015-06-26 15:48:50 +03:00
Péter Szilágyi
6994a3daaa p2p: instrument P2P networking layer 2015-06-24 18:33:33 +03:00
Felix Lange
6fb810adaa p2p: throttle all discovery lookups
Lookup calls would spin out of control when network connectivity was
lost. The throttling that was in place only took effect when the table
returned zero results, which doesn't happen very often.

The new throttling should not have a negative impact when the host is
online. Lookups against the network take some time and dials for all
results must complete or hit the cache before a new one is started. This
usually takes longer than four seconds, leaving online lookups
unaffected.

Fixes #1296
2015-06-22 01:07:58 +02:00
Felix Lange
70da79f04c p2p: improve disconnect logging 2015-06-15 15:03:46 +02:00
Felix Lange
8dcbdcad0a p2p: track write errors and prevent writes during shutdown
As of this commit, we no longer rely on the protocol handler to report
write errors in a timely fashion. When a write fails, shutdown is
initiated immediately and no new writes can start. This will also
prevent new writes from starting after Server.Stop has been called.
2015-06-15 15:03:46 +02:00
Felix Lange
a8e4cb6dfe p2p/discover: use separate rand.Source instances in tests
rand.Source isn't safe for concurrent use.
2015-06-10 15:18:01 +02:00
Felix Lange
261a8077c4 p2p/discover: deflake TestUDP_successfulPing 2015-06-10 13:08:21 +02:00
Péter Szilágyi
1cbbfbe7fa p2p: fix a close race in the dial test 2015-06-09 22:26:26 +03:00
Felix Lange
3239aca69b p2p: bump global write timeout to 20s
The previous value of 5 seconds causes timeouts for legitimate messages
if large messages are sent.
2015-06-09 17:07:10 +02:00
Péter Szilágyi
ff84352fb7 p2p: fix close data race 2015-06-09 16:12:24 +03:00
Felix Lange
fc6a5ae3ec p2p/nat: add timeout for UPnP SOAP requests 2015-06-04 22:25:43 +02:00
Felix Lange
8e4512a5e7 p2p/nat: bump timeout in TestAutoDiscRace 2015-05-28 01:09:26 +02:00
Péter Szilágyi
612f01400f p2p/discover: bond with seed nodes too (runs only if findnode failed) 2015-05-26 23:30:41 +02:00
Péter Szilágyi
3630432dfb p2p/discovery: fix a cornercase loop if no seeds or bootnodes are known 2015-05-26 23:30:40 +02:00
Péter Szilágyi
f539ed1e66 p2p/discover: force refresh if the table is empty 2015-05-26 23:30:40 +02:00
Péter Szilágyi
5076170f34 p2p/discover: permit temporary bond failures for previously known nodes 2015-05-26 23:30:40 +02:00
Péter Szilágyi
6078aa08eb p2p/discover: watch find failures, evacuate on too many, rebond if failed 2015-05-26 23:30:40 +02:00
Péter Szilágyi
64174f196f p2p/discover: add support for counting findnode failures 2015-05-26 23:30:40 +02:00
Péter Szilágyi
68898a4d6b p2p: fix Self() panic if listening is disabled 2015-05-26 19:16:05 +03:00
Péter Szilágyi
e1a0ee8fc5 cmd/geth, cmd/utils, eth, p2p: pass and honor a no discovery flag 2015-05-26 19:07:24 +03:00
Péter Szilágyi
278183c7e7 eth, p2p: start the p2p server even if maxpeers == 0 2015-05-26 17:49:37 +03:00
Felix Lange
9e1fd70b50 p2p: decrease frameReadTimeout to 30s
This detects hanging connections sooner. We send a ping every 15s and
other implementation have similar limits.
2015-05-25 01:17:14 +02:00
Felix Lange
1440f9a37a p2p: new dialer, peer management without locks
The most visible change is event-based dialing, which should be an
improvement over the timer-based system that we have at the moment.
The dialer gets a chance to compute new tasks whenever peers change or
dials complete. This is better than checking peers on a timer because
dials happen faster. The dialer can now make more precise decisions
about whom to dial based on the peer set and we can test those
decisions without actually opening any sockets.

Peer management is easier to test because the tests can inject
connections at checkpoints (after enc handshake, after protocol
handshake).

Most of the handshake stuff is now part of the RLPx code. It could be
exported or move to its own package because it is no longer entangled
with Server logic.
2015-05-25 01:17:14 +02:00
Felix Lange
9f38ef5d97 p2p/discover: add ReadRandomNodes 2015-05-25 01:17:14 +02:00
Felix Lange
64564da20b p2p: decrease maximum message size for devp2p to 1kB
The previous limit was 10MB which is unacceptable for all kinds
of reasons, the most important one being that we don't want to
allow the remote side to make us allocate 10MB at handshake time.
2015-05-25 01:17:14 +02:00
Felix Lange
dbdc5fd4b3 p2p: delete Server.Broadcast 2015-05-25 01:17:14 +02:00
Péter Szilágyi
cbd3ae6906 p2p/discover: fix #838, evacuate self entries from the node db 2015-05-21 19:41:46 +03:00
Péter Szilágyi
af24c271c7 p2p/discover: fix database presistency test folder 2015-05-21 19:28:10 +03:00
Jeffrey Wilcke
90b94e64fc Merge pull request #971 from fjl/p2p-limit-tweaks
p2p: tweak connection limits
2015-05-14 08:15:51 -07:00
Felix Lange
d2f119cf9b p2p/discover: limit open files for node database 2015-05-14 15:01:13 +02:00
Felix Lange
206fe25971 p2p: remove testlog 2015-05-14 14:56:34 +02:00
Felix Lange
7fa2607bd1 p2p/discover: bump maxBondingPingPongs to 16
This should increase the speed a bit because all findnode
results (up to 16) can be verified at the same time.
2015-05-14 14:53:29 +02:00
Felix Lange
691cb90284 p2p: log remote reason when disconnect is requested
The returned reason is currently not used except for the log
message. This change makes the log messages a bit more useful.
The handshake code also returns the remote reason.
2015-05-14 14:53:29 +02:00
Felix Lange
c14de2e973 p2p/nat: tweak port mapping log messages and levels
People stil get confused about the messages. This commit changes
the levels so that the only thing printed at the default level (info)
is a successful mapping.
2015-05-14 12:54:59 +02:00
Felix Lange
663d4e0aff p2p/nat: add test for UPnP auto discovery via SSDP
The test listens for multicast UDP packets on the default interface
because I couldn't get it to work reliably on loopback without massive
changes to goupnp. This means that the test might fail when there is a
UPnP-enabled router attached on that interface. I checked that locally
by looping the test and it passes reliably because the local SSDP server
always responds faster.
2015-05-14 12:13:19 +02:00
Felix Lange
983f5a717a p2p/nat: fix concurrent access to autodisc Interface
Concurrent calls to Interface methods on autodisc could return a "not
discovered" error if the discovery did not finish before the call.
autodisc.wait expected the done channel to carry the found Interface
but it was closed instead.

The fix is to use sync.Once for now, which is easier to get right.
And there is a test. Finally.

This will have to change again when we introduce re-discovery.
2015-05-14 03:53:11 +02:00
Felix Lange
7efeb4bd96 p2p: bump maxAcceptConns and defaultDialTimout
On the test network, we've seen that it becomes harder to connect
if the queues are so short.
2015-05-14 03:48:28 +02:00
Felix Lange
251846d65a p2p/discover: fix out-of-bounds slicing for chunked neighbors packets
The code assumed that Table.closest always returns at least 13 nodes.
This is not true for small tables (e.g. during bootstrap).
2015-05-13 21:49:04 +02:00
subtly
8eef2b765a fix test. 2015-05-13 20:15:01 +02:00
subtly
a32693770c Manual send of multiple neighbours packets. Test receiving multiple neighbours packets. 2015-05-13 20:03:17 +02:00
subtly
7473c93668 UDP Interop. Limit datagrams to 1280bytes.
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
2015-05-13 19:03:00 +02:00
Bas van Kervel
95773b9673 removed redundant newlines in import block 2015-05-12 15:20:53 +02:00
Bas van Kervel
b79dd188d9 replaced several path.* with filepath.* which is platform independent 2015-05-12 14:24:11 +02:00
Felix Lange
d4f0a67323 p2p: drop connections with no matching protocols 2015-05-08 16:09:55 +02:00
Felix Lange
9c0f36c46d p2p: use maxDialingConns instead of maxAcceptConns as dial limit 2015-05-08 16:09:55 +02:00
Felix Lange
914e57e49b p2p: fix disconnect at capacity
With the introduction of static/trusted nodes, the peer count
can go above MaxPeers. Update the capacity check to handle this.
While here, decouple the trusted nodes check from the handshake
by passing a function instead.
2015-05-08 16:09:54 +02:00
Péter Szilágyi
8735e5addd p2p: increase the handshake timeout in the tests 2015-05-07 15:30:56 +03:00
Péter Szilágyi
4d5a719f25 cmd, eth, p2p: introduce pending peer cli arg, add tests 2015-05-07 15:30:56 +03:00
Péter Szilágyi
af93217775 p2p: reduce the concurrent handshakes to 10/10 in/out 2015-05-07 15:22:09 +03:00
Péter Szilágyi
2060bc8bac p2p: fix dial throttling race condition 2015-05-07 15:22:08 +03:00
Péter Szilágyi
29fef349ef p2p: fix a dialing race in the throttler 2015-05-07 15:22:08 +03:00
Péter Szilágyi
3953bf0031 p2p: limit the outbound dialing too 2015-05-07 15:22:08 +03:00
Jeffrey Wilcke
a0cb1945ae Merge pull request #866 from fjl/p2p-last-minute
Last minute p2p fixes
2015-05-06 14:49:52 -07:00
Felix Lange
3e2a928caa p2p: stop dialing at half the maximum peer count 2015-05-06 23:44:51 +02:00
Felix Lange
6a2fec5309 p2p, whisper: use glog for peer-level logging 2015-05-06 23:19:14 +02:00
Felix Lange
bcfd788661 p2p/discover: bump packet timeouts to 500ms 2015-05-06 22:59:00 +02:00
Felix Lange
fd4b75cfa8 p2p/nat: less confusing error logging 2015-05-06 22:58:03 +02:00
obscuren
062fa049d0 fixed merge issue 2015-05-06 22:54:21 +02:00
Felix Lange
2adcc31bb4 p2p/discover: new distance metric based on sha3(id)
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.
2015-05-06 16:10:41 +02:00
Péter Szilágyi
4accc187d5 eth, p2p: add trusted node list beside static list 2015-05-04 13:59:51 +03:00
Péter Szilágyi
54db54931e p2p: add static node dialing test 2015-05-04 13:08:42 +03:00
Péter Szilágyi
e82ddd9198 p2p: correct a leftover trusted -> static 2015-04-30 19:34:33 +03:00
Péter Szilágyi
413ace37d3 eth, p2p: rename trusted nodes to static, drop inbound extra slots 2015-04-30 19:32:48 +03:00
Péter Szilágyi
701591b403 cmd, eth, p2p: fix review issues enumerated by Felix 2015-04-30 16:15:29 +03:00
Péter Szilágyi
1528dbc171 p2p: add trust check to handshake, test privileged connectivity
Conflicts:
	p2p/server_test.go
2015-04-30 16:06:47 +03:00
Péter Szilágyi
14f32a0c3a p2p: reduce the severity of a debug log 2015-04-30 16:04:09 +03:00
Péter Szilágyi
de0549fabb cmd/geth, cmd/mist, cmd/utils, eth, p2p: support trusted peers 2015-04-30 16:03:10 +03:00
Felix Lange
72ab6d3255 p2p/discover: track sha3(ID) in Node 2015-04-30 15:02:23 +02:00
Felix Lange
b34a8ef624 p2p, p2p/discover: protocol version 4 2015-04-30 14:57:34 +02:00
Felix Lange
fc747ef4a6 p2p/discover: new endpoint format
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.
2015-04-30 14:57:33 +02:00
obscuren
01e3d694a6 p2p: added received at to peer message
p2p.Msg.ReceivedAt can be used for determining block propagation from
begining to end.
2015-04-29 22:49:58 +02:00
Péter Szilágyi
b569550a39 p2p/discover: fix api issues caused by leveldb update 2015-04-28 13:57:57 +03:00
Péter Szilágyi
4992765032 p2p/discover: fix goroutine leak due to blocking on sync.Once 2015-04-28 10:28:04 +03:00
Péter Szilágyi
437cf4b3ac p2p/discover: add node expirer and related tests 2015-04-27 17:38:28 +03:00
Péter Szilágyi
a136e2bb22 p2p/discover: parametrize nodedb version, add persistency tests 2015-04-27 15:28:17 +03:00
Péter Szilágyi
75fd738dea p2p/discover: drop a superfluous warning 2015-04-27 15:06:31 +03:00
Péter Szilágyi
706da56f75 p2p/discover: wrap the pinger to update the node db too 2015-04-27 14:56:42 +03:00
Péter Szilágyi
85b4b44235 p2p/discover: use iterator based seeding, drop old protocol test 2015-04-27 14:45:35 +03:00
Péter Szilágyi
8de8f61d36 p2p/discover: write the basic tests, catch RLP bug 2015-04-27 12:33:06 +03:00
Péter Szilágyi
0201c04b95 p2p/discovery: fix issues raised in the nodeDb PR 2015-04-27 10:19:16 +03:00
Péter Szilágyi
8646365b42 cmd/bootnode, eth, p2p, p2p/discover: use a fancier db design 2015-04-24 18:04:41 +03:00
Péter Szilágyi
6def110c37 cmd/bootnode, eth, p2p, p2p/discover: clean up the seeder and mesh into eth. 2015-04-24 11:33:55 +03:00
Péter Szilágyi
971702e7a1 p2p/discovery: fix broken tests due to API update 2015-04-24 11:23:20 +03:00
Péter Szilágyi
af923c965f p2p/discovery: use the seed table for finding nodes, auto drop stale ones 2015-04-24 11:23:20 +03:00
Péter Szilágyi
5f735d6fce cmd, eth, p2p, p2p/discover: init and clean up the seed cache 2015-04-24 11:23:20 +03:00
Felix Lange
936c8e19ff p2p/discover: store nodes in leveldb 2015-04-24 11:23:20 +03:00
Felix Lange
635b66acdc p2p: return zero node from Self if the server is not running
This helps with fixing the tests for cmd/geth to run without networking.
2015-04-22 12:31:19 +02:00
Felix Lange
9c7281c17e p2p: make DiscReason bigger than byte
We decode into [1]DiscReason in a few places. That doesn't work anymore
because package rlp no longer accepts RLP lists for byte arrays.
2015-04-17 14:45:10 +02:00
Felix Lange
eedbb1ee9a p2p/discover: use rlp.DecodeBytes 2015-04-17 14:45:09 +02:00
Felix Lange
56a48101dc cmd/rlpdump, cmd/utils, eth, p2p, whisper: use rlp input limit 2015-04-17 14:45:09 +02:00
Felix Lange
5528abc795 p2p: fix the dial timer
The dial timer was not reset properly when the peer count reached
MaxPeers.
2015-04-17 08:17:01 +02:00
obscuren
474aa924ca p2p: added limiter function to limit package broadcasting 2015-04-14 12:47:31 +02:00
Felix Lange
0217652d1b p2p/discover: improve timer handling for reply timeouts 2015-04-13 18:08:11 +02:00
Felix Lange
b8aeb04f6f p2p/discover: remove unused field Node.activeStamp 2015-04-13 17:44:14 +02:00
Felix Lange
b9929d289d p2p: fix unsynchronized map access during Server shutdown
removePeer can be called even after listenLoop and dialLoop have returned.
2015-04-13 17:37:32 +02:00
Felix Lange
995fab2ebc p2p: fix yet another disconnect hang
Peer.readLoop will only terminate if the connection is closed. Fix the
hang by closing the connection before waiting for readLoop to terminate.

This also removes the british disconnect procedure where we're waiting
for the remote end to close the connection. I have confirmed with
@subtly that cpp-ethereum doesn't adhere to it either.
2015-04-13 17:34:08 +02:00
Felix Lange
79a6782c1c p2p: fix goroutine leak when handshake read fails
This regression was introduced in b3c058a9e4.
2015-04-13 17:06:19 +02:00
Felix Lange
c5332537f5 p2p: limit number of lingering inbound pre-handshake connections
This is supposed to apply some back pressure so Server is not accepting
more connections than it can actually handle. The current limit is 50.
This doesn't really need to be configurable, but we'll see how it
behaves in our test nodes and adjust accordingly.
2015-04-10 17:24:41 +02:00
Felix Lange
56977c225e p2p: use RLock instead of Lock for pre-dial checks 2015-04-10 17:23:09 +02:00
Felix Lange
b3c058a9e4 p2p: improve disconnect signaling at handshake time
As of this commit, p2p will disconnect nodes directly after the
encryption handshake if too many peer connections are active.
Errors in the protocol handshake packet are now handled more politely
by sending a disconnect packet before closing the connection.
2015-04-10 16:57:56 +02:00
Felix Lange
99a1db2d40 p2p: don't mess with the socket deadline in Peer.readLoop
netWrapper already sets a read deadline in ReadMsg.
2015-04-10 13:26:28 +02:00
Felix Lange
145330fdf2 p2p: properly decrement peer wait group counter for setup errors 2015-04-10 13:26:27 +02:00
Felix Lange
f1d710af00 p2p: fix Peer shutdown deadlocks
There were multiple synchronization issues in the disconnect handling,
all caused by the odd special-casing of Peer.readLoop errors. Remove the
special handling of read errors and make readLoop part of the Peer
WaitGroup.

Thanks to @Gustav-Simonsson for pointing at arrows in a diagram
and playing rubber-duck.
2015-04-10 13:26:27 +02:00
Felix Lange
22d1f0faf1 p2p: improve peer selection logic
This commit introduces a new (temporary) peer selection
strategy based on random lookups.

While we're here, also implement the TODOs in dialLoop.
2015-04-10 13:26:27 +02:00
Felix Lange
7be05b4b9d p2p/discover: don't log packet content 2015-04-10 13:26:27 +02:00
Felix Lange
9cd8c96157 p2p/discover: make packet processing less concurrent 2015-04-10 13:26:27 +02:00
obscuren
688d118c7e Updated logging 2015-04-07 14:57:04 +02:00
Felix Lange
a77c431e37 p2p/discover: fix off by one error causing buckets to contain duplicates 2015-04-01 17:00:12 +02:00
Felix Lange
de7af720d6 p2p/discover: implement node bonding
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.
2015-04-01 17:00:12 +02:00
Felix Lange
92928309b2 p2p/discover: add version number to ping packet
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.
2015-04-01 15:53:04 +02:00
zelig
9880f99ccb fix p2p/testlog_test 2015-03-23 16:41:41 +00:00
obscuren
a7ad9c309b Merge branch 'develop' into conversion 2015-03-21 14:52:42 +01:00
obscuren
4f5b362bda %#x => %x 2015-03-20 12:52:03 +01:00
Felix Lange
b9e0b11e7d p2p: interrupt MsgPipe payload read/write
This is better because protocols might not actually read the payload for
some errors (msg too big, etc.) which can be a pain to test with the old
behaviour.
2015-03-19 15:16:06 +01:00
Felix Lange
a7bced779a p2p: log disconnect requests
This helps a lot with debugging.
2015-03-19 15:15:07 +01:00
Felix Lange
5ba51594c7 p2p: use package rlp to encode messages
Message encoding functions have been renamed to catch any uses.
The switch to the new encoder can cause subtle incompatibilities.
If there are any users outside of our tree, they will at least be
alerted that there was a change.

NewMsg no longer exists. The replacements for EncodeMsg are called
Send and SendItems.
2015-03-19 15:11:02 +01:00
Felix Lange
4811f460e7 p2p: export ExpectMsg (for eth protocol testing) 2015-03-19 15:08:04 +01:00
zelig
b3e133dd15 Merge branch 'frontier/js' into frontier/nodeadmin.js 2015-03-16 22:50:29 +07:00
obscuren
b523441361 Moved ethutil => common 2015-03-16 11:27:38 +01:00
zelig
e150832734 p2p: server>discover table Self=Node exported 2015-03-15 13:38:41 +07:00
Taylor Gerring
485e37e889 Move MakeName to ethutil 2015-03-11 14:29:07 -05:00
Felix Lange
215c763d53 eth, p2p: delete p2p.Blacklist
It is unused and untested right now. We can
bring it back later if required.
2015-03-04 16:54:36 +01:00
Felix Lange
429828cd92 p2p: reject messages that cannot be written as simple RLPx frames
Until chunked frames are implemented we cannot send messages
with a size overflowing uint24.
2015-03-04 16:42:01 +01:00
Felix Lange
22659a7fea p2p: restore read/write timeouts
They got lost in the transition to rlpxFrameRW.
2015-03-04 16:42:00 +01:00
Felix Lange
7964f30dcb p2p: msg.Payload contains list data
With RLPx frames, the message code is contained in the
frame and is no longer part of the encoded data.

EncodeMsg, Msg.Decode have been updated to match.
Code that decodes RLP directly from Msg.Payload will need
to change.
2015-03-04 12:27:24 +01:00
Felix Lange
21649100b1 p2p: verify protocol handshake node ID 2015-03-04 12:27:24 +01:00
Felix Lange
7d39fd6678 p2p: make encryption handshake code easier to follow
This mostly changes how information is passed around.
Instead of using many function parameters and return values,
put the entire state in a struct and pass that.

This also adds back derivation of ecdhe-shared-secret. I deleted
it by accident in a previous refactoring.
2015-03-04 12:27:24 +01:00
Felix Lange
2c505efd1e p2p/discover: add NodeID.Pubkey 2015-03-04 12:27:24 +01:00
Felix Lange
d344054e5a p2p: make RLPx frame MAC 16 bytes as defined in the spec 2015-03-04 12:27:24 +01:00
Felix Lange
d084aed5e9 p2p: delete frameRW 2015-03-04 12:27:24 +01:00
Felix Lange
736e632215 p2p: use RLPx frames for messaging 2015-03-04 12:27:23 +01:00
Felix Lange
51e01cceca p2p: encrypted and authenticated RLPx frame I/O 2015-03-04 12:27:23 +01:00
Felix Lange
936dd0f3bc p2p: add basic RLPx frame I/O 2015-03-04 12:27:23 +01:00
Felix Lange
3719db352a p2p: emit JSON connect/disconnect events 2015-02-19 17:09:33 +01:00
Felix Lange
dd871e791c p2p: initialize Server.ourHandshake before accepting connections 2015-02-19 17:08:18 +01:00
Felix Lange
3dbd32093c p2p: enable devp2p ping
This should prevent connection drops.
2015-02-19 16:54:54 +01:00
Felix Lange
73f94f3755 p2p: disable encryption handshake
The diff is a bit bigger than expected because the protocol handshake
logic has moved out of Peer. This is necessary because the protocol
handshake will have custom framing in the final protocol.
2015-02-19 16:54:53 +01:00
Jeffrey Wilcke
c1d0693cb1 Merge pull request #325 from fjl/deps-cleanup
Cleanup imports
2015-02-17 23:19:45 +01:00
Felix Lange
7ea131d4ff p2p/discover: fix pending replies iteration
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).
2015-02-17 15:21:39 +01:00
Felix Lange
f965f41b6e p2p/nat: switch to github.com/huin/goupnp
My temporary fix was merged upstream.
2015-02-17 13:10:11 +01:00
Felix Lange
34d0e1b2c3 p2p: fix ecies dependency in tests
We forgot to update this reference when moving ecies into the
go-ethereum repo.
2015-02-17 12:04:20 +01:00
obscuren
09e53367a2 Use a mutex write-lock for a write operation 2015-02-15 02:13:24 +01:00
obscuren
65159d65c8 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-02-14 00:27:46 +01:00
obscuren
84f7c966f7 Moved ECIES to repo & added secondary title for webview
* ECIES moved from obscuren to ethereum
* Added html META[name=badge] to reflect menuItem.secondaryTitle
2015-02-14 00:25:47 +01:00
Felix Lange
4bef3ce284 p2p: print Cap as name/version 2015-02-13 23:54:34 +01:00
Felix Lange
32a9c0ca80 p2p: bump devp2p protcol version to 3
For compatibility with cpp-ethereum
2015-02-13 15:08:40 +01:00
Felix Lange
fd3e1061e0 p2p: handle disconnect before protocol handshake 2015-02-13 15:06:47 +01:00
Felix Lange
cf754b9483 p2p/discover: fix race in ListenUDP
udp.Table was assigned after the readLoop started, so
packets could arrive and be processed before the Table was there.
2015-02-13 15:06:47 +01:00
Felix Lange
5cc1256fd6 p2p: ensure we don't dial ourself
addPeer doesn't allow self connects, but we can avoid opening
connections in the first place.
2015-02-13 15:06:47 +01:00
Felix Lange
7101f44998 p2p: add I/O timeout for encrytion handshake 2015-02-13 15:06:47 +01:00
Felix Lange
22ee366ed6 p2p: fix goroutine leak for invalid peers
The deflect logic called Disconnect on the peer, but the peer never ran
and wouldn't process the disconnect request.
2015-02-13 15:06:46 +01:00
Felix Lange
5110f80bba p2p: improve read deadlines
There are now two deadlines, frameReadTimeout and payloadReadTimeout.

The frame timeout is longer and allows for connections that are idle.
The message timeout is still short and ensures that we don't get stuck
in the middle of a message.
2015-02-13 14:44:00 +01:00
Felix Lange
170eb3ac68 p2p/discover: map listening port using configured mechanism 2015-02-13 11:39:32 +01:00
Felix Lange
82f0bd9009 p2p/discover: code review fixes 2015-02-13 11:39:31 +01:00
Felix Lange
d0a2e655c9 cmd/ethereum, cmd/mist, eth, p2p: use package p2p/nat
This deletes the old NAT implementation.
2015-02-13 11:39:31 +01:00
Felix Lange
1543833ca0 p2p/nat: new package for port mapping stuff
I have verified that UPnP and NAT-PMP work against an older version of
the MiniUPnP daemon running on pfSense. This code is kind of hard to
test automatically.
2015-02-13 11:39:31 +01:00
Felix Lange
9915d3c3be p2p/discover: deflake UDP tests 2015-02-09 11:02:32 +01:00
Felix Lange
028775a086 cmd/ethereum, cmd/mist: add flag for discovery bootstrap nodes 2015-02-07 00:52:49 +01:00
Felix Lange
2cf4fed11b cmd/mist, eth, javascript, p2p: use Node URLs for peer suggestions 2015-02-07 00:46:56 +01:00
Felix Lange
e34d134102 p2p: fixes for actual connections
The unit test hooks were turned on 'in production'.
2015-02-07 00:43:52 +01:00
Felix Lange
8564eb9f7e p2p/discover: add node URL functions, distinguish TCP/UDP ports
The discovery RPC protocol does not yet distinguish TCP and UDP ports.
But it can't hurt to do so in our internal model.
2015-02-07 00:12:23 +01:00
Felix Lange
5bdc115943 p2p: integrate p2p/discover
Overview of changes:

- ClientIdentity has been removed, use discover.NodeID
- Server now requires a private key to be set (instead of public key)
- Server performs the encryption handshake before launching Peer
- Dial logic takes peers from discover table
- Encryption handshake code has been cleaned up a bit
- baseProtocol is gone because we don't exchange peers anymore
- Some parts of baseProtocol have moved into Peer instead
2015-02-06 00:00:36 +01:00
Felix Lange
739066ec56 p2p/discover: add some helper functions 2015-02-06 00:00:36 +01:00
Felix Lange
12224c7f59 p2p/discover: new package implementing the Node Discovery Protocol 2015-02-06 00:00:36 +01:00
zelig
2e48d39fc7 key generation abstracted out, for testing with deterministic keys 2015-02-06 00:00:36 +01:00
zelig
488a042736 fix clientidentity test after privkey removed 2015-02-06 00:00:36 +01:00
zelig
71765957e4 get rid of Private Key in ClientIdentity 2015-02-06 00:00:36 +01:00
zelig
68205dec9f make crypto handshake calls package level, store privateKey on peer + tests ok 2015-02-06 00:00:36 +01:00
zelig
4499743522 apply handshake related improvements from p2p.crypto branch 2015-02-06 00:00:35 +01:00
zelig
54252ede31 add temporary forced session token generation 2015-02-06 00:00:35 +01:00
zelig
faa069a126 peer-level integration test for crypto handshake
- add const length params for handshake messages
- add length check to fail early
- add debug logs to help interop testing (!ABSOLUTELY SHOULD BE DELETED LATER)
- wrap connection read/writes in error check
- add cryptoReady channel in peer to signal when secure session setup is finished
- wait for cryptoReady or timeout in TestPeersHandshake
2015-02-06 00:00:35 +01:00
zelig
20aade56c3 chop first byte when cryptoid.PubKeyS is set from identity.Pubkey() since this is directly copied in the auth message 2015-02-06 00:00:35 +01:00
zelig
1f2adb05b5 add initial peer level test (failing) 2015-02-06 00:00:35 +01:00
zelig
4afde4e738 add code documentation 2015-02-06 00:00:35 +01:00
zelig
364b783281 changes that fix it all:
- set proper public key serialisation length in pubLen = 64
- reset all sizes and offsets
- rename from DER to S (we are not using DER encoding)
- add remoteInitRandomPubKey as return value to respondToHandshake
- add ImportPublicKey with error return to read both EC golang.elliptic style 65 byte encoding and 64 byte one
- add ExportPublicKey falling back to go-ethereum/crypto.FromECDSAPub() chopping off the first byte
- add Import - Export tests
- all tests pass
2015-02-06 00:00:35 +01:00
zelig
58fc2c679b important fix for peer pubkey. when taken from identity, chop first format byte! 2015-02-06 00:00:35 +01:00
zelig
923504ce3d add equality check for nonce and remote nonce 2015-02-06 00:00:35 +01:00
zelig
2e868566d7 add minor comments to the test 2015-02-06 00:00:35 +01:00
zelig
e252c634cb first stab at integrating crypto in our p2p
- abstract the entire handshake logic in cryptoId.Run() taking session-relevant parameters
- changes in peer to accomodate how the encryption layer would be switched on
- modify arguments of handshake components
- fixed test getting the wrong pubkey but it till crashes on DH in newSession()
2015-02-06 00:00:35 +01:00
zelig
1803c65e40 integrate cryptoId into peer and connection lifecycle 2015-02-06 00:00:35 +01:00
zelig
489d956283 completed the test. FAIL now. it crashes at diffie-hellman. ECIES -> secp256k1-go panics 2015-02-06 00:00:35 +01:00
zelig
076c382a74 handshake test to crypto 2015-02-06 00:00:35 +01:00
zelig
3b6385b146 handshake test to crypto 2015-02-06 00:00:34 +01:00
zelig
714b955d6e fix crash
- add session token check and fallback to shared secret in responder call too
- use explicit length for the types of new messages
- fix typo resp[resLen-1] = tokenFlag
2015-02-06 00:00:34 +01:00
zelig
b855f671a5 rewrite to comply with latest spec
- correct sizes for the blocks : sec signature 65, ecies sklen 16, keylength 32
- added allocation to Xor (should be optimized later)
- no pubkey reader needed, just do with copy
- restructuring now into INITIATE, RESPOND, COMPLETE -> newSession initialises the encryption/authentication layer
- crypto identity can be part of client identity, some initialisation when server created
2015-02-06 00:00:34 +01:00
zelig
4e52adb84a add crypto auth logic to p2p 2015-02-06 00:00:34 +01:00
zelig
d227f6184e fix protocol to accomodate privkey 2015-02-06 00:00:34 +01:00
zelig
88167f39a6 add privkey to clientIdentity + tests 2015-02-06 00:00:34 +01:00
zelig
c8a8aa0d43 initial hook for crypto handshake (void, off by default) 2015-02-06 00:00:34 +01:00
obscuren
67f9783e6a Moved obscuren secp256k1-go 2015-01-22 00:35:00 +01:00
obscuren
8d1637f567 Moved connection errors to DebugDetail level 2015-01-19 11:21:46 +01:00
Felix Lange
3caa4ad1ba p2p: improve test for peers message
The test now checks that the number of of addresses is correct
and terminates cleanly.
2015-01-06 12:23:38 +01:00
Felix Lange
b0ff946b55 p2p: move peerList back into baseProtocol
It had been moved to Peer, probably for debugging.
2015-01-06 12:23:38 +01:00
Felix Lange
eb0e7b1b81 eth, p2p: remove EncodeMsg from p2p.MsgWriter
...and make it a top-level function instead.

The original idea behind having EncodeMsg in the interface was that
implementations might be able to encode RLP data to their underlying
writer directly instead of buffering the encoded data. The encoder
will buffer anyway, so that doesn't matter anymore.

Given the recent problems with EncodeMsg (copy-pasted implementation
bug) I'd rather implement once, correctly.
2015-01-06 12:23:38 +01:00
obscuren
6abf8ef78f Merge 2015-01-05 17:10:42 +01:00
obscuren
09841b1c9b Cleaned up some of that util 2015-01-04 14:20:16 +01:00
Felix Lange
aa3b91b802 p2p: fix call to Server.removePeer (might help with #209) 2014-12-15 22:36:59 +01:00
obscuren
56dac74f71 made mist in a compilable, workable state using the new refactored packages 2014-12-15 13:00:29 +01:00
Jeffrey Wilcke
15e46b97b4 Merge pull request #204 from fjl/fix-p2p-disconnect
p2p: fix decoding of disconnect reason
2014-12-15 10:22:35 +01:00
Felix Lange
da900f9435 p2p: add test for base protocol disconnect 2014-12-15 00:28:20 +01:00
Felix Lange
f0f6727778 p2p: use an error type for disconnect requests
Test-tastic.
2014-12-15 00:28:20 +01:00
Felix Lange
65e39bf20e p2p: add MsgPipe for protocol testing 2014-12-15 00:28:20 +01:00
Felix Lange
e28c60caf9 p2p: improve and test eofSignal 2014-12-12 11:40:02 +01:00
Felix Lange
9423401d73 p2p: fix decoding of disconnect reason (fixes #200) 2014-12-12 11:40:02 +01:00
obscuren
1fb84d3c5f Fixed tests 2014-12-10 10:57:19 +01:00
Felix Lange
cfd7e74c25 p2p: add test for NewPeer 2014-11-26 22:49:40 +01:00
Felix Lange
3a09459c4c p2p: make Disconnect not hang for peers created with NewPeer 2014-11-26 22:08:54 +01:00
Felix Lange
9b85002b70 p2p: remove Msg.Value and MsgLoop 2014-11-25 16:01:39 +01:00
Felix Lange
6049fcd52a p2p: use package rlp for baseProtocol 2014-11-25 12:25:31 +01:00
Felix Lange
c1fca72552 p2p: use package rlp 2014-11-24 19:03:20 +01:00
Felix Lange
59b63caf5e p2p: API cleanup and PoC 7 compatibility
Whoa, one more big commit. I didn't manage to untangle the
changes while working towards compatibility.
2014-11-21 21:52:45 +01:00
Felix Lange
e4a601c644 p2p: disable failing Server tests for now 2014-11-21 21:52:45 +01:00
Felix Lange
7149191dd9 p2p: fix issues found during review 2014-11-21 21:52:45 +01:00
Felix Lange
f38052c499 p2p: rework protocol API 2014-11-21 21:52:45 +01:00
obscuren
429dd2a100 Implemented new miner w/ ui interface for merged mining. Closes #177
* Miner has been rewritten
* Added new miner pane
* Added option for local txs
* Added option to read from MergeMining contract and list them for
  merged mining
2014-11-07 12:18:48 +01:00
Felix Lange
f3473312ba all: fix rename breakage 2014-10-31 18:52:58 +01:00
zelig
771fbcc02e initial commit of p2p package 2014-10-23 16:57:54 +01:00