Commit Graph

35 Commits

Author SHA1 Message Date
Jane Lusby 8281b9040c
Start work on new Amount type (#554) 2020-07-01 16:31:30 -07:00
teor d8b48f885b
consensus: Add a checkpoint verifier stub (#502)
consensus: Add a checkpoint verifier stub

This stub only verifies blocks whose hashes are in the checkpoint
list.

It doesn't have tests, chain child verifies to their ancestors, or
support checkpoint maximum height queries.

Part of #429.
2020-06-22 08:51:43 +10:00
Henry de Valence a023ba9b16
Add serde bounds to zebra-chain structures. (#231) 2020-06-15 15:08:14 -07:00
Jane Lusby b6b35364f3 cleanup warnings throughout codebase 2020-05-27 15:42:29 -04:00
Deirdre Connolly a5f4db7528 Move just the Network enum to -chain, keep everything else in -network 2020-03-12 22:02:17 -04:00
Deirdre Connolly b68e1e2d55 Move Network, Magic, and magics to zebra-chain 2020-03-12 22:02:17 -04:00
Henry de Valence d887faf16f Add PartialOrd, Ord to BlockHeight. 2020-02-14 18:23:41 -05:00
Henry de Valence 44b299d15c Parse block heights in coinbase transactions.
BIP34, which is included in Zcash, encodes the block height into each
block by adding it into the unused BitcoinScript field of the block's
coinbase transaction.  However, this is done just by requiring that the
script pushes the block height onto the stack when it executes, and
there are multiple different ways to push data onto the stack in
BitcoinScript.  Also, the genesis block does not include the block
height, by accident.

Because we want to *parse* transactions into an algebraic data type that
encodes their structural properties, rather than allow possibly-invalid
data to float through the internals of our node, we want to extract the
block height upfront and store it separately from the rest of the
coinbase data, which is inert.  So the serialization code now contains
just enough logic to parse BitcoinScript-encoded block heights, and
special-case the encoding of the genesis block.

Elsewhere in the source code, the `LockTime` struct requires that we
must use block heights less than 500,000,000 (above which the number is
interpreted as a unix timestamp, not a height).  To unify invariants, we
ensure that the parsing logic works with block heights up to
500,000,000, even though these are unlikely to ever be used for Zcash.
2020-02-14 18:23:41 -05:00
Deirdre Connolly 824f206dbe Add several Debug impls for existing types
Resolves #237
2020-02-07 21:30:48 -08: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 f04f4f0b98 Apply clippy fixes 2020-02-05 12:42:32 -08:00
Deirdre Connolly e82cf0f5a8 Add BlockHeaderHash (de)serialization roundtrip proptest 2020-02-04 18:04:53 -05:00
Deirdre Connolly 46fa30a66a Don't use Utc::now() in our LockTime strategy 2020-01-28 03:48:23 -05:00
Deirdre Connolly ac3c31b1c2 Rearrange and tidy imports 2020-01-28 03:48:23 -05:00
Deirdre Connolly a259a6b4b1 Add and use v4_strategy() 2020-01-28 03:48:23 -05:00
Deirdre Connolly b786e1e19c derive Arbitrary on BlockHeight 2020-01-28 03:48:23 -05:00
Deirdre Connolly f4df61eb47 Remove commented out extra Arbitrary impl for Locktime 2020-01-28 03:48:23 -05:00
Deirdre Connolly dfb28b7854 Stubbing out an Arbitrary impl for variant V1 of the Transaction enum 2020-01-28 03:48:23 -05:00
Deirdre Connolly eb5b3dfefc Add zcash_[de]serialize roundtrip proptest for Script type 2020-01-28 03:48:23 -05:00
Deirdre Connolly 86f631f9b7 Truncate LockTime::Time datetimes to only seconds for proptests 2020-01-28 03:48:23 -05:00
Deirdre Connolly 71d5571e39 Add roundtrip proptest for LockTime serialization/deserialization
Relates to #150
2020-01-28 03:48:23 -05:00
Henry de Valence 1199cfa23e impl Zcash[De]Serialize for Script 2019-12-31 02:46:39 -05:00
Henry de Valence 2965187b91 Upgrade tokio, futures, hyper to released versions. 2019-12-13 17:42:15 -05:00
Henry de Valence c013895cd7 Update Transaction definition. (#105)
* Added a few more top-level fields for the Transaction struct

* Add a placeholder Script type.

This could alternately use bytes::Bytes to save some allocations
but I don't think this is important to get perfectly now.  In the future, we
will want to have all of the script handling code in the zebra-script crate,
but we will need to have a container type for an encoded script in zebra-chain,
because otherwise zebra-chain would depend on zebra-script and not the other
way around.

* Rename Transaction{Input,Output} -> Transparent{Input,Output}.

These are only *transparent* inputs and outputs, so by putting Transparent in
the name (instead of Transaction) it's more clear that a transaction's inputs
or outputs can also be shielded.

* Add a LockTime enum.

* First attempt at a Transaction enum.

This attempts to map the versioning and field presence rules into an ADT, so
that structurally invalid transactions (e.g., a BCTV14 proof in a Sapling
transaction) are unrepresentable.

* Update zebra-chain/src/transaction.rs

Co-Authored-By: Daira Hopwood <daira@jacaranda.org>

* Add fixme note on type refinement.

* Rename Transaction variants according to version.

* Split transaction.rs into submodules.

* Start filling in spend, output descriptions.

* Progress on JoinSplit data structures.

This has a lot of duplication and should really use generics to abstract over
Sprout-on-BCTV14 or Sprout-on-Groth16.

* Add data types for Bctv14 and Groth16 proofs.

This also adds a trait to abstract over them.

* Make JoinSplit descriptions generic over the proof system.

* Update zebra-chain/src/transaction/joinsplit.rs
2019-12-05 15:56:58 -05:00
Deirdre Connolly 65d988471a Implement custom Debug for Sha256dChecksum
Relates to #63
2019-10-17 09:33:10 -07: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
Deirdre Connolly 7340c7d9ce Adding BlockHeader, BlockHash, MerkleRootHash, Sha256dWriter 2019-09-26 23:41:25 -04:00
Deirdre Connolly 73740841e1 Move `Transaction` and related types to their own module (#9)
* Move `Transaction` and related types to their own module

Resolves #6

* Fix references to `Transaction` after move
2019-09-19 07:45:37 -07:00
Deirdre Connolly 60fb4f6bb0 Remove InventoryType::MsgCmpctBlock
From BIP-152, which is not implemented by Zcash.
2019-09-18 17:32:06 -04:00
Deirdre Connolly 65632e9f42 Correct comment about pzec bytes::Bytes 2019-09-18 17:32:06 -04:00
Deirdre Connolly 46984cbb27 Add `tx` message, along with `Transaction`, `Transaction(In|Out)put`, and `OutPoint` types 2019-09-18 17:32:06 -04:00
Henry de Valence 733d090b9b Add missing derives to newtypes. 2019-09-18 17:32:06 -04:00
Henry de Valence 42cb9c1ff9 Add a `Sha256dChecksum` type for truncated double SHA256. 2019-09-18 17:32:06 -04:00
Deirdre Connolly a2e50833be Add InventoryType, InventoryVector, and Message::{Inventory, GetData, NotFound} 2019-09-18 17:32:06 -04:00
Deirdre Connolly ac0d9732a0 WIP: Version message and various sub structures
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2019-09-18 17:32:06 -04:00