Commit Graph

1183 Commits

Author SHA1 Message Date
Henry de Valence 8e15c16b42 chain: TransparentAddress -> transparent::Address 2020-08-17 11:46:34 -07:00
Henry de Valence ebdceb5197 chain: rename TransactionHash to transaction::Hash 2020-08-17 11:46:34 -07:00
Henry de Valence d49d3d2b30 chain: tweak docs for JoinSplitData, ShieldedData 2020-08-17 11:46:34 -07:00
Henry de Valence 5c176d2f96 chain: move JoinSplit to sprout 2020-08-17 11:46:34 -07:00
Henry de Valence 1fc859d0c5 chain: move Spend, Output into sapling
The ShieldedData container for the spend and output descriptions of a
transaction does *not* move, because it's encoding transaction
structure.  A good sign that this is the right factoring is that the
transaction module now only needs to pull in sapling::{Spend, Output}
and not all the internals.
2020-08-17 11:46:34 -07:00
Henry de Valence d945cd28e8 chain: move Transparent{Input,Output} to transparent
Also bring the `Script` type there too.
2020-08-17 11:46:34 -07:00
Deirdre Connolly 25f63518f4 Allow clippy::unit_arg because of derive(Arbitrary) 2020-08-17 11:46:34 -07:00
Henry de Valence d57390d265 chain: doc tweaks (mostly block::) 2020-08-17 11:46:34 -07:00
Henry de Valence 94d6d448bb chain: rename to block::merkle::{Root, Tree}. 2020-08-17 11:46:34 -07:00
Henry de Valence 2712c4b72a chain: rename BlockHeader to block::Header 2020-08-17 11:46:34 -07:00
Henry de Valence 103b663c40 chain: rename BlockHeight to block::Height 2020-08-17 11:46:34 -07:00
Henry de Valence 61dea90e2f chain: rename BlockHeaderHash to block::Hash
This is the first in a sequence of changes that change the block:: items
to not include Block as a prefix in their name, in accordance with the
Rust API guidelines.
2020-08-17 11:46:34 -07:00
Henry de Valence 04ba696515 chain: remove block::block 2020-08-17 11:46:34 -07:00
Henry de Valence 9766d32fa6 chain: touch up amount docs 2020-08-17 11:46:34 -07:00
Henry de Valence d0ee7a9961 chain: amount::AmountConstraint -> amount::Constraint 2020-08-17 11:46:34 -07:00
Henry de Valence fd548592bf chain: remove clippy::try_error annotation 2020-08-17 11:46:34 -07:00
Henry de Valence dcc1e19129 chain: touch up docs 2020-08-17 11:46:34 -07:00
Henry de Valence ce1e81b274 chain: move merkle_tree to block::merkle.
This Merkle tree is the SHA256d one used only for including transactions
in a block, so it should be kept there in order to not be confused with
other Merkle trees (like the note commitment trees).
2020-08-17 11:46:34 -07:00
Henry de Valence 7298e7c636 chain: create a transparent module. 2020-08-17 11:46:34 -07:00
Henry de Valence e8f923ec86 chain: move Memo into transaction 2020-08-17 11:46:34 -07:00
Henry de Valence 312c66264a chain: extract sprout code into sprout module. 2020-08-17 11:46:34 -07:00
Henry de Valence e06f59ee21 chain: extract sapling code to sapling module 2020-08-17 11:46:34 -07:00
Henry de Valence c5a8cb0c91 chain: create primitives module.
This contains definitions of primitive types used in other structures
and re-exports of component libraries.
2020-08-17 11:46:34 -07:00
Henry de Valence 196e841cd9 chain: rename LightClientRootHash to RootHash
It's not accurate to call it a LightClientRootHash, because it's not
always a root has for a light client -- sometimes it's a different kind
of root hash.
2020-08-17 11:46:34 -07:00
Henry de Valence b296d1e2a3 chain: move Block into a leaf module.
This might make things a little easier to rearrange.  In the future it
would probably be good to change to block::Hash, block::Header, etc.
2020-08-17 11:46:34 -07:00
Henry de Valence 948b067808 chain: move Network, NetworkUpgrade to parameters
Also, avoid using star-imports of the enum variants, which pollutes the
namespace.
2020-08-17 11:46:34 -07:00
Henry de Valence 64d9d55992 chain: organize block tests
This moves the tests::generate module into the block tests.  Because
this whole set of changes is just focused on reorganization, the
generate code is unchanged, but in the future, the code should be
rewritten as a collection of proptest strategies.
2020-08-17 11:46:34 -07:00
Henry de Valence 855b89dec4 chain: create a new work module for proof-of-work
This extracts the `difficulty` module from `block` and the
`equihash_solution` module from the crate root.  The PoW calculations
are significantly more complicated than the other block code and pretty
dissimilar from it, so it makes more sense to create a common proof of
work module.

The `EquihashSolution` and `EQUIHASH_SOLUTION_SIZE` are renamed to
`equihash::Solution` and `equihash::SOLUTION_SIZE` and imported that
way, except in `block/header.rs`, to avoid a conflict with the
`equihash` crate.  In the future it would be better to encapsulate the
equihash solution check into the `equihash::Solution` type so that
callers only need to import our `work::equihash`.

The test organization leaves a little to be desired but I think that
this can be improved as we fill out the proof of work implementation.
2020-08-17 11:46:34 -07:00
Henry de Valence dad6340cd3 chain: move BlockHeight into block 2020-08-17 11:46:34 -07:00
Henry de Valence 5f71bcd0d1 chain: move LockTime into transaction 2020-08-17 11:46:34 -07:00
Henry de Valence 8e9a239687 chain: clean transaction tests module.
This moves the transaction strategies to `arbitrary`, to live with the
other strategy impls (`Arbitrary` is just a default type-associated
strategy), splits the proptests into a new `prop` module, and splits the
test vector checks into a `vector`s module.

