Commit Graph

1001 Commits

Author SHA1 Message Date
Michal Fousek 5c979f42e6 [#209] Add support for multiple instances of the SDKSynchronizer
Closes #209.

[#845] Introduce ZcashSynchronizerAlias enum

Closes #845.

[#852] SDKSynchronizer using queues label based on the alias

Closes #852.

[#847] Remove posibility to use DatabaseStorageManager as singleton

Closes #847.

[#850] Remove synchronizerConnectionStateChanged notification

Closes #850.

[#855] Add check if the Alias is already used

Closes #855

- Added `UsedAliasesChecker` utility which is used to register aliases
  that are in use.
- `prepare()` and `wipe()` methods now check if the current alias can't
  be used and if not then `InitializerError.aliasAlreadyInUse` is
  thrown/emitted.
- Some public methods that could cause harm if used with the Alias that
  is already in use now throw `SynchronizerError.notPrepared`. Thanks to
  this the client app is forced to call `prepare()` first. And
  `prepare()` does check for the Alias.
- Added tests for new conditions.

[#849] Make InternalSyncProgress aware of the Alias

Closes #849.

[#853] Only instance with default Alias migrates legacy cache DB

Closes #853.

[#851] Apply the Alias to the URLs

Closes #851.

- `Initializer` now updates paths according to alias before paths are
  used anywhere in the SDK.
- Paths update can fail. It would be incovenient for the client apps to
  handle errors thrown from `Initiliazer` constructor. So the error is
  then handled in `SDKSynchronizer.prepare()` or `SDKSynchronizer.wipe()`.

[#846] Stop using SDKMetrics as singleton (#862)

- metrics are not longer a singleton
- tests fixed
- metrics outside init of the synchronizer

[#848] Make logger aware of the alias

- logger is now an instance passed throughout the sdk instead of a static proxy

[#848] Make logger aware of the alias (#868)

- comments addressed

[#848] Make logger aware of the alias (#868)

- returning protocol back

Fix typos

[#856] Add possibility to test multiple synchronizers in the sample app

Closes #856.

- Added `alias` property to `Synchronizer`.
- Added `SyncBlocksListViewController` which provides UI to use multiple
  synchronizers at once.

[#209] Add changelog

- Add changelog for #209.
- Overall improve readability of the rendered changelog. Tickets
  references are now prefixed with `###` instead of `- `.

Fix compilation
2023-03-27 20:42:52 +02:00
Michal Fousek 2ff6b81b4b
Merge pull request #873 from Chlup/871_async_cleanup
[#871] Cleanup internals of the SDK and use async where applicable
2023-03-27 20:37:21 +02:00
Michal Fousek c2d9c6f1e8 [#871] Cleanup internals of the SDK and use async where applicable
Closes #871.
2023-03-27 16:16:42 +02:00
Michal Fousek 1d6b30116c
Merge pull request #872 from Chlup/870_grpc_to_async
[#870] LightWalletGRPCService is using only async streamer
2023-03-27 15:57:47 +02:00
Michal Fousek ce83dcef12 [#870] LightWalletGRPCService is using only async streamer
Closes #870.
2023-03-27 13:45:22 +02:00
Michal Fousek 52d5e00850
Merge pull request #860 from Chlup/fix_testListTransparentReceivers_test
Fix flaky testListTransparentReceivers test
2023-03-23 13:28:45 +01:00
Michal Fousek 21f90fe93c Fix flaky testListTransparentReceivers test
Data DB name is derived from timestamp in TemporaryDbBuilder. Timestamp
is converted to seconds before it's used to generate Data DB name. So
if the test is super fast and can run twice in one seconds it fails.
Solution is to always remove data DB at the end of the test.
2023-03-23 12:46:11 +01:00
Michal Fousek 56f195f2cc
Merge pull request #844 from zcash/feature/831_solve_async_nonasync
[#831] Add SDKSynchronizer wrappers for non-async API
2023-03-23 09:06:54 +01:00
Michal Fousek 436fa1fc47 [#831] Add SDKSynchronizer wrappers for non-async API
This change introduces two new protocols: `ClosureSynchronizer` and
`CombineSynchronizer`. These two protocols define API that doesn't use
`async`. So the client can choose exactly which API it wants to use.
    This change also introduces two new objects: `ClosureSDKSynchronizer`
and `CombineSDKSynchronizer`. These two implement the respective protocols
mentioned above. Both are structures. Neither of these two keeps any state.
Thanks to this each is very cheap to create. And usage of these two isn't
mutually exclusive. So devs can really choose the best SDK API for each
part of the client app.

[#831] Use async inside of the SDKSynchronizer

- In general lot of methods inside the `SDKSynchronizer` and
  `CompactBlockProcessoer` which weren't async are now async. And other
  changes are made because of this change.
- `CompactBlockProcessor` no longer uses Combine to communicate with
  `SDKSynchronizer`. Reason for this is that Combine doesn't play great
  with async. Closure passed to `sink` isn't async.
- Because of this and because of how our tests work (receiving signals
  from CBP directly) `CompactBlockProcessor` must be able to handle more
  event closures. Not just one. So it now has `eventClosures`
  dictionary. It's little bit strange but it works fine.
- `SyncStatus` inside the `SDKSynchronizer` was previously protected by
  lock. Now it's protected by simple actor wrapper.
- Changes in tests are minimal. Changes were mady only because
  `CompactBlockProcessor` changes from Combine to closures.

[#831] Add tests for ClosureSDKSynchronizer

- Added tests are testing in general if the `ClosuresSDKSynchronizer` is correctly
  calling `Synchronizer` and if the values are correctly returned.
- `ClosuresSDKSynchronizer` doesn't contain any logic but it is public
  API and we should be sure that it works correctly.

[#831] Add tests for CombineSDKSynchronizer

[#831] Add changelog
2023-03-21 22:47:19 +01:00
Michal Fousek c88fd684e8
Merge pull request #834 from Chlup/724_change_notifications
[#724] Switch from NotificationCenter to Combine
2023-03-17 10:19:09 +01:00
Michal Fousek a38e8134b8 [#724] Switch from NotificationCenter to Combine
Closes #724

- All the notifications are gone. Only
  `synchronizerConnectionStateChanged` stayed because it's used
  internally. Let's deal with this one in another task.
- Synchronizer has now two new publishers (`stateStream` and
  (`eventStream`) which are used to notify the client app about
  what is going on. These publishers replace notifications.
- There is also new property `latestState` which can be used to get the
  SDK state in synchronous manner.
- `SDKSynchronizer.status` is no longer public. It is used internally to
  refresh `latestState` and emit new values from `stateStream.
- When `SDKSynchronizer.status` is update `notify()` function is
  triggered. And this function is now responsible for generating new
  snapshot of `SynchronizerState` and updating `latestState` and
  `stateStream`.
2023-03-17 10:18:51 +01:00
Lukas Korba 7f69f643b9
[#832] Check for missing spending and output params is not full (#833)
- fixed copy paste bug
- fixed params not being downloaded when transparent funds available
- verified checks are not necessary, removed
2023-03-17 10:18:35 +01:00
Lukas Korba 587977d1d1
[#818] Swift 5.7 syntax update (#828)
- code updated
2023-03-14 09:11:17 -03:00
Michal Fousek b34ae033ae
Merge pull request #827 from Chlup/826_change_initialisation
[#826] Change how the SDK is initialised
2023-03-14 12:30:42 +01:00
Michal Fousek cb31acdd81 [#826] Change how the SDK is initialised
Closes #826

- `viewingKeys` and `walletBirthday` are removed from `Initializer`
  constuctor. These parameters are moved to `SDKSynchronizer.prepare`
  function.
- Constructor of the `SDKSynchronizer` no longer throws exception.
- Any value emitted from `lastState` stream before `SDKSynchronizer.prepare`
  is called has `latestScannedHeight` set to 0.
- `Initializer.initialize` function isn't public anymore. To initialize
  SDK call `SDKSynchronizer.prepare` instead.
- Real birthday is now known after the `SDKSynchronizer.prepare` is
  called. But this function isn't async and therefore it's hard to
  pass birthday from here to `CompactBlockProcessor` in synchronous
  manner. We must be sure that it's safe to call start() after prepare
  function finishes.
    For this reason `CompactBlockProcessor` has `walletBirthdayProvider`
  instead of `walletBirthday`. And this new parameter is closure which
  reads birthday from `Initiliazer` on each call. Thanks to this
  `CompactBlockProcessor` has always the right birthday.
- Some cleanup is done in `TestCoordinator`.
2023-03-13 15:32:55 +01:00
Francisco Gindre f600a3f066
[#824] Release 0.19.1-beta (#825) 2023-03-10 11:16:12 -03:00
Francisco Gindre 24da80d36b
[#821] `failedToWriteMetadata` at sync startup (#822)
contains no public API changes.

Adds `func shouldClearBlockCacheAndUpdateInternalState() -> BlockHeight?` to `SyncRanges`
so that the compact block processor can advert internal states that are not consistent and
recover from such state.

Closes #821
2023-03-09 15:40:06 -03:00
Michal Fousek de473a3958
Merge pull request #823 from Chlup/linter_change
Remove linter binary from repository
2023-03-09 16:07:02 +01:00
Michal Fousek adcc8a2263 Remove linter binary from repository 2023-03-09 14:51:02 +01:00
Francisco Gindre 763d3eaeee
Release 0.19.0 beta (#815)
* Add Mainnet Checkpoints

* Add testnet checkpoints

* Add Changelog update for 0.19.0-beta
2023-03-02 18:51:36 -03:00
Francisco Gindre 172dd9fd6f
Merge pull request #817 from Chlup/816_fix_rewind
[#816] Improve how rewind(policy:) call can be used
2023-03-02 18:02:03 -03:00
Michal Fousek 7e646adba0 [#816] Improve how rewind(policy:) call can be used
Closes #816

- `SDKSynchronizer.rewind(policy:)` can be now called anytime.
- If the sync is in progress then the sync is first stopped and then rewind is executed.
- Rewind now returns AnyPublisher which completes or fails when wipe is done.
- `AgterSyncHooksManager` is used to execute rewind after sync process
  is stopped.
2023-03-02 13:19:25 +01:00
Michal Fousek 9bfbdcb4c5
Merge pull request #811 from Chlup/logger_small_fix
Set oslog inside OSLogger public for read
2023-03-01 14:13:48 +01:00
Michal Fousek ea4d56536e Set oslog inside OSLogger public for read
- This is necessary to finish https://github.com/zcash/secant-ios-wallet/issues/529.
  The Secant has special log method for logging tca stuff. And this
  method will be in extension of `OSLogger` and it needs to access
  `oslog`.
2023-03-01 14:07:14 +01:00
Michal Fousek d87fc1fec6
Merge pull request #808 from Chlup/789_fix_testRescanToHeight_test
[#789] Fix testRescanToHeight test
2023-02-27 17:33:40 +01:00
Michal Fousek b4b0eadbf4
Merge pull request #807 from Chlup/790_fix_testRescanToTransaction_test
[#790] Fix testRescanToTransaction test
2023-02-27 17:33:31 +01:00
Michal Fousek 21d07aba49
Merge pull request #809 from Chlup/644_enable_testReOrgRemovesIncomingTxForever_test
[#644] Enable test testReOrgRemovesIncomingTxForever
2023-02-27 17:33:20 +01:00
Michal Fousek 8385c22100 [#644] Enable test testReOrgRemovesIncomingTxForever
- Test works with currently used lightwalletd. It doesn't work with
  newer. It can be enabled for now.
2023-02-27 14:44:37 +01:00
Michal Fousek 27f0efa0a7 [#789] Fix testRescanToHeight test
Closes #789
2023-02-27 14:39:07 +01:00
Michal Fousek 1fe7b494d5 [#790] Fix testRescanToTransaction test
Closes #790
2023-02-27 14:36:32 +01:00
Michal Fousek 137788d81c
Merge pull request #805 from Chlup/show_values_in_zec
[#803] Fix how transaction value is showed in the SDK sample app
2023-02-23 19:34:28 +01:00
Michal Fousek 3b2d972b2d [#803] Fix how transaction value is showed in the SDK sample app
Closes #803
2023-02-23 11:50:21 +01:00
Michal Fousek e3c9530416
Merge pull request #802 from Chlup/801_improve_wipe
[#801] Improve wipe implementation
2023-02-23 09:38:58 +01:00
Michal Fousek c1b640b44e [#801] Improve wipe implementation
Closes #801

- `SDKSynchronizer.wipe()` can be now called anytime.
- If the sync is in progress then the sync is first stopped and then
  wipe is executed.
- Wipe now returns AnyPublisher which completes or fails when wipe is
  done.
- Majority of wipe's work is to delete files. That is only operation
  that can throw error during wipe. This operation should succeed every
  time. If it fails that something is seriously wrong. When this happens
  the SDK can happen in inconsistent state. There is no recovery for
  now. Only way how to fix this is to reinstall the app in the device.
- Added hooks mechanism. This is implemented in `AfterSyncHooksManager`
  and it is used by `CompactBlockProcessor`. It's just more organized
  way how to track what should happen when the sync process is canceled.
2023-02-22 10:36:33 +01:00
Michal Fousek e439e66896
Merge pull request #798 from Chlup/795_sapling_files_tests_locally
[#795] Include sapling-spend file into bundle for tests
2023-02-20 22:32:10 +01:00
Michal Fousek f0827fc775
Merge pull request #800 from Chlup/784_fix_test_testVerifyBalanceAfterExpiredTransaction
[#784] Fix testVerifyBalanceAfterExpiredTransaction test
2023-02-20 22:31:57 +01:00
Michal Fousek d09b00cabe [#795] Include sapling-spend file into bundle for tests
Closes #795

- Added structure `SaplingParamsSourceURL` which holds source URLs for
  sapling-spend file and sapling-output file. URLs are ultimately passed
  to `SaplingParameterDownloader`.
- This is done so it's possible to pass different URLs when running
  tests.
- sapling-spend file and sapling-output file are in tests bundle. And
  when running tests these files are loaded from bundle and not from
  network.
2023-02-20 10:03:16 +01:00
Michal Fousek c80ef173f8 [#784] Fix testVerifyBalanceAfterExpiredTransaction test
Closes #784
2023-02-20 09:53:06 +01:00
Michal Fousek bb0e27dc93
Merge pull request #794 from Chlup/793_fix_stop_notifications
[#793] Send synchronizerStopped notification only when sync process stops
2023-02-20 09:45:37 +01:00
Michal Fousek 699b374193
Merge pull request #799 from Chlup/788_fix_test_testSmallDownloadAsync
[#788] Fix testSmallDownloadAsync test
2023-02-20 09:45:14 +01:00
Michal Fousek 6db7f88f0f [#788] Fix testSmallDownloadAsync test
Closes #788
2023-02-17 11:02:24 +01:00
Michal Fousek 3aad1470f1 [#793] Send synchronizerStopped notification only when sync process stops
Closes #793
2023-02-17 08:49:55 +01:00
Michal Fousek c7574b81a2
Merge pull request #797 from Chlup/796_fix_memory_tests
[#796] Fix tests
2023-02-17 08:48:19 +01:00
Michal Fousek 65a096d6cd [#796] Fix tests 2023-02-16 17:14:31 +01:00
Michal Fousek a7a6755f81
Merge pull request #792 from Chlup/780_green_policy_baseline
[#780] Disable tests that aren't currently working
2023-02-15 09:57:18 +01:00
Michal Fousek 3edcfe853b [#780] Disable tests that aren't currently working 2023-02-15 09:33:31 +01:00
Michal Fousek 753e3bf605
Merge pull request #779 from Chlup/two_swiftlint_configs
[#778] Add swiflint config file only for tests
2023-02-15 09:31:41 +01:00
Michal Fousek 27b99013f7
Merge pull request #775 from Chlup/715_parametrize_seedPhrase_tests
[#715] Move seed phrase from specific tests to Environment
2023-02-13 15:10:07 +01:00
Michal Fousek 663a785b8f
Merge pull request #776 from Chlup/713_remove_unusedMethods_testcoordinator
[#713] Remove unused methods from TestCoordinator
2023-02-13 13:42:35 +01:00
Michal Fousek 65d6347bcf [#778] Add swiflint config file only for tests
Closes #778

- .swiftlint.yml is now used to lint only the code of the SDK.
- .swiftlint_tests.yml is now used to lint only the code of the tests.
  This config disables rules that were previously disabled in the code
  in lot of tests.
2023-02-13 13:36:58 +01:00