Commit Graph

2954 Commits

Author SHA1 Message Date
Kris Nuttycombe b3474724a9
Merge pull request #909 from AArnott/AArnott-patch-1
Fix API doc comment on UnifiedSpendingKey
2023-08-24 13:19:05 -06:00
Andrew Arnott 9859066c72
Fix API doc comment on UnifiedSpendingKey
This fixes a simple copy/paste error of the docs from the unified viewing key.
2023-08-24 07:47:30 -06:00
Daira Emma Hopwood b580c42bdc
Merge pull request #903 from nuttycom/sbs/scan_queue_init
zcash_client_sqlite: Initialize the scan queue as part of `init_blocks_table`
2023-08-22 14:30:55 +01: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
str4d f61d60bb96
Merge pull request #894 from nuttycom/sbs/select_only_witnessable
zcash_client_sqlite: Only select notes for which witnesses can be constructed.
2023-08-18 01:15:50 +01: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
str4d 104577c108
Merge pull request #896 from nuttycom/chain_tip_target_height
zcash_client_sqlite: Ensure that target and anchor heights are relative to the chain tip.
2023-08-17 22:29:13 +01: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
str4d d25f2bd6ab
Merge pull request #893 from zcash/scanning-bugfixes
Scanning bugfixes
2023-08-10 00:16:10 +01:00
Jack Grigg d3fc9670d5 zcash_client_backend: Fix `scan_cached_blocks` panic with genesis block
If `from_height = 0` and `limit > 1`, then the conditional being used to
initialise `continuity_check_metadata` was previously running for every
block, and would therefore panic while processing the block at height 1.
2023-08-09 17:57:00 +00: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
str4d 81d1928497
Merge pull request #890 from nuttycom/received_note_id_display
Add `Display` impl for `ReceivedNoteId`
2023-08-07 20:06:28 +01:00
Kris Nuttycombe 1c4e63718f Add `Display` impl for `ReceivedNoteId` 2023-08-07 12:24:05 -06:00
str4d f6eef20f62
Merge pull request #888 from nuttycom/feature/tx_output_note_refs
Restrict use of backend-specific note identifiers.
2023-08-07 18:55:11 +01:00
Kris Nuttycombe f602ec125d Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-08-07 11:28:28 -06:00
Kris Nuttycombe d3b7dffa3c zcash_client_backend: Restrict use of backend-specific note identifiers.
In general, it is preferable to use globally relevant identifiers where
possible. This PR removes the `WalletRead::TxRef` associated type in
favor of using `TxId` directly for the transaction identifier, and
restricts the use of the `NoteRef` type to those scenarios where the
result of one query is intended to be used directly as the input to
another query.

