ZcashFoundation / zebra

Zcash - Financial Privacy in Rust 🦓
https://zfnd.org/zebra/
Apache License 2.0
410 stars 104 forks source link

Parse Sapling data in Transaction Version 5 #1829

Closed teor2345 closed 3 years ago

teor2345 commented 3 years ago

Is your feature request related to a problem?

In #1824, we parse the transaction header and transparent data for transaction version 5.

Transaction version 5 also contains Sapling data, which we need to parse:

Describe the solution you'd like

Implementation

Spend

Implement serialization and deserialization for:

Test Arbitrary Spend (both variants):

Output

Implement serialization and trusted vector deserialization for:

Test Arbitrary Output (both transaction versions):

ShieldedData

Documentation

Implement serialization and deserialization for:

TestArbitrary Option<sapling::ShieldedData<SharedAnchor>>

Test manual implementations:

Transaction

TestArbitrary Transaction::V5

Cleanups and Refactoring

Testing

Test round-trip serialization and deserialization for transaction v4 and v5 (without orchard)

Unit tests

Test vectors

Describe alternatives you've considered

This is a required change for NU5.

Follow Up Tasks

"Fake" Sapling-only and Sapling/Transparent v5 transactions based on zebra_test::vectors::block::BLOCKS

Test vectors

oxarbitrage commented 3 years ago

Blocked on https://github.com/ZcashFoundation/zebra/issues/1863

mpguerra commented 3 years ago

I just wanted to highlight this item from the spec which may be relevant here also:

For a v5 transaction, vbalanceSapling is implicitly zero if the transaction has no Spend descriptions or Output descriptions.

teor2345 commented 3 years ago

I just wanted to highlight this item from the spec which may be relevant here also:

For a v5 transaction, vbalanceSapling is implicitly zero if the transaction has no Spend descriptions or Output descriptions.

Thanks Pili, that was a bug in the draft PR, I've added a comment at https://github.com/ZcashFoundation/zebra/pull/1860/files#r595643213

teor2345 commented 3 years ago

I just wanted to highlight this item from the spec which may be relevant here also:

For a v5 transaction, vbalanceSapling is implicitly zero if the transaction has no Spend descriptions or Output descriptions.

Thanks Pili, that was a bug in the draft PR, I've added a comment at https://github.com/ZcashFoundation/zebra/pull/1860/files#r595643213

These was actually also a missing related Orchard spec rule as well:

Screen Shot 2021-03-18 at 08 41 45

I've opened #1917 to implement those rules, and I'll also update the transaction RFC.

teor2345 commented 3 years ago

I opened #2023 and #2047 for follow-up, so we can close this ticket now.