Closes#764
- All notification that were previously sent from CompactBlockProcessor are now gone.
- `CompactBlockProcessor` now provides `eventStream` to communicate with `SDKSynchronizer`.
- Added `synchronizerStoredUTXOs` notification.
- Tests are updated to not use notifications anymore. Some tests there
weren't working before are now fixed.
- Added `CompactBlockProcessorEventHandler` utility class. Previously
expectations were subscribing to notifications. This class replaces
this functionality. It subscribes to events from
`CompactBlockProcessor` and fullfill expectations.
Closes#771
- Renamed `cacheDirectory` param in `FSCompactBlockRepository`
constructor to `fsBlockDbRoot`.
- Pass same paths to `FSCompactBlockRepository` and `FSMetadataStore`
from tests.
This implements `getRecipients()` function which retrieves the possible
recipients from a sent transaction. These can either be addresses or
internal accounts depending on the transaction being a shielding tx
or a regular outgoing transaction.
Closes#767
Other changes:
Fix version of zcash-light-client-ffi to 0.1.1
Enhance error reporting on a test make Mock comply with protocol
Update CHANGELOG.md
Closes#746
- `LightWalletGRPCService` is no longer public. `LightWalletService` is no longer public.
- `LightWalletGRPCService` shouldn't be used dicrectly. Use `LightWalletServiceFactory` to create instance of the service.
- Moved sending of `blockProcessorConnectivityStateChanged` notification to `Initilizer`.
- All the errors from GRPC are mapped to `LightWalletServiceError`. Handling of `GRPCStatus` in the SDK is no longer required.
- `Service` directory (that contains GRPC code) is moved to `Modules/Service`. We can put more code to `Modules/` if we decide
to modularize more code.
Closes#743
- Added new protocol `BlockValidator` and `BlockValidatorImpl` class. All the code related to blocks validation is extracted to `BlockValidatorImpl`.
- Fixed `testSingleDownloadAndScan()` test.
- Changed how validation error are handled. Previously validation error were handled directly next to validation code. And when some validation
errors happened method from `CompactBlockProcessor` were called. Now validation errors are handled in `CompactBlockProcessor.processNewBlocks`
in a same way as any other error that can occur during sync process.
Closes https://github.com/zcash/ZcashLightClientKit/issues/697
Closes https://github.com/zcash/ZcashLightClientKit/issues/720
Closes https://github.com/zcash/ZcashLightClientKit/issues/587
Closes https://github.com/zcash/ZcashLightClientKit/issues/667
Closes https://github.com/zcash/ZcashLightClientKit/issues/443
Closes https://github.com/zcash/ZcashLightClientKit/issues/754
- [#790] Fix ShieldFundsTests
Closes#790
Removes comments on `ShieldFundsTests` since those issues have been fixed
Depends on zcash-light-client-ffi changes that adopt newer versions of
librustzcash crates `zcash_primitives 0.10`, `zcash_client_backend 0.7`,
`zcash_proofs 0.10`, `zcash_client_sqlite 0.5.0`.
Also allows wallets to define a shielding_threshold and will set
foundations to customize minimum confirmations for balances, spends
and shielding operations.
**Test Bootstrapping**
- `ZcashCompactBlockDescriptor`: struct that holds functions to
describe blocks as filenames and compare those filenames
`ZcashCompactBlockDescriptor.live` has the actual implementation
but it can be replaced by mocks if needed on Tests
main implementations are held under `FSCompactBlockRepository.filenameDescription` and `FSCompactBlockRepository.filenameComparison` on a separate extention
`DirectoryListingProviders` provide two default implementations of listing a
directory deterministically. `FileManager` does not define a sorting and needs to be done in-memory by calling `.sorted()` on the resulting collection. If this
is a big toll on performance it can be changed to a POSIX implementation but
this is good for now.
`ZcashCompactBlockDescriptor` adds a `height` helper function to
turn a filename into the height of the block stored.
Implemented `func latestHeight() throws -> BlockHeight ` that
returns the blockheight by querying the cache directory in a sorted
fashion and getting the last value and turning the filename into a
`BlockHeight`
Added `Meta` struct to ZcashCompactBlock.
Tests implemented:
- `filterBlockFiles`
- `testClearTheCache`
- `testLatestHeightEmptyCacheThrows`
- `testLatestHeightEmptyCacheThrowsAsync`
- `testRewindEmptyCacheDoesNothing`
- `testRewindEmptyCacheDoesNothingAsync`
- `testWhenBlockIsStoredItFollowsTheDescribedFormat`
- `testWhenBlockIsStoredItFollowsTheFilenameConvention`
- `testGetLatestHeight`
- `testRewindDeletesTheRightBlocks` test
- `testPerformanceExample` test. This isn't a real performance test because the API doesn't work with async/await yet
adopts `shield_funds` shielding threshold parameter
Implements `initBlockMetadataDb` and fix tests
Renames dbCache parameter to `fsBlockDbRoot`. Builds but tests don't pass.
Removes cacheDb uses from code. Testing utilities still persist.
Added needed information in MIGRATING and CHANGELOG.
Added helper to perform deletion of legacy db and creation a the
new file system backed cache.
Renames parameters and changes code where needed.
Network Constants turned into `enum` with static methods.
DeletelastDownloadedBlock helper from initializer
Removes CompactBlockStorage and CompactBlockEntity.
Implements `latestCachedBlockHeight` on rustbackend.
*Replaces dependencies on ZcashRustWelding with `FSMetadataStore`*
This allows the tests to not depend in a particular implementation
of either the MockRustBackend of or ZcashRustBackend. Also provides
a way to test errors properly and switch implementations of critical
areas like `writeBlocks`.
Closes#740
`CompactBlockDownloading` protocol is renamed to `BlockDownloaderService`. `CompactBlockDownloader` is renamed to `BlockDownloaderServiceImpl`.
What is the motivation for this rename?
Goal of this change is to extract code from `CompactBlockProcessor` which is related to downloading. So naturaly it should be called "downloader".
But `CompactBlockDownloader` was already taken. After analysis of `CompactBlockDownloading` and `CompactBlockDownloader` I found out that
`CompactBlockDownloader` doesn't download blocks exactly. It's more like abstraction over `LightWalletService`. And it does very similar job to
`LightWalletService`. That is why I decided to rename it to "service".
What is the motivation for protoco/impl naming scheme?
First `BlockDownloaderService` protocol doesn't describe capability in my eyes. It describe what something is. Also `BlockDownloaderServicing` sounds
strange. I agree that add suffix "Impl" to class name isn't super nice. But it is acceptable. And it makes sense to use nicer type name
(e.g. `BlockDownloaderService`) for protocol because it's used on much more places in the code.
- Added `BlockDownloader` protocol and `BlockDownloaderImpl` class. The code related to downloading was exctracted to this class.
- `id` property of transcations is no longer Optional. `id` column in DB
is primary key and it can't be nil. This was oversight in previous
changes.
- Sorting order of transactions is switched from asc to desc. asc is
oversight in previous changes. Android is using desc.
- Using `IFNULL` when sorting transactions by minedHeight.
- Update tests accordingly. And revert few changes on darkside tests.
These changes are no longer needed because using `desc` sorting order
on transactions.
- Fix all the tests. In few tests code had to be changes because order
of transactions is newly defined. It wasn't before.
- Change properties of Transaction.* objects. Some had to be made
Optional to make all tests work.
- Add new tests for TransactionDAO.
- Removed methods from TransactionDAO that weren't used.
- Removed `Transaction` struct and `TransactionEntity` protocol.
- Removed some other protocols from `TransactionEntity.swift`.
Use correct default fee and memo count
- SDKMetrics singleton for the measurement
- download, validate and scan blocks supported
- Sample app refactored to use SDKMetrics, connected to appropriate notifications and labels
- enhancement metric added
- total sync time metric added
- sample app extended to show summary time and operations summaries
- unit tests for the SDKMetrics
- doc for the SDKMetrics and our approach for the performance testing in general
- changelog update
This change is prerequisity for future changes. API of
`TransactionRepository` is changed a bit. Now it's possible to filter
transaction by kind (all/sent/received) event when
`TransactionNG.Overview` structure is returned.
Tests are now fixed for new methods and new objects. For this mocked
database `darkside_data.db` had to be updated to the latest scheme used
by the Rust code.
Closes#677
- Previously when keychain wanted to do wipe wallet had to do it on it's
own. Which isn't good. Now wallet can simply call
`synchronizer.wipe()` and it's done.
- This change brings support for wipe. `Synchronizer` has new method
`wipe()` which takes care of everything. All the database connections
are closed. Databases are removed. `InternalSyncProgress` is reset.
Change condition when wipe can run
Closes#657
- Now SDK downloads N downloads and scan those. And repeat until sync is
done. This safes lot of space of disk used to store downloaded blocks.
- Most changes are done in `CompactBlockProcessor.processNewBlocks`.
- `SyncRanges` structure is changed a bit.
- `SyncStatus` is changed. SDK now report that it's syncing with
progress. It doesn't report each phase of the sync process separately.
Also appropriate notifications were updated.
Address review comments
- Small changes
- Add tests to check computation of processing ranges for single loop
- Structures that represent transactions DB views are newly define.
- New structures are:
- TransactionNG.Overview
- TransactionNG.Received
- TransactionNG.Sent
- `TransactionNG` is used as temporary name. `Transaction` is existing
structure in the code. `TransactionNG` will be eventually renamed to
`Transaction` once current `Transaction` is removed from code.
- New methods that are using new structures are added to
`TransactionRepository`. Those are slightly changed compared to
predecessors. Those are now little bit simpler to use.
Address review comments
- Previously we had one range for each sync which was used for each
phase of sync process. Newly there is separate range for each phase of
the sync process.
- I added `InternalSyncProgress` utility. This utility tracks progress
of some phases. And it is able to compute right ranges which should be
used for syncing.
- Some unused download code from `CompactBlockProcessor` is removed.
Fix tests
Address review comments
- Rebase to master
- Update how range for `processBatchFinished()` is computed.
- Refactor `InternalSyncProgress`
- Add tests for `InternalSyncProgress`
Address review comments
Change how latest downloaded block is tracked
- Cache DB is no longer used to track which block was downloaded as
latest. `InternalSyncProgress` is used to do that.
- Thanks to that #660 is fixed. And cache DB can be completely removed
after sync process.
- Added sleep(1) to some darkside tests when latest block height is set.
Otherwise lightwalletd in darkside mode doesn't have time to setup and
tests are flaky.
Fix TransactionEnhancementTests.testBasicEnhancement test
There's a problem withstanding:
````
▿ RustWeldingError
▿ genericError : 1 element
- message : "Error while fetching transparent balances for AccountId(0): Invalid column type Null at index: 0, name: address"
````
Which is fixed by commit `d0297bff0cdaaff42ad26f3be5bc261f6c828e8f` of "https://github.com/zcash/librustzcash".
nil-coalesce thrown errors on test so it reaches the end.
Make balance calls throwing to show underlying errors but nil-coalesce in non-throwing APIs
Add missing fulfill() calls
Add changelog entry
document and handle errors on getting shielded balance before
attempting to download sapling parameters.
- sync process enhanced to try to download sapling params if needed
- tests fixed
- failing import Crypto -> import CryptoKit
- download params only if there are sapling funds
This provides a method for clients to handle UI for text memo
limit correctly handling memos that are visibly fit within the
capacity defined in ZIP-302 but when encoded into UTF-8 bytes
their size exceeds such limit.
Closes#639