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

Check for colliding component FVKs #1489

Merged
merged 3 commits into from
Aug 11, 2024

Conversation

daira
Copy link
Contributor

@daira daira commented Aug 10, 2024

When adding an account, check whether any component of its UFVK (if available) collides with an existing imported or derived FVK.

This does not check for collisions on IVK for Incoming accounts (#1490), which is okay because those are not yet exposed in the public API.

Builds on #1479, fixes #1474

@daira daira requested review from nuttycom and str4d August 10, 2024 19:38
@daira daira force-pushed the check-for-colliding-component-fvks branch from fcbf3f3 to 90f8789 Compare August 10, 2024 19:45
Copy link

codecov bot commented Aug 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.13%. Comparing base (9cfce18) to head (bd38645).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1489      +/-   ##
==========================================
- Coverage   61.16%   61.13%   -0.03%     
==========================================
  Files         141      141              
  Lines       16661    16663       +2     
==========================================
- Hits        10190    10187       -3     
- Misses       6471     6476       +5     

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

@daira daira force-pushed the check-for-colliding-component-fvks branch 2 times, most recently from 050a58e to 59d9224 Compare August 10, 2024 20:53
// Make a best effort to determine the AccountId of the pre-existing row
// An account conflict occurred. This should already have been caught by
// the check using `get_account_for_ufvk` above, but in case it wasn't,
// make a best effort to determine the AccountId of the pre-existing row
// and provide that to our caller.
Copy link
Contributor Author

@daira daira Aug 10, 2024

Choose a reason for hiding this comment

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

This code just below this will no longer be reached when a collision occurs, which explains the small reduction in test coverage.

(if available) collides with an existing imported or derived FVK.

This does not check for collisions on IVK for `Incoming` accounts.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
@daira daira force-pushed the check-for-colliding-component-fvks branch from 59d9224 to bd38645 Compare August 10, 2024 23:24
let seed_based = st.wallet_mut().create_account(&seed, &birthday).unwrap();
let seed_based_account = st.wallet().get_account(seed_based.0).unwrap().unwrap();
let ufvk = seed_based_account.ufvk().unwrap();

assert_matches!(
st.wallet_mut().import_account_ufvk(ufvk, &birthday, AccountPurpose::Spending),
st.wallet_mut().import_account_hd(&seed, zip32_index_0, &birthday),
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 import_account_ufvk check is done in check_collisions below, so this is adding an extra check for collisions between create_account and import_account_hd.

Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK bd38645

@nuttycom nuttycom merged commit b0a3ad3 into zcash:main Aug 11, 2024
26 of 27 checks passed
@str4d
Copy link
Contributor

str4d commented Sep 16, 2024

Post-hoc utACK bd38645

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.

Precisely document same-UFVK errors on account creation and ensure they are per-component
3 participants