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_client_backend: add Orchard spends and outputs to transaction construction #1105

Merged
merged 7 commits into from
Feb 22, 2024

Conversation

nuttycom
Copy link
Contributor

@nuttycom nuttycom commented Jan 9, 2024

Builds upon #1187

@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch 6 times, most recently from 2229f31 to a3cc2df Compare January 16, 2024 22:52
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch from a3cc2df to 80585bb Compare January 26, 2024 02:01
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 157 lines in your changes are missing coverage. Please review.

Comparison is base (c6656c1) 64.98% compared to head (184286c) 64.44%.

Files Patch % Lines
zcash_client_backend/src/data_api/wallet.rs 53.20% 95 Missing ⚠️
zcash_client_backend/src/proposal.rs 33.33% 22 Missing ⚠️
zcash_keys/src/address.rs 0.00% 19 Missing ⚠️
zcash_client_backend/src/wallet.rs 53.33% 7 Missing ⚠️
zcash_client_sqlite/src/lib.rs 74.07% 7 Missing ⚠️
zcash_client_backend/src/data_api/error.rs 0.00% 4 Missing ⚠️
zcash_client_backend/src/data_api.rs 50.00% 2 Missing ⚠️
zcash_client_backend/src/fees/standard.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1105      +/-   ##
==========================================
- Coverage   64.98%   64.44%   -0.54%     
==========================================
  Files         115      115              
  Lines       11437    11639     +202     
==========================================
+ Hits         7432     7501      +69     
- Misses       4005     4138     +133     

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

@nuttycom nuttycom marked this pull request as ready for review February 6, 2024 16:30
@nuttycom nuttycom requested review from str4d and daira February 6, 2024 16:30
@nuttycom nuttycom marked this pull request as draft February 6, 2024 21:53
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch from 80585bb to 12b6909 Compare February 7, 2024 00:38
@nuttycom nuttycom marked this pull request as ready for review February 7, 2024 00:39
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch 2 times, most recently from ed7de98 to 97ee67a Compare February 7, 2024 00:59
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.

I believe this is going to be rebased on top of #1187, but looks good so far.

@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch from f67158a to fcbfdaa Compare February 16, 2024 04:31
In the event that the pool to which change should be sent cannot
automatically be determined based upon the inputs and outputs of a
transaction, it is up to the caller to specify where change should
be sent.
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch from fcbfdaa to 4e3d99f Compare February 16, 2024 04:45
@AArnott
Copy link
Contributor

AArnott commented Feb 18, 2024

Accrues toward #403

daira
daira previously approved these changes Feb 19, 2024
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.

utACK

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Flushing comments from my in-progress review.

zcash_client_backend/src/data_api.rs Outdated Show resolved Hide resolved

/// The type of the backing [`ShardStore`] for the Orchard note commitment tree.
#[cfg(feature = "orchard")]
type OrchardShardStore<'a>: ShardStore<
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, we can't use the default trick to make the feature flag additive here, because the bound directly involves orchard crate types.

In a pairing with @nuttycom we came to the conclusion that the WalletRead, WalletWrite, and WalletCommitmentTrees are close enough to the application layer that it is less likely that people will run into "spooky feature flag enabling at a distance". However, the other things in zcash_client_backend that also interact with the feature flags (e.g. batch scanning) can result in this, and we have concrete evidence of people wanting to depend on zcash_client_backend solely to build on those things and not the app-layer traits.

So what we will develop towards is splitting out the non-app-layer things into separate crates (which are the boundaries on which feature flags operate, thus providing insulation against the problem), and focus zcash_client_backend solely on "just below app" use cases.

If we can also get rid of the associated types here (which @nuttycom said he would like to do), then we can also go back to providing a default implementation of these feature-flagged methods, fixing the problem.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Reviewed as of 8c78d7f.

for<'a> F: FnMut(
&'a mut ShardTree<
Self::OrchardShardStore<'a>,
{ ORCHARD_SHARD_HEIGHT * 2 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think I'd prefer a cast from the orchard crate type, but this is fine given that everything here is divisible by 2.

for<'a> F: FnMut(
&'a mut ShardTree<
Self::OrchardShardStore<'a>,
{ ORCHARD_SHARD_HEIGHT * 2 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: ditto.

zcash_client_backend/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/data_api.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/data_api/error.rs Show resolved Hide resolved
let selectable_pools = &[ShieldedProtocol::Sapling];
#[cfg(zcash_unstable = "orchard")]
#[cfg(feature = "orchard")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm: we now don't attempt to select from the Orchard pool if orchard is disabled. What was the previous behaviour that made this change necessary, given that the wallet_db method is publicly reachable and thus other people could also run into it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The objective here is to make the zcash_unstable only be a gate for the 'orchard' feature, which is then the ultimate gate (that will remain in place permanently) for Orchard functionality. Removing the other uses of the config flag means that we have less variation in compilation to account for.

zcash_client_backend/src/lib.rs Show resolved Hide resolved
zcash_client_sqlite/src/testing.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/testing.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/testing.rs Outdated Show resolved Hide resolved
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch 2 times, most recently from 1a9bdb7 to 81694e1 Compare February 21, 2024 18:54
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch from 81694e1 to 050a124 Compare February 21, 2024 18:55
@nuttycom nuttycom requested a review from str4d February 21, 2024 21:05
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Reviewed as of 050a124.

zcash_client_backend/src/data_api/error.rs Outdated Show resolved Hide resolved
zcash_client_backend/CHANGELOG.md Outdated Show resolved Hide resolved
zcash_client_backend/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/fees/standard.rs Show resolved Hide resolved
zcash_client_backend/src/fees/zip317.rs Show resolved Hide resolved
zcash_client_backend/src/proto.rs Show resolved Hide resolved
zcash_client_backend/src/data_api/wallet.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/proposal.rs Outdated Show resolved Hide resolved
Co-authored-by: str4d <thestr4d@gmail.com>
@nuttycom nuttycom force-pushed the wallet/orchard_spends_and_outputs branch from 5303cb0 to 184286c Compare February 22, 2024 00:44
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK 184286c

match output_pool {
#[cfg(not(feature = "orchard"))]
PoolType::Shielded(ShieldedProtocol::Orchard) => {
return Err(Error::ProposalNotSupported);
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation for this error variant is now out of date.

@str4d str4d removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2024
@str4d str4d merged commit 04343e1 into zcash:main Feb 22, 2024
22 of 24 checks passed
@nuttycom nuttycom deleted the wallet/orchard_spends_and_outputs branch February 22, 2024 01:33
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.

4 participants