Commit Graph

569 Commits

Author SHA1 Message Date
Jack Grigg b54969953f zcash_client_sqlite: Simplify range query in `replace_queue_entries`
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-09-08 03:43:07 +00:00
Kris Nuttycombe 341379ee8d
Merge pull request #951 from nuttycom/wallet/balance_for_all_accounts
zcash_client_sqlite: Return a balance for every account from `get_wallet_summary`
2023-09-07 11:49:23 -06:00
Kris Nuttycombe 8dfab23683
Merge pull request #946 from nuttycom/test/unspendable_chain_tip
zcash_client_sqlite: Add a test demonstrating chain tip fund unavailability
2023-09-07 11:27:51 -06:00
Kris Nuttycombe 2131cd547e zcash_client_sqlite: Return a balance for every account from `get_wallet_summary`
Fixes #948
2023-09-07 11:02:59 -06:00
Kris Nuttycombe 0937c6a384 zcash_client_sqlite: Add a test demonstrating chain tip fund unavailability.
This also factors out and cleans up repeated code that checks for anchor
shard completeness.
2023-09-07 10:55:16 -06:00
Kris Nuttycombe 19582a4ca6
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-09-07 10:29:21 -06:00
Kris Nuttycombe a6328a098f zcash_client_sqlite: Bound creation of scan ranges on wallet birthday.
This modifies `update_chain_tip` and `scan_complete` to ensure that
newly created scan ranged do not extend below the wallet birthday
height.

Fixes #947
2023-09-07 09:58:21 -06:00
Kris Nuttycombe f56c5d8f4b Measure scan progress from wallet birthday, not the fully scanned height. 2023-09-06 12:07:18 -06:00
Jack Grigg c9d58b223c zcash_client_sqlite: Fix bug in `check_shard_discontinuity`
The previous code was checking that the existing shard range was at
least partially inside the proposed insertion range, but this didn't
handle the case where the proposed insertion range was fully contained
by the existing shard range.
2023-09-06 17:13:12 +00:00
Kris Nuttycombe 65420f59df zcash_client_backend: Add `WalletRead::block_max_scanned`
Fixes #941
2023-09-06 08:49:43 -06:00
str4d b4772e948d
Merge pull request #938 from ebfull/check-subtree-discontinuity
Check for potential discontinuities when inserting into the `*_tree_shards` table
2023-09-06 01:05:18 +01:00
str4d 236e9f2cd0
Merge pull request #914 from nuttycom/sbs/nonlinear_sync_aware_balance
Add `get_wallet_summary` to `WalletRead`
2023-09-06 01:04:42 +01:00
str4d 1e12e9d0e6
Clarify zero-conf shielded note behaviour for `get_wallet_summary`
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-06 00:18:11 +01:00
Kris Nuttycombe 6cbb107c71 zcash_client_sqlite: allow zero-conf transactions in unshielded balance. 2023-09-05 16:49:36 -06:00
Kris Nuttycombe 7abd1324de Apply suggestions from code review
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-09-05 16:49:36 -06:00
Kris Nuttycombe f53ea2d778 Add `get_wallet_summary` to `WalletRead`
The intent of this API is to provide a single API which returns in a
single call:

* per-account balances, including pending values
* wallet sync progress

Fixes #865
Fixes #900
2023-09-05 16:06:55 -06:00
Sean Bowe 976b0f0931 Check for potential discontinuities when inserting into the `*_tree_shards` table.
Closes #924
2023-09-05 15:25:26 -06:00
Kris Nuttycombe 6478113855
Merge pull request #935 from nuttycom/sbs/post_907_cleanup
Address unresovled code review comments from #907
2023-09-05 10:42:43 -06:00
Kris Nuttycombe dd60f51d3c Address unresovled code review comments from #907 2023-09-05 09:30:17 -06:00
str4d f132af1f33
Documentation fixes
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-05 15:54:15 +01:00
Jack Grigg afec2ee218 `zcash_client_sqlite`: Fix refactor bug: ignore pre-Sapling chain tips
The pre-refactor code did this correctly, but the comment was moved
without fully moving the logic.
2023-09-05 14:52:33 +00:00
Jack Grigg 81d7d9349c zcash_client_sqlite: Fix bugs in `update_chain_tip`
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-09-02 03:01:23 +00:00
Jack Grigg 9f9a1fb92f zcash_client_sqlite: Rework `update_chain_tip` tests to pin behaviour 2023-09-02 03:01:19 +00:00
Kris Nuttycombe 5b3f544102 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-01 10:38:20 -06:00
Kris Nuttycombe a51712830f zcash_client_sqlite: ignore unscanned ranges below the birthday height in note selection 2023-09-01 10:12:19 -06:00
Kris Nuttycombe 0b0274cdc1 zcash_client_backend: Make wallet and account birthday heights available via the data access API 2023-09-01 10:11:43 -06:00
Kris Nuttycombe 459dc49b54 zcash_client_backend: Accept account birthday as a parameter to `create_account`
This also removes the zcash_client_sqlite-specific database
initialization procedures in favor of a standardized approach using the
methods available via the data access API.
2023-09-01 10:08:17 -06:00
Kris Nuttycombe c99c0fc884 zcash_client_sqlite: Enable forced re-scanning of previously scanned ranges.
When `force_rescans` is set to `true` in a call to
`replace_queue_entries`, previously scanned ranges will have their
existing priority overwritten by the scan priority for a provided range;
otherwise, the existing scan priority dominance rule continues to be
enforced. This enables us to require previously scanned ranges be
re-scanned without interfering with higher-priority scan operations.
2023-09-01 08:13:11 -06:00
Kris Nuttycombe 8bcc3c1cc1 Fix unused imports. 2023-08-31 17:56:04 -06:00
Kris Nuttycombe fb8c3a178c zcash_client_sqlite: Ensure that fragmentation also can't occur at scan range ends. 2023-08-31 17:52:29 -06:00
Kris Nuttycombe 4fe9d61959
zcash_client_sqlite: Fix a comment on range inclusion.
Co-authored-by: str4d <thestr4d@gmail.com>
2023-08-31 15:07:07 -06:00
Kris Nuttycombe bcafb7d4b4 zcash_client_sqlite: Prevent scan range fragmentation.
Fixes #922

