Commit Graph

1618 Commits

Author SHA1 Message Date
Henry de Valence 2c0f48b587 Refactor connection logic and try a block request.
Attempting to implement requests for block data revealed a problem with
the previous connection logic.  Block data is requested by sending a
`getdata` message with hashes of the requested blocks; the peer responds
with a sequence of `block` messages with the blocks themselves.

However, this wasn't possible to handle with the previous connection
logic, which could only convert a single Bitcoin message into a
Response.  Instead, we factor out the message handling logic into a
Handler, which can statefully accumulate arbitrary data into a Response
and signal completion.  This is still pretty ugly but it does work.

As a side effect, the HeartbeatNonceMismatch error is removed; because
the Handler now tries to process messages until it comes to a Response,
it just ignores mismatched nonces (and will eventually time out).

The previous Mempool and Transaction requests were removed but could be
re-added in a different form later.  Also, the `Get` prefixes are
removed from `Request` to tidy the name.
2020-02-10 09:03:56 -08:00
Henry de Valence 3c6fda8e0b Make the BlockHeaderHash conversions work on borrows. 2020-02-10 09:03:56 -08:00
Henry de Valence 5f6bf188ff Derive Hash for BlockHeaderHash.
This allows using BlockHeaderHashes in HashSets, HashMaps, etc.
2020-02-10 09:03:56 -08:00
Henry de Valence ebf60b8840 Make BlockHeader fields public. 2020-02-10 09:03:56 -08:00
Deirdre Connolly 824f206dbe Add several Debug impls for existing types
Resolves #237
2020-02-07 21:30:48 -08:00
Deirdre Connolly 866acde6e8 Add BLOCK_MAINNET_415000_BYTES test vector and a test to deserialize it
And println! it, for human eyeballs checking.

Resolves #218

Also changes the header constant to use _BYTES.
2020-02-07 13:42:21 -08:00
dependabot-preview[bot] d6c2b7ac32 Bump futures from 0.3.3 to 0.3.4
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.3...0.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-07 10:28:32 -06:00
dependabot-preview[bot] 0392d8fa5d Bump byteorder from 1.3.2 to 1.3.4
Bumps [byteorder](https://github.com/BurntSushi/byteorder) from 1.3.2 to 1.3.4.
- [Release notes](https://github.com/BurntSushi/byteorder/releases)
- [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/byteorder/compare/1.3.2...1.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-07 10:24:49 -06:00
Henry de Valence 972d16518f Make ZcashSerialize infallible mod its Writer.
Closes #158.

As discussed on the issue, this makes it possible to safely serialize
data into hashes, and encourages serializable data to make illegal
states unrepresentable.
2020-02-05 19:48:43 -05:00
Henry de Valence b0f61c4dd2 Remove outdated comment (we use tokio codecs now) 2020-02-05 19:44:35 -05:00
Henry de Valence ab94acf7da fmt 2020-02-05 19:44:35 -05:00
Henry de Valence eeb4a2470b Remove version fields from Block, Tx messages.
These are included in the Block, Transaction objects themselves, so the
previous code ended up trying to deserialize two version fields per
object.

Closes #226.
2020-02-05 19:44:35 -05:00
Henry de Valence 51c744b1ae Update network version number. 2020-02-05 14:06:35 -08:00
Henry de Valence 9273f83761 Remove tracing-subscriber.
We don't need to handle the subscriber directly since we upstreamed this
functionality into Abscissa.
2020-02-05 14:05:46 -08:00
Henry de Valence 8d58dd804f Note that tracing causes clippy false positives
Thanks @hawkw for pointing this out.
2020-02-05 12:42:32 -08:00
Henry de Valence f04f4f0b98 Apply clippy fixes 2020-02-05 12:42:32 -08:00
Henry de Valence a0d0d297d9 Try clippy in CI 2020-02-05 12:42:32 -08:00
dependabot-preview[bot] 979cf7ac6d Bump indexmap from 1.3.1 to 1.3.2
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.3.1...1.3.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-05 14:14:51 -05:00
dependabot-preview[bot] e2e63f9b9d Bump futures from 0.3.1 to 0.3.3
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.1 to 0.3.3.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.1...0.3.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-04 21:14:26 -08:00
Henry de Valence b24f53f4a1 Add From impls for InventoryHash 2020-02-04 17:48:36 -08:00
Deirdre Connolly b860461644 Update test block header hash 2020-02-04 18:04:53 -05:00
Deirdre Connolly 6dedb7e101 Write and read the equihash solution compactsize on (de)serialize 2020-02-04 18:04:53 -05:00
Deirdre Connolly a79969b38f Add comment around sha256d_flush test 2020-02-04 18:04:53 -05:00
Deirdre Connolly 4fcb66ad3b Read and write the block header version, which is fixed at 4 2020-02-04 18:04:53 -05:00
Deirdre Connolly 7ebb5ccd41 Add a simple test to check that our mainnet blockheader test vector deserializes without error 2020-02-04 18:04:53 -05:00
Deirdre Connolly 9257d838bd Use Result::expect() in test (de)serializations 2020-02-04 18:04:53 -05:00
Deirdre Connolly 9b6a9d8e86 Remove debugging variable assignments 2020-02-04 18:04:53 -05:00
Deirdre Connolly d12db25acb Cleanup 2020-02-04 18:04:53 -05:00
Deirdre Connolly 54628d889e Add proptests-regressions/block/tests.txt 2020-02-04 18:04:53 -05:00
Deirdre Connolly 36e9bb162f Move block type tests and proptest support impls to block::tests 2020-02-04 18:04:53 -05:00
Deirdre Connolly 6508540a92 Remove derive(Arbitrary) on BlockHeader 2020-02-04 18:04:53 -05:00
Deirdre Connolly 26469952b0 Update .gitignore 2020-02-04 18:04:53 -05:00
Deirdre Connolly b758a8f753 Extend blockheaderhash unit test to check a single (de)serialization case roundtrip 2020-02-04 18:04:53 -05:00
Deirdre Connolly dab99ba861 Impl Zcash(De)Serialization for Block 2020-02-04 18:04:53 -05:00
Deirdre Connolly f5c135ee1b Use updated EquihashSolution in BlockHeader 2020-02-04 18:04:53 -05:00
Deirdre Connolly 4d7bd3e2d7 derive(Copy) on SaplingNoteTreeRootHash 2020-02-04 18:04:53 -05:00
Deirdre Connolly 0f4d3e4a6d derive(Arbitrary) on MerkleTreeRootHash 2020-02-04 18:04:53 -05:00
Deirdre Connolly d5800e168c Add a roundtrip (de)serialization proptest for EquihashSolution 2020-02-04 18:04:53 -05:00
Deirdre Connolly c2bb6c15f8 Implement a bunch of traits for EquihashSolution 2020-02-04 18:04:53 -05:00
Deirdre Connolly e82cf0f5a8 Add BlockHeaderHash (de)serialization roundtrip proptest 2020-02-04 18:04:53 -05:00
Deirdre Connolly 69164a6943 Add test for BlockHeaderHash::from(BlockHeader) 2020-02-04 18:04:53 -05:00
Deirdre Connolly 29e1be2442 Impl Zcash(De)Serialize for BlockHeader 2020-02-04 18:04:53 -05:00
Deirdre Connolly e9d1f91d67 Make MerkleTreeRootHash wrapped array public 2020-02-04 18:04:53 -05:00
Deirdre Connolly 3ea4a6a9ab Move transaction test vectors around
Resolves #210
2020-02-04 18:04:53 -05:00
Deirdre Connolly 6d3d4c4f64 s/GetData/NotFound/ in read_notfound 2020-02-04 18:04:53 -05:00
Deirdre Connolly 1ca55846eb Little test to exercise sha256dWriter::flush() 2020-02-04 18:04:53 -05:00
Deirdre Connolly f9d9d6b4f4 0.17.0 has an old version cached, rolling back to 0.15.0 2020-02-04 04:44:38 -05:00
Deirdre Connolly 9405b7d97b Pin cloud builder version
The builder image was pointing at latest, 0.16.0 introduced a breaking
change that requires an extra flag.
2020-02-04 04:44:38 -05:00
dependabot-preview[bot] 73463c33f4 Bump ed25519-zebra from 0.1.0 to 0.2.0
Bumps [ed25519-zebra](https://github.com/ZcashFoundation/ed25519-zebra) from 0.1.0 to 0.2.0.
- [Release notes](https://github.com/ZcashFoundation/ed25519-zebra/releases)
- [Changelog](https://github.com/ZcashFoundation/ed25519-zebra/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ZcashFoundation/ed25519-zebra/compare/0.1.0...0.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-30 20:51:20 -08:00
dependabot-preview[bot] a66e7458ab Bump abscissa_core from 0.5.1 to 0.5.2
Bumps [abscissa_core](https://github.com/iqlusioninc/abscissa) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/iqlusioninc/abscissa/releases)
- [Changelog](https://github.com/iqlusioninc/abscissa/blob/develop/CHANGES.md)
- [Commits](https://github.com/iqlusioninc/abscissa/compare/v0.5.1...v0.5.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-30 15:43:33 -05:00