Skip to content

Commit

Permalink
Define our own AccountId
Browse files Browse the repository at this point in the history
This is work toward supporting arbitrary imported keys, which may not be based on seeds (as far as we know) and may consist only of a full viewing key or incoming viewing key.

- Several tests needed to be updated because they assumed the result of `create_account` was a ZIP-32 account index where it was really only documented to return an account id or that the first account id would be 0. In fact in the sqlite implementation these two values are no longer the same. I've updated the docs and CHANGELOG to call out this behavior.
- In addition to adding a few columns to the `accounts` table, I also *renamed* a couple of existing columns to avoid their being used with their old semantics. I also added indexes for the FK columns of each table that had to be migrated.
- The `add_utxo_account` migration was improperly relying on internal crate code to query the database as part of migration. The problem with this is the internal crate code assumes the _latest_ db schema, whereas the migration must be able to run with an earlier schema. With this PR, a later migration occurs that breaks the schema in ways that required internal crate updates, and a migration that runs _before_ those updates then failed when calling into the 'newer' crate code. The fix is to remove the dependency: migrations should never make indirect sql calls through non-migration code. I copied the two functions from the regular code into the migration and reverted the changes I had made to them so that the migration works again. This code in the migration may be trimmable to something smaller to fit what the migration needs, but I didn't want to rewrite it.
- The new db schema renames the `accounts.ufvk` column to `uvk` to allow for UFVKs today, and UIVKs tomorrow. Code remains in the crate itself that only tries to parse the value of this column as a UFVK because no UIVK type exists yet. But I've tried to model the APIs to allow for adding support for that with no further breaking changes.
  • Loading branch information
AArnott committed Feb 14, 2024
1 parent e6e40ee commit 862efdb
Show file tree
Hide file tree
Showing 27 changed files with 884 additions and 365 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ and this library adheres to Rust's notion of
- `Note::Orchard`

### Changed
- Several structs and functions had `AccountId` added as a generic type
parameter in order to decouple the concepts of an account identifier
and a ZIP-32 account index.
- `zcash_client_backend::data_api`:
- Arguments to `BlockMetadata::from_parts` have changed.
- Arguments to `ScannedBlock::from_parts` have changed.
- Changes to the `WalletRead` trait:
- Added `get_orchard_nullifiers`
- Added `get_account_parameters`
- `ShieldedProtocol` has a new `Orchard` variant.
- `zcash_client_backend::fees`:
- Arguments to `ChangeStrategy::compute_balance` have changed.

### Removed
- `data_api::Error::ChildIndexOutOfRange`

## [0.11.0-pre-release] Unreleased

### Added
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ document-features.workspace = true
byteorder = { workspace = true, optional = true }
percent-encoding.workspace = true

# - Digests
blake2b_simd = { workspace = true }

# - Scanning
crossbeam-channel.workspace = true
rayon.workspace = true
Expand Down
Loading

0 comments on commit 862efdb

Please sign in to comment.