Commit Graph

2895 Commits

Author SHA1 Message Date
Jack Grigg 2a98f94f05 Add more debug and trace logging
The `Debug` impl for `sapling::Node` is updated to output hex-encoded
bytes for readability.
2023-07-18 17:23:57 +00:00
Jack Grigg 510944777c Transactionally modify the wallet DB in `replace_queue_entries`
We don't want to delete old scan range queue entries unless we are
guaranteed to write the updated queue entries.
2023-07-18 17:23:57 +00:00
Jack Grigg 281dbd5524 Ensure that `extended_range` in `scan_complete` is a superset of `range`
Previously `extended_range` only covered the extent of the leaves of
all subtrees in which notes were found during a scan. When the scanned
range was large, this was not guaranteed to be contained within the
subtree leaves, causing an assertion failure when an invalid `ScanRange`
was constructed.
2023-07-18 17:23:57 +00:00
Jack Grigg cb887efa06 Use correct levels for cap nodes in `put_shard_roots`
The Merkle hashes used for the note commitment trees are domain
separated by level, so when pretending that the subtree roots are leaves
of the cap tree, we need to adjust for their level not being zero.

Closes zcash/librustzcash#874.

Co-authored-by: Sean Bowe <ewillbefull@gmail.com>
2023-07-18 17:23:57 +00:00
Jack Grigg f7163e9dd9 Code simplifications
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-07-18 17:23:55 +00:00
Jack Grigg bb920341a6 Fix bug in `RightFirstDisjoint` insertion logic 2023-07-18 17:22:48 +00:00
Jack Grigg 2c0acac1bd Use explicit arguments for internal `suggest_scan_ranges` helper
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-07-18 17:22:48 +00:00
Jack Grigg ed4b6dc9b9 Fix bugs in `ScanRange::truncate_*` 2023-07-18 17:22:48 +00:00
Jack Grigg e3aeb63e0a Fix off-by-one bugs with `ScanRange` end bounds
Maximum chain heights are end-inclusive, while `ScanRange` is
end-exclusive.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-07-12 16:27:52 +00:00
Kris Nuttycombe 352e1c709a Add a test for `scan_complete` and `update_chain_tip` 2023-07-07 20:13:45 -06:00
Kris Nuttycombe 6db4355fc4 Fix an error in dominance calculation. 2023-07-07 20:13:45 -06:00
Kris Nuttycombe 6fa0b46d8e Implement `suggest_scan_ranges` and `update_chain_tip`
This implements a priority queue backed by the wallet database for scan
range ordering. The scan queue is updated on each call to `put_blocks`
or to `update_chain_tip`.
2023-07-07 20:13:45 -06:00
str4d 4d5dc28ab1
Merge pull request #871 from zcash/shardtree-bugfixes
Bump patched dependencies to bring in shardtree bugfixes
2023-07-07 00:06:33 +01:00
str4d 4cb36d3d9d
Merge pull request #870 from zcash/fix-get_transaction
zcash_client_sqlite: Fix `WalletDb::get_transaction` for unmined txs
2023-07-07 00:05:24 +01:00
Jack Grigg 8d792bb7b5 zcash_client_sqlite: Fix `WalletDb::get_transaction` for unmined txs 2023-07-06 22:24:59 +00:00
Jack Grigg a11545459b Bump patched dependencies to bring in shardtree bugfixes 2023-07-06 22:19:21 +00:00
str4d c75ff850d7
Merge pull request #869 from nuttycom/feature/pre_dag_sync-put_blocks
Replace `put_block` with `put_blocks`
2023-07-06 22:52:15 +01:00
Kris Nuttycombe d55fa09464 Add a check to ensure that blocks passed to `put_blocks` are sequential. 2023-07-06 12:13:39 -06:00
Kris Nuttycombe 1b5a24a655 Batch data store writes of `put_block`
Instead of calling `put_block` for each block scanned,
`scan_cached_blocks` will now defer the block writes until the scan of a
batch is complete and will perform the block writes and note commitment
tree updates all within a single transaction.

This should ordinarily be fine in terms of memory consumption, because
the block data being saved is pruned to only that spend an output
information that is related to transactions in the wallet, which will
normally be sparse enough that the block range size that is appropriate
for a given platform to run within a batch scanner adequately bounds the
memory consumption of this pruned representation.
2023-07-06 12:13:39 -06:00
str4d 82705a4ae4
Merge pull request #867 from nuttycom/feature/pre_dag_sync-require_scan_range
zcash_client_backend: Make scan range bounds required in `data_api::chain::scan_cached_blocks`
2023-07-06 18:59:17 +01:00
Kris Nuttycombe 81a32f284e Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-07-06 11:24:16 -06:00
str4d bc17102557
Merge pull request #861 from nuttycom/feature/fast_spendability
Add interfaces & support for subtree root insertion.
2023-07-06 12:07:29 +01:00
Kris Nuttycombe 98147e0d7d Make `from_height` and `limit` parameters to `scan_cached_blocks` non-optional. 2023-07-05 18:56:19 -06:00
Kris Nuttycombe faccf56f04 Split `PoolType` enum into `PoolType` and `ShieldedProtocol`
There are cases where we wish to return informaiton that is relevant to
a specific shielded protocol and `Transparent` is an invalid case. This
is a minor preparatory refactoring that makes this distinction
expressible.
2023-07-05 18:20:43 -06:00
Kris Nuttycombe 1e5b23aeba zcash_client_backend: Add `put_sapling_subtree_roots` to `WalletCommitmentTrees`
Also add the `zcash_client_sqlite` implementation & tests for the new
method.
2023-07-05 18:18:20 -06:00
Kris Nuttycombe d8148f90e7
Merge pull request #831 from nuttycom/feature/pre_dag_sync
Migrations & data storage for pre-DAG-sync
2023-07-04 13:52:10 -06:00
Kris Nuttycombe c13c8c6678 Address comments from code review. 2023-07-03 17:08:01 -06:00
Kris Nuttycombe c363e71fa9 Rename proto::compact::{BlockMetadata => ChainMetadata} 2023-07-03 16:19:13 -06:00
Kris Nuttycombe 42ed6ba2a1 Rename `zcash_client_backend::welding_rig` to `zcash_client_backend::scanning` 2023-07-03 10:49:03 -06:00
Kris Nuttycombe 09a0096c74 Use valid serialized CommitmentTree values for migration tests. 2023-07-03 10:49:03 -06:00
Kris Nuttycombe e3aafdad19 Move chain continuity checks into `scan_block_with_runner`
In preparation for out-of-order range-based scanning, it is necessary
to ensure that the size of the Sapling note commitment tree is carried
along through the scan process and that stored blocks are always
persisted with the updated note commitment tree size.
2023-07-03 10:49:03 -06:00
Kris Nuttycombe 77b638012b Remove `zcash_client_backend::data_api::chain::validate_chain`
Local chain validation will be performed internal to
`scan_cached_blocks`, and as handling of chain reorgs will need to
change to support out-of-order scanning, the `validate_chain` method
will be superfluous. It is removed in advance of other changes in order
to avoid updating it to reflect the forthcoming changes.
2023-07-01 17:58:01 -06:00
Kris Nuttycombe e225a54d2e Use `NonZeroU32` for all `min_confirmations` values. 2023-06-30 12:37:41 -06:00
Kris Nuttycombe 8625e9a777 Handle parsing of the not-present `CommitmentTree` sentinel. 2023-06-30 12:08:06 -06:00
Kris Nuttycombe 70497a241c Only store z->t transaction data once, not once per Sapling output. 2023-06-30 10:42:48 -06:00
Kris Nuttycombe cd939f94c4 Ensure that checkpoints are ordered by position when querying for pruning. 2023-06-30 09:48:19 -06:00
Kris Nuttycombe 95745dd620 Use ruqlite::Rows::mapped to allow `collect` 2023-06-30 09:45:06 -06:00
Kris Nuttycombe 45177a51e1 Fix off-by-one error in scan_block_with_runner. 2023-06-30 09:30:24 -06:00
Kris Nuttycombe c05b3d0c8c Add a test demonstrating off-by-one error in `scan_block_with_runner` 2023-06-30 09:30:24 -06:00
Kris Nuttycombe 8fa3a08c0b Fix indexing error in checkpoint determination. 2023-06-30 09:30:24 -06:00
Kris Nuttycombe d65b129b43 Apply changelog, documentation & style suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-06-30 09:30:24 -06:00
Kris Nuttycombe ba709177d3 Reorganize Sapling and Orchard note commitment tree sizes in CompactBlock.
We move thes fields out into a separate BlockMetadata struct to ensure
that future additions to block metadata are structurally separated from
future additions to block data.
2023-06-29 15:35:18 -06:00
Kris Nuttycombe 547634e210 zcash_client_sqlite: Move the SqliteShardStore implementation out of the `wallet::sapling` module. 2023-06-29 15:35:18 -06:00
Kris Nuttycombe 106669d977 zcash_client_sqlite: Generalize SQLite-backed ShardStore impl to make it reusable for Orchard. 2023-06-29 15:35:18 -06:00
Kris Nuttycombe 0a4236f725 zcash_client_sqlite: Add tests for sqlite-backed ShardTree & fix revealed issues. 2023-06-29 15:35:18 -06:00
Kris Nuttycombe 425b5e01d7 zcash_client_sqlite: Support shardtree checkpoint functionality 2023-06-29 15:35:18 -06:00
Kris Nuttycombe c42cffeb1d zcash_client_backend: Replace `WalletWrite::advance_by_block` with `WalletWrite::put_block`
Also, add assertions to prevent attempting the creation of zero-conf
shielded spends.
2023-06-29 15:35:18 -06:00
Kris Nuttycombe d11f3d2acc zcash_client_sqlite: Add shardtree truncation & checkpoint operations. 2023-06-29 15:35:18 -06:00
Kris Nuttycombe ade882d01c zcash_client_sqlite: Add shard & checkpoint insertion. 2023-06-29 15:35:18 -06:00
Kris Nuttycombe 9f2bb94a5e zcash_client_sqlite: Add shard persistence to wallet migration. 2023-06-29 15:35:18 -06:00