Co-authored-by: Sean Bowe <ewillbefull@gmail.com>
2023-08-31 14:18:30 -06:00
Kris Nuttycombe 22b6ddd754 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-08-29 17:02:46 -06:00
Kris Nuttycombe ff8104fa75 zcash_client_sqlite: (testing) Initialize wallets using an `AccountBirthday` struct. 2023-08-28 19:25:52 -06:00
Kris Nuttycombe a238007e14 zcash_client_sqlite: Remove `testing::network` global accessor function. 2023-08-28 17:27:23 -06:00
Kris Nuttycombe 3be55ae964 zcash_client_backend: Add test-only convenience methods for default addresses. 2023-08-28 14:05:17 -06:00
Jack Grigg 8af74de931 `zcash_client_sqlite`: Add `TestState::propose_shielding`
Currently unused (causing an expected lint), but will be in an upcoming PR.
2023-08-28 18:58:37 +00:00
Jack Grigg 578eac15df zcash_client_sqlite: Rename `TestRunner` to `TestState` 2023-08-28 18:54:35 +00:00
Jack Grigg 84a5d5ca94 zcash_client_sqlite: Migrate all tests to `TestBuilder` 2023-08-28 16:55:51 +00:00
Jack Grigg ce3e4cd34a zcash_client_sqlite: Introduce `TestBuilder` and `TestRunner`
These provide a standard way to set up tests, and helper methods for
performing common test actions.
2023-08-28 16:55:51 +00:00
Jack Grigg 7ba36c7bd2 zcash_client_sqlite: Move testing helper functions into module 2023-08-25 23:16:37 +00:00
Kris Nuttycombe 4d6e236e23
zcash_client_sqlite: minor test documentation improvement.
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-08-21 17:13:45 -06:00
Kris Nuttycombe 61ac79c006 Add debug logging of ignored block range in `init_blocks_table` 2023-08-21 12:26:56 -06:00
Kris Nuttycombe b3be0318c6 zcash_client_sqlite: Initialize the scan queue as part of `init_blocks_table`
Fixes #902
Fixes #898
2023-08-21 09:03:31 -06:00
Kris Nuttycombe 1f8108e8da zcash_client_sqlite: Use constant for SAPLING_SHARD_HEIGHT in v_sapling_shard_unscanned_ranges 2023-08-17 16:20:54 -06:00
Kris Nuttycombe 75ca045786 zcash_client_sqlite: Note selection requires commitment tree positions to be known.
Fixes #895
2023-08-17 16:20:54 -06:00
Kris Nuttycombe 0e7ee0ebd7 zcash_client_sqlite: Ensure that the shard at the chain tip is complete to anchor height.
If the tip shard has any un-scanned range below the anchor height, we
can't compute witnesses for any of our notes.
2023-08-17 16:20:54 -06:00
Kris Nuttycombe 50ea2a5b0f zcash_client_sqlite: Only select notes for which witnesses can be constructed.
This change modifies the implementation of `get_spendable_sapling_notes`
and `select_spendable_sapling_notes` to only return notes at positions
where the associated note commitment tree shard has been fully scanned.
This is slightly more conservative than it needs to be, because
there could be cases where witnesses imported into the tree in the
`shardtree_support` migration cover the complete range of a subtree (and
hence that subtree doesn't need to be re-scanned). However, we can't
detect or depend upon that condition in general without attempting to
create a witness for each note retrieved.

A possible alternative to this approach would be to not bound our query
results on the requested total, and instead attempt to construct a
witness for each note we retrieve, skipping the note if we cannot
construct a witness. However, given that accessing the note commitment
tree can be a costly operation requiring nontrivial deserialization
costs, the more conservative database-oriented approach is perhaps
better.
2023-08-17 16:20:54 -06:00
Kris Nuttycombe dee43854cb zcash_client_sqlite: Ensure that target and anchor heights are relative to the chain tip.
Prior to the scan-before-sync changes, the wallet was able to assume
that the maximum scanned block height at the time of the spend was
within a few blocks of the chain tip. However, under linear scanning
after the spend-before-sync changes this invariant no longer holds,
resulting in a situation where in linear sync conditions the wallet
could attempt to create transactions with already-past expiry heights.

This change separates the notion of "chain tip" from "max scanned
height", relying upon the `scan_queue` table to maintain the wallet's
view of the consensus chain height and using information from the
`blocks` table only in situations where the latest and/or earliest
scanned height is required.

As part of this change, the `WalletRead` interface is also modified to
disambiguate these concepts.
2023-08-16 11:53:24 -06:00
Jack Grigg 44abd3450b Require `BlockSource::with_blocks` fail on non-existent `from_height`
Previously this was not clearly specified, and the implementations in
`zcash_client_sqlite` behaved similarly to when `from_height = None`.

Closes zcash/librustzcash#892.
2023-08-09 17:57:00 +00:00