Commit Graph

4471 Commits

Author SHA1 Message Date
Henry de Valence 16f51e4d48 Add a timeout to the `PeerServer` event loop.
I think this code could be cleaned up significantly (e.g., removing the
other use of select!) but that's potentially a larger change than this
PR.
2019-10-15 14:49:11 -04:00
Henry de Valence b45efbdaf2
Add peer count data to TimestampData::update trace (#66)
* Add peer count data to TimestampData::update trace

* Update docstring typo
2019-10-11 12:41:37 -07:00
Henry de Valence ae1a164ff8
Beginning of peerset implementation. (#62)
* Don't expose submodules of zebra_network::peer.

* PeerSet, PeerDiscover stubs.

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>

* Initial work on PeerSet.

This is adapted from the MIT-licensed tower-balance implementation.

* Use PeerSet in the connect stub.
2019-10-10 18:15:24 -07:00
Henry de Valence 4f88bddd2b Remove zebra-reactor.
This functionality will just go in zebrad and use abscissa, allowing
configs, component registries, etc.

Closes #59
2019-10-10 20:52:39 -04:00
Deirdre Connolly dc18e8f24c Remove .expect()s for block and transaction, they might fail for writer reasons 2019-10-09 22:25:37 -04:00
Deirdre Connolly e1f2eaa446 Add details about max_count to read_list docstring 2019-10-09 22:25:37 -04:00
Deirdre Connolly 4ec7590b42 Add placeholders for remaining messages in write_body 2019-10-09 22:25:37 -04:00
Deirdre Connolly d8986098c6 Add write_body implementations for GetData, NotFound, and a placeholder for Reject 2019-10-09 22:25:37 -04:00
Deirdre Connolly 483d6584f9 Add Block msg reader and writers, and Tx msg writer 2019-10-09 22:25:37 -04:00
Deirdre Connolly 8dc9181610 Fill out write_body for GetBlocks, GetHeaders, Headers messages 2019-10-09 22:25:37 -04:00
Deirdre Connolly a0302a5507 Implement read_getaddr 2019-10-09 22:25:37 -04:00
Deirdre Connolly cfbe8dfdbf Add comments about the 500 blocks /2000 headers max numbers are speculative based on Bitcoin docs 2019-10-09 22:25:37 -04:00
Deirdre Connolly 5acdaa6d2f Remove some defunct XXXs 2019-10-09 22:25:37 -04:00
Deirdre Connolly dd1b9166b0 Implement Zcash(De)Serialize for BlockHeaderHash, use general read_list for getheaders/headers 2019-10-09 22:25:37 -04:00
Deirdre Connolly eed69063f6 Add read_list to ReadZcashExt 2019-10-09 22:25:37 -04:00
Deirdre Connolly d470dd9709 Parse messages 2019-10-09 22:25:37 -04:00
Deirdre Connolly b991c413cd Parse GetBlock messages 2019-10-09 22:25:37 -04:00
Deirdre Connolly 7632d5b8cc Abstract the common case of a message with a Vec<InventoryHash> 2019-10-09 22:25:37 -04:00
Deirdre Connolly 9699ef2fa1 Codec::read_tx() 2019-10-09 22:25:37 -04:00
Deirdre Connolly 565dc92afe Support a response message 2019-10-09 22:25:37 -04:00
Henry de Valence 4efceb490d Update architecture diagram. (#60) 2019-10-09 17:46:59 -04:00
Henry de Valence 8a3b4f48fc Move all git dependencies to published crates. (#58)
The earlier issues with version resolution incompatibilities are now
resolved, and all the upstream changes we made to tracing are released.
2019-10-09 00:10:01 -04:00
Henry de Valence 6f79f2843d Use emojis in user-agent to detect Unicode support. 2019-10-08 23:34:16 -04:00
Henry de Valence f284f6d6cf Tweak debug output in PeerConnector handshake. 2019-10-08 23:34:16 -04:00
Henry de Valence fb2b502eb9 Add a `Config` struct to zebra-network.
This struct is pulled into the main abscissa config as a subsection.
2019-10-08 23:34:16 -04:00
Henry de Valence 1266653be2
Handle error conversions properly. (#56)
This adds a type alias, BoxedStdError, for a boxed std::error::Error
trait object, and uses it in the where bounds for the generic service
code.  In the future, we may want to standardize on using
std::error::Error exclusively, but we would then possibly lose out on
backtrace information.
2019-10-08 13:49:12 -07:00
Henry de Valence 92dc7a5ea1
Fix authorship, license information. (#55)
* Fix authorship, license information.

I *thought* I had done a sed pass over the Cargo defaults when doing
repository initialization, but I guess I missed it or something.
Anyways, fixed now.
2019-10-08 09:25:59 -07:00
Henry de Valence ed608f7231
Initial tower-based peer implementation. (#17)
Add a tower-based peer implementation.  

Tower provides middleware for request-response oriented protocols, while Bitcoin/Zcash just send messages which could be interpreted either as requests or responses, depending on context.  To bridge this mismatch we define our own internal request/response protocol, and implement a per-peer event loop that scans incoming messages and interprets them either as requests from the remote peer to our node, or as responses to requests we made previously.  This is performed by the `PeerService` task, and a corresponding `PeerClient: tower::Service` can send it requests.  These tasks are themselves created by a `PeerConnector: tower::Service` which dials a remote peer and performs a handshake.
2019-10-07 15:36:16 -07:00
Henry de Valence 5939857fbb Add peer handling diagram. 2019-10-01 13:05:27 -04:00
Henry de Valence f5dca597dd Replace PeerServices(u64) with a bitflags struct.
This gives considerably better ergonomics.
2019-10-01 01:07:56 -04:00
Henry de Valence 9603a29399 Rename `Services` to `PeerServices`.
This field is called `services` in Bitcoin and Zcash, but because we use
that word internally for other purposes, calling it `PeerServices`
disambiguates the meaning to "the services advertised by the peer",
rather than, e.g., a `tower::Service`.
2019-10-01 01:07:56 -04:00
Henry de Valence 47513b1ae7 Suppress warnings from stub functions.
This just replaces a bunch of variable names with underscored variants
while the function bodies are still `unimplemented!()`.
2019-09-30 21:32:57 -04:00
Henry de Valence 79c36a979c Use try_bind when building tracing endpoint.
Prior to this commit, the tracing endpoint would attempt to bind the
given address or panic; now, if it is unable to bind the given address
it displays an error but continues running the rest of the application.
This means that we can spin up multiple Zebra instances for load
testing.
2019-09-30 21:30:36 -04:00
Henry de Valence 1323fa7af7 Update zebra-chain/src/transaction.rs 2019-09-27 19:22:34 -07:00
Deirdre Connolly 2739970113 Fill out TransactionHash and rename
Resolves #35
2019-09-27 19:22:34 -07:00
Deirdre Connolly b21b09bf8e Moved stub TxHash into zebra_chain::transaction 2019-09-27 19:22:34 -07:00
Deirdre Connolly 29591df47e Use the BlockHeaderHash from zebra-chain in the Inv message parsing 2019-09-27 19:22:34 -07:00
Henry de Valence 0a85be285d Add addr, getaddr serialization. 2019-09-27 20:41:45 -04:00
Henry de Valence 9f43d0987b nit: suppress async_await nightly warning. 2019-09-27 20:41:45 -04:00
Henry de Valence b426630613 Clarify comment in decoder state. 2019-09-27 20:41:45 -04:00
Henry de Valence 422c783a47 Rename Message::Inventory -> Message::Inv
I don't feel super strongly about this change, so I'm happy to drop it,
but it makes the parsing match statements line up nicely and aligns
naming with the naming used in Bitcoin.
2019-09-27 20:41:45 -04:00
Henry de Valence 958fca8e68 Parse inv messages, refactor inventory vectors.
This removes the inventory vector structs from `zebra-chain` (as they
are really part of the network protocol) and refactors them into a
single `InventoryHash` type.  This corresponds to Bitcoin's "inventory
vector" but with a different, better name (it's not a vector, it's just
a typed hash of some other item).
2019-09-27 20:41:45 -04:00
Henry de Valence 64b210b53c Add a read_32_bytes helper method.
These are starting to stack up but I think until generic arrays arrive
the cure is worse than the disease :S
2019-09-27 20:41:45 -04:00
Henry de Valence 44b855aab8 Remove unused import in connect stub. 2019-09-27 20:41:45 -04:00
Henry de Valence ab06750db3 zebra-network: move types -> protocol::types
These types are used for protocol messages, so it makes more sense to
keep them scoped with the protocol handling, rather than other
networking logic.
2019-09-27 20:41:45 -04:00
Deirdre Connolly 19258d6f54 Remove duplicate from MerkleTree 2019-09-26 23:41:25 -04:00
Deirdre Connolly b4b72829b2 Sanity: checked 2019-09-26 23:41:25 -04:00
Deirdre Connolly 6236909210 Update zebra-chain/src/transaction.rs
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2019-09-26 23:41:25 -04:00
Deirdre Connolly 4e85bdb51b Explain in BlockHeaderHash docstrings block hash vs block header hash 2019-09-26 23:41:25 -04:00
Deirdre Connolly 35f03dc55d Make Message.Block just point at a Block type, in codec call block.zcash_serialize() 2019-09-26 23:41:25 -04:00