Commit graph

293 commits

Author SHA1 Message Date
Ignotus Peverell
5efcdbc077
Refuse duplicate peer IPs (#2347)
* Refuse duplicate peer IPs
* Explicitly mentioning NAT in code comment
* Well of course that would mess with tests. Only trigger using IP test when on the wild internet (~DNS seeding).
2019-01-11 15:51:38 -08:00
Gary Yu
7698b28e16
fix: wait_for_min_peers shouldn't wait forever when all peers are in same work (#2340) 2019-01-12 07:38:27 +08:00
Ignotus Peverell
1a6b46b09d
Ban peers that can't complete a handshake (#2320)
* Break out of main peer loop on error
* Force client conn shutdown on error
* Fix borrow error
* Ban peers that fail handshake
* Fix add_peer for ban, remove useless disconnect
2019-01-11 10:00:32 -08:00
Ignotus Peverell
60d3ee3c44
Bump version to 0.5.2 for release 2019-01-11 01:26:30 +00:00
Ignotus Peverell
f86c90ade5
rustfmt 2019-01-10 01:23:02 +00:00
Ignotus Peverell
6a244e904a
Fix add_peer for ban, remove useless disconnect 2019-01-10 01:22:48 +00:00
Ignotus Peverell
cf088f6f51
Ban peers that fail handshake 2019-01-09 20:31:09 +00:00
Ignotus Peverell
26d250bbea
Fix borrow error 2019-01-09 20:24:57 +00:00
Ignotus Peverell
7a44ee9aa0
Force client conn shutdown on error 2019-01-09 19:24:59 +00:00
Ignotus Peverell
684e8164f5
Break out of main peer loop on error 2019-01-09 19:14:50 +00:00
Ignotus Peverell
2c5ba853f7
Version bump to 0.5.1 2019-01-07 19:41:07 +00:00
Gary Yu
0b73e87f8c
fix: connection close should stay outside the poll loop (#2308) 2019-01-07 14:44:07 +08:00
Gary Yu
e79123fd5c
clean the unused p2p sockets (i.e. not in peers list) (#2298)
* clean the unused p2p sockets (i.e. not in peers list)

* add function comments
2019-01-07 14:41:41 +08:00
Gary Yu
6165c0873c fix: shutdown the tcpstream when we initiate to close a peer connection (#2288) 2019-01-04 09:08:44 -08:00
Gary Yu
7e8296dce0
fix: peer connect panic on log (#2272) 2019-01-02 09:54:17 +08:00
Gary Yu
23df6fa976
fix: check_banned must care about ip address only, and ignore the peer port info (#2267) 2019-01-01 11:43:05 +08:00
Yoni
972cea5fe9 more idiomatic way of picking the peer 2018-12-31 22:48:24 +02:00
Yoni
a5e5ae83b6 typo + styling 2018-12-31 20:00:33 +02:00
Yoni
b2cc5ba7e1 Enable setting a fixed dandelion peer 2018-12-31 18:49:05 +02:00
Gary Yu
738d49d560
fix: one peer occupy multiple tcp connections (#2262)
* shutdown the tcpstream when peer connect or accept fail

* remove the unnecessary 3 times retry on peer connecting

* connect/accept are actually handshakings instead of tcpstream connect/accept
2018-12-31 19:24:30 +08:00
Gary Yu
ea7eea3f84
Skip connecting PeerWithSelf by checking ip address (#2253)
* skip the connecting to self
2018-12-31 07:15:58 +08:00
Ignotus Peverell
9234e3c251
Re-launch floonet (#2249)
*  Fix secondary scaling bugs;  rename is_testnet -> is_floonet (#2215)
* add global::is_mainnet()
* use it to change pre-genesis pow type
* rename is_testnet -> is_floonet
* Support multiple chain configurations (#2217)
* Support multiple chain configurations
Supports generating the proper configuration for each chain type
(mainnet, floonet, usernet). Will run them by default under
their respective root directory (~/.grin/main, ~/.grin/floo, etc).
Assigned default ports for mainnet, overriding them to keep Floonet
ports unchanged.
For now, starting on mainnet will abort.
* Fixed usernet command line help message. Fixes #2217
* Differing magic numbers for each chain type (#2208)
* stick to e=H(R|P|m) when use schnorr signature (#2200)
* stick to e=H(R|P|m) when use schnorr signature
* (1)add verify_slate_messages for wallet receive (2)log the message content
* remove debug log on verify_slate_messages
* verify the sender's message signature when receive_tx in wallet listen
* Revert "remove debug log on verify_slate_messages"

This reverts commit 65ea32a407.

* Revert "rustfmt"

This reverts commit c380ab9185.

* Revert "(1)add verify_slate_messages for wallet receive (2)log the message content"

This reverts commit 9584ca7a89.

* [re-floonet] Keychain Floonet BIP32 version/network option (#2235)

* add 'is_floonet' property to keychain
* fix hex encoding and tests

* Fix couple floonet loose ends (#2230)

* Fix couple floonet loose ends. Fixes #2216
* Doc fix for sig message

* Refuse unkown kernel features (#2244)

* Minor: magic number change for re-floonet

* Set pre genesis is_secondary to true (#2247)

* Minor: tx validation error display underlying

* New floonet genesis

* genesis rustfmt

* Use chain-specific config for wallet toml gen

* Fix default wallet_listener_url

* New more reasonable genesis block, bumped version

* genesis rustfmt

* Couple minor fixes to genesis generation script
2018-12-28 14:46:21 -08:00
Gary Yu
c0507b2ab1 Ban a fraud peer which claims a fake height and total difficulty (#2237)
* ban a peer with highest height but can't send us the proper headers
* reset self.stalling_ts if syncing goes well
* fix: switch to peers.ban_peer() instead of peer.set_banned()
2018-12-28 14:09:09 -08:00
Gary Yu
55334caec8 fix: peers::is_banned need check peers data from database (#2243) 2018-12-28 13:54:37 -08:00
Ignotus Peverell
7284cfec72
Changed magic number and seeds for Floonet (#2188)
* Changed magic number and seeds for Floonet.
* Genesis generator now loads a local wallet seed to build coinbase.
2018-12-20 11:08:01 -08:00
Antioch Peverell
2d4538c428
Clean shutdown via stop_state (#2117)
* clean shutdown wip

* rustfmt

* introduce StopState that we can lock on

* rustfmt

* take lock on stop_state during critical processing (process_block_single etc.)

* rustfmt

* take lock on stop_state during chain::init()

* cleanup

* cleanup

* rustfmt

* docs/comments

* fixup servers tests

* cleanup p2p tests
2018-12-11 11:07:41 +00:00
hashmap
aedac483f5
Convert to Rust 2018 edition (#2084)
* Convert to Rust 2018 edition

* Update gitignore
2018-12-08 00:59:40 +01:00
hashmap
a6bb6344ac
Fix seed thread crash (#2096)
We get overflow in some tests, peraps in real life too
Fixes #2095
2018-12-07 17:09:26 +01:00
Ignotus Peverell
87bfd9aaa4
Mark all crates as publishable 2018-12-07 00:08:15 +00:00
Antioch Peverell
a3523028dc
Sync headers slice (#2085)
* pass slices of headers around, not vec of headers

* rustfmt
2018-12-05 16:50:32 +00:00
Antioch Peverell
7b07fe99a7
bump 0.4.1 -> 0.4.2 so we can watch the HF (#2057) 2018-11-30 11:20:12 +00:00
antiochp
f7608f5b9c
rustfmt 2018-11-16 14:34:05 +00:00
antiochp
4b48eebdfe
refactor some p2p to use Read/Write over TcpStream 2018-11-16 14:33:35 +00:00
Antioch Peverell
f0fa410273
Streaming headers (#1989)
* headers msg is now "streamed" off the tcp stream

* rustfmt

* cleanup

* move StreamingReader into ser.rs
extract read_exact out into util crate

* rustfmt
2018-11-16 11:00:39 +00:00
Antioch Peverell
cb652e7ef1
do not treat txhashset.zip download as abusive behavior (#1973)
* do not treat txhashset.zip download as abusive behavior

* count times, not bytes so we exclude quiet increments

* use inc_quiet when tracking sent bytes via an attachment

* add comment

* fixup "quiet" counter entries

* rustfmt
2018-11-13 21:34:45 +00:00
Antioch Peverell
01900f2e4d Enable TX_KERNEL_HASH capability by default (#1971) 2018-11-13 09:28:36 -08:00
Antioch Peverell
236fe56f60
ask for peers with PEER_LIST capability when asking for more peers (#1969)
do not simply look for peers with the same capabilities we have
2018-11-13 10:59:33 +00:00
Antioch Peverell
c631b45ab6
cleanup how we deal with flexible rproof size in ser/deser (#1965) 2018-11-13 09:30:40 +00:00
Antioch Peverell
a3c1c6d603
Do not use mem::size_of() when calculating serialized size of data (#1967)
* use FixedLength to define serialized size in bytes of various structs
replace usages of mem::size_of() with ::LEN so we correctly calculate serialized sizes in bytes

* rustfmt
2018-11-13 09:30:02 +00:00
Gary Yu
7ff1ee5fde
Peer send receive bytes statistics missed response messages and attachment (#1953)
* fix: peer send receive bytes statistics missed response message and attachment

* rustfmt
2018-11-11 07:30:57 +08:00
Gary Yu
2352275dff
Suppress some peers logs by trace level instead of debug (#1952)
* suppress some peers boring logs by trace instead of debug

* rustfmt
2018-11-11 07:30:14 +08:00
Gary Yu
9af9ca9518
refactor the state_sync to handle the long fork (#1902)
* split horizon into two explicit values for cut through and txhashset request

* let node which has 2-7 days of history be able to handle forks larger than 2 days

* add test simulate_long_fork

* add pause/resume feature on p2p for tests

* refactor the state_sync

* ignore the test case simulate_long_fork for normal Travis-CI

* refactor function check_txhashset_needed to be shared with body_sync

* fix: state TxHashsetDone should allow header sync
2018-11-10 11:27:52 +08:00
Antioch Peverell
39ebb33ba1
bump 0.4.0 -> 0.4.1 (tx kernel broadcast support) (#1950) 2018-11-09 14:57:25 +00:00
Ignotus Peverell
f7d0fe1840
Bug fix, tuning of peer message rate counting 2018-11-07 22:15:12 +00:00
Antioch Peverell
ab30f714fc
Capabilities now deserialize safely (#1946)
* deserialize capabilities dropping unknown flag bits

* add tests for capabilities deserialization

* rustfmt

* FULL_NODE needs to be handled safely for legacy nodes
2018-11-07 11:15:37 +00:00
Antioch Peverell
e25a3b9d72
Fix capabilities (#1944)
* we cannot safely update nodes to use capabilities bits = 15 ...

* rustfmt
2018-11-07 10:00:42 +00:00
Antioch Peverell
949f75c77c
fix the lock on the new mutex (#1942) 2018-11-07 09:40:39 +00:00
Antioch Peverell
d97a6c2189
[DNM] broadcast tx kernel hash (if supported by peer) (#1929)
broadcast tx kernel hash (if supported by peer)
2018-11-07 09:28:17 +00:00
Ignotus Peverell
8b546632fe
Peer rate limiting (#1933)
* Rate counter in peer conn to monitor traffic 
* Ban peers that trigger is_abusive
2018-11-06 17:51:22 -08:00
hashmap
d2088ff48c Fix recently introduced peer deadlock (#1941) 2018-11-06 16:42:36 -08:00