Commit Graph

371 Commits

Author SHA1 Message Date
Deirdre Connolly f64e0c4bc5 Sapling value commitment, half done Sapling note commitment 2020-08-14 02:04:12 -04:00
Deirdre Connolly 823b06b219 Break out subtypes into modules, including arbitrary's 2020-08-14 02:04:12 -04:00
Deirdre Connolly dfb10ab10f Add NoteCommitment.extract_u() 2020-08-14 02:04:12 -04:00
Deirdre Connolly 33730a05cb Do not confuse a NoteCommitment for U(NoteCommitment) 2020-08-14 02:04:12 -04:00
Deirdre Connolly 0f46a9b6a8 NoteCommitments, renames, ValueCommitment, strategies, stub commit() 2020-08-14 02:04:12 -04:00
Deirdre Connolly fa053e2b0b Derive a Sprout nullifier from a nullifier seed (rho) and spending key 2020-08-14 02:04:12 -04:00
Deirdre Connolly 0d618a3abf Start treestate module 2020-08-14 02:04:12 -04:00
Deirdre Connolly 28a7420079 Remove unused imports 2020-08-14 02:04:12 -04:00
Deirdre Connolly 15899bc6d3 More Note refinements 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
Jane Lusby 8b78a55c71 Start work implementing sprout note commitment function 2020-08-14 02:04:12 -04:00
teor 0e21a70b88
feature: Implement CompactDifficulty to Work (#838)
* Implement CompactDifficulty to Work
* Add Bitcoin test vectors for difficulty
2020-08-14 09:48:15 +10:00
Henry de Valence 07917421cb
Correct coinbase check (#898)
* chain: add Transaction::is_coinbase()

This matches the check in zcashd/src/primitives/transaction.h:682
(CTransaction::IsCoinBase).

* chain: correct Block::is_coinbase_first

This matches zcashd/src/main.cpp:3968-3974 in CheckBlock.

Previously, the check allowed the first transaction to have multiple coinbase inputs.

* chain: return slices from Transaction::inputs()/outputs()

They're slices internally so we might as well just expose them that way.
2020-08-13 14:04:43 -07:00
Henry de Valence 36093b4721 Tweak light client root hash definition.
This changes the `light_client_root_hash` field to `light_client_root_bytes` to
hint that it's unparsed, and makes it public to match the rest of the
`BlockHeader` fields.  The `LightClientRootHash` serialization methods are
hidden from the public API, so that the `LightClientRootHash` has to be
constructed by the method on the `Block`.
2020-08-11 19:13:50 -04:00
dependabot[bot] 5cb61136c9
build(deps): bump tracing from 0.1.18 to 0.1.19 (#872)
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.18 to 0.1.19.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.18...tracing-0.1.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-11 10:18:54 -07:00
Henry de Valence f8a24f9c11
Rename script fields to lock/unlock scripts. (#866)
This is slightly clearer and more correct than the previous pk_script.
2020-08-10 11:49:38 -07:00
teor 7afd76f5fb feature: Add light_client_root_hash(network) to Block
* use the right variant in LightClientRootHash::from_bytes()
* make block.header.light_client_root_hash pub(super)
* add tests for LightClientRootHash and block.light_client_root_hash
2020-08-10 18:54:42 +10:00
teor ee6f0de14d refactor: Move NetworkUpgrade to zebra-chain 2020-08-10 18:54:42 +10:00
teor c4eb136426 feature: Add a LightClientRootHash type 2020-08-10 18:54:42 +10:00
teor 53ce01fd23 fix: Rename the light client hash field 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
teor d49c11ee70 fix: Allow PROPTEST_CASES to override the lower block case default 2020-08-05 02:07:05 -07:00
teor ac7a4ae517 fix: Speed up the block round trip proptest
Reduce the number of cases run by the block round trip proptest, to
speed up the Zebra tests.
2020-08-04 22:35:01 -07:00
teor 78b5bf5e9a refactor: Move the difficulty tests into their own file 2020-08-04 15:24:52 -04:00
teor efb9313460 fix: Resolve a type ambiguity in a proptest
For some reason, implementing
`PartialOrd<BlockHeaderHash> for ExpandedDifficulty` (or its converse)
makes this unrelated code ambiguous.
2020-08-04 12:29:07 +10:00
teor c8b502a5da feature: Compare ExpandedDifficulty and BlockHeaderHash 2020-08-04 12:29:07 +10:00
teor b7fac7b3bc feature: Make ExpandedDifficulty use U256 internally
Adds a dependency on the primitive-types crate.

Also adds custom hex debug formatting for compact and expanded
difficulties.
2020-08-04 12:29:07 +10:00
teor c04d1b7b8f doc: Consensus-critical difficulty encodings 2020-08-04 12:29:07 +10:00
teor 06157a7c8e
Update the BlockHeader fields for Heartwood (#767)
The Heartwood upgrade changes the meaning of the hashFinalSaplingRoot to
hashLightClientRoot. Since we don't know the network upgrade heights in
zebra-chain, we just use [u8; 32] for now.
2020-08-04 12:15:28 +10:00
dependabot[bot] f3b65f9609 build(deps): bump tracing from 0.1.17 to 0.1.18
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.17 to 0.1.18.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.17...tracing-0.1.18)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-03 15:49:30 -04:00
teor 195948e5b1 feature: Add an ExpandedDifficulty type and conversion
Also add tests.
2020-08-03 10:28:31 +10:00
teor c4dec3fb36 feature: Make a CompactDifficulty wrapper
Wrap the compact difficulty "bits" field in a CompactDifficulty struct,
and rename the header field for clarity.
2020-08-03 10:28:31 +10:00
Jane Lusby 1015db25a8
remap the state storage to only store blocks once (#741) 2020-07-31 09:21:54 +10:00
Henry de Valence 7d0a3debb6 chain: ensure impl Deserialize for Amount validates data.
This uses serde's try_from attribute to run deserialized values through the
TryFrom impl.  Also adds a test to make sure that validation actually does
happen.
2020-07-28 12:20:40 -07:00
teor 5ece62f0a5 fix: Update comments for Heartwood's hashChainHistoryRoot 2020-07-27 14:00:56 -04:00
Henry de Valence 4aa00ad216 Align crate versions and user-agent with NU numbers.
We had a brief discussion on discord and it seemed like we had consensus on the
following versioning policy:

* zebrad: match major version to NU version, so we will start by releasing
  zebrad 3.0.0;

* zebra-* libraries: start by matching zebrad's version, then increment major
  versions of each library as we need to make breaking changes (potentially
  faster than the zebrad version, always respecting semver but making no
  guarantees about the longevity of major releases).

This commit sets all of the crate versions to 3.0.0-alpha.0 -- the -alpha.0
marks it as a prerelease not subject to perfect adherence to compatibility
guarantees.
2020-07-24 11:46:37 -07:00
teor 41225660fb doc: The genesis coinbase is the same in every network 2020-07-23 03:46:24 -04:00
Jane Lusby 7d4e717182
Add block locator request to state layer (#712)
* Add block locator request to state layer

* pass genesis in request

* Update zebrad/src/commands/start/sync.rs

* fix errors
2020-07-22 18:01:31 -07:00
Henry de Valence 90ec2982bf docs: fix broken links 2020-07-22 17:55:52 -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
Jane Lusby b8de256c48 remove serialization error variant of EquihashError 2020-07-22 11:09:22 +10:00
teor 1b0c0f027f
Add Hard-Coded Checkpoint Lists (#674)
* Add checkpoint list generation scripts
* Limit the checkpoint block data size
* Limit the checkpoint height gap
* Add Mainnet and Testnet checkpoint lists
* Parse hard-coded checkpoint lists

The lists were generated using the following limits:
- 256 MB spacing, based on block byte size, and
- 2000 blocks.
2020-07-21 23:11:51 +10:00
dependabot[bot] 474de52e5c
build(deps): bump displaydoc from 0.1.6 to 0.1.7 (#689)
Bumps [displaydoc](https://github.com/yaahc/displaydoc) from 0.1.6 to 0.1.7.
- [Release notes](https://github.com/yaahc/displaydoc/releases)
- [Commits](https://github.com/yaahc/displaydoc/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-20 11:00:15 -07:00
Alfredo Garcia fe2a468417
add favicon to generated docs (#681) 2020-07-17 16:45:29 -07:00
teor 1915634d2b
Check for bad heights or hashes in checkpoint lists (#639)
* Add MIN and MAX for BlockHeight and LockTime
* Remove duplicate test cases
* fix a comment about the minimum lock time

The minimum LockTime::Time is 5 November 1985 00:53:20 UTC, so the first
day that only contains valid times is 6 November 1985 (in all timezones).

Similarly, the maximum LockTime::Time is 7 February 2106 06::28::15 UTC,
so the last day that only contains valid times in all time zones is
5 February 2106.

* fix: Reject checkpoint lists with bad hashes or heights

Reject the all-zeroes hash, because it is the parent hash of the genesis
block, and should never appear in a checkpoint list.

Reject checkpoint heights that are greater than the maximum block
height.
2020-07-16 15:09:22 +10:00
teor a19fdd9f25 fix: Rename to is_time_valid_at 2020-07-15 09:16:54 -07:00
teor b2bb872df0 Use Unicode for section reference
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-07-15 09:16:54 -07:00
teor c2e4f7b0a5 refactor: Move the local clock check to a BlockHeader method 2020-07-15 09:16:54 -07:00
teor 5548dffd3b refactor: Move the coinbase first check to a Block method 2020-07-15 09:16:54 -07:00
teor e452ba1c13 fix: Use matches!() based on a new nightly clippy lint 2020-07-15 12:50:11 +10:00