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

Preparatory refactoring for zcash/librustzcash#1673 #1675

Merged

Conversation

nuttycom
Copy link
Contributor

@nuttycom nuttycom commented Dec 30, 2024

This is the preparatory work pulled out from #1673

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be better handled by taking a golden testing approach: branching from the commit where this test was added, create a wallet database file containing the buggy state, and store it in the repository; then, add an ordinary test that begins from that buggy database file and ensure that migrating to the current state results in the bug having been fixed.

@nuttycom nuttycom force-pushed the feature/transparent_gap_limit_handling-prep branch from 3e51560 to 7a46303 Compare December 30, 2024 16:53
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be better handled by taking a golden testing approach: branching from the commit where this test was added, create a wallet database file containing the buggy state, and store it in the repository; then, add an ordinary test that begins from that buggy database file and ensure that migrating to the current state results in the bug having been fixed.

zcash_keys/src/keys.rs Outdated Show resolved Hide resolved
zcash_keys/src/keys.rs Outdated Show resolved Hide resolved
zcash_keys/src/keys.rs Outdated Show resolved Hide resolved
zcash_keys/src/keys.rs Outdated Show resolved Hide resolved
daira
daira previously approved these changes Dec 30, 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 with comments.

@nuttycom nuttycom force-pushed the feature/transparent_gap_limit_handling-prep branch 4 times, most recently from 03d4d2e to 6ba9b48 Compare December 30, 2024 19:39
@nuttycom nuttycom force-pushed the feature/transparent_gap_limit_handling-prep branch from 6ba9b48 to cccbf01 Compare December 30, 2024 20:57
@nuttycom nuttycom force-pushed the feature/transparent_gap_limit_handling-prep branch 4 times, most recently from 990cd7e to c2dbd20 Compare December 30, 2024 22:10
…he `transparent-inputs` feature flag.

This variant should not have been a part of the public API unless
`tranpsarent-inputs` was enabled, as it's necessary for the wallet to be
able to spend a transparent input in order for a ZIP 320 transaction to
be properly constructed and authorized.

In addition, this simplifies the `Recipient` API by removing its type
parameters in favor of concrete types, made possible by using a
separate type for the build process.
…gration.

This test is not specific to the migration; it's a more general test of
ephemeral address rotation behavior and should evolve with the evolution
of address rotation and gap limit handling, not be tied to the behavior
of methods at the time that this migration was created.
This permits `UnifiedAddressRequest` values an additional dimension of
flexibility, permitting generation of unified addresses having receivers
for all recever types for which a key item exists and a diversifier
index is valid.
This removes a `fix_bad_change_flagging` migration test duplicated from
`zcash_client_backend::data_api::testing::pool::shiled_transparent`. It
is impractical to maintain backwards compatibility to earlier database
states for the entire test harness, which is more or less what retaining
this test would require, and the desired outcome is already demonstrated
by the `shield_transparent` test; demonstrating the fix directly is
unnecessary.
@nuttycom nuttycom force-pushed the feature/transparent_gap_limit_handling-prep branch from c2dbd20 to e6b45f7 Compare December 30, 2024 22:15
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 e6b45f7

Comment on lines 581 to 589
(Require, Omit) => None,
(Require, Require) => Some(Require),
(Require, Allow) => Some(Require),
(Allow, Require) => Some(Require),
(Allow, Allow) => Some(Allow),
(Allow, Omit) => Some(Omit),
(Omit, Require) => None,
(Omit, Allow) => Some(Omit),
(Omit, Omit) => Some(Omit),
Copy link
Contributor

Choose a reason for hiding this comment

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

Slightly more concise:

Suggested change
(Require, Omit) => None,
(Require, Require) => Some(Require),
(Require, Allow) => Some(Require),
(Allow, Require) => Some(Require),
(Allow, Allow) => Some(Allow),
(Allow, Omit) => Some(Omit),
(Omit, Require) => None,
(Omit, Allow) => Some(Omit),
(Omit, Omit) => Some(Omit),
(Require, Omit) | (Omit, Require) => None,
(Require, _) | (_, Require) => Some(Require),
(Omit, _) | (_, Omit) => Some(Omit),
(Allow, Allow) => Some(Allow),

@str4d str4d merged commit 5651d80 into zcash:main Dec 30, 2024
30 checks passed
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

Attention: Patch coverage is 47.32510% with 128 lines in your changes missing coverage. Please review.

Project coverage is 52.22%. Comparing base (6ead8f8) to head (e6b45f7).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
zcash_client_sqlite/src/wallet.rs 53.75% 37 Missing ⚠️
zcash_client_backend/src/data_api/wallet.rs 50.00% 35 Missing ⚠️
zcash_keys/src/keys.rs 53.57% 26 Missing ⚠️
components/zcash_protocol/src/consensus.rs 0.00% 21 Missing ⚠️
zcash_keys/src/address.rs 0.00% 6 Missing ⚠️
...lite/src/wallet/init/migrations/addresses_table.rs 50.00% 1 Missing ⚠️
...llet/init/migrations/ensure_orchard_ua_receiver.rs 0.00% 1 Missing ⚠️
..._sqlite/src/wallet/init/migrations/ufvk_support.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1675      +/-   ##
==========================================
- Coverage   52.30%   52.22%   -0.09%     
==========================================
  Files         179      179              
  Lines       21343    21353      +10     
==========================================
- Hits        11164    11152      -12     
- Misses      10179    10201      +22     

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

output_pool,
},
#[cfg(feature = "transparent-inputs")]
BuildRecipient::EphemeralTransparent { .. } => unreachable!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this unreachable?

ephemeral_address,
outpoint,
},
BuildRecipient::InternalAccount { .. } => unreachable!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this unreachable?

/// this UFVK.
///
/// Returns `None` if the specified index does not produce a valid diversifier.
/// Returns an error if the this key does not produce a valid receiver for a required receiver
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "if the this"

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.

Post-hoc utACK with questions.

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.

3 participants