-
Notifications
You must be signed in to change notification settings - Fork 36
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
Multi-account and PCZT support #1517
base: 1514-Finish-multi-account-support
Are you sure you want to change the base?
Multi-account and PCZT support #1517
Conversation
- the FFI has been switched to a preview of import UFVK
- importAccount() WIP
- Some of the Zip32AccountIndex has been refactored to UUID - Public import UFVK method in the SDK added AccountUUID refactor - phase 1 - rebased
- SDK builds again, UUIDs refactored everywhere in the SDK and demo app - tests will follow in the next phase - refactor of documented code in the follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it has a problem to me, which is that by just picking the first account in a lot of cases it may get inconsistent results. The order of accounts is nondeterministic, and it shouldn't be left to chance even if it was deterministic; the account that's in use needs to be tracked explicitly.
...ple/ZcashLightClientSample/ZcashLightClientSample/Get Address/GetAddressViewController.swift
Show resolved
Hide resolved
...ple/ZcashLightClientSample/ZcashLightClientSample/Get Balance/GetBalanceViewController.swift
Show resolved
Hide resolved
Example/ZcashLightClientSample/ZcashLightClientSample/Get UTXOs/GetUTXOsViewController.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking good; the one thing that I think needs to be changed is that keySource
should be optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking good; the one thing that I think needs to be changed is that keySource
should be optional.
- Comments in the code updated and cleaned up - OfflineTests passes again, those failing has been removed from the bundle and marked to be fixed with a TODO Fixes of build - The SDK builds again
01984b2
to
27af6f1
Compare
OfflineTests fixes
- updated to build and tests that are obsolete are now taken out of the bundle
- rust backend `getAccount` method implemented, it returns Account with associated data - `listAccount()` has been modified to return an array of Accounts instead of AccountUUIDs
- Account refactored to conform to Equatable, Hashable, Codable, Identifiable
- importAccount(ufvk, purpose, name, keySource) API
UnifiedAddress Hashable conformance
9c239be
to
dcf6cd9
Compare
- a new public API for DerivationTool to derive UA from the UFVK added
- also attempt to fix _uuid in views
- Refactored to the proper types
- ufvk removed from the parameters
from_account_uuid
985e677
to
dd587ac
Compare
ee8a88e
to
75cfd08
Compare
alias reverted Alias logic updated
75cfd08
to
632626a
Compare
- The comments were provided - Changelog updated - Code cleaned up - Tests fixed - Error codes for the Pczt
- FFI version bumped to 0.12.0
...e/ZcashLightClientSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed ce667eb. I did not review ZcashLightClientSample
or most of the test changes.
@@ -102,11 +104,11 @@ class ZcashRustBackendTests: XCTestCase { | |||
var uAddresses: [UnifiedAddress] = [] | |||
for i in 0...2 { | |||
uAddresses.append( | |||
try await rustBackend.getCurrentAddress(account: 0) | |||
try await rustBackend.getCurrentAddress(accountUUID: TestsData.mockedAccountUUID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is now broken. Previously account: 0
would happen to correctly point to the account created by the rustBackend.createAccount
call above. Now, TestData.mockedAccountUUID
always causes an error because it will never be a valid UUID. Instead, the test should use the real UUID returned from rustBackend.createAccount
, which I believe is returned as a property of usk
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public struct UnifiedSpendingKey: Equatable, Undescribable { let network: NetworkType let bytes: [UInt8] }
doesn't hold the UUID of the Account, that is why I marked the test (and removed it from the suite) to be fixed in #1518 as a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely disagree with disabling large swathes of tests in order to get a new feature in. The entire point of tests is to ensure that the changes being made don't break anything.
let rawID = Data(fromHexEncodedString: "08cb5838ffd2c18ce15e7e8c50174940cd9526fff37601986f5480b7ca07e534")! | ||
let transaction = ZcashTransaction.Overview( | ||
accountId: 0, | ||
accountUUID: TestsData.mockedAccountUUID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is using TestDbBuilder.prePopulatedMainnetDataDbURL()
:
zcash-swift-wallet-sdk/Tests/TestUtils/TestDbBuilder.swift
Lines 49 to 51 in c9fb348
static func prePopulatedMainnetDataDbURL() -> URL? { | |
Bundle.module.url(forResource: "darkside_data", withExtension: "db") | |
} |
darkside_data.db
is currently 2 years old, so is quite outdated. I don't see anywhere in this test that runs an initDataDb
, which is what would upgrade it in-test to the latest DB state. That means the test was inherently broken prior to this PR.
After this PR, the same test bug applies as I wrote earlier: we cannot use TestsData.mockedAccountUUID
in any call to the Rust backend (or any code that itself calls through to the Rust backend, like TransactionRepository
. In the case of this test, the test code should fetch the actual UUID out of the database in setUp()
, and then use it here instead of TestsData.mockedAccountUUID
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, same here: The reason why this and other tests is/are broken is very likely not related to multi-account support but for some reasons long living in the code.
Sources/ZcashLightClientKit/Transaction/TransactionEncoder.swift
Outdated
Show resolved
Hide resolved
Sources/ZcashLightClientKit/Transaction/WalletTransactionEncoder.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a8b1524 addresses my non-test comments, and the PR is probably fine. However, I cannot give it an ACK, because large swathes of tests have been disabled.
If @LukasKorba confirms that the now-disabled tests were in a broken state prior to this PR (and thus disabling them has no effect on the correctness checking in this PR), then I'll let the PR be merged as-is, but only if #1518 is made the number 1 priority. We cannot allow this many tests to be disabled in the long term; that is an unacceptable risk. cc @true-jared.
In any case, fixing the code comment is blocking.
@@ -91,7 +91,9 @@ protocol TransactionEncoder { | |||
/// - Parameter transaction: a transaction overview | |||
func submit(transaction: EncodedTransaction) async throws | |||
|
|||
func createTransactionsFromTxIds(_ txIds: [Data]) async throws -> [ZcashTransaction.Overview] | |||
/// Tries to fetch the transaction for the given transction ids. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Tries to fetch the transaction for the given transction ids. | |
/// Tries to fetch the transaction for the given transaction ids. |
@@ -123,3 +123,8 @@ class TestsData { | |||
self.networkType = networkType | |||
} | |||
} | |||
|
|||
extension TestsData { | |||
/// `mockedAccountUUID` is used to mock the rust backend for check only purposes. It's never passed to it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently false; mockedAccountUUID
is passed into the Rust backend repeatedly. AFAICT it only happens in tests that are currently disabled, but that still makes this "never" false.
If the intention is to never pass this into the backend (and given my previous review, it should be), and the tests do not get fixed in this PR (which I strongly think they should be), then update this comment to point to the issues that will fix the code in order to make this statement true.
Closes #522
Closes #1513
Closes #1514
This code review checklist is intended to serve as a starting point for the author and reviewer, although it may not be appropriate for all types of changes (e.g. fixing a spelling typo in documentation). For more in-depth discussion of how we think about code review, please see Code Review Guidelines.
Author
Reviewer