Commit Graph

847 Commits

Author SHA1 Message Date
Francisco Gindre a57d302c5a
Merge pull request #773 from Chlup/770_update_grpc
[#770] Update GRPC swift library
2023-02-10 15:42:16 -03:00
Michal Fousek 84fb032185
Merge pull request #768 from Chlup/764_notifications_gone_inside
[#764] Stop using Notifications inside the SDK
2023-02-09 20:33:09 +01:00
Michal Fousek 1ec12269ae [#764] Stop using Notifications inside the SDK
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.
2023-02-09 20:09:51 +01:00
Michal Fousek be8afabec4 [#770] Update GRPC swift library
Closes #770
2023-02-09 19:55:46 +01:00
Michal Fousek e83bec6db7
Merge pull request #772 from Chlup/rename_fsmeta_param
[#771] Fix tests failing because of different paths passed to `FSCompactBlockRepository` and `FSMetadataStore`
2023-02-09 15:19:50 +01:00
Michal Fousek 34c08a3a81 [#771] Fix tests failing because of different paths passed to `FSCompactBlockRepository` and `FSMetadataStore`
Closes #771

- Renamed `cacheDirectory` param in `FSCompactBlockRepository`
  constructor to `fsBlockDbRoot`.
- Pass same paths to `FSCompactBlockRepository` and `FSMetadataStore`
  from tests.
2023-02-09 13:58:49 +01:00
Francisco Gindre cf60f44aa8
Merge pull request #769 from zcash/release/0.18.1-beta
implement getRecipients() for Synchronizer and Release 0.18.1 beta
2023-02-08 13:26:57 -03:00
Francisco Gindre 67dd061523 Merge branch 'main' into release/0.18.1-beta 2023-02-08 12:48:20 -03:00
Francisco Gindre 2c211732e1 [#767] implement getRecipients() for Synchronizer.
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
2023-02-08 08:44:29 -03:00
Michal Fousek 07180dca2d
Merge pull request #766 from Chlup/736_final_touches
[#763] Finishing touches for CompactBlockProcessor refactor
2023-02-07 15:46:59 +01:00
Francisco Gindre 4a82e2de75
Merge pull request #765 from zcash/remove_html_docs
- [#759] Remove Jazz-generated HTML docs
2023-02-06 15:55:20 -03:00
Michal Fousek 172c1e0623 [#763] Finishing touches for CompactBlockProcessor refactor
Closes #763
2023-02-06 19:30:49 +01:00
Michal Fousek bccacbb1c4
Merge pull request #761 from Chlup/744_fetch_utxo_extract
[#744] Refactor UTXO fetching code in CompactBlockProcessor
2023-02-06 19:06:25 +01:00
Michal Fousek ac4f9a8f7a [#744] Refactor UTXO fetching code in CompactBlockProcessor
Closes #744

- Added `UTXOFetcher` protocol and `UTXOFetcherImpl` struct.
2023-02-06 19:06:07 +01:00
Michal Fousek a241ff4c0a
Merge pull request #762 from Chlup/745_sapling_params_extract
[#745] Refactor sapling parameters handling code in CompactBlockProcessor
2023-02-06 19:04:30 +01:00
Michal Fousek 276dcad8fa [#745] Refactor sapling parameters handling code in CompactBlockProcessor
Closes #745

- Added `SaplingParametersHandler` protocol and `SaplingParametersHandlerImpl` struct.
2023-02-06 19:03:54 +01:00
Michal Fousek b3dd634e5c
Merge pull request #760 from Chlup/741_enhance_extract
[#741] Refactor transaction enhancement code in CompactBlockProcessor
2023-02-06 19:02:25 +01:00
Francisco Gindre 2d46a0a699 - [#759] Remove Jazz-generated HTML docs
We remove these documents since they are outdated and we rely on the docs in the
code itself.

Closes 759
2023-02-06 14:29:22 -03:00
Michal Fousek 7fa1ace2c3 [#741] Refactor transaction enhancement code in CompactBlockProcessor
Closes #741

- Added `BlockEnhancer` protocol and `BlockEnhancerImpl` struct.
2023-02-06 14:33:16 +01:00
Michal Fousek a5ac045877
Merge pull request #763 from Chlup/fix_testStoringTenSandblastedBlocksFailsAndThrows
Possibly fix testStoringTenSandblastedBlocksFailsAndThrows test
2023-02-06 14:05:00 +01:00
Michal Fousek 09bc1332eb Possibly fix testStoringTenSandblastedBlocksFailsAndThrows test 2023-02-06 13:28:19 +01:00
Michal Fousek a5b1b63507
Merge pull request #751 from Chlup/746_grpc_encapsulation
[#756] Modularize GRPC related code
2023-02-03 22:32:02 +01:00
Michal Fousek 385c0a7195 [#746] Modularize GRPC related code
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.
2023-02-03 22:25:54 +01:00
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