Commit Graph

15151 Commits

Author SHA1 Message Date
Homu c34162d6dd Auto merge of #5225 - LarryRuane:2021-06-v5-transaction, r=str4d
Implement v5 transaction consensus rules

Part of zcash/zcash#5196.
2021-07-01 12:37:17 +00:00
Jack Grigg e18da34468 miner: Set coinbase expiry height to block height from NU5 activation 2021-07-01 13:34:56 +01:00
Jack Grigg 0a78f4c6ec test: Fix OverwinterExpiryHeight test after ZIP 203 contextual changes 2021-07-01 13:17:08 +01:00
Jack Grigg 9a5951aab1 test: Check for updated empty-tx reject messages in transaction tests 2021-07-01 13:05:26 +01:00
Kris Nuttycombe 7a2be88768 ZIP 213: Add checks to support Orchard shielded coinbase outputs. 2021-07-01 12:42:37 +01:00
Jack Grigg 6bbe0906a8 ZIP 203: Enforce coinbase nExpiryHeight consensus rule from NU5 2021-07-01 12:42:37 +01:00
Kris Nuttycombe 6145cb8ae1 Prevent undefined behaviour in `CTransaction::GetValueOut()`
If `valueBalanceSapling` were `INT64_MIN`, the negation would be undefined
behaviour. Also, if `valueBalanceSapling` were a large-magnitude value
then `nValueOut += -valueBalanceSapling;` could overflow, which would be
undefined behaviour.

In practice neither of these cases can happen because `GetValueOut()` is
only called on non-contextually valid transactions, for which
`valueBalanceSapling` will have been checked to be in range.

`GetShieldedValueIn()` is similarly cleaned up for consistency.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-01 12:42:37 +01:00
Kris Nuttycombe b0b797b4e9 Add check that v5 transactions have empty Sprout joinsplits. 2021-07-01 12:41:25 +01:00
Kris Nuttycombe d882c68274 Retract partial Orchard test support.
Testing for Orchard transaction construction will be introduced
separately.
2021-07-01 12:41:25 +01:00
Kris Nuttycombe 1f7aaf2368 Account for Orchard balance in GetValueOut and GetShieldedValueIn.
Also adds Orchard information to CTransaction::ToString.
2021-07-01 12:41:25 +01:00
Kris Nuttycombe 22854f7998 Add Orchard value balance checks. 2021-07-01 12:41:25 +01:00
Kris Nuttycombe 5bfdbb4c74 Make valueBalanceSapling a private non-const member of CTransaction. 2021-07-01 12:41:25 +01:00
Kris Nuttycombe fd91f099f4 Rename tx.valueBalance -> tx.valueBalanceSapling 2021-07-01 12:41:25 +01:00
Kris Nuttycombe feef0e03f6 Check consensus branch ID for V5 transactions. 2021-07-01 12:41:25 +01:00
Kris Nuttycombe 3aae84cc49 Add NU5 upper bound check on nSpendsSapling, nOutputsSapling, nActionsOrchard
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-01 12:41:25 +01:00
Kris Nuttycombe 53828a38ba Make CTransaction::nConsensusBranchId a std::optional 2021-07-01 12:41:25 +01:00
Kris Nuttycombe 52568f58a8 Ensure Sapling versions are valid after NU5 2021-07-01 12:41:25 +01:00
Larry Ruane 66de454a20 ZIP 225: v5 transaction check rules 2021-07-01 12:41:25 +01:00
Homu c3fe01200b Auto merge of #5235 - str4d:tx-dynamic-usage, r=str4d
Include Orchard bundle in transaction dynamic usage

