Commit Graph

63 Commits

Author SHA1 Message Date
Conrado Gouvea 9688811e35
Update multiple crates to ensure bitvec 0.22.3 is being used (#2351)
* Update multiple crates to ensure bitvec 0.22.3 is being used and avoid package conflicts

* Add documentation to zebra-chain::sapling to indicate that ZIP-216 rules are enforced by jubjub

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com>
2021-06-23 13:16:22 +10:00
teor 2f0f379a9e
Standardise clippy lints and require docs (#2238)
* Standardise lints across Zebra crates, and add missing docs

The only remaining module with missing docs is `zebra_test::command`

* Todo -> TODO

* Clarify what a transcript ErrorChecker does

Also change `Error` -> `BoxError`

* TransError -> ExpectedTranscriptError

* Output Descriptions -> Output descriptions
2021-06-04 08:48:40 +10:00
Alfredo Garcia a57c09a3b8
Orchard data in V5 parsing (#2116)
* initialize the work on parsing orchard data in V5
* add the rest of orchard serialization
* fix serialization according to spec
* fix arbitrary for Signature<SpendAuth>
* move deserialization of AuthorizedAction to shielded_data module
* use `from_bits_truncate` to generate valid arbitrary flags
* change panic message
* fix serialization/deserialization when nActionsOrchard is empty
* fix Halo2Proof deserialization
* implement ZcashSerialize and ZcashDeserialize for flags
* implement ZcashSerialize and ZcashDeserialize for orchard::tree::Root
* use ZcashSerialize and ZcashDeserialize for binding_sig
* implement from_parts()
* implement Arbitrary for  Signature<Binding>
* add trusted preallocate with tests
* fix Arbitrary for orchard Nullifier
* Use zcash_serialize_bytes instead of write_compactsize

Co-authored-by: teor <teor@riseup.net>
2021-05-21 00:42:06 +00:00
Deirdre Connolly 376603d4c0 Flesh out Orchard note and nullifier derivation 2021-04-30 00:48:23 -04:00
Deirdre Connolly 1ff8874b8d Orchard: remove unused imports, more warn(missing_docs) lint to orchard for now 2021-04-30 00:48:23 -04:00
Deirdre Connolly 40383b2741 Partway done with typing out Orchard chain types 2021-04-30 00:48:23 -04:00
teor 0d8ffc367e Move LedgerState into the block module 2021-04-23 09:34:13 -04:00
teor d19585cfca Fix some missed Sapling to Canopy checkpoint code changes 2021-03-18 10:13:47 +10:00
Alfredo Garcia d7c40af2a8
Fix shutdown panics (#1637)
* add a shutdown flag in zebra_chain::shutdown
* fix network panic on shutdown
* fix checkpoint panic on shutdown
2021-02-03 19:03:28 +10:00
teor b1d28b73fd Stop disabling lints that no longer cause warnings on nightly 2021-01-19 11:02:20 -05:00
teor 258789ed9b Use the rustc unknown lints attribute
The clippy unknown lints attribute was deprecated in
nightly in rust-lang/rust#80524. The old lint name now produces a
warning.

Since we're using `allow(unknown_lints)` to suppress warnings, we need to
add the canonical name, so we can continue to build without warnings on
nightly.

But we also need to keep the old name, so we can continue to build
without warnings on stable.

And therefore, we also need to disable the "removed lints" warning,
otherwise we'll get warnings about the old name on nightly.

We'll need to keep this transitional clippy config until rustc 1.51 is
stable.
2021-01-19 11:02:20 -05:00
teor 92eb92d1dd
Disable the nightly clippy unnecessary_wraps lint (#1403)
It seems to be a bit broken - some of our functions return `Result` for
consistency with similar functions. But the lint picks them up anyway.
2020-12-01 12:20:57 +10:00
Alfredo Garcia 4544463059
Inbound `FindBlocks` and `FindHeaders` (#1347)
* implement inbound `FindBlocks`
* Handle inbound peer FindHeaders requests
* handle request before having any chain tip
* Split `find_chain_hashes` into smaller functions

Add a `max_len` argument to support `FindHeaders` requests.

Rewrite the hash collection code to use heights, so we can handle the
`stop` hash and "no intersection" cases correctly.

* Split state height functions into "any chain" and "best chain"
* Rename the best chain block method to `best_block`
* Move fmt utilities to zebra_chain::fmt
* Summarise Debug for some Message variants

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-12-01 07:30:37 +10:00
teor 54cb9277ef Allow some new clippy nightly lints 2020-11-17 10:07:37 +10:00
Jane Lusby 855f9b5bcb
Implement MVP of NonFinalizedState and integrate it with the state service (#1101)
* implement most of the chain functions
* implement fork
* fix outpoint handling in Chain struct
* update expect for work
* split utxo into two sets
* update the Chain definition
* remove allow attribute in zebra-state/lib.rs
* merge ChainSet type into MemoryState
* Add error messages to asserts
* export proptest impls for use in downstream crates
* add testjob for disabled feature in zebra-chain
* try to fix github actions syntax
* add module doc comment
* update RFC for utxos
* add missing header
* working proptest for Chain
* propagate back results over channel
* Start updating RFC to match changes
* implement queued block pruning
* and now it syncs wooo!
* remove empty modules
* setup config for proptests
* re-enable missing_docs lint
* update RFC to match changes in impl
* add documentation
* use more explicit variable names
2020-10-08 13:07:32 +10:00
Jane Lusby 86ed13060f
Add tests for `Chain` implementation (#1093)
* Begin work on RFC5 implementation

* I think this is necessary

* holy shit supertrait implemented via subtrait

* implement most of the chain functions

* change to slightly better name

* implement fork

* fix outpoint handling in Chain struct

* update expect for work

* resolve review comment

* split utxo into two sets

* update the Chain definition

* just a little more

* update comment

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* apply changes from code review

* remove allow attribute in zebra-state/lib.rs

* Update zebra-state/src/memory_state.rs

Co-authored-by: teor <teor@riseup.net>

* merge ChainSet type into MemoryState

* rename state impl types

* Add error messages to asserts

* checkpoint so I can split off arbitrary changes into a PR

* export proptest impls for use in downstream crates

* add testjob for disabled feature in zebra-chain

* run rustfmt

* try to fix github actions syntax

* differentiate name

* prove that github action tests zebra-chain build without features

* revert change from last commit now that test is running

* remove accidentally introduced newline

* checkpoint

* add module doc comment

* update RFC for utxos

* add missing header

* working proptest for Chain

* apply change from chain impl PR

* setup config for proptests

* Update zebra-chain/src/block/arbitrary.rs

Co-authored-by: teor <teor@riseup.net>

* run rustfmt

Co-authored-by: teor <teor@riseup.net>
2020-10-02 15:51:51 -07:00
Jane Lusby 6744f415d2
Implement sighash (#870)
* Implement sighash

* move sighash logic to a separate module

* start filling in more of the alg

* start setting up a test case

* make the test useful

* Iter transaction inputs

* better error message for expect

* add support for zip243 sighash

* ohey first testvector is passing, yayyy

* pass the second testvector

* add last testvector

* move a use statement

* use common deserialization code for amount everywhere

* cleanup attributes

* bring in fixed preimage

* fix discrepancy with spec

* always deserialize as a signed value

* Update zebra-chain/src/transaction/sighash.rs

* update unreachable statements

* add serialization impls for nonnegative amounts

* Apply suggestions from code review

* document sighash fn

* tweek docs

* fix mistake in translation for zip243

* consistent error messages

* reorder because i like it more that way

* document more panics

* Update zebra-chain/src/amount.rs

* Add comment regarding the serialization of spend descriptions in sighash

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2020-09-05 19:31:11 -04: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 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 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 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
Deirdre Connolly b6385ca36f Move commitment types into commitments module
Docs, tidy
2020-08-14 02:04:12 -04:00
Deirdre Connolly 0d618a3abf Start treestate module 2020-08-14 02:04:12 -04:00
Deirdre Connolly 2c285985c8 Move nullifiers to respective note modules, pull in existing types from keys 2020-08-14 02:04:12 -04:00
teor ee6f0de14d refactor: Move NetworkUpgrade to zebra-chain 2020-08-10 18:54:42 +10:00
Henry de Valence a987394782
Add KaTeX to rendered docs. (#832)
This adds a single test formula to the `zebra-chain` docs.  We can remove it
after merging this and running it through CI to confirm that it works.
2020-08-05 17:34:30 -07:00
Alfredo Garcia db2eb80b3e
Create consensus utils and move byte_reverse_hex function to it (#705)
* move byte_reverse_hex function
2020-07-22 12:29:14 +10:00
Alfredo Garcia fe2a468417
add favicon to generated docs (#681) 2020-07-17 16:45:29 -07:00
teor 5548dffd3b refactor: Move the coinbase first check to a Block method 2020-07-15 09:16:54 -07:00
Alfredo Garcia db30e53470
Create a test for block size (#558)
* add block size limit test
* calculate max_transactions_in_block and max_inputs_in_tx
* abstract block generation
* move all test vectors to zebra-test
2020-07-07 10:37:32 +10:00
Jane Lusby 00e750654a
add nullifier types (#568)
* add nullifier types

* Apply suggestions from code review

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

* add zcash_deserialize impls

* Add docs

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2020-07-01 17:57:32 -07:00
Henry de Valence a023ba9b16
Add serde bounds to zebra-chain structures. (#231) 2020-06-15 15:08:14 -07:00
Deirdre Connolly b263489af6
Export ed25519 zebra (#445)
And use that one, and our similar redjubjub export, everywhere.

Fixes #405

* Move PRs to 'In Progress' column on project board when created
2020-06-06 18:10:32 -04:00
Deirdre Connolly df7ed7ae81
Move note encryption types around (#362)
* Move around and dedupe note *Cipertext types

* Bump code coverage test timeout to 5 minutes

* Try uploading coverage to codecov.io
2020-04-19 14:45:25 -04:00
Deirdre Connolly 6dc0830ea6 Impl Default for Network, as Mainnet 2020-04-15 03:22:48 -04:00
Deirdre Connolly b9240971fd Add impl Arbitrary for TransparentAddress and a roundtrip proptest
addresses.rs is now large with just transparent stuff, i am already planning to break this up
further in the addresses/ module.
2020-03-12 22:02:17 -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
Deirdre Connolly 9887b7c8b7 Fix up TransparentAddresses 2020-03-12 22:02:17 -04:00