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

Add WalletRead::get_seed_account #1259

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

nuttycom
Copy link
Contributor

Builds atop #1258

Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 12.00000% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 63.22%. Comparing base (5e810d3) to head (79f5bb4).

Files Patch % Lines
zcash_client_sqlite/src/wallet.rs 0.00% 18 Missing ⚠️
zcash_client_backend/src/data_api.rs 0.00% 2 Missing ⚠️
zcash_client_sqlite/src/lib.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1259      +/-   ##
==========================================
- Coverage   63.32%   63.22%   -0.11%     
==========================================
  Files         121      121              
  Lines       13496    13519      +23     
==========================================
+ Hits         8546     8547       +1     
- Misses       4950     4972      +22     

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

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 1271f98

zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet.rs Show resolved Hide resolved
@str4d str4d added this to the Librustzcash Zashi 1.0 milestone Mar 12, 2024
@nuttycom nuttycom force-pushed the sqlite_wallet/get_seed_account branch from 1271f98 to 79f5bb4 Compare March 12, 2024 17:50
@nuttycom nuttycom requested a review from str4d March 12, 2024 17:51
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 79f5bb4

@@ -69,6 +69,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
(account_type = {account_type_imported} AND hd_seed_fingerprint IS NULL AND hd_account_index IS NULL)
)
);
CREATE UNIQUE INDEX hd_account ON accounts_new (hd_seed_fingerprint, hd_account_index);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the full subtleties of UNIQUE INDEX vs CONSTRAIN UNIQUE and why you'd choose one over the other. AFAICT:

  • They both produce an index.
  • UNIQUE INDEX can be removed and added without altering the table (and I guess CREATE UNIQUE INDEX fails if the table contains non-unique data?)
  • UNIQUE INDEX can include expressions
  • CONSTRAIN UNIQUE has greater support in ON CONFLICT logic (whereas UNIQUE INDEX only supports INSERT ... ON CONFLICT I think).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was looking at this today. I think that the ON CONFLICT capabilities are actually the same, from what I was reading, at least for recent releases? Given that the separate indices can be dropped and added independently, I think I have a slight preference for them, but I don't think it makes much difference one way or the other.

Comment on lines +439 to +443
let expected_indices = vec![
r#"CREATE UNIQUE INDEX accounts_ufvk ON "accounts" (ufvk)"#,
r#"CREATE UNIQUE INDEX accounts_uivk ON "accounts" (uivk)"#,
r#"CREATE UNIQUE INDEX hd_account ON "accounts" (hd_seed_fingerprint, hd_account_index)"#,
r#"CREATE INDEX "addresses_accounts" ON "addresses" (
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this; I was unaware that uniqueness constraints were starting to be embedded in the indices (which prior to now I only thought were present for performance). I rely heavily on changes to init.rs to track changes to the database structure and determine what constraints are applied.

@nuttycom nuttycom merged commit 3dcac7a into zcash:main Mar 12, 2024
20 of 25 checks passed
@nuttycom nuttycom deleted the sqlite_wallet/get_seed_account branch March 12, 2024 18:29
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