This ensures that we keep code in leaf modules and only have
organization (use statements) in non-leaf modules.
2020-08-17 11:46:34 -07:00
Henry de Valence a35604aef3 chain: move amount to a top-level module. 2020-08-17 11:46:34 -07:00
Henry de Valence cee7d0b8eb chain: move serde_helpers into serialization. 2020-08-17 11:46:34 -07:00
Henry de Valence b36fe8f937 chain: move sha256d to serialization module.
This extracts the SHA256d code from being split across two modules and puts it
in one module, under serialization.

The code is unchanged except for three deleted tests:

* `sha256d_flush` in `sha256d_writer` (not a meaningful test);
* `transactionhash_debug` (constructs an invalid transaction hash, and the
  behavior is tested in the next test);
* `decode_state_debug` (we do not need to test the Debug output of
  DecodeState);
2020-08-17 11:46:34 -07:00
Henry de Valence 9f31e551c9 chain: split serialization.rs into files
The code is unchanged except for removing an unneeded clippy annotation in proptests.rs.
2020-08-17 11:46:34 -07:00
Henry de Valence 0d1f56ad2f chain: remove utils module
A catch-all utils module can really easily slip into being a place to stash
miscellaneous functions that don't really belong anywhere in particular.
2020-08-17 11:46:34 -07:00
teor 4bbefeb68e
Implement Add for Work (#894)
* feature: Implement CompactDifficulty to Work

* fix: Test Work on all difficulty test cases

* fix: Add Bitcoin test vectors for difficulty

* feature: Cumulative Work

* impl Add, AddAssign for Work
* derive Default for Work
* test cumulative work

* fix: comments

* fix: More comments

* Fix comment links

* Remove unused import

Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com>
2020-08-14 20:48:56 -04:00
Deirdre Connolly eda6d86d3e Try naively parallelizing test and build jobs on our platform matrix 2020-08-14 20:27:53 -04:00
Deirdre Connolly 27ed2288b5 Remove redundant clones for PathBufs 2020-08-14 20:15:24 -04:00
Alfredo Garcia b41e33e066
Bytes read and bytes written metrics (#901)
* add bytes read and written metrics

* Apply suggestions from code review

Co-authored-by: Jane Lusby <jlusby42@gmail.com>

* store address as string

* Apply suggestions from code review

Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>

* change addr to label

Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>

* remove newline

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 15:50:26 -07:00
teor 120c7ef648
rfc: Parallel Verification (#763)
* rfc: Parallel Verification Draft

An initial draft RFC for parallel verification.

* rfc: Integrate the CheckpointVerifier design

Describe how the CheckpointVerifier interacts with chain state updates.

* rfc: Add a chain tips update service

* rfc: Add network upgrade context changes

* rfc: Add main chain tip section

* rfc: Clarify and expand genesis block rules

* rfc: More genesis special cases

* Add another chain tips edge case

* Remove the final tie-breaker for tip ties

Instead, change the design to make them impossible.

* rfc: add a definitions section to parallel verification

* rfc: Split parallel verification into two RFCs

This is the semantic verification RFC.

* rfc: Add guide and examples for parallel verification

* rfc: Fix GitHub markdown

* rfc: Fix parallel function design

We don't need separate functions, we can just do the awaits as late as
possible.

* rfc: Fix typo

* rfc: Stop assigning responsibilities to modules

* rfc: Add more parallel verification definitions

* rfc: Say "block height consensus rule"

* rfc: Tidy some of the TODOs

* rfc: Expand rationale and alternatives

* rfc: Delete "try to depend on older blocks"

* rfc: Delete coinbase checks which are unrelated to BlockHeight

And remove some duplicate references to BlockHeight checks.

* rfc: Focus on verification stages

And rewrite some stages for clarity.

* rfc: Remove reference to zebra-network
2020-08-14 11:04:17 -07:00
Deirdre Connolly 616d82faaf Use the jubjub::AffinePoint in the canonical, encoded little-endian byte form in
Pedersen tests

Keeps the librustzcash test vectors with their big-endian byte order
as comments, for greppability.
2020-08-14 02:04:12 -04:00
Deirdre Connolly a2c9011e06 Impl ZcashDeserialize for jubjub::Fq, use in transaction deserialization 2020-08-14 02:04:12 -04:00
Deirdre Connolly 1255cec6a4 Serialize Amount to bytes using byteorder::LittleEndian 2020-08-14 02:04:12 -04:00
Deirdre Connolly 646b506e7a Whoops forgot to add sprout::NoteTreeRootHash 2020-08-14 02:04:12 -04:00
Deirdre Connolly 4914b80cdb Add a TODO about caching Pedersen hash generator points 2020-08-14 02:04:12 -04:00
Deirdre Connolly f753e63f3b Clarify docstring on NoteCommitment::new() 2020-08-14 02:04:12 -04:00
Deirdre Connolly 437f40d3c8 Refine JoinSplit::anchor to be a sprout::NoteTreeRootHash type 2020-08-14 02:04:12 -04:00
Deirdre Connolly 5a5882700c Tidy JoinSplit nullifiers deserialization 2020-08-14 02:04:12 -04:00
Deirdre Connolly 6b13ce3e83 Add Sapling EphemeralPublicKey type that wraps jubjub::AffinePoint 2020-08-14 02:04:12 -04:00