Commit Graph

1202 Commits

Author SHA1 Message Date
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
Deirdre Connolly 52a10d2837 Add note about whether sign checks in Amount -> Fr conversion matter
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly 75cad3bb0a Impl TryFrom's for Diversifier and use those to construct Sapling NoteCommitments 2020-08-14 02:04:12 -04:00
Deirdre Connolly c8771ef620 Defer to From/Into [u8; 32] vs Zcash(De)Serialize for sprout::NoteCommitments 2020-08-14 02:04:12 -04:00
Deirdre Connolly 619afffa16 Use convenience Reader/Writer methods to only use From/Into for nullifer serialization
And thus remove duplicative Zcash(De)Serialization impls
2020-08-14 02:04:12 -04:00
Deirdre Connolly 13b6ff1c65 Add 32byte and 64 bytes convenience writer methods to WriteExt 2020-08-14 02:04:12 -04:00
Deirdre Connolly e8fdd0e1f3 Impl TryFrom for Commitments, call from impl ZcashDeserialize 2020-08-14 02:04:12 -04:00
Deirdre Connolly 5d13880461 Remove Zcash(De)Serialize impls for *Commitments 2020-08-14 02:04:12 -04:00
Deirdre Connolly 014afd8e4a Move Pedersen hash functions to their own submodule 2020-08-14 02:04:12 -04:00
Deirdre Connolly be7ea200c8 Accept an Amount<NonNegative> for the value arg of a ValueCommitment constructor 2020-08-14 02:04:12 -04:00
Deirdre Connolly e024e43896 Support nullifier derivation from borrowed Spending, NullifierDeriving keys 2020-08-14 02:04:12 -04:00
Deirdre Connolly 40b5a73a15 impl From<&NullifierDerivingKey>, use that to derive Sapling Nullifier 2020-08-14 02:04:12 -04:00
Deirdre Connolly a8625b7b84 Remove empty doc comment 2020-08-14 02:04:12 -04:00
Deirdre Connolly a3530b0eed Move pedersen_hash() to go with the other Sapling hash functions, for now 2020-08-14 02:04:12 -04:00
Deirdre Connolly 0242df30cb A space 2020-08-14 02:04:12 -04:00
Deirdre Connolly 9d9491c4e8 Index at 1, not 0, the main loop of PedersenHashToPoint, to match spec math 2020-08-14 02:04:12 -04:00
Deirdre Connolly e5c07721b4 Typo fix
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly ca81e48843 Remove an extra line 2020-08-14 02:04:12 -04:00
Deirdre Connolly 60ae9d74e7 Typo
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly fe45c6402a Remove clippy::unit_arg allowance 2020-08-14 02:04:12 -04:00
Deirdre Connolly 2942bad6ff Make diversify_hash() private again 2020-08-14 02:04:12 -04:00
Deirdre Connolly 5a249f8da5 A space
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly 5ba453c2a1 Remove unused SaplingNoteTreeRootHash types re: Heartwood 2020-08-14 02:04:12 -04:00
Deirdre Connolly 68871c5bd4 From<Nullifier> for [u8; 32] 2020-08-14 02:04:12 -04:00
Deirdre Connolly b2584c4a8f A space 2020-08-14 02:04:12 -04:00
Deirdre Connolly 0c299972ec Clarify docstring about the Jubjub prime-order subgroup on generate_trapdoor() 2020-08-14 02:04:12 -04:00
Deirdre Connolly f816761a5c The pedersen hash to point test vectors now pass 2020-08-14 02:04:12 -04:00
Deirdre Connolly 425275ad35 Fix exclusive range, shift up enumerate() indexes with map() 2020-08-14 02:04:12 -04:00
Deirdre Connolly be22ef64e5 At least fewer M_i() rounds for test cases 2020-08-14 02:04:12 -04:00
Deirdre Connolly 41c8076dab Add test vectors that aren't being consumed right now 2020-08-14 02:04:12 -04:00
Deirdre Connolly 14d502a54b Compute pedersen hash to point in scalar field 2020-08-14 02:04:12 -04:00
Deirdre Connolly 8ececebea7 A space
Co-authored-by: teor <teor@riseup.net>
2020-08-14 02:04:12 -04:00