Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from ZIP 32 account indices to UUID account identifiers #1640

Merged
merged 47 commits into from
Dec 11, 2024

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Nov 22, 2024

This PR is opened against main as a draft solely so it can be pre-reviewed. Once #1632 is complete and merged, I'll rebase this branch and then retarget it against a feature branch (so we can review and merge it before the backing Rust changes are released).

Closes #1633.

Author

  • Self-review your own code in GitHub's web interface1
  • Add automated tests as appropriate
  • Update the manual tests2 as appropriate
  • Check the code coverage3 report for the automated tests
  • Update documentation as appropriate (e.g README.md, Architecture.md, etc.)
  • Run the demo app and try the changes
  • Pull in the latest changes from the main branch and squash your commits before assigning a reviewer4

Reviewer

  • Check the code with the Code Review Guidelines checklist
  • Perform an ad hoc review5
  • Review the automated tests
  • Review the manual tests
  • Review the documentation, README.md, Architecture.md, etc. as appropriate
  • Run the demo app and try the changes6

Footnotes

  1. Code often looks different when reviewing the diff in a browser, making it easier to spot potential bugs.

  2. While we aim for automated testing of the SDK, some aspects require manual testing. If you had to manually test
    something during development of this pull request, write those steps down.

  3. While we are not looking for perfect coverage, the tool can point out potential cases that have been missed. Code coverage can be generated with: ./gradlew check for Kotlin modules and ./gradlew connectedCheck -PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true for Android modules.

  4. Having your code up to date and squashed will make it easier for others to review. Use best judgement when squashing commits, as some changes (such as refactoring) might be easier to review as a separate commit.

  5. In addition to a first pass using the code review guidelines, do a second pass using your best judgement and experience which may identify additional questions or comments. Research shows that code review is most effective when done in multiple passes, where reviewers look for different things through each pass.

  6. While the CI server runs the demo app to look for build failures or crashes, humans running the demo app are
    more likely to notice unexpected log messages, UI inconsistencies, or bad output data. Perform this step last, after verifying the code changes are safe to run locally.

@str4d str4d force-pushed the account-uuids branch 2 times, most recently from de385b2 to 192c5e1 Compare November 22, 2024 23:49
@str4d
Copy link
Contributor Author

str4d commented Nov 22, 2024

Force-pushed to rebase on main afer #1641 was merged.

Copy link
Contributor

@HonzaR HonzaR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encode_usk function in lib.rs still works upon ZIP32 account index, while it needs to switch to the new account_uuid logic to align with the updated JniUnifiedSpendingKey class on the Kotlin side. @str4d can you please make this change as part of this PR? My current branch 1632-remove-default-account is built on these changes.

@HonzaR HonzaR mentioned this pull request Nov 29, 2024
13 tasks
@str4d str4d changed the base branch from main to feature-2.2.7 December 4, 2024 16:13
@HonzaR
Copy link
Contributor

HonzaR commented Dec 4, 2024

We need to ensure that this is fulfilled as part of this PR.

str4d and others added 2 commits December 4, 2024 10:48
To emphasize the distinction between Account and TransactionRecipient.Account
(&account_name).into(),
(&env.byte_array_from_slice(account.id().expose_uuid().as_bytes())?).into(),
hd_account_index,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the hd_account_index and seed fingerprint go together, as they're the two necessary bits of HD derivation information.

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfinished but looks good so far. Please add a Zip32AccountIndex class to replace Int for ZIP 32 account indices.

Copy link
Contributor Author

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 7a064ec. Any further changes can be made in subsequent PRs to the feature branch.

@str4d str4d merged commit 2cb7315 into feature-2.2.7 Dec 11, 2024
9 of 11 checks passed
@str4d str4d deleted the account-uuids branch December 11, 2024 15:44
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post-hoc ACK, but before release we should remove the Account parameter from createSpend etc. and look those up based on the USK.

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-hoc ACK with comments. Follow-up tickets: #1651, #1652, #1654, #1655.

HonzaR added a commit that referenced this pull request Dec 13, 2024
* `Account` documentation fix

* Make `AccountPurpose.Spending` args not null

As they now live under `AccountPurpose.Spending` where we need them not null
+ `AccountImportSetup` doc fix

* Replace `bytes` with `usk` in `AccountUsk`

* Change test name
HonzaR added a commit that referenced this pull request Dec 13, 2024
* `Account` documentation fix

* Make `AccountPurpose.Spending` args not null

As they now live under `AccountPurpose.Spending` where we need them not null
+ `AccountImportSetup` doc fix

* Replace `bytes` with `usk` in `AccountUsk`

* Change test name
HonzaR added a commit that referenced this pull request Dec 13, 2024
* Migrate to latest revision of Zcash crates

* Integrate PCZT APIs into the Android SDK

* Fix `Backend.createPcztFromProposal` parameter

* Add Synchronizer side of PCZT logic