This was missed in #5202.
2021-06-29 14:07:06 +00:00
Jack Grigg 8ad7371800 Include Orchard bundle in transaction dynamic usage 2021-06-29 15:05:46 +01:00
Homu 52e3a74a75 Auto merge of #5233 - nuttycom:feature/orchard_merkle, r=str4d
Implement Orchard commitment tree logic.
2021-06-29 12:18:18 +00:00
Jack Grigg d72f722915 test: Update CCoinsViewTest with changes to CCoinsView interface
I just LOVE how C++ didn't complain that the changes to the virtual
method APIs didn't cause any compilation errors for the tests...
2021-06-29 03:34:08 +01:00
Kris Nuttycombe 3251f0c935
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 17:56:57 -06:00
Kris Nuttycombe 0d40ea8494 Add Orchard nullifiers to nullifiers cache. 2021-06-28 17:43:23 -06:00
Kris Nuttycombe f9d823726c Add consensus check for duplicate Orchard nullifiers within a single transaction. 2021-06-28 17:37:32 -06:00
Kris Nuttycombe 572719fca6 Apply suggestions from code review
Use const pointers wherever possible.

Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 17:37:32 -06:00
Kris Nuttycombe 8fbc84842b Document source of Orchard merkle tree test data. 2021-06-28 16:40:11 -06:00
Kris Nuttycombe 5550dbe1b8 Fix implmentation of OrchardMerkleTree.DynamicMemoryUsage 2021-06-28 16:33:40 -06:00
Kris Nuttycombe 8ee8c9f6ab Consistently panic on null commitment tree pointers.
Orchard commitment tree pointers should never be null.
2021-06-28 15:27:21 -06:00
Kris Nuttycombe d46dbd9ea4 Apply style suggestions. 2021-06-28 14:49:39 -06:00
Kris Nuttycombe d533d3ccbf Fix header guards for incremental_sinsemilla_tree.h 2021-06-28 13:54:15 -06:00
Kris Nuttycombe 60f58890ec Fix Orchard incremental Merkle tree empty root. 2021-06-28 13:54:15 -06:00
Kris Nuttycombe 4b36b6fc20 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 13:54:15 -06:00
Kris Nuttycombe a3214285c2 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 13:54:15 -06:00
Kris Nuttycombe 34f192b8f0 Update to released version of incrementalmerkletree 2021-06-28 09:56:05 -06:00
Kris Nuttycombe ecec1f9769 Update orchard dependency. 2021-06-24 11:53:30 -06:00
Kris Nuttycombe 0a1e845681 Documentation cleanup. 2021-06-23 16:17:53 -06:00
Kris Nuttycombe 13fd4c9a1c Add Orchard merkle tree anchor tests. 2021-06-23 16:06:30 -06:00
Kris Nuttycombe 9569bfc291 Add Orchard bundle commitments to merkle tree. 2021-06-23 16:06:30 -06:00
Kris Nuttycombe 0c1a5878ad Check nullifiers length against bundle actions length. 2021-06-23 16:06:30 -06:00
Kris Nuttycombe fd34ecc64d Return std::optional for GetAnchor 2021-06-23 16:06:30 -06:00
Kris Nuttycombe 437b8c488a Orchard changes to coins & consensus. 2021-06-23 16:06:30 -06:00
Kris Nuttycombe 68ce7e4828 Implement the Rust side of the incremental merkle tree FFI. 2021-06-23 16:06:30 -06:00
Homu 0247c0c682 Auto merge of #5232 - str4d:5195-orchard-proof-verification, r=str4d
Check Orchard bundle-specific consensus rules, i.e. proofs

This obviously doesn't check the correct proofs yet, but this adds the consensus rule machinery so that when the circuit is implemented, we just need to upgrade the `orchard` dependency.

Closes zcash/zcash#5195.
2021-06-21 17:42:06 +00:00
Jack Grigg 1072cd4e3e Check Orchard bundle-specific consensus rules, i.e. proofs
We are already checking the other bundle-specific consensus rules:
- Encodings are checked during transaction parsing.
- Signatures are batch-validated.

Closes zcash/zcash#5195.
2021-06-21 18:33:57 +01:00
Jack Grigg 9ad5b75b30 rust: Load Orchard circuit parameters at startup 2021-06-21 18:33:57 +01:00
Homu 785803382a Auto merge of #5228 - str4d:orchard-pool-tracking, r=str4d
Orchard pool tracking

Includes the ZIP 209 update to enforce the Orchard pool never being negative.
2021-06-21 16:09:57 +00:00
str4d 86ac3e12f0
Minor fixes to documentation and formatting
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-21 17:08:22 +01:00
Jack Grigg 509e7c7d79 Implement Orchard pool value tracking
The ZIP 209 rules preventing the Sprout and Sapling pool values from
going negative, are extended to the Orchard pool.
2021-06-21 01:40:49 +01:00
Homu 9253e2828e Auto merge of #5227 - str4d:v2-history-tree, r=str4d
Integrate V2 history tree

Closes #5037.
2021-06-20 22:26:04 +00:00