Commit Graph

535 Commits

Author SHA1 Message Date
Jane Lusby b287ea58c2 Add proptest for work roundtrip 2020-11-12 09:14:52 -05:00
Jane Lusby 1bc833dbcc Move work conversion helpers to test code 2020-11-12 09:14:52 -05:00
Jane Lusby c41a7303fa Add helpers for setting work on fake chains 2020-11-12 09:14:52 -05:00
teor 9baec96c18 Add tests for testnet minimum difficulty blocks 2020-11-12 12:30:54 +10:00
teor b2a9ea62fe Round-trip the PoWLimit through the compact representation
`zcashd` converts the PoWLimit into a compact representation before
using it to perform difficulty filter checks.

The Zcash specification converts to compact for the default difficulty
filter, but not for testnet minimum difficulty blocks. (ZIP 205 and
ZIP 208 don't specify this conversion either.) See #1277.
2020-11-12 12:30:54 +10:00
teor 8f838166a8 Make ExpandedDifficulty Debug byte order match Hash
Bugfix on PR #1171.
2020-11-12 12:30:54 +10:00
teor 76a9f5b8c4 Refactor block target spacing into NetworkUpgrade methods
And add a method for the minimum difficulty time gap threshold.
2020-11-12 12:30:54 +10:00
Alfredo Garcia 128643d81e
Call `zebra_test::init` where needed. (#1227)
* Add missing `zebra_test::init()` to zebra-chain
* Add missing `zebra_test::init()` to zebra-consensus
* Add missing `zebra_test::init()` to zebra-network
* Add missing `zebra_test::init()` to zebra-state
* Add missing `zebra_test::init()` to zebra-test
* Add missing `zebra_test::init()` to zebrad
2020-11-10 10:29:25 +10:00
teor 01aeaae3f8 Placate rustfmt 2020-10-30 14:41:38 -07:00
teor f37f48918b Replace into with Some in difficulty::arbitrary 2020-10-30 14:41:38 -07:00
teor d883462d83 Silence a clippy equal arguments warning
The unit tests need to pass identical arguments to an equality
comparison, to make sure equality is implemented correctly.
2020-10-30 14:40:42 -07:00
teor 1c31225aac
Implement Expanded to Compact Difficulty Conversion (#1196)
* Implement Expanded to Compact Difficulty
* Implement Arbitrary for CompactDifficulty
Remove the derive, and generate values from random block
hashes.
* Implement Arbitrary for ExpandedDifficulty and Work
* Use Arbitrary for CompactDifficulty in Arbitrary for Block
* Test difficulty on all block test vectors
And cleanup some duplicate test code
* Round-trip tests for compact test cases
* Round-trip tests for compact difficulty in block test vectors
* Make Add for Work return PartialCumulativeWork
Remove AddAssign for Work
Rewrite a proptest using Sub for PartialCumulativeWork
Use Arbitrary for Work
* Add roundtrip work sum tests
* Add roundtrip comparison difficulty tests
* Add failing proptest cases due to test bugs
* Use Some(_) rather than _.into()
* Reduce visibility of difficulty type inner values
* Split work and other difficulty proptests
This change makes sure that rejected work values don't disable property
tests on other types.
2020-10-30 11:36:59 +10:00
Jane Lusby 2095b4f0d3 state: insert into nullifier trees 2020-10-29 09:58:56 -07:00
teor 9667ee650f Run deserialize_blockheader on every test vector 2020-10-28 21:24:28 -04:00
teor 456842aa86 Run the equihash tests on every block test vector 2020-10-28 21:24:28 -04:00
Alfredo Garcia bcb027ebc5 change canopy.pdf to stable protocol.pdf 2020-10-28 11:34:53 -04:00
teor d745d2b47c
Stop assuming Mainnet in Address From impls (#1191) 2020-10-22 07:58:52 +10:00
Alfredo Garcia 21ad6ffc47
Reverse displayed endianness of transaction and block hashes (#1171)
* Reverse displayed endianness of transaction and block hashes
* fix zebra-checkpoints utility for new hash order
* Stop using "zebrad revhex" in zebrad-hash-lookup
* Rebuild checkpoint lists in new hash order
This change also adds additional checkpoints to the end of each list.

* Replace TransactionHash with transaction::Hash
This change should have been made in #905, but we missed Debug impls
and some docs.

Co-authored-by: Ramana Venkata <vramana@users.noreply.github.com>
Co-authored-by: teor <teor@riseup.net>
2020-10-22 07:54:02 +10:00
Deirdre Connolly eb56666d30 chain: add ShieldedData::binding_verification_key() 2020-10-20 11:16:22 -04:00
Deirdre Connolly 5a78bbb6c9 Add nullifiers(), and note_commitments() to ShieldedData 2020-10-20 11:16:22 -04:00
Deirdre Connolly f9de91716c Add docstrings for sighash 2020-10-20 11:16:22 -04:00
Deirdre Connolly db54a623b7 Export sighash::HashType 2020-10-20 11:16:22 -04:00
teor efb9bfa5de
Merge pull request #1165 from teor2345/difficulty-tidy
Tidy some difficulty code
2020-10-16 06:50:08 +10:00
teor de04e76564 Reduce the equihash proptest run time
Reduce the default number of cases run by the equihash proptests,
so they run in under 10 seconds on my machine.

Set the PROPTEST_CASES env var to override the default.
2020-10-16 06:49:43 +10:00
teor c3a8fd3894 Check PoWLimit for difficulty threshold 2020-10-15 08:31:18 +10:00
teor 00de709dd8 impl From<U256> for ExpandedDifficulty 2020-10-15 08:31:18 +10:00
teor 407962b864 Rename any remaining is_time_valid_at instances
Automated search and replace, using the script:

sed -i 's/is_time_valid_at/time_is_valid_at/' \
    $(grep -r is_time_valid_at zebra* | cut -d: -f1 | sort -u)
2020-10-13 08:11:11 +10:00
teor d504232720 Apply error and span suggestions
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-10-13 08:11:11 +10:00
teor c4630cd1f5 Improve error messages for header.time validation 2020-10-13 08:11:11 +10:00
teor 77e227dfe4 Fix some function docs and parameter names 2020-10-13 08:11:11 +10:00
Alfredo Garcia c0a14ecc8c
move genesis parameters to zebra-chain (#1151) 2020-10-12 14:08:23 -07:00
Alfredo Garcia c93f0b3a2e
Block Subsidy and Founders Reward Amounts (#1051)
* add general and founders reward subsidy modules
* validate founders reward
* Use funding streams after Canopy on testnet
ZIP-1014 only applies to mainnet, where Canopy is at the first halving.
On testnet, Canopy is before the first halving, and the dev fund rules
apply from Canopy. (See ZIP-214.)
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Jane Lusby <jlusby42@gmail.com>

* pass all test vectors through current subsidy validation
* Add testnet and halving subsidy tests
* add subsidy validation error tests

* rename block validation methods
* add network to block verifier

* add amount operators
* Implement Ord, Eq, and Hash for Amount
* Implement Add<Height> for Height
And make the existing Height operators do range checks.
* Apply operator suggestions
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-10-13 06:54:48 +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
Deirdre Connolly 8b8ef6dc4d Remove extra Sum impl 2020-10-07 01:29:08 -04:00
Deirdre Connolly cc44711204 Impl<'a> Sub<&'a ValueCommitment> for ValueCommitment 2020-10-07 01:29:08 -04:00
Deirdre Connolly de6994ad52 Dupe the multiple Add impls
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-10-07 01:29:08 -04:00
Deirdre Connolly 62ad554d84 Remove redundant non_snake_case 2020-10-07 01:29:08 -04:00
Deirdre Connolly b5b2d6a359 Impl more Add, Sum for references and Sum test 2020-10-07 01:29:08 -04:00
Deirdre Connolly 7cd730c552 Add tests for impl (Add|Sub)(Assign) for ValueCommitment 2020-10-07 01:29:08 -04:00
Deirdre Connolly d4da79af86 Impl (Add|Sub)(Assign) for ValueCommitment 2020-10-07 01:29:08 -04:00
Deirdre Connolly f7095ae9a2 Add some more human-readable language to the doc comment on merkle_crh_sprout 2020-10-05 23:44:25 -04:00
Deirdre Connolly 0cf24be8e0 Use VecDeque in places
The unwrap()'s are all after checks to make sure the value should never be None.
2020-10-05 23:44:25 -04:00
Deirdre Connolly d6cac9ea0a Allow dead code for now 2020-10-05 23:44:25 -04:00
Deirdre Connolly ee8ac1fd38 Remove LittleEndian import 2020-10-05 23:44:25 -04:00
Deirdre Connolly b85fcdfce9 Hex-encode empty root test vectors to height 29 2020-10-05 23:44:25 -04:00
Deirdre Connolly 8ab0f92d45 Persist the byte-reversed commitments 2020-10-05 23:44:25 -04:00
Deirdre Connolly ebbb494fb3 It woooooorks 2020-10-05 23:44:25 -04:00
Deirdre Connolly 30491c2c55 Fix merkle_crh_sprout 2020-10-05 23:44:25 -04:00
Deirdre Connolly 064021b7bf Update test vectors 2020-10-05 23:44:25 -04:00
Deirdre Connolly 24fa507e41 Tidy tests 2020-10-05 23:44:25 -04:00