Commit Graph

3196 Commits

Author SHA1 Message Date
Kris Nuttycombe 8ebcb6dfd6
Merge pull request #965 from nuttycom/private_tree_ser
zcash_client_sqlite: `serialization` module should not have been public.
2023-09-11 19:48:22 -06:00
Kris Nuttycombe f2dcba3a34 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-09-11 18:39:27 -06:00
Kris Nuttycombe 24e8c82546 zcash_client_backend: Get commitment tree depth for a given number of confirmations from the database.
This fixes the following bug:

Due to complexities related to non-linear scanning, checkpoints are only
added to the wallet's commitment tree in cases where there are notes
discovered within a scanned block. At present, the `shardtree` API only
makes it possible to add multiple checkpoints of the same tree state
when adding checkpoints at the chain tip, and this functionality is not
used by `zcash_client_backend` because we perform checkpoint insertion
in batches that may contain gaps in the case that multiple blocks
contain no Sapling notes. While it would be possible to fix this by
altering the `shardtree` API to permit explicit insertion of multiple
checkpoints of the same tree state at a given note position, this fix
takes a simpler approach.

Instead of ensuring that a checkpoint exists at every block and
computing the required checkpoint depth directly from the minimum number
of confirmations required when attempting a spend, we alter the
`WalletCommitmentTrees` API to allow internal information of the note
commitment tree to be used to determine this checkpoint depth, given the
minimum number of commitments as an argument. This allows us to select a
usable checkpoint from the sparse checkpoint set that resulted from the
sparse insertion of checkpoints described above.
2023-09-11 18:38:54 -06:00
Daira Emma Hopwood 101c9c0ea4 Add passing test for current behaviour of wallet restore from seed.
refs #936

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-12 01:33:12 +01:00
Daira Emma Hopwood 401af23484 Improve wallet tests.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-12 01:33:12 +01:00
str4d 3c2787ce89
Merge pull request #966 from zcash/ci-build-latest
CI: Add job to build with latest Rust and dependencies
2023-09-12 01:19:38 +01:00
Kris Nuttycombe 771e4013c3 Move shardtree serialization to the `zcash_client_backend` crate 2023-09-11 18:18:08 -06:00
Jack Grigg c1dc648cf0 CI: Add job to build with latest Rust and dependencies
This ensures that we catch non-MSRV compilation breakages caused by
SemVer updates.
2023-09-11 23:50:11 +00:00
Kris Nuttycombe 28f1f7d296 zcash_client_sqlite: Add a test for when gaps exist in checkpoints. 2023-09-11 17:08:51 -06:00
Kris Nuttycombe 92237a5558 zcash_client_sqlite: `serialization` module should not have been public. 2023-09-11 16:48:13 -06:00
str4d 46e2c4c800
Merge pull request #964 from zcash/check-in-lockfile
Add `Cargo.lock` to repository
2023-09-11 23:38:42 +01:00
Jack Grigg 15fed12e95 cargo update
The `blake2*_simd` updates are ignored because they bump MSRV.
2023-09-11 22:12:52 +00:00
Jack Grigg fad1b91377 Add `Cargo.lock` to repository
This is currently "whatever lockfile happened to last work for str4d",
but going forward will be the lockfile we use for testing our MSRV. See
https://blog.rust-lang.org/2023/08/29/committing-lockfiles for rationale
on this change.
2023-09-11 22:12:52 +00:00
Kris Nuttycombe 1b1116ed0c
Merge pull request #958 from zcash/sbs-release-candidates
Spend-before-Sync release candidates
2023-09-08 14:33:04 -06:00
Jack Grigg 62e3299255 zcash_client_sqlite 0.8.0-rc.1 2023-09-08 19:58:46 +00:00
Jack Grigg 9db68c76ee zcash_client_backend 0.10.0-rc.1 2023-09-08 19:50:53 +00:00
Jack Grigg 87ca71b8db zcash_proofs 0.13.0-rc.1 2023-09-08 19:48:55 +00:00
Jack Grigg 67b84c25e0 zcash_primitives 0.13.0-rc.1 2023-09-08 19:45:54 +00:00
Kris Nuttycombe 4c4364630c
Merge pull request #955 from nuttycom/sbs/pre_release_cleanup
Pre-release cleanups
2023-09-08 13:38:52 -06:00
Kris Nuttycombe 46cc6666df Address comments from code review.
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-08 13:03:53 -06:00
Jack Grigg 94c1f2413d Migrate to `incrementalmerkletree 0.5`, `orchard 0.6` 2023-09-08 18:57:25 +00:00
Kris Nuttycombe 61e06d2227 zcash_client_sqlite: Update CHANGELOG.md for 0.8.0 release 2023-09-08 11:02:37 -06:00
Jack Grigg 6e34e2d113 zcash_client_backend: Migrate to `prost 0.12`, `tonic 0.10` 2023-09-08 16:21:48 +00:00
Kris Nuttycombe 1fe763de5f zcash_client_backend: Update CHANGELOG.md for 0.10.0 release. 2023-09-08 10:15:49 -06:00
Kris Nuttycombe 0ea2290670 zcash_primitives: update CHANGELOG.md in preparation for the 0.13.0 release 2023-09-08 08:54:39 -06:00
Kris Nuttycombe aa039819df Fix formatting & clippy lints. 2023-09-08 08:46:20 -06:00
dependabot[bot] 3a7ef20947
build(deps): bump actions/cache from 3.3.1 to 3.3.2
Bumps [actions/cache](https://github.com/actions/cache) from 3.3.1 to 3.3.2.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.3.1...v3.3.2)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-08 05:24:37 +00:00
Kris Nuttycombe 85156e2b7c
Merge pull request #953 from zcash/cornucopia-of-bugs
Fix a veritable cornucopia of bugs
2023-09-07 22:50:05 -06:00
Jack Grigg 504efcfab7 zcash_client_sqlite: Fix scan range matching with incomplete shard
The `v_sapling_shard_scan_ranges` view pairs every scan range with every
shard range, such that each row shows an overlapping pair.

For the complete shards, this is an overlap check between two ranges,
which the previous query was performing correctly (if verbosely).

For the last incomplete shard, we have a half-open range that needs to
be handled separately. The previous query only handled the case where a
scan range was contained within the last shard, and did not handle the
case where the scan range contained the last shard.

This led to a puzzling bug, where `WalletDb::get_wallet_summary` was
sometimes treating any note received within the last shard as part of
the wallet's pending balance. If the wallet's scan queue contained a
range that encompassed the last incomplete shard, the bug in the
`v_sapling_shard_scan_ranges` view meant that it omitted any mention of
the last shard, which translated into these notes being considered
unmined when joining `sapling_received_notes` against the sub-view
`v_sapling_shards_scan_state`.

The bug was made harder to diagnose due to the previous commit's bug
that was causing scan ranges to not be correctly merged; this resulted
in smaller scan ranges that were more likely to be contained within the
last shard, making it visible in `v_sapling_shard_scan_ranges` and
enabling notes to be detected as mined.

The fixed view uses a simpler query that enables us to handle complete
and incomplete shards together.

Time spent investigating and fixing: 4.5 hours

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-09-08 04:04:10 +00:00
Jack Grigg 457c9d26dd zcash_client_sqlite: Prevent empty `FoundNote` ranges in `scan_complete`
In the sandblasting block ranges, shard trees only cover a few hundred
blocks at most. When scanning block ranges much larger than this, it is
likely that when a note is discovered, its parent shard tree is entirely
contained within the scan range. In this situation, `extended_range`
would be set to `range`, and then because an extended range existed,
ranges with `FoundNote` priority would always be created - that in this
case are empty.

In an effectively-linear-scanning wallet situation, this leads to a
`SpanningTree` being constructed with adjacent `Scanned` ranges,
separated by empty `FoundNote` ranges, which it was unable to merge.

We address this by both preventing generation of the empty `FoundNote`
ranges, and by defensively fixing `SpanningTree::into_vec` to skip empty
ranges.

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-09-08 03:57:21 +00:00
Jack Grigg 7a4954c242 zcash_client_sqlite: Fix off-by-one in `scan_complete`
Shard end heights are end-inclusive, while Rust `Range`s are
end-exclusive.

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-09-08 03:44:03 +00:00
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
str4d a89e65b302
Merge pull request #949 from nuttycom/sbs/update_tip_lower_bound
zcash_client_sqlite: Bound creation of scan ranges on wallet birthday.
2023-09-07 17:31:27 +01: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
str4d 3d0ec004a2
Merge pull request #944 from nuttycom/wallet/progress_from_birthday
Measure scan progress from wallet birthday, not the fully scanned height
2023-09-06 19:38:28 +01:00
Kris Nuttycombe f56c5d8f4b Measure scan progress from wallet birthday, not the fully scanned height. 2023-09-06 12:07:18 -06:00
ebfull 362e5d05f1
Merge pull request #943 from zcash/938-bugfix
zcash_client_sqlite: Fix bug in `check_shard_discontinuity`
2023-09-06 11:59:35 -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 0cc0af7ac5
Merge pull request #942 from nuttycom/wallet/block_max_scanned
zcash_client_backend: Add `WalletRead::block_max_scanned`
2023-09-06 09:57:56 -06: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