502 Commits

Author SHA1 Message Date
hashmap 8a22fb516a Reduce number of allocations in to_key calls (#3311)
We have to make an extra allocation per db get request because key generation function to_key takes Vec. Taking byte slice (AsRef<[u8]> to be precise) also simplifes the code a bit.
2020-04-30 17:47:44 +02:00
hashmap a82041d0ed Refactor Readable trait (#3309)
Currently Writable accepts trait Write as a type parameter but Readable
takes Read as a trait object, which is not symmetrical and also less performant. This PR changes Readable trait and all places where it's used
2020-04-30 17:42:19 +02:00
Quentin Le Sceller be4779c923 Less cloning and pattern simplifications (#3305)
* Cleanup 
* Pattern simplification
2020-04-24 11:19:34 +02:00
hashmap e64e90623b Reduce number of allocations in Headers message read (#3301)
We allocate 17 vectors (in the heap) per 512 headers, this PR reduces the number to 1 by resuing the buffer for headers and eliminating the need in the vector of indices
2020-04-18 14:07:26 +01:00
jaspervdm 6bdf31f23d Remove unused code in message handling (#3269) 2020-03-13 12:50:35 +01:00
Yeastplume b73fc0bb9b Version bump for next development release 2020-03-02 12:27:16 +00:00
Yeastplume 533da2d192 version bump for 3.1.0 release (#3258) 2020-03-02 10:38:56 +00:00
Antioch Peverell ef755a5c49 bump to 3.1.0-beta.3 (#3252) 2020-02-28 12:42:08 +00:00
Antioch Peverell 5071084445 bump version to 3.1.0-beta.2 (#3244) 2020-02-27 09:35:44 +00:00
Antioch Peverell f2380585a7 explicit read_timeout and write_timeout during hand/shake (#3249)
* explicit read_timeout and write_timeout during hand/shake

* longer timeout for reading Hand and Shake messages to give peer time to send it over
2020-02-27 07:49:38 +00:00
Antioch Peverell 8a15007c8a ignore error from set_read_timeout (#3243) 2020-02-25 20:23:32 +00:00
Antioch Peverell 6855241a56 handle mpsc channel disconnect from peer_write thread (#3241)
* handle mpsc channel disconnect from peer_write thread
also actually shutdown the writer when we say we are going to

* fix - we need to break here
2020-02-25 19:15:27 +00:00
Joseph Goulden 0d2e58e90e feat: allow DNS names in peers/seeds list and resolve them (#3125)
* feat: allow DNS names in peers/seeds list and resolve them

* tests: add mod for peer tests

* refactor: rename some variables

* chore: use Serde desrialize to resolve DNS names into PeerAddrs

* fix: compile

* fix: add back code to remove duplicate ip addresses from resolved DNS seeds
2020-02-14 14:58:57 +00:00
Quentin Le Sceller 053415ddf8 Convert ipv4-mapped ipv6 when accepting peer (#3225) 2020-02-14 09:38:02 -05:00
Quentin Le Sceller b400a4b1cf Attempt to read ipv4-mapped ipv6 to ipv4 if possible (#3221) 2020-02-14 09:37:14 -05:00
Quentin Le Sceller 04a0123752 Less cloning and additional pattern simplifications (#3223)
* API Cleanup

* Chain Cleanup

* Core Cleanup

* Keychain Cleanup

* P2P Cleanup

* Pool Cleanup

* Store Cleanup

* Util Cleanup

* Cleanup clone_from_slice

* Address jasper comments
2020-02-12 19:35:33 +01:00
Antioch Peverell 616dad43fd Cleanup redundant AsFixedBytes and FixedLength traits (#3131)
* no need for AsFixedBytes we can just use AsRef<[u8]>

* cleanup FixedLength trait

* revert this change for now

* fix store tests

* cleanup and fix tests after rebase

* fix tests

* update based on PR review
less hard-coded values now

* cleanup
2020-01-29 13:41:50 +00:00
Quentin Le Sceller 6e5afe496b Update License to 2020 (#3196) 2020-01-20 11:40:58 +00:00
hashmap c2026bd686 Remove unused crates (#3185)
* Remove unused crates

also bump minor versions in Cargo.lock
2020-01-15 11:34:14 +01:00
Yeastplume 2bf4080866 versioning for master 2019-12-20 11:13:39 +00:00
Yeastplume 266af4e91f version bump for master 2019-12-20 11:07:58 +00:00
Yeastplume a50200799b version bump (#3174) 2019-12-19 16:24:02 +00:00
Yeastplume 2f8a1f2712 Versioning for 3.0.0-beta.2 (#3170)
* versioning for beta build

* Cargo.lock
2019-12-12 20:37:50 +00:00
Antioch Peverell bde19777f0 drop msg if sync_sender buffer is full (do not close peer connection) (#3164) 2019-12-10 20:06:17 +00:00
Yeastplume 6a54334576 Version bump for beta.1 (#3159) 2019-12-06 12:01:53 +00:00
Antioch Peverell 8b8f0a0abd pass stopped into consume so we can halt txhashset mid download (#3157) 2019-12-05 12:14:41 +00:00
hashmap cbc17ff5f7 Set longer timeout for msg body read/write operations (#3145)
* Set longer timeout for msg body read operations

* Introduce a channel timeout
2019-12-02 12:00:30 +00:00
Antioch Peverell 7f7d51a748 our TCP listener is nonblocking so we *must* set the accepted stream to blocking explicitly... (#3154) 2019-12-01 00:56:23 +01:00
hashmap 3f528a8e66 Captute "type" byte for unknow message type (#3146)
Found it useful for debugging
2019-11-29 13:04:55 +01:00
Quentin Le Sceller 04e7d307ce Replace MimbleWimble by Mimblewimble (#3118)
* Replace MimbleWimble by Mimblewimble

* MimbleWimble->Mimblewimble
2019-11-19 10:49:32 +00:00
mmgen 928097ad62 Increase IO_TIMEOUT to allow nodes on high-latency connections to sync (#3109)
Commit d3dbafa80b "Use blocking IO in P2P to reduce CPU load" (merged
into v2.1.0) introduced the constant IO_TIMEOUT, setting it to 1 second.

On nodes with high-latency connections, this short timeout causes the
txhashset archive download during step 2 of the IBD process to
invariably fail before it completes.  Since there's no mechanism for
resuming a failed download, this means the node gets stuck at this stage
and never syncs.

Increasing IO_TIMEOUT to 10 seconds solves the issue on my node; others
might suggest a more optimal value for the constant.
2019-11-13 21:12:38 +01:00
hashmap 1f5de6beb9 Verify headers and blocks only when needed (#3023)
* Verify headers and blocks only when needed

Curretnly we have some lightweigt validation implemented as part of
entity deserialization, which is safer and allows us to not parse the
entire object if some part is invalid. At the same time this logic
always applies when we read an entity, eg when reading from DB.

This PR introduces UntrustedHeader/Block which is used when we read from
the network. It does partial validation during read, then it is supposed
to be converted into regular header/block which doesn't validate itself.

Also this PR adds "lightweight" validation to block header read like we have
for block body, so we don't parse block body if the header is invalid.

Fixes #1642

* Move version validation to untrusted header

* update fuzz tests
2019-10-27 08:40:52 +01:00
Antioch Peverell 8f4a1cba67 track opts when requesting blocks (not just if we requested them) (#3089) 2019-10-10 09:38:25 +01:00
Antioch Peverell a3f3fc25dc use sender thread consistently to send msgs to a peer (#3067) 2019-10-07 16:22:05 +01:00
Quentin Le Sceller eefd87aa2e More robust peer banning (#3086)
More robust peer banning
2019-10-04 18:00:49 -04:00
Yeastplume 24cf75cead update versioning to 3.0.0 alpha (#3080) 2019-10-04 10:51:55 +01:00
Antioch Peverell b78ace8329 bump version to v2.1.0-beta.3 (#3075) 2019-10-03 10:36:54 +01:00
Quentin Le Sceller 6be6391225 Change 2018 to 2019 in copyright files (#3072) 2019-10-02 09:40:20 +01:00
Antioch Peverell 751ca06560 bump version number (#3066) 2019-09-30 10:58:49 +01:00
Yeastplume ae556a8a2a change release versioning for 2.1.0 beta build (#3056) 2019-09-24 13:54:12 +01:00
Antioch Peverell f3baceb51b bump version for 2.1.0 dev (still on master) (#3050) 2019-09-19 15:03:44 +01:00
Antioch Peverell bc6108cf12 Kernels v2 (variable size) (#3034)
* wip

* exhaustive match

* write with fixed v1 strategy when writing for hashing

* local protocol version is 2

* cleanup "size" tests that exercise v1 vs v2 vs default protocol versions

* add proto version to Connected! log msg

* cleanup docs

* negotiate protocol version min(local, peer) when doing hand/shake
2019-09-19 14:31:46 +01:00
Antioch Peverell 28d5ee8242 Peer is_known robustness (#3040)
* add some test coverage around peers map (peer_addr hashing impl)

* make is_known a bit more robust

* fix typos
2019-09-12 21:04:09 +01:00
Antioch Peverell 32286ccd7a add some test coverage around peers map (peer_addr hashing impl) (#3039) 2019-09-12 10:37:29 +01:00
hashmap 80a8f76c4c Optimize Option to Error conversion (#3036)
To convert option to error we generate an error message. In some places
it contains header or block hash code or other data which is costly to
produce. So during the initial header sync we spend 12% of all time on
generating those messages (in 99% cases we don't use it). This PR
introduces a lazy generation of error messages which completely
eliminates CPU load during the header sync.
2019-09-10 14:38:36 +02:00
Gary Yu 4faac470d4 fix: the cpuload 100% in case the tcpstream WouldBlock (#3029)
* fix: the cpuload 100% in case the tcpstream WouldBlock

* extending the sleep on WouldBlock to all read/write

* rustfmt
2019-09-10 07:55:57 +08:00
Antioch Peverell dcd405e263 cleanup deprecation warnings about missing dyn with trait objects (#2997) 2019-08-26 21:17:47 +01:00
Antioch Peverell d06b56cf6d simplify broadcast - send to all connected peers (#2996) 2019-08-22 16:35:31 +01:00
Antioch Peverell 5bf813ee93 improve checking for p2p connection limits (revised) (#2993)
* Add check for p2p connection limits

* Simplify undesirable connection shutdown

* Make inbound and outbound connections more explicit

* Cleanup inbound and outbound connections

* Cleanup an outbound peers check

* Rename healthy_peers_mix to enough_outbound_peers

* be a lot less restrictive when picking some candidate peers to connect to
keep the peer address queue drained but actually attempt a healthy number of connections
as most of these attempts are going to fail due to majority of nodes not being publicly accessible
2019-08-21 19:58:43 +01:00
antiochp 17dddeeb0d Revert "Improve checking for p2p connection limits (#2985)"
This reverts commit 24f0a52437.
2019-08-21 15:02:10 +01:00