Closes #834
2023-08-07 11:27:38 -06:00
str4d d7bd566b21
Merge pull request #889 from nuttycom/avoid_checkpoint_add_conflict
zcash_client_sqlite: Ensure that re-adding the same checkpoint information does not cause a database conflict.
2023-08-07 18:18:53 +01:00
str4d cdb904a28c
Merge pull request #886 from nuttycom/bug/memo_row_absent
Fix a number of bugs related to the creation of change memos and storage of empty memos.
2023-08-07 15:49:30 +01:00
Kris Nuttycombe 522f1e4da0 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-08-07 08:07:21 -06:00
Kris Nuttycombe 027b3c9af8 zcash_client_sqlite: Ensure that re-adding the same checkpoint information does not cause a database conflict.
The `add_checkpoint` method is intended to be idempotent. In the case
that we add a checkpoint at an already-checkpointed block height, we
should only raise an error in the case that the note commitment tree
position or the set of notes spent in the checkpointed block has
changed.
2023-08-04 15:12:04 -06:00
Kris Nuttycombe 0ee45e40c4 zcash_client_sqlite: Replace Either-based definition of `wallet::commitment_tree::Error` with a bespoke error type. 2023-08-04 15:01:15 -06:00
Kris Nuttycombe cb0d16cfa9 Fix clippy complaint. 2023-08-04 14:35:58 -06:00
Kris Nuttycombe 90412ebdc2 Fix SentTransactionOutput documentation. 2023-08-04 14:11:24 -06:00
Kris Nuttycombe a5a8562ddd zcash_client_backend, zcash_client_sqlite: Ensure consistency between sent & stored memos. 2023-08-04 14:05:00 -06:00
Kris Nuttycombe f0b2fc3421 zcash_client_sqlite: Store the empty memo as a single 0xf6 byte. 2023-08-02 11:35:27 -06:00
Kris Nuttycombe 40ecaaf758 zcash_client_backend: Fix error where change memos were not being included in sent transactions. 2023-08-02 11:35:27 -06:00
Kris Nuttycombe e718e76989 zcash_client_sqlite: Add a test that demonstrates the expected behavior of `get_memo` for empty-memo situations. 2023-08-02 11:35:27 -06:00
str4d eade2acab9
Merge pull request #887 from nuttycom/fix/time_msrv
Pin `time` dependency to avoid forced MSRV bump.
2023-08-02 18:34:24 +01:00
Kris Nuttycombe e640f82ff6 Pin `time` dependency to avoid forced MSRV bump.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-08-02 10:22:54 -06:00
str4d 176ec3e96f
Merge pull request #884 from zcash/update-shardtree-rev
Migrate to latest `shardtree` revision
2023-07-27 21:43:28 +01:00
Jack Grigg facd4ccac5 Migrate to latest `shardtree` revision 2023-07-25 20:57:49 +00:00
str4d b4f083f4eb
Merge pull request #883 from zcash/put_blocks-parallel-tree-building
zcash_client_sqlite: Build subtrees from new commitments in a threadpool
2023-07-25 18:24:41 +01:00
str4d b2bb1b8716
Merge pull request #881 from zcash/zcash_client_backend-cache-ivks
zcash_client_backend: Precompute IVKs in `scan_cached_blocks`
2023-07-25 17:00:14 +01:00
str4d 20c53fc7cd
Merge pull request #882 from zcash/nullifier-map-index
`zcash_client_sqlite`: Add index for foreign key of `nullifier_map` table
2023-07-25 16:59:35 +01:00
Jack Grigg 99ecdf3a89 zcash_client_sqlite: Build subtrees from new commitments in a threadpool
The new `multicore` feature flag can be used to disable this behaviour.
2023-07-25 15:59:03 +00:00
Jack Grigg 0f6970aefd zcash_client_sqlite: Cache statement for `wallet::prune_nullifier_map` 2023-07-25 13:46:44 +00:00
Jack Grigg e773cd3ed4 zcash_client_sqlite: Add index for foreign key of `nullifier_map` table
This greatly improves the performance of `wallet::prune_nullifier_map`
by speeding up `ON DELETE CASCADE`.
2023-07-25 13:45:52 +00:00
Jack Grigg 2d3d5e8fe6 zcash_client_backend: Precompute IVKs in `scan_cached_blocks` 2023-07-25 02:21:15 +00:00
Jack Grigg b33330f9ca zcash_client_backend: Accept owned keys in `scan_block_with_runner`
This internal helper function can now take owned or borrowed keys. The
public `scan_block` function is left unaltered.
2023-07-25 02:14:18 +00:00
str4d 46ca3202e4
Merge pull request #879 from zcash/877-shardtree-migration-perf
zcash_client_sqlite: Only import recent frontiers into `ShardTree`
2023-07-24 00:09:35 +01:00
Jack Grigg ed06a37b09 zcash_client_sqlite: Mark existing blocks scanned in `shardtree` migration
The `shardtree` migration is applied to a database state that was
created via linear scanning, so we have complete wallet information for
those blocks.
2023-07-21 21:01:03 +00:00
Jack Grigg 97a3f818ec zcash_client_sqlite: Only import recent frontiers into `ShardTree`
We only need to load frontiers into the ShardTree that are close enough
to the wallet's known chain tip to fill `PRUNING_DEPTH` checkpoints, so
that ShardTree's witness generation will be able to correctly handle
anchor depths. Loading frontiers further back than this doesn't add any
useful nodes to the ShardTree (as we don't support rollbacks beyond
`PRUNING_DEPTH`, and we won't be finding notes in earlier blocks), and
hurts performance (as frontier importing has a significant Merkle tree
hashing cost).

Closes zcash/librustzcash#877.
2023-07-21 20:59:24 +00:00
str4d 2ed0747b67
Merge pull request #878 from zcash/876-nullifier-map
zcash_client_sqlite: Maintain a nullifier map from out-of-order scanning
2023-07-21 21:57:12 +01:00
Jack Grigg 0f2689b9c3 zcash_client_sqlite: Maintain a nullifier map from out-of-order scanning
Closes zcash/librustzcash#876.
2023-07-21 18:01:52 +00:00
Jack Grigg 4d2abd5c3a zcash_client_sqlite: Add test showing out-of-order balance problem 2023-07-21 17:53:14 +00:00