* Add `getAccountForUfvk`  method to Rust backend & fix key derivation null issue. (#1656)

* Add `getAccountForUfvk` method to the FFI.

* Only decode key derivation metadata when creating a count with `Spending` purpose.

Also, ensure that a spending account can still be created without providing
key derivation metadata.

* Update to `librustzcash` revision `205d4c930319b7b6d24aeb4efde69e9b4d1b6f7b`

* Add the new `getAccountForUfvk` to `TypesafeBackend`

* Update `FakeRustBackend`

---------

Co-authored-by: Honza <[email protected]>

* Remove unused `TransactionEncoder` functions (#1660)

* Resolve [#1640] review comments

* `Account` documentation fix

* Make `AccountPurpose.Spending` args not null

As they now live under `AccountPurpose.Spending` where we need them not null
+ `AccountImportSetup` doc fix

* Replace `bytes` with `usk` in `AccountUsk`

* Change test name

* Testnet Synchronizer test fix

* Detekt warning

* Changelog update

---------

Co-authored-by: Jack Grigg <[email protected]>
Co-authored-by: Honza <[email protected]>
Co-authored-by: Honza Rychnovský <[email protected]>
HonzaR added a commit that referenced this pull request Dec 17, 2024
* [#1632] Refactor `Account.DEFAULT` (#1645)

* [#1632] Remove `Account.DEFAULT`

* Update Account related APIs

* Refactor balances APIs

* Adopt `getAccounts` in fragment-based Demo app

We have deprecated the old Fragment-based Demo app. See #973. So, the purpose of these changes is purely the buildability of the new Compose-based Demo app.

* Add init to `JniUnifiedSpendingKey.kt`

* Update deprecated Fragment-based Demo app

This part of the Demo app will be removed as part of #973

* Remove deprecated functions from Synchronizer

* Update WalletSnapshot and WalletVM APIs in Demo

+ necessary fixtures changes

* Update newer Compose-based Demo app

* Hide `Synchronizer.createAccount` form public API

As it was, as making it public could bring more requirements on our multi-account support in version 1

* Add all accounts flow API

* Refactor AccountFixture

- We deduplicated the fixture across the related modules and their tests
- Documentation added

* Fix `fetchUtxos` error (code 14)

- Closes #1648
- This also impacts SDK’s ability to recover from loss of internet connection
- Changelog updated

* Switch from ZIP 32 account indices to UUID account identifiers (#1640)

* Switch from ZIP 32 account indices to UUID account identifiers

* Rename TransactionRecipient.Account

To emphasize the distinction between Account and TransactionRecipient.Account

* Fix `Backend.createAccount` API parameters

* Add `importAccountUfvk` to the Rust backend.

* Propagate accountName and keySource across SDK

* Propagate new importAccount across SDK

* Wrap createAccount setup information

* Wrap importAccount setup information

* Add `Zip32AccountIndex` wrapper

* Update key source parameter

* Remove account from `UnifiedSpendingKey`

* Fix `importAccountByUfvk` API

* Refactor Account.accountUuid to wrapper class

So we can easily keep it typesafe and compare it to each other

* Add `JniAccountUsk`

* Add `seedFingerprint` and `zip32AccountIndex`

To public API `importAccountUfvk`

* Transactions by account UUID

* Refactor default account creation

* Migrate to Rust crate revision with bugfixes to account UUID migration

* Refactor inputs of `importAccountUfvk`

* Use `FirsClassByteArray` for `seed` parameter

---------

Co-authored-by: Honza <[email protected]>
Co-authored-by: Kris Nuttycombe <[email protected]>
Co-authored-by: Honza Rychnovský <[email protected]>
Co-authored-by: Daira-Emma Hopwood <[email protected]>

* Remove unused `TransactionEncoder` functions (#1660)

* Resolve [#1640] review comments

* `Account` documentation fix

* Make `AccountPurpose.Spending` args not null

As they now live under `AccountPurpose.Spending` where we need them not null
+ `AccountImportSetup` doc fix

* Replace `bytes` with `usk` in `AccountUsk`

* Change test name

* Feature/proposal to pczt (#1647)

* Migrate to latest revision of Zcash crates

* Integrate PCZT APIs into the Android SDK

* Fix `Backend.createPcztFromProposal` parameter

* Add Synchronizer side of PCZT logic

* Add `getAccountForUfvk`  method to Rust backend & fix key derivation null issue. (#1656)

* Add `getAccountForUfvk` method to the FFI.

* Only decode key derivation metadata when creating a count with `Spending` purpose.

Also, ensure that a spending account can still be created without providing
key derivation metadata.

* Update to `librustzcash` revision `205d4c930319b7b6d24aeb4efde69e9b4d1b6f7b`

* Add the new `getAccountForUfvk` to `TypesafeBackend`

* Update `FakeRustBackend`

---------

Co-authored-by: Honza <[email protected]>

* Remove unused `TransactionEncoder` functions (#1660)

* Resolve [#1640] review comments

* `Account` documentation fix

* Make `AccountPurpose.Spending` args not null

As they now live under `AccountPurpose.Spending` where we need them not null
+ `AccountImportSetup` doc fix

* Replace `bytes` with `usk` in `AccountUsk`

* Change test name

* Testnet Synchronizer test fix

* Detekt warning

* Changelog update

---------

Co-authored-by: Jack Grigg <[email protected]>
Co-authored-by: Honza <[email protected]>
Co-authored-by: Honza Rychnovský <[email protected]>

* Peformance optimizations

* Revert "Peformance optimizations"

This reverts commit 68de6ae.

* PCZT support follow-ups (#1663)

* Rename exception

* Add sapling param fetching to new KS-related fun

* Add dedicated clone PZCT function

* Add `Synchronizer.Status.INITIALIZING`

For wallets to know that accounts and other APIs are not ready yet

* [#1665] Checkpoints update

Closes #1665

* Bump lib version to 2.2.7

* Migrate to the published Zcash crate releases including PCZT v1 (#1664)

Co-authored-by: Honza <[email protected]>

---------

Co-authored-by: Jack Grigg <[email protected]>
Co-authored-by: Kris Nuttycombe <[email protected]>
Co-authored-by: Daira-Emma Hopwood <[email protected]>
Co-authored-by: Kris Nuttycombe <[email protected]>
Co-authored-by: Milan Cerovsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants