Commit Graph

974 Commits

Author SHA1 Message Date
Michal Fousek 62437c5c7d
Merge pull request #755 from Chlup/742_scanning_extract
[#742] Refactor blocks scanning in CompactBlockProcessor
2023-02-03 22:24:00 +01:00
Francisco Gindre 617d8bac54
Merge pull request #757 from zcash/release/0.17.6-beta
[#756] 0.17.5-beta updates to libzcashlc 0.2.0 when it shouldn't
2023-02-03 15:34:53 -03:00
Francisco Gindre f481bc87c2 Merge branch 'main' into release/0.17.6-beta 2023-02-03 15:01:11 -03:00
Francisco Gindre d7470c350d [#756] 0.17.5-beta updates to libzcashlc 0.2.0 when it shouldn't
Updated checkpoint to the ones present in 0.18.0-beta

Closes #756

 Update Cocoapods
2023-02-03 14:58:44 -03:00
Michal Fousek 34e444e632 [#742] Refactor blocks scanning in CompactBlockProcessor
Closes #742

- Added new protocol `BlockScanner` and new struct `BlockScannerImpl`. Scanning related code is extracted to `BlockScannerImpl`.
2023-02-03 15:54:10 +01:00
Michal Fousek 64a85bf306
Merge pull request #753 from Chlup/743_validating_extract
[#743] Refactor blocks validation in CompactBlockProcessor
2023-02-03 15:52:31 +01:00
Michal Fousek 1a03fa6f7c [#743] Refactor blocks validation in CompactBlockProcessor
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.
2023-02-03 09:58:36 +01:00
Francisco Gindre fad3aae174
- [#679] Implementation of the File-system based block cache (#679)
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`.
2023-02-02 13:58:12 -03:00
Michal Fousek d6aaa2cedc
Merge pull request #752 from Chlup/740_compactblockdownload_type
[#740] Refator blocks downloading in CompactBlockProcessor
2023-02-01 10:17:26 +01:00
Michal Fousek 6bbaad4cb1 [#740] Refator blocks downloading in CompactBlockProcessor
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.
2023-01-31 15:24:41 +01:00
Michal Fousek 6982c936f1
Merge pull request #739 from Chlup/735_swiftlint
[#735] Use Swiftlint for the SDK
2023-01-31 09:53:00 +01:00
Francisco Gindre 731c7bbf45
[#415] Release 0.18.0 beta (#750)
* New Checkpoints for 0.18.0-beta candidate

* Add Changelog for 0.18.0-beta
2023-01-30 19:33:20 -03:00
Michal Fousek a0d0c90555 [#735] Use Swiftlint for the SDK
- Swiftlint binary is included in the repository.
2023-01-27 11:44:25 +01:00
Lukas Korba f69da50ba9
[#747] Remove SampleLogger and replace it with OSLogger (#748)
- SampleLogger removed
- OSLogger used
- category default
2023-01-26 18:14:07 +01:00
Francisco Gindre 4ca6944540
[#645] Default rewind after ReOrg is 20 blocks when it should be 10 (#737)
This fixes an issue where the default reorg was 20 blocks rewind instead of 10. The
reorg count was incremented before calling the rewind height computing function.

Closes #645
2023-01-25 17:06:31 -03:00
Michal Fousek 43e00ecb62
Merge pull request #734 from zcash/556_using_transactions_db_views
[#556] Using DB views for transactions instead of raw SQL
2023-01-23 12:59:49 +01:00
Michal Fousek c7c16fbb06
Merge pull request #732 from Chlup/556_changelog
[#556] Add changelog
2023-01-23 11:30:31 +01:00
Michal Fousek 789f12719c
Merge pull request #733 from Chlup/556_rename_transaction
[#556] Rename Transaction to ZCashTransaction
2023-01-23 10:48:10 +01:00
Michal Fousek 4b70c4e6b5 [#556] Add changelog
- Added changelog for #556.
- Update formatting so changelog is easier to read when it's rendered.
2023-01-23 10:47:46 +01:00
Francisco Gindre ec0adfcd25
[#730] Swiftlint picks the wrong files (#731)
This adds the `included` rule to specify which folders to lint
Closes #730
2023-01-23 06:09:02 -03:00
Michal Fousek ce4d7bab45 [#556] Rename Transaction to ZCashTransaction
- Xcode's refactor feature used. Only renamed happened no logic was
  changed.
2023-01-23 10:01:07 +01:00
Michal Fousek 82ac6ea4f3 Merge branch 'main' into 556_using_transactions_db_views 2023-01-20 13:10:06 +01:00
Michal Fousek f7668e8e73
Merge pull request #729 from Chlup/remove_swiftlint_plugin
[#728] Remove Swiftilint SPM package plugin
2023-01-20 13:09:49 +01:00
Michal Fousek bb57d5d9fe [#728] Remove Swiftilint SPM package plugin
Closes #728
2023-01-20 09:24:50 +01:00
Michal Fousek 28de8d4ac3 Merge branch 'main' into 556_using_transactions_db_views 2023-01-19 12:44:28 +01:00
Lukas Korba 372ea5af70
[#711] Add Swiftlint plug in to SDK (#722)
- plugin integrated
- errors resolved
- warnings resolved
- package.swift macos platform version 10_15 -> 12
2023-01-18 17:09:04 +01:00
Michal Fousek c0dbb3d866
Merge pull request #723 from Chlup/556_fix_sorting
[#556] Fix sorting when selecting transactions without minedHeight
2023-01-18 08:15:53 +01:00
Michal Fousek b4e320b9c3 [#556] Fix sorting when selecting transactions without minedHeight
- `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.
2023-01-16 13:18:08 +01:00
Michal Fousek da10219a84
Merge pull request #712 from Chlup/556_8_tests
[#556] Fix tests and fix few bugs
2023-01-12 19:40:20 +01:00
Lukas Korba dcc6ef1757
[#671] Make CompactBlockProcessor Internal (#710)
- sdk and demo app modified
- changelog updated
2023-01-12 13:05:11 +01:00
Michal Fousek 14f1436987 [#556] Fix tests and fix few bugs
- 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.
2023-01-10 23:20:46 +01:00
Michal Fousek cb2d077200
Merge pull request #709 from Chlup/687_7_memo_api
[#683] Add Synchronizer API to fetch memos for transactions
2023-01-10 23:19:13 +01:00
Michal Fousek cb62101e2d [#683] Add Synchronizer API to fetch memos for transactions
Closes #683

Fix tests
2023-01-10 11:03:57 +01:00
Michal Fousek 169fd3da46 Merge branch 'main' into 556_using_transactions_db_views 2023-01-10 11:02:12 +01:00
Michal Fousek c6af1cace3
Merge pull request #702 from zcash/657_download_change
657 download change
2023-01-09 15:17:07 +01:00
Michal Fousek c5b6e86a91
Merge pull request #707 from Chlup/556_6_rename_TransactionNG
[#556] Rename Transaction to TransactionNG
2023-01-09 13:31:25 +01:00
Michal Fousek 382905b06a [#657] Fix typos 2023-01-09 13:29:43 +01:00
Michal Fousek 473326fc55
Merge pull request #708 from Chlup/657_scan_batch_not_global
[#657] Scan batch size is computed for each scan loop
2023-01-09 13:23:41 +01:00
Michal Fousek abe647e28d Update how progress is reported while scanning blocks 2023-01-06 16:45:49 +01:00
Francisco Gindre 851023842f
[#612] Remove Support for Cocoapods (#706)
Our main dependency, Swift-GRPC is dropping support for Cocoapods from version 1.8.2.

Even though they make a great work at maintaining backwards compatibility, we will eventually be forced to drop Cocoapods support.

We've reached out partners like NighthawkApps, Horizontal Systems (Unstoppable) and Edge, who have reported not depending on Cocoapods.

We intend to end Cocoapods support on 0.18.0.

Closes #612
2023-01-06 12:26:00 -03:00
Michal Fousek 09e9148b88 [#657] Scan batch size is computed for each scan loop 2023-01-06 13:16:12 +01:00
Michal Fousek c4df36db36 [#556] Rename Transaction to TransactionNG
This change is really only replace one string with other. No logic was
changed.
2023-01-06 10:12:00 +01:00
Michal Fousek 3d488f6e15
Merge pull request #703 from Chlup/556_5_remove_ConfirmedTransaction
[#556] Remove ConfirmedTransaction and ConfirmedTransactionEntity
2023-01-06 10:10:04 +01:00
Michal Fousek e8aa451b17 [#657] Update changelog 2023-01-05 15:13:27 +01:00
Michal Fousek becadf21c8 Merge branch 'main' into 657_download_change 2023-01-05 09:50:00 +01:00
Michal Fousek ef88023171 [#556] Remove ConfirmedTransaction and ConfirmedTransactionEntity 2023-01-05 09:42:50 +01:00
Michal Fousek de25513c9c
Merge pull request #694 from Chlup/556_4_remove_entities
[#556] Remove Transaction and TransactionEntity
2023-01-04 21:18:48 +01:00
Michal Fousek 91af862a4e
Merge pull request #701 from Chlup/556_fix_properties
[#556] Make expiryHeight and raw optional
2023-01-04 21:18:35 +01:00
Michal Fousek ed47bc2327 [#556] Make expiryHeight and raw optional
There can be stored transactions with expiryHeight and raw set to NULL
in database. So these two properties must be optional in code.
2023-01-04 16:21:47 +01:00
Francisco Gindre f6be12fd8c
Merge pull request #699 from zcash/release/0.17.5-beta
[#698] Updated Checkpoints release 0.17.5-beta
2023-01-04 10:53:21 -03:00