Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcash_primitives: Refactor Transaction to permit omitting protocol-specific bundles #1388

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

str4d
Copy link
Contributor

@str4d str4d commented May 11, 2024

Draft because there are still some things that need doing:

  • I want some feedback on the overall approach to check the direction makes sense.
  • I haven't documented much yet (spent my time getting the refactor structured correctly so the commits make sense).
  • I haven't checked all the various feature flag combinations yet.
  • The PR needs tests that exercise the various NoProtocol combinations.
  • The Authorization-ish traits are still tied to the protocol-specific crates. I think I need to introduce intermediate traits with blanket impls.
  • Factor out Sprout for completeness (even though we don't depend on anything for Sprout that we don't inherently need for basic Zcash support).
  • Factor out ZFuture.
  • Needs changelog updates.

Copy link

codecov bot commented May 11, 2024

Codecov Report

Attention: Patch coverage is 76.19048% with 60 lines in your changes missing coverage. Please review.

Project coverage is 63.23%. Comparing base (5bd911f) to head (16988be).

Files Patch % Lines
zcash_primitives/src/transaction/mod.rs 62.71% 22 Missing ⚠️
zcash_primitives/src/transaction/components/tze.rs 0.00% 18 Missing ⚠️
zcash_primitives/src/transaction/sighash_v4.rs 89.23% 7 Missing ⚠️
zcash_primitives/src/transaction/txid.rs 76.92% 6 Missing ⚠️
zcash_primitives/src/transaction/components.rs 50.00% 4 Missing ⚠️
...sh_primitives/src/transaction/components/sprout.rs 94.73% 1 Missing ⚠️
...imitives/src/transaction/components/transparent.rs 93.75% 1 Missing ⚠️
zcash_primitives/src/transaction/sighash_v5.rs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1388      +/-   ##
==========================================
+ Coverage   63.20%   63.23%   +0.02%     
==========================================
  Files         128      129       +1     
  Lines       14869    14948      +79     
==========================================
+ Hits         9398     9452      +54     
- Misses       5471     5496      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far. I was a little bit alarmed about the name UnauthorizedTransactionDataWithSaplingProofs (i.e. why so unorthogonal?), but then I saw the motivation and it's fine.

@daira
Copy link
Contributor

daira commented May 12, 2024

I haven't done anything with ZFuture, and am not quite sure what to do there.

Can we just delete TZE support? I don't care about them and I very much doubt they are ever going to be deployed. We should ask on #libraries in the R&D Discord obviously. Deleting them should be easy given that they're feature flagged.

@str4d
Copy link
Contributor Author

str4d commented May 13, 2024

I was a little bit alarmed about the name UnauthorizedTransactionDataWithSaplingProofs (i.e. why so unorthogonal?), but then I saw the motivation and it's fine.

My hope is that this type goes away once I land the refactor that follows after this one (to restructure the zcash_primitives transaction builder to match Sapling and Orchard, by separating the building of the unauthorized bundle and its authorization). At that point, this type will be a well-defined intermediate state (as an explicit method output), instead of an ill-defined internal detail of Builder::build that requires type-pinning to help the compiler.

@str4d
Copy link
Contributor Author

str4d commented May 13, 2024

In e3a29b8 I've added Yet Another Intermediate Trait Bundles, which I think solves the "conditional compilation of bundles" that is necessary for merging code that is not currently part of consensus (as well as making the enabling of these bundles in consensus less of a breaking change to downstream code). If this approach looks good, I'll rebase the PR to merge the Bundles changes back into the earlier commits (simplifying them).

@str4d str4d force-pushed the transaction-refactor branch 2 times, most recently from e3a29b8 to d185e6f Compare May 13, 2024 17:04
@str4d
Copy link
Contributor Author

str4d commented May 13, 2024

Force-pushed to merge the commit introducing the Bundles trait back into the rest of the commits, simplifying them.

@str4d
Copy link
Contributor Author

str4d commented May 13, 2024

Force-pushed to address some initial review comments from a pairing with @nuttycom.

@str4d
Copy link
Contributor Author

str4d commented May 13, 2024

Force-pushed to move Sprout onto the Bundles trait. It has no authorization traits because we only support already-authorized Sprout bundles (due to not supporting Sprout in transaction building).

@str4d str4d force-pushed the transaction-refactor branch 2 times, most recently from 43d2820 to 443855e Compare May 13, 2024 23:52
@str4d
Copy link
Contributor Author

str4d commented May 13, 2024

Force-pushed to move TZEs onto the Bundles trait, as a proof-of-concept for other conditionally-compiled transaction format changes that we want to merge into the codebase before inclusion in consensus (e.g. ZSAs).

@str4d
Copy link
Contributor Author

str4d commented May 16, 2024

Force-pushed to adjust how the new traits work in order to eliminate the bounds on the protocol-crate-specific authorization traits.

@str4d
Copy link
Contributor Author

str4d commented May 16, 2024

Force-pushed with some further decoupling adjustments and trait renames. It also removes the NoTransparent etc. changes (and the TransactionWith refactor) as not currently necessary, because the dependency removal will be done by altering the Transparent<A> etc. types (in a way that is technically a breaking change, but in a way that should only be observable as purely additive in our API).

@str4d str4d marked this pull request as ready for review May 16, 2024 16:57
@str4d
Copy link
Contributor Author

str4d commented Jun 26, 2024

Rebased on main to fix a small merge conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants