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

Improve progress representation in WalletSummary #1541

Merged
merged 5 commits into from
Sep 20, 2024

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Sep 19, 2024

We now split progress into "scan progress" and "recover progress" based on the recover-until height (if set, otherwise recover progress is always 100%).

Part of #1070.

@str4d str4d force-pushed the 1070-zcb-wallet-summary-progress branch 3 times, most recently from 76670cf to 711b4c8 Compare September 19, 2024 03:44
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 63.11111% with 83 lines in your changes missing coverage. Please review.

Project coverage is 60.50%. Comparing base (f7228a5) to head (b4da98e).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
zcash_client_sqlite/src/wallet.rs 62.78% 83 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1541      +/-   ##
==========================================
+ Coverage   60.46%   60.50%   +0.04%     
==========================================
  Files         147      147              
  Lines       17115    17313     +198     
==========================================
+ Hits        10348    10476     +128     
- Misses       6767     6837      +70     

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

@str4d str4d force-pushed the 1070-zcb-wallet-summary-progress branch from 711b4c8 to d872202 Compare September 19, 2024 12:25
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.

My review is not yet complete, but the last comment about the use of last_completed_subtree_index is blocking.

@@ -839,21 +839,23 @@ fn subtree_scan_progress(
fully_scanned_height: BlockHeight,
chain_tip_height: BlockHeight,
) -> Result<Option<Ratio<u64>>, SqliteClientError> {
let mut stmt_scanned_count_from = conn.prepare_cached(&format!(
Copy link
Contributor

Choose a reason for hiding this comment

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

One of the things that I "left for later" when I was originally writing this code was the fact that this query seems potentially expensive/wasteful. It's probably not worth changing without benchmarking, but it does feel weird to do a sum over potentially millions of rows as a matter of course.

zcash_client_sqlite/src/wallet.rs Show resolved Hide resolved
zcash_client_backend/src/data_api.rs Show resolved Hide resolved
let mut stmt_start_tree_size = conn.prepare_cached(&format!(
"SELECT MAX({table_prefix}_commitment_tree_size - {output_count_col})
FROM blocks
WHERE height <= :start_height",
Copy link
Contributor

Choose a reason for hiding this comment

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

This query could potentially be inefficient; it would really be best if we could take advantage of our understanding that the note commitment tree size monotonically increases with block height instead of performing a million subtractions.

zcash_client_backend/CHANGELOG.md Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
Comment on lines +1034 to +1038
// TODO: it would be nice to be able to reliably have the size of the
// commitment tree at the chain tip without having to have scanned that
// block.
Copy link
Contributor

Choose a reason for hiding this comment

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

I have wanted this before. It would be possible to use the GetLatestTreeState data for this, but really it should just be part of the GetLatestBlock results. That's a simple additive change to the protobuf; we should just do it.

zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
@str4d str4d force-pushed the 1070-zcb-wallet-summary-progress branch from d872202 to 8cc7566 Compare September 19, 2024 21:46
@str4d
Copy link
Contributor Author

str4d commented Sep 19, 2024

Force-pushed to address review comments.

@str4d str4d force-pushed the 1070-zcb-wallet-summary-progress branch from 8cc7566 to d29a9fd Compare September 19, 2024 22:25
@str4d
Copy link
Contributor Author

str4d commented Sep 19, 2024

Force-pushed to address more comments and fix a compilation bug.

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.

A couple of off-by-one errors.

zcash_client_sqlite/src/wallet/scanning.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet/scanning.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet/scanning.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
zcash_client_sqlite/src/wallet.rs Outdated Show resolved Hide resolved
After splitting recover progress out from scan progress, the
overestimation of the chain tip tree size became much more noticeable.
We now extrapolate from the most recent known "notes per block" rate.
…ests

The wrong subtree was being completed, which didn't matter before but
does now that scan progress is extrapolated.
@str4d str4d force-pushed the 1070-zcb-wallet-summary-progress branch from d29a9fd to b4da98e Compare September 20, 2024 16:40
@str4d
Copy link
Contributor Author

str4d commented Sep 20, 2024

Force-pushed to address remaining comments.

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.

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 b4da98e

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