Commit graph

386 commits

Author SHA1 Message Date
Yeastplume
28985bad55 Make peer parameters user-configurable (#883)
* make peer parameters user-configurable
* rename peer_preferred_count to peer_min_preferred_count
2018-03-27 17:17:01 +00:00
Antioch Peverell
4fcf5fdbca
drop msgs received from a banned peer (#886) 2018-03-27 12:09:41 -04:00
Antioch Peverell
90c71625aa shorter log msg for ping/pong (#882) 2018-03-27 14:23:19 +01:00
hashmap
e32d353543 Externalize Grin User Agent (#880)
Take the version from the root Cargo.toml
Fixes #875
2018-03-27 13:52:59 +01:00
Ignotus Peverell
327293d28e Genesis, version changes and doc for testnet2 (#865)
* Bump up crates versions

* Finally add a Cargo.lock to avoid dependency breakages

* Build doc update for testnet2

* Fix test framework not really using its mining config

* Testnet2 genesis, best so far at 128 difficulty (a nice number)

* Minor build doc update
2018-03-26 10:48:46 +01:00
Simon B
9285de2c24 Here is a case where ~ is needed, to allow cargo update to only touch the patch level version (third number). Anything else than ~ means that both first numbers can be raised, so "2.1" updaates to "2.2" (#866) 2018-03-25 20:08:38 +00:00
Ignotus Peverell
2bf656646c
Force slog version to 2.1 (2.2 broke some traits) 2018-03-25 19:54:41 +01:00
Simon B
f9b87164e7 Idiomatic cargo toml (#862)
* Specify versions SemVer-style
 - slog and serde
* Comments for not update-able pre-1.0 crates:
 - urlencoded at "0.5" since 0.6+ lacks trait `plugin::Plugin<iron::Request<'_, '_>>`
* alpha-sort deps
* Specify versions SemVer-style
 - backtrace, bitflags, blake2-rfc, bodyparser, built, byteorder
 - chrono, clap, demonize, enum_primitive, env_logger
 - failure, failure_derive, futures
 - hyper, iron, itertools, lazy_static, libc
 - memmap, mount, net2, num_bigint, prettytable-rs
 - rand, regex, rocksdb, router, siphasher
 - term, time, tokio-core, tokio-retry, urlencoded, uuid, walkdir, zip
2018-03-25 17:44:27 +00:00
Simon B
a8fc82d8c1 Console debug fixes (#861)
* move some debug! to trace!

* more informative debugs

* standardising on always showing chain tips as "cumulative difficulty @ height [hash]"

* make 2 debug outputs into a single

* "no peers" as warning (not info) to let it stand out more clearly

* move fn param (used only in this one debug line)

* clarify difficulty "units"
2018-03-25 12:41:12 -04:00
Yeastplume
80887196a8
Restore wallet restore (#843)
* adding appropriate message to bulletproofs to allow for restore

* rustfmt

* should work, now test

* rustfmt

* fix to wallet restore, works now

* fix pool tests

* fix pool tests

* rustfmt
2018-03-23 10:13:57 +00:00
Quentin Le Sceller
836391cc53 Dandelion relay update (#825)
* Change error logger to debug logger
* Dandelion relay update after monitor peers
* Typo + kick off Travis build
2018-03-22 22:51:09 +00:00
Simon B
4fa9ccc4f7 Cargo.toml (#818)
* Make sure no grin crates get published by mistake: https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish--field-optional
* add missing workspace = '..', [workspace docs for interested readers](https://doc.rust-lang.org/cargo/reference/manifest.html#the-workspace-section)
* dev- or dev_ works equally well, but dev- is what's typically used
* authors = Grin Developers <maillist>
* [dependencies] keep grin-* at the end + readability
2018-03-20 18:21:29 +00:00
Quentin Le Sceller
fcfe7bc6a4 Basic Dandelion transaction routing (#719)
* Initial Dandelion Commit
* Changed stem_tx_pool to tx_stempool
* Introduction of stem memory pool and stem pool config
* Pool push now send to stem memory pool
* Add stem transaction functions
* Add stem transaction pool
* Drastically simplified code structure
* Add monitor transactions
* Add Dandelion monitor and remove transactions from stempool
* Add peer relay monitor
* Reconcile block with stempool
* Fix total size bug
* Add fluff option for pool push
* Added details on dandelion monitor
* Fix issue with missing parent
* Child transaction with stempool parent are now forced stem
* Update Dandelion Relay from outgoing peers
* Fix missing pool reconciliation
* Add the ability to fluff a transaction directly
* Fix tests for Dandelion
* Missing send_stem_transaction method...
* Add fluff handler for wallet
* Add logger when successfully updated Dandelion relay
* Launch transaction monitor last
* Fix dandelion relay misplaced
* Add logging and updating for stempool
* Additionnal check for stem transaction
* Fix 2 Locks in a row
2018-03-20 03:18:54 +00:00
Yeastplume
e268993f5e
[WIP] Needs more TUI (#765)
* first explorations at attempting to integrate more user-friendly status screen/ui

* rustfmt

* adding some logo and color for visual interest

* formatting

* better integration with stdout, cleaner looking startup and shutdown

* rustfmt

* update to framework, and first collection of stats from server

* rustfmt

* commit of basic stat screen, think it's in a good enough state to share

* rustfmt

* fix to automated tests

* fix to automated tests

* grin.toml setting

* grin.toml setting

* grin.toml setting

* merge from upstream

* merge from upstream

* merging

* merging

* formatting

* adding more status screens, beginning to collect peer data

* rustfmt

* beginnings of peer info

* adding tui dir

* rustfmt

* missing table

* create title bar

* Split up UI elements into separate files, create trait for update

* Added basic mining view
2018-03-13 18:10:45 +00:00
Antioch Peverell
449fabf24f
cannot use write_mode in rustfmt.toml in stable (get rid of the warnings) (#752) 2018-03-05 15:23:52 -05:00
Yeastplume
1143d84238
Remove Sumtree References and disambiguate some naming (#747)
* start of renamathon

* api renaming

* Rename UTXO-Output to lessen ambiguity

* compile warning

* compile error

* readme fix

* remove file commit in error
2018-03-05 19:33:44 +00:00
Ignotus Peverell
be8d9633e4
rustfmt all the things 2018-03-04 00:19:54 +00:00
Alexey Miroshkin
d116a434bf Log the reason of peer ban (#736)
This PR fixed #455 by adding a few debug log messages
2018-02-27 20:33:40 +00:00
Quentin Le Sceller
ccf8eb9eeb Add Inbound/Outbound for connected peers (#725)
* Add Inbound/Outbound for connected peers

* Fix tests

* Undo removing trailing commas

* Revert "Fix tests"

This reverts commit 0d024188d4.
2018-02-24 16:00:38 -05:00
Quentin Le Sceller
755d0b7902 Typo broadcast/transaction (#718) 2018-02-20 21:27:18 +00:00
Antioch Peverell
4022b82817
cleanup various build warnings (#714)
* cleanup various build warnings

* use serde_json in tests only
2018-02-17 12:56:22 -05:00
Antioch Peverell
5572fa075e
tx pool lookup for kernel short ids (compact block hydration) (#710)
* wip - basic tx pool lookup for kernel short ids (compact block hydration)

* use the nonce in the compact_block to correctly generate short_ids for lookup

* query the tx pool based on kernel short_ids

* tests passing

* cleanup some logging

* cleanup logging
2018-02-16 10:42:27 -05:00
Ignotus Peverell
76796738c1
Clean server shutdown, generalizes usage of Weak (#700)
* Clean server shutdown, generalizes usage of `Weak`. Introduces 2 main changes:

  * A shared `AtomicBool` that signals server shutdown. All server
threads regularly check it to break out of their main loops when
it changes to `true`.
  * Breaking of circular `Arc` references, which can never be
destroyed, by downgrading to `Weak` instead. Only the main server
keeps the `Arc` while all other components get the `Weak` variant.

Both of these are required for all long-living structs to be
cleanly destroyed. Note that in Rust this is fairly important as
most resource-freeing logic is associated with `drop`,
which is only called when said struct is free of scope or `Arc`
references.

Should address most of #536 (only need the stop hook to call
`Server` shutdown).

* Test for fast sync, followed by restart, followed by re-fast-sync

* P2P test fix

* Double sync taking too long for Travis, commenting out for now
2018-02-13 00:38:52 +00:00
Ignotus Peverell
22c521eec8
[WIP] Abridged sync (#440)
* Util to zip and unzip directories
* First pass at sumtree request/response. Add message types, implement the exchange in the protocol, zip up the sumtree directory and stream the file over, with necessary adapter hooks.
* Implement the sumtree archive receive logicGets the sumtree archive data stream from the network and write it to a file. Unzip the file, place it at the right spot and reconstruct the sumtree data structure, rewinding where to the right spot.
* Sumtree hash structure validation
* Simplify sumtree backend buffering logic. The backend for a sumtree has to implement some in-memory buffering logic to provide a commit/rollback interface. The backend itself is an aggregate of 3 underlying storages (an append only file, a remove log and a skip list). The buffering was previously implemented both by the backend and some of the underlying storages. Now pushing back all buffering logic to the storages to keep the backend simpler.
* Add kernel append only store file to sumtrees. The chain sumtrees structure now also saves all kernels to a dedicated file. As that storage is implemented by the append only file wrapper, it's also rewind-aware.
* Full state validation. Checks that:
    - MMRs are sane (hash and sum each node)
    - Tree roots match the corresponding header
    - Kernel signatures are valid
    - Sum of all kernel excesses equals the sum of UTXO commitments
minus the supply
* Fast sync handoff to body sync. Once the fast-sync state is fully setup, get bacj in body sync
mode to get the full bodies of the last blocks we're missing.
* First fully working fast sync
* Facility in p2p conn to deal with attachments (raw binary after message).
* Re-introduced sumtree send and receive message handling using the above.
* Fixed test and finished updating all required db state after sumtree validation.
* Massaged a little bit the pipeline orphan check to still work after the new sumtrees have been setup.
* Various cleanup. Consolidated fast sync and full sync into a single function as they're very similar. Proper conditions to trigger a sumtree request and some checks on receiving it.
2018-02-09 22:32:16 +00:00
Antioch Peverell
78a6447a09
fix bad merge - missing support for header msg type (#690) 2018-02-07 11:26:52 -05:00
Ignotus Peverell
eb0ebab2d3
Add forgotten ping loop, fix TCP send interlacing 2018-02-05 23:09:57 +00:00
Ignotus Peverell
a9f4f36117
P2p ping and partial header reads fixes (#684)
* Re-introduce peer regular ping/pong
* Fix partial header reads. Turns out that on async tcp streams, even a small chunk like a
header can be read partially. So header read needs to rely on our
fixed-up `read_exact`, with an additional boolean to allow yield
when no bytes were read.
2018-02-05 19:52:11 +00:00
Quentin Le Sceller
fb46fad0ac Remove unused import and uniformize crates (#686)
* Removed unused crates
* Add listconnectedpeers in grin client
* Removed unused import and uniformize crates
2018-02-05 19:46:56 +00:00
Ignotus Peverell
c7418cfe04
[WIP] Rewrite peer-to-peer logic to replace tokio with simple threading (#664) 2018-02-02 02:03:12 +00:00
Quentin Le Sceller
1e50d56c7e Add unit tests for API Endpoint (#653)
* First tests for API handlers

* Test chain UTXO handler

* Add test sumtrees handlers

* Fix typo

* Removed unused logger

* Update bitflags to ^1.0

* Missing test for bitflags update

* Moved test to grin directory

* Remove tests dependencies

* Add API P2P tests

* Fix hex string commitment

* Fix conflicting port

* Fix directory conflict and server port

* Wait for at least one block is mined on Travis
2018-02-01 13:14:32 -05:00
Antioch Peverell
3f15f7f2f9
Request compact blocks (#667)
* first pass at allow/deny lists for hard-coded peers (not just seeds)

* commit

* add peers_allow and peers_deny examples and comments to grin.toml

* always ask for compact block
always fail to hydrate
always fallback to requesting full block

* decide to send full (empty) block over compact (empty) block

* add some randomness to the decision around broadcasting an empty block
as a block or as a compact block (so we can exercise more code paths easily)
2018-01-31 15:39:55 -05:00
Antioch Peverell
5fd47fb875
peers_allow/peers_deny in grin.toml (#665)
* first pass at allow/deny lists for hard-coded peers (not just seeds)

* commit

* add peers_allow and peers_deny examples and comments to grin.toml

* fix build issue with simulnet tests

* fix p2p tests
2018-01-30 16:44:13 -05:00
Antioch Peverell
6647823177
header first propagation (#654)
* [wip] header first propagation
successfully propagating headers (unless we mined the block itself)
not yet asking for the block if we receive a header

* call request_block after successful processing header

* cleanup and skip asking for block if header is an orphan

* comments around error handling in receive_header
2018-01-30 09:42:04 -05:00
Antioch Peverell
5dce526f90
fix bug - p2p store was ignoring port numbers (#657) 2018-01-29 09:45:01 -05:00
Simon B
86ff4e5bd0 Fix 658 and compiler complaints (#661)
* Tried but failed to fix `cargo build` complaint about unused #[macro use]. See also 7a803a8dc1
* Compiler complaints be-gone
* Give sumtree tests method-tagged folder names so they don't overwrite each others' files
Fixes #658
2018-01-28 06:12:33 +00:00
Simon B
885c2d73ea Making initial sync easier on the eyes [master] (#623)
* Making initial sync easier on the eyes:
- display "chain pointers" as: cumulative @ height [hash]
- clarify and line up to make the "pointers" easy to compare
- make every 100th block show info on debug level info, else as before
2018-01-18 22:47:42 +00:00
Quentin Le Sceller
911aadf8b4 Fix #439 Temporary peer banning (#631)
* Fix #439 Temporary peer banning
2018-01-18 18:39:56 +00:00
Quentin Le Sceller
c8383dac93 Add POST peers/a.b.c.d/unban in REST API (#571)
Add unban peer in rest API and clean TODO
2018-01-04 03:25:14 +00:00
Matthew Slipper
e83e696a6f Fix #506 - use OS-assigned port in peer_handshake (#570) 2018-01-03 01:53:50 +00:00
Quentin Le Sceller
7b13b25782 Add GET peers/a.b.c.d handler in REST API (#564)
* Change name of get_peer to get_connected_peer and add a get_peer method with store
* Change to get_connected_peer
* Added handler for GET peers/a.b.c.d
2018-01-03 01:03:44 +00:00
AntiochP
30c20294f5
reset header_head and sync_head on peer ban (#551) (#553)
handle orphan blocks based on age (not fixed count)
2017-12-28 19:49:27 -05:00
Quentin Le Sceller
2dac10a690 Display chain status with grin client status (#543)
* Add term and grin_p2p for grin client

* Setting msg as public for the client

* Specifying binary for cargo build

* Minimal client implementation

* Using server configuration for the client

* Display current chain height

* Display difficulty and last block pushed

* Remove unneeded secp256k1 dependency
2017-12-22 18:46:28 +00:00
AntiochP
b37820bd40
broadcast all accepted blocks, main chain or fork (#515) (#517)
tweak logging to be more consistent
2017-12-18 16:18:36 -05:00
Simon B
99186e90f0 better error messages + some cleanup (#497)
* distinguish select (among futures) from select coins. Regex search in project for select\b shows we hardly use select, but maybe could use it to add timeouts more cleanly. ("Want to add a timeout to any future? Just do a select of that future and a timeout future!" from https://aturon.github.io/blog/2016/08/11/futures/)

* remove a trailing space

* FAQ.md - fix typo

* wallet: display problematic tx

* update FAQ build troubleshooting to cover #443

* stdout_log_level = Info
file_log_level = Debug

* sync: show total diff @ height when syncronization is completed

* better wallet send dest format error

* move INFO "Client conn ... lost" and "Connected to peer" down to Debug

* move some level=Info to Debug, add 1000-block outputs
2017-12-18 08:17:11 -05:00
AntiochP
9e94d3bd6c
broadcast to subset of peers (in case we are connected to more than preferred number of peers) (#488) (#489) 2017-12-14 15:33:22 -05:00
AntiochP
b17e42fb42
[testnet1] De-Duplicate expected responses in TimeoutConnection (#484) (#485)
* timeout connection already tracks "expected" responses
use this to deduplicate requests and do not ask a peer for the same thing again
(until either success or timeout)

* do not ask for orphan blocks repeatedly
allow more than preferred number of peers (clean if we exceed max number)
2017-12-14 12:23:35 -05:00
Simon B
38741c91e2 cherry-pick "[testnet1] cpu_pool and buffered fold in read_msg (#479)" (#482) 2017-12-14 07:19:43 -05:00
AntiochP
487e50c3d2 compare genesis during peering handshake (#327)
* wip - send genesis in handshake
* error if genesis mismatch on handshake
* fix the tests
* preserve order of existing fields in hand/shake
2017-12-14 01:13:05 +01:00
Ignotus Peverell
e50703d79e Externalized all peers selection and handling (#468)
Moved handling to the peer map out of the p2p server and into
its own struct. Allowed factoring code from the net adapter and
simplification of some interactions. Also removes the need for
the adapter to reference the p2p server or peers.

Fixes #430, #453 and #456
2017-12-14 01:13:05 +01:00
Simon B
17d5898677 Forgotten testnet1 cherries (#475)
* Very quick peer banning endpoint, helps with #406
* Ping heights (#407)
* add height to ping/ping
* reformat output
* fix p2p test
* Fix orphan handling, not related to current head. Fixes #412
* Check before borrow, fixes #267
* Not finding an output commit in pos is an AlreadySpent
* Fix race condition, sending before conn is ready
* Explicit error for unknown pos of a forked block
* Remove config outdated tests. Fix #333
* Check ref and try before borrow, fix #400
* We do not want to sync with old peers anyway
* Hide cargo compiler warning for unused NoopAdapter and unused test code. Add TODOs
2017-12-13 21:52:21 +00:00
AntiochP
bffd955c26
Revert "introduce cpu_pool to read_msg (#477)" (#478)
This reverts commit 45b9962109.
2017-12-13 16:30:59 -05:00
AntiochP
45b9962109
introduce cpu_pool to read_msg (#477)
* introduce cpu_pool to read_msg

* cleanup and less unwrap() in handler

* expose cpu_pool as part of net_adapter (reuse across all peer connections and handlers)

* fix DummyAdaptor for test usage

* add new() to DummyAdapter for convenience
2017-12-13 15:05:25 -05:00
Simon B
8f77933f4f Fixes #469 (#470) 2017-12-12 19:12:07 +00:00
Simon B
a4729b51ac Issue 458 too verbose slog lines initial sync (#459)
* Alleviate slog-async channel overflow by shortening while clarifying some log lines.

* add debug logging to GetBlock handling

* make another log line less rendudantly chatty
2017-12-11 09:51:52 -05:00
Simon B
8b81a2f806 Seed debug outputs cleanup (#460)
* DRY up

* iterate 66% less

* clarify debug! outputs

* less verbose peer queuing

Rationale: debug outputs that happen _a lot_ is nice if they're short and distinct, making them easier to pattern match / willfully ignore while reading through logs

* update comment to mention last weeks' added usecases

* .push() less
2017-12-11 09:38:46 -05:00
AntiochP
10030a224a
more aggressive peering (#445) (#446)
* [WIP] aggressive peer connections (and logging)

* get peer list from each connected peer when low on peers

* cleanup the try_read() calls and log consistent warning messages
(will clean these up later)

* cleanup error logging (log at debug level)
2017-12-07 20:24:03 -05:00
AntiochP
179f74462a
simplify sync process further - one thread for both body and header sync (#427) (#428)
* simplify sync process further - one thread, try_read on peer for robustness
* add most_work_peers() for convenience, add most_work_peers count to "monitoring peers" log msg
2017-12-05 11:42:25 -05:00
Ignotus Peverell
7b9351864a
Banning of misbehaving peer, applied to bad blocks
Added support for peer banning on the p2p server. The peer status
is changed and the peer is disconnected. A banned peer won't be
able to reconnect as well.

Tracking of chain errors due to a block that's intrinsically bad
and banning of the peer that sent it. If we're syncing, resetting
the header chain to the same as the main chain to force
backtracking.
2017-12-05 02:14:55 +00:00
AntiochP
442ef3b255
port across "simple_sync" changes from testnet1 branch (#409)
* port across "simple_sync" changes from testnet1 branch
Cleanup direct refs to peer map or peer store
P2P server acts as a facade, handling the list of connected peers
and the storage of their information. Everything else goes through
the p2p server instead of having a peer map reference or going
straight to the store.
Fix p2p tests

* fix "monitoring peers" log msg (use connected_peers)
2017-11-30 10:27:50 -05:00
AntiochP
25969424ff
notify syncer on every block received (including orphans) (#379)
prefer random peers with more difficulty than us
do not keep asking for headers over and over
2017-11-23 00:16:36 -05:00
AntiochP
c6b94dd2c4
generate locator heights all the way down to 0 by powers of 2 (#378) 2017-11-22 22:59:33 -05:00
AntiochP
348038f0ed Add some randomness to most_work_peer (#364) 2017-11-22 16:07:21 -05:00
AntiochP
7573f6a556
use read lock over write lock where possible (#363)
fix issue with sync starting twice
2017-11-21 22:28:31 -05:00
AntiochP
6352dfbac9
add total_diff to ping/pong msgs (#350)
* add total_diff to ping/pong msgs
debug log for total_diff on each ping/pong

* expose peer addr to the handle_payload fn
so we know where it came from

* fix p2p tests for ping

* default to 0 if we cannot read total_difficulty

* updating a connected peer in place

* actually update peer info diff

* fixup p2p tests
2017-11-21 09:24:29 -05:00
AntiochP
00d82f2c04 compare genesis during peering handshake (#327)
* wip - send genesis in handshake
* error if genesis mismatch on handshake
* fix the tests
* preserve order of existing fields in hand/shake
2017-11-20 12:35:52 -05:00
Ignotus Peverell
8ce494536e
Regularly ping all peers to check liveness
Ping all our peers every 20 sec. If no pong occurs within a
reasonable time (5 sec), disconnects.
2017-11-19 20:40:49 -05:00
Ignotus Peverell
c1be4e2113
Debug log for block broadcast 2017-11-19 20:40:36 -05:00
AntiochP
256283966a
Allowable write size as u64 instead of usize. Fix #303. 2017-11-18 13:43:57 -05:00
AntiochP
90012c86ac
use a short timeout when opening the connection to possible peers (#300)
* use a short timeout when opening the connection to possible peers
lots of peers in the db are unavailable and we do not want to wait 60s for these

* also randomize peers so we don't always try and connect to peers with low ip addresses

* bump timeout up to 5s for peering
2017-11-17 20:13:49 -05:00
Ignotus Peverell
bb7a61d284
Return error when peer_addr() fails on connection
Likely issue is the connection failed right after being
established, leading `peer_addr()` to fail and the `unwrap()`
crashes the process instead of failing gracefully. Fix #293.
2017-11-17 14:28:26 -05:00
AntiochP
c2a95637b3 more robust peer handling (#244)
* use HashMap internally for tracking connected peers (to avoid duplicates)
* reuse the handshake on the server so we can track our own nonce to avoid self connections correctly
* make sure we start up the clean_peers loop even in seedless mode
* logging in monitoring peers loop
* simplify monitoring for no seeds
* fixup and cleanup simulnet tests (real seeds in places)
* only start the sync if we have either seeds or peers that we know about, exit syncer safely if we have no connected peers
2017-11-14 13:57:16 -05:00
Ignotus Peverell
8f78b74d67
Preventing save of loopback IPs, fix #236 2017-11-03 19:08:04 -04:00
Ignotus Peverell
15705b3fa1
Detect unspecified IP and use TCP conn IP instead 2017-11-03 16:47:35 -04:00
AntiochP
8a42a692ce add new /v1/peers endpoints to the api (#225)
* add new /v1/peers endpoint to the api
* /peers/connected and /peers/all endpoints
2017-11-02 12:49:33 -04:00
Ignotus Peverell
362fbcf90f
Proper p2p remote address detection when accepting conn
A receiving peer trusts the address advertised by a client.
However as we do not have external address detection (and there is
generally no very good way to do that), the address detected by
a peer is the loopback, which is useless. So we attempt to detect
these cases and use the IP detected by the TCP connection while
keeping the advertised port.
2017-11-01 18:56:59 -04:00
Ignotus Peverell
e4ebb7c7cb
Cleanup HTTP APIs, update ports to avoid gap, rustfmt
Moved the HTTP APIs away from the REST endpoint abstraction and
to simpler Hyper handlers. Re-established all routes as v1.
Changed wallet receiver port to 13415 to avoid a gap in port
numbers.

Finally, rustfmt seems to have ignored specific files arguments,
running on everything.
2017-10-31 19:42:56 -04:00
Ignotus Peverell
efe414bf07 No send back for blocks and transactions (#212)
* Do not send txs and blocks to senders. Keeps a ring buffer of transaction and blocks hashes that a peer has received. Do not send what we've already received.
* Test fix and fmt
2017-10-26 17:48:51 +00:00
Ignotus Peverell
e2e24bc38e Transaction broadcast (#209)
* Add transaction broadcast to all known peers once they have been
accepted by our own transaction pool.
* Some debug log

Fixes #200
2017-10-25 21:06:24 +00:00
Yeastplume
9c0411ac5e Bind to services to all interfaces rather than loopback (#197)
* changing default ip
2017-10-23 16:34:43 +00:00
Yeastplume
49797853d9 tweaks to logging configuration (#176)
* tweaks to logging configuration
* doc port update
2017-10-13 16:42:04 +00:00
Ignotus Peverell
361e39c87c
Log connection errors 2017-10-12 19:26:10 +00:00
Yeastplume
8e382a7593 slog-rs logging (#171)
* added global slog instance, changed all logging macro formats to include logger instance
* adding configuration to logging, allowing for multiple log outputs
* updates to test, changes to build docs
* rustfmt
* moving logging functions into util crate
2017-10-12 16:56:44 +00:00
AntiochP
677d0a3a95 keychain crate (no more secretkeys in core) (#146)
* introduce grin_keychain, encapsulate derivation of secret_keys
* core compiles against keychain, tests don't run yet
* core tests are now passing against keychain
* wip - getting wallet working with keychain
* add util and keychain to travis test matrix
* basic test around key derivation
2017-10-03 00:02:31 +00:00
Seamus Finnigan
2e819c72aa Fix deprecated futures items (#148)
* Update futures deprecated send item
* Update futures deprecated iter item
* Fix cargo req for futures
2017-10-01 21:34:14 +00:00
Ignotus Peverell
8504efb796
Cargo fmt all the things 2017-09-29 18:44:25 +00:00
AntiochP
7c5b7d23e7 Replace secp256k1 directory with repository dependency (#126)
* workaround the "commitment is not a public key" problem by using to_two_keys() from rust-secp256k1-zkp
* remove secp256k1zkp, update the various Cargo.toml to use rust-secp256k1-zkp from external git repo, update code to not rely on to_pubkey (and use verify_from_commit)
* secp256k1zkp from git
* cleanup secp256k1 dependencies
* gitignore node1 and node2 dirs
2017-09-21 00:07:40 +00:00
AntiochP
3b4a48b2fd Cleanup build warnings (#87)
* minor cleanup - unused imports
* cleanup build warnings - unused vars
* make structs pub to get rid of the private_in_public lint warning
* missing docs on RangeProof
* add missing docs to store delete function
* cleaned up deprecation warning -
tokio_core -> tokio_io
complete() -> send()
2017-08-10 00:54:10 +00:00
Jacob Payne
60705eff76 Use io::Read/Write interface instead of AsyncRead/AsyncWrite + Finish Tests (#74) 2017-07-05 18:42:55 +00:00
Ignotus Peverell
15ea8da34a
New Chain struct acting as facade for all chain operations
Introduce a new Chain struct that maintains the current head,
acts as facade to the store and the block processing pipeline
and handles all appropriate locking.

All higher level components, like the overall server, REST APIs
and miner have been update to only depend on Chain. Cleaned up
some duplication and tests now that there's a single entry point
to all blockchain operations.
2017-07-04 09:17:11 -07:00
Jacob Payne
6a15100c96 [WIP] Rate Limiting (#57)
* Setup tests for rate limiting
* Add send and receive rate configs to P2P Config
* Setup ThrottledConnection and ThrottledWrite
* Add Tokio io
* Fix ThrottledReader + Add Bytes
* Attach Rate Limiting to Connection
2017-06-18 01:15:46 +02:00
Ignotus Peverell
3d5411b6ad
Deprecated. 2017-06-06 12:27:39 -07:00
Ignotus Peverell
40d23db6c1
Revert "[WIP] Partial Transition from Writeable/Readable to Codecs (#51)"
This reverts commit de4ebdde71.
2017-05-31 15:47:52 -07:00
Ignotus Peverell
f79fb8ef95
Sending end of the wallet
Most of the logic to build a transaction that sends coin to
another party. Still requires more debugging and clean up.
Main changes and additions are:

* Update to serde 1.0
* API endpoint to retrieve an Output
* Output is now Serialize and Deserialize
* Wallet configuration
* Command line for the send operation
* Wallet data checker to update created outputs into confirmed
* Wallet-specific configuration
2017-05-28 20:21:29 -07:00
Jacob Payne
de4ebdde71 [WIP] Partial Transition from Writeable/Readable to Codecs (#51)
* Sample Signatures for put_enc and get_dec
* Implement put_enc and get_dec
* Implement ChainCodec in grin_chain
* Truncate src only on complete Blocks
* Truncate src only on complete Tip + Check Len
* Move BlockHeader Encoding to BlockHeaderCodec
* Define put_enc for store::Batch
* Replace BlockCodec and BlockHeaderCodec with generic BlockCodec<T>
* Implement Default for BlockCodec Manually
* Replace get_ser/put_ser with get_enc/get_dec for chain::ChainKVStore
* Remove Writeable/Readable for chain::Tip
* Add Tokio-io and Bytes to grin_p2p
* Additional Setup for Message enum + Msg{Encode,Decode} traits
* base msg ping pong encoding and test
* fill out msg-codec tests
* Implement Hand Encoding/Decoding
* msg-encode shake
* msg-encode getpeeraddr
* codec peer-addrs message, SockAddr struct wierdness
* header message codec
* msg encoding finished prelim
* Implement PeerCodec Encoding/Decoding
* Set PeerStore to use PeerCodec for Encoding/Decoding
* Add a DecIterator
* Prune PeerStore
* Replace Decoding and Encoding in handle_payload
* Prune Writeable/Readable methods in store::Store
* Remove Incomplete Frame Testing ( Not Nessesary right now )
* separate block and tx codec tests
* Refactor {Tx,Block}Codec Tests
2017-05-22 19:16:13 +02:00
Ignotus Peverell
1b78a73328
Variety of small p2p fixes to block sync
Adds a couple utility function to p2p server to check whether
we're already connected to a peer before trying again. Other
very minor fixes and logging improvements.
2017-04-27 22:05:12 -07:00
Ignotus Peverell
3fe28b0f03
Server types cleanup and serde for configuration types
Moved error and configuration types from server.rs to types.rs
where they should have been from the start. Configuration types
for the server and p2p modules now derive serde Serialize and
Deserialize so we can have a simple JSON configuration file.
2017-04-24 18:49:57 -07:00
Ignotus Peverell
a37e2b99fb
Trivial formatting fixes 2017-04-24 18:47:36 -07:00
Merope Riddle
39ddeb0a2a core: various cleanups, improvements, code comments (#38)
* core: cleanup slicing impls for Hash
* core: clean up Readable trait, implement Readable/Writeable for various integers
* core: change Hash debug output to hex
* core: correct warnings in all modules
2017-04-09 23:17:23 -07:00
Jacob Payne
9e82fb1774 Replace AsFixedBytes with Sized + AsRef<[u8]> (#35)
* Replace AsFixedBytes with Sized + AsRef<[u8]>
* Add AsRef<u8> to impl_array_newtype!
* Include AsFixedBytes as marker trait
* Related fixes
* Remove Deref
2017-04-06 22:54:54 -07:00
Ignotus Peverell
382754e54c
Add workspace support for all crates 2017-04-05 23:41:49 -07:00
Ignotus Peverell
38d5d67e79
Add features bitmask to Block, Output, Kernel; coinbase validation
Block, Output and Kernel now have bitmasks to hold supported
features and eventually versioning. Will make adding features and
updates easier and open the possibility of soft forks.

First added feature for Output and Kernel is the marking of coinbase
related ones. Allows the validation of the coinbase part of a block.
2017-03-23 17:06:00 -07:00
Ignotus Peverell
f64d20749f
Framework to define services as RESTful HTTP API services. Serde implementations for some core types. 2017-03-07 17:00:34 -08:00
Ignotus Peverell
d900f0b934
P2P server cleanup of disconnected peers. Mark those that don't respect the protocol as banned. 2017-02-27 14:17:53 -08:00
Ignotus Peverell
7c72ccec7c
Cleaned up error handling in p2p module. Setting peer status on disconnect. 2017-02-26 20:08:40 -08:00
Ignotus Peverell
c0e635071c
Fixed p2p tests. 2017-02-18 18:56:07 -08:00
Ignotus Peverell
eb024e91d2
Discovery and seeding of other peers. Relies either on a gist with IP addresses or a static list. Connects to a first list, sending peer request messages to discover more. Monitor the server to make sure there's always enough peer connections. 2017-02-18 18:42:34 -08:00
Ignotus Peverell
786da24653
A db store for peer data. 2017-02-09 20:16:34 -08:00
Ignotus Peverell
85edf57366
Iterator for Readable impls stored in DB. 2017-02-09 20:15:22 -08:00
Ignotus Peverell
4af049a887
Added full node sync mode. Follows closely the bitcoin header-first sync. Related p2p messages and protocol. 2017-02-07 13:52:17 -08:00
Ignotus Peverell
2d81abc16c
Added height as part of handshake to inform syncing. 2017-02-02 15:51:48 -08:00
Ignotus Peverell
7f029cb4c0
Added a Connection wrapper to handle timeouts when we want information from a peer in a request/response style. 2017-02-01 19:05:17 -08:00
Ignotus Peverell
572c1951e1
Introduced a higher-level connection abstraction, allowing the protocol to stay relatively simple. Deals with the lower level details of sending, receiving data, timeouts and dealing with futures. 2017-01-29 22:43:20 -08:00
Ignotus Peverell
dc33ebcf39
Network block broadcasting. 2016-12-20 17:33:20 -08:00
Ignotus Peverell
e688ff99e6
Started putting in place the adapter between the chain and p2p modules to forward blocks and transactions. Cleaned up chain store references. 2016-12-18 15:51:54 -08:00
Ignotus Peverell
bc61c5dae7
Read block and transaction messages and forward to the adapter. 2016-12-15 14:57:04 -08:00
Ignotus Peverell
d395b3d128
Added another server implementation for when the client needs to stay in control of the event loop (i.e. multiple servers for tests). Test to spin up 5 servers and connect them all together. 2016-12-14 16:10:39 -08:00
Ignotus Peverell
19a700b81e
Minor fixes, testing server peer count. 2016-12-13 16:05:24 -08:00
Ignotus Peverell
7bea7341ab
Various cleanup and reorganization. 2016-12-11 13:04:52 -08:00
Ignotus Peverell
4b5c010b05
Rewrote most of p2p code to use futures-rs instead of mioco. Need some cleanup and support for a few more message types. 2016-12-10 19:11:49 -08:00
Ignotus Peverell
309cb497f8
Configurable host and port for p2p server. Utility for client connection. 2016-11-29 18:49:03 -08:00
Ignotus Peverell
632e3af8ee
Test for sending tx from one peer to another. Common tests module. 2016-11-07 14:02:45 -08:00
Ignotus Peverell
ea425dc614
Protocol cleanup. Tests cleanup. Additional test for transaction broadcast. 2016-11-05 16:31:45 -07:00
Ignotus Peverell
28f007240e
Usefuly read and write implementations to limit and count bytes. 2016-11-04 08:59:49 -07:00
Ignotus Peverell
098d17ee42
Added limited and counting readers for protocol to maintain its stats. Added primitive error count. Cleaned up protocol. 2016-11-02 14:19:40 -07:00
Ignotus Peverell
edc6c62577
Fixed message serialization following changes in core. Sending of block and transaction. 2016-11-01 10:42:33 -07:00
Merope Riddle
565374bac7 p2p: fix for changes in core serialization API 2016-11-01 02:16:57 +00:00
Ignotus Peverell
3ffc2f5d8c
Tests improvement. Protocol also measures bytes received (at least for pings). 2016-10-31 12:30:48 -07:00
Garrick Ollivander
d7dcd6d3ae
nicer processing of message types 2016-10-31 13:08:48 +01:00
Ignotus Peverell
ee6fcab8db
Proper server and protocol event loop. Channels for shutdown and ping/pong trivial roundtrip. Working test. 2016-10-30 18:24:19 -07:00
Ignotus Peverell
a23308dd9d
Added clean stop logic on server and peers. Broken unit test. 2016-10-30 08:24:19 -07:00
Ignotus Peverell
42769c373c
Re-implemented the whole interaction between server, peer and protocol to be more Rust-ish. Server maintains peer references and protocol is internally mutable. 2016-10-29 12:36:45 -07:00
Ignotus Peverell
fdaf2ba6af
First working test with related fixes demonstrating a full peer handshake. 2016-10-27 14:28:02 -07:00
Ignotus Peverell
a9dc8a05ac
Preliminary impl of p2p package compiles now. Next step: basic handshake integration test. 2016-10-26 11:21:45 -07:00
Ignotus Peverell
b1762cb5f4
p2p module getting close to first integration test allowing 2 peers to connect. Fleshed out handshake and protocol use. Fixed most errors, just need to make the borrow checker happy. 2016-10-25 22:06:13 -07:00
Ignotus Peverell
4657b09c4e
WIP: more p2p code, mostly interaction between peer, protocol and server as well as ser/deser for first message types. 2016-10-24 21:35:10 -07:00
Ignotus Peverell
c8aa8d7c18
Getting started on the p2p networking code. 2016-10-23 17:02:02 -04:00