Commit Graph

974 Commits

Author SHA1 Message Date
Michal Fousek 8983b01f6c Rename Single and Completable 2023-04-03 17:19:40 +02:00
Lukas Korba 16d70cfead
[#896] Fix SDK compilation fail caused by Swift 5.8 (#897)
- Fixed the guard with explicit self
2023-04-03 09:16:07 +02:00
Francisco Gindre e8c2aeecc3
[#889] fix branches that will be built with CodeQL (#894) 2023-03-31 15:08:31 -03:00
Francisco Gindre 2537296db0
[#889] Add github action for CodeQL beta (#890)
Closes 889

switch to from autobuild to swift build

configure swift build

fix architecture parameter

remove CodeQL on pushes
2023-03-31 13:29:27 -03:00
Michal Fousek 34ac9ff7c5
Merge pull request #891 from Chlup/877_OutboundTransactionManager_async
[#877] OutboundTransactionManager to async
2023-03-31 16:40:05 +02:00
Michal Fousek cb7faf4614
Merge pull request #892 from Chlup/878_UnspentTransactionOutputRepository_async
[#878] UnspentTransactionOutputRepository to async
2023-03-31 16:39:50 +02:00
Michal Fousek d7eef113ff
Merge pull request #893 from Chlup/remove_notifications
Remove anything related to Notifications
2023-03-31 16:39:36 +02:00
Michal Fousek 866fe3d6f0 Remove anything related to Notifications
- There was still some code inside the SDK related to NotificationCenter
  and notifications. But notifications are no longer needed. So all this
  code can go away.
2023-03-31 11:04:39 +02:00
Michal Fousek 7826258e24 [#878] UnspentTransactionOutputRepository to async
Closes #878.
2023-03-31 10:59:46 +02:00
Michal Fousek f420c81ceb [#877] OutboundTransactionManager to async
Closes #877.

- Most of the methods in `OutboundTransactionManager` were already async
  so this is not big of a change.
- Some methods/properties in the `SDKSynchronizer` were made async. But
  these were async in the `Synchronizer` already. So let's not consider
  this change of the public API.
2023-03-31 10:49:06 +02:00
Michal Fousek 10281c712c
Merge pull request #887 from Chlup/462_remove_xctestcase_wait
[#462] Get rid of XCTestCase.wait
2023-03-31 10:09:43 +02:00
Michal Fousek 96f763d42f [#462] Get rid of XCTestCase.wait 2023-03-31 08:58:19 +02:00
Michal Fousek 3764054db4
Merge pull request #886 from Chlup/469_rust_async
[#469] Make ZcashRustBackendWelding async
2023-03-31 08:41:53 +02:00
Michal Fousek c4f7f6ff1e [#469] Make ZcashRustBackendWelding async
Closes #469.

- Methods defined in `ZcashRustBackendWelding` protocol which are doing
  some IO operations are now async.
- `Initializer` no longer have methods to get balance. Only
  `Synchronizer` now have these methods. These methods are newly async.
  And `Initilializer` doesn't have alternative APIs.
- There is lot of changes in tests but those are mostly adding `await`.
  No logic is changed.
2023-03-30 19:08:56 +02:00
Francisco Gindre ae971d526c
[#874] Release 0.20.0-beta (#881)
Cloese #874

Update MIGRATING.md
2023-03-30 07:45:42 -03:00
Francisco Gindre c4d3f74205
[#880] Make some deprecations effective (#885)
* Deprecate `func getShieldedBalance(accountIndex: Int) -> Int64`

* Deprecate `func getShieldedVerifiedBalance(accountIndex: Int) -> Int64`

* deprecate `func getBalance(account index: Int = 0) -> Int64`

* deprecate `func defaultFee(for height: BlockHeight) -> Int64`

* deprecate `func getReceivedMemoAsUTF8(dbData:idNote:networkType:) -> String?`

* Deprecate `func getSentMemoAsUTF8(dbData:idNote:networkType:) -> String?`

* deprecate `getVerifiedBalance`

Closes #880
2023-03-28 15:56:14 -03:00
Michal Fousek 5a2496f2fb
Merge pull request #882 from Chlup/876_multiple_synchronizers_tests
[#876] Add tests which runs multiple instances of the SDKSynchronizer
2023-03-28 16:35:44 +02:00
Michal Fousek 94f016ecf9
Merge pull request #884 from Chlup/883_fix_test
[#883] Use async in TransactionSQLDAO
2023-03-28 16:20:06 +02:00
Michal Fousek 8e5db5e0b5 [#876] Add tests which runs multiple instances of the SDKSynchronizer
Closes #876.

- Add `testMultipleSynchronizersCanRunAtOnce()` test which creates
  multiple instances of the `SDKSynchronizer` and then executes sync in
  parallel.
- To achieve this it's required to have multiple instances of the
  lightwalletd in the darkside mode. Because of this new test is in the
  new target `AliasDarksideTests`. It's little bit harder to run this
  test than to run regular darkside tests. So it has it's own target.
- Fix bug when all the instances of the `SDKSynchronizer` used same data
  DB even with different aliases.
- Add script to run multiple instances of the lightwalletd in
  darkside mode. And add script to stop these instances and clean after
  those.
- Update `DarksideWalletService` a little so the endpoint can be passed
  to it. Without this it would always use default endpoint when created
  with service.
- Small cleanup in `TestCoordinator`.
2023-03-28 16:11:13 +02:00
Michal Fousek bb17299695 [#883] Use async in TransactionSQLDAO 2023-03-28 15:54:58 +02:00
Michal Fousek d7e6a413b7
Merge pull request #879 from Chlup/484_transactions_repository_async
[#484] Use async for TransactionsRepository
2023-03-28 12:49:41 +02:00
Michal Fousek 3971f80eef [#484] Use async for TransactionsRepository
Closes #484.

- `TransactionRepository` has async API. `Synchronizer` and alternative
  APIs are updated accordingly.

These methods and properties in the `Synchronizer` are async now:
- `cancelSpend(transaction:)`
- All the variants of the `getMemos(for:)` method.
- All the variants fo the `getRecipients(for:)` method.
- `allConfirmedTransactions(from:limit:)`
- `pendingTransactions`
- `clearedTransactions`
- `sentTransactions`
- `receivedTransactions`
2023-03-28 10:17:14 +02:00
Michal Fousek 026a96ffba
Merge pull request #875 from zcash/feature/209_support_multiple_instances
[#209] Add support for multiple instances of the SDKSynchronizer
2023-03-27 21:32:09 +02:00
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