Commit Graph

59 Commits

Author SHA1 Message Date
Francisco Gindre c736dd37fb
[#1019] Memo has trailing garbled text (#1023)
Changes the way unpadded bytes are turned into a UTF-8 Swift String
without using cString assuming APIs that would overflow memory and
add garbled trailing bytes.

Closes #1019

add changelog entry
2023-05-05 15:51:50 -03:00
Francisco Gindre f5e7c027af
[#1001] Remove PendingDb in favor of `v_transactions` and `v_tx_output` Views (#1001)
Removes `PendingTransactionEntity` and all of its related components.
Pending items are still tracked and visualized by the existing APIs
but they are retrieved from the `TransactionRepository` instead by
returning `ZcashTransaction.Overview` instead.

`pendingDbURL` is removed from every place it was required. Its
deletion is responsibility of wallet developers.

`ClearedTransactions` are now just `transactions`.

`MigrationManager` is deleted. Now all migrations are in charge of
the rust welding layer.

`PendingTransactionDao.swift` is removed.

Implementation of `AccountEntity` called `Account` is now `DbAccount`

`ZcashTransaction.Overview` can be checked for "pending-ness" by calling
`.isPending(latestHeight:)` latest height must be provided so that minedHeight
can be compared with the lastest and the `defaultStaleTolerance` constant.

`TransactionRecipient` is now a public type.

protocol `PendingTransactionRepository` is removed.

`TransactionManagerError` and `PersistentTransactionManager` are deleted.

`OutboundTransactionManager` is deleted and replaced by `TransactionEncoder`
which now incorporates `submit(encoded:)` functionality

`WalletTransactionEncoder` now uses a `LightWalletService` to submit the
encoded transactions.

Add changelog changes

Delete references to PendingDb from tests and documentation.

Fixes some typos. Adds the ability to trace transaction repository
SQL queries from test

Fix rebase conflicts and generate code

[#837] Memo tests regarding transparent address

Closes #837

Add model for transaction output

Point to FFI branch

Fix issue where sync wouldn't resume after wipe. Becasue GRPC
channel would be closed

Fix Tests

Fix testPendingTransactionMinedHeightUpdated

Fix testLastStates

[#921] Fix  broken SynchronizerDarksideTests

Add ZcashTransaction.Output API to Synchronizer

Changelog + comment fix

Add Assertions for transaction outputs and recipients

Point to FFI 0.3.1

Fix Demo App Compiler errors

Fix Demo App Compiler errors

fix cacheDb warnings

Fix Tests and compiler errors of rebase

build demo app

Remove `ZcashTransaction.Sent` and `.Received`. Add `.State` and tests

Fix SPM warning

PR Suggestions

Removes errors that are not used anymore

fix warnings
2023-05-05 14:30:47 -03:00
Michal Fousek 0032fedde7 [#442] Introduce parallel downloading and scanning
- `BlockDownloaderImpl` is changed. It now spawns detached Task to
  download blocks. So blocks can be downloaded in parallel with scanning
  process.
- `Synchronizer.stop()` is no longer async.
- Blocks cache cleaning is changed. It's not possible to drop the whole
  cache now. There are some blocks pre-downloaded which weren't scanned
  yet.
2023-05-05 09:35:43 +02:00
Matthew Watt 58b99c8fb1
[#1013] - Enable more granular control over logging behavior (#1014)
* Add new model for logging configuration

* Fix the example app and update the changelog
2023-05-02 16:59:49 -03:00
Michal Fousek 724d410fad
[#361] Introduce ZcashError (#1005)
This PR introduces `ZcashError` enum. This enum represents any error
that can be thrown inside of the SDK and outside of the SDK. Also
`ZcashError` is used in `LightWalletGRPCService` and handled in
`CompactBlockProcessor` as example.

Why enum? First I tried this with some structure which contained code,
message and underlyingError. Problem was when some specific place in the
SDK would like to attach some additional data to error. I didn't want to
add some generic dictionary to store anything with the error.

So I used enum to identify error. Each member can have specified amount
of associated values. So specific error can bring some context data. And
it's type safe.

Each error has also a code. Relationship between errors and codes is
1:1. It may looks bit redundant but it's important. The client app now
can choose how to process errors. Either identify those by the error
itself or by code.

Definition or errors and codes is in `ZcashErrorDefinition`. And then
`ZcashError` and `ZcashErrorCode` are generated by Sourcery. Thanks to
this it is easier to maintain the final code. And it gives us ability to
generate any kind of documentation for the errors and codes. I created
simple example of this in this PR. And it doesn't make the SDK
completely dependent on the Sourcery. Final structures aren't super
complicated and can be written manually if needed.

[#923] Update error handling in DatabaseStorageManager.swift

- cleanup of DatabaseStorageManager, not used anymore
- ZcashError for SimpleConnectionProvider

Revert "[#923] Update error handling in DatabaseStorageManager.swift"

This reverts commit 94e028d31a.

Fix script which generates ZcashError

[#922] Update error handling in DatabaseMigrationManager.swift

Closes #922

[#923] Update error handling in DatabaseStorageManager.swift

- The DatabaseStorageManager is not used so I deleted it
- SimpleConnectionProvider's errors updated

Fix tests

[#955] Update error handling in SaplingParameterDownloader

Closes #955

[#936] Update error handling in NotesDao

Closes #936

[#935] Update error handling in BlockDao

Closes #935

[#931] InternalSyncProgress.computeNextState doesn't need to throw

Closes #931

[#950] Update error handling in rust backend

Closes #949
Closes #950

[#941] Update error handling in AccountEntity

Closes #941

[#928] Update error handling in FSCompactBlockRepository

Closes #928

[#925] Update error handling in BlockDownloaderService (#974)

- BlockDownloaderService errors updated

[#924] Update error handling in BlockDownloader (#973)

- BlockDownloaderStream nextBlock updated

[#942] Update error handling in TransactionEntity (#977)

- ZcashTransaction init errors converted to the ZcashError

[#939] Update error handling in TransactionDao (#976)

- TransactionRepositoryError removed and replaced with ZcashError
- all TransactionDAO errors converted to ZcashError

[#943] Update error handling in ZcashCompactBlock

Closes #943

[#945] Update error handling in Memo

Closes #945

[#934] Update error handling in Checkpoint

Closes #944
Closes #934

[#938] Update error handling in PendingTransactionDao

Closes #938

[#926] Update error handling in BlockEnhancer

- WIP, switching to transaction repository to unblock this ticket

[#926] Update error handling in BlockEnhancer

- enhancer's errors done

[#926] Update error handling in BlockEnhancer (#994)

- cleanup

[#952] Update error handling in DerivationTool

Closes #952

[#932] Update error handling in BlockValidator

Closes #932

[#940] Update error handling in UnspentTransactionOutputDao

Closes #940

[#946] Update error handling in WalletTypes

Closes #946

[#954] Update error handling in WalletTransactionEncoder

Closes #954

[#953] Update error handling in PersistentTransactionManager

Closes #953

[#956] Update error handling in Initializer

Closes #956

[#947] Update error handling in Zatoshi (#996)

- Zatoshi's errors converted to ZcashError

[#927] Update error handling in UTXOFetcher (#997)

- UTXOFetcher resolved

Use let instead of var where applicable

In the SDK `var` was used on places where `let` would be sufficient. And
default strategy in Swift should use use `let` until mutability is
required. So all these places are changed. No logic is changed.

[#933] Update error handling in CompactBlockProcessor

- CompactBlockProcessor's errors refactored to ZcashError

[#933] Update error handling in CompactBlockProcessor #999

- comments addressed

[#951] Update error handling in SDKSynchronizer

- SDKSynchronizer's errors refactored to ZcashError

[#951] Update error handling in SDKSynchronizer (#1002)

- comments resolved

Make DerivationTool constructor public

DerivationTool.init should be public. This was removed by accident when
adopting async.

[#361] Add changelog
2023-04-24 18:15:20 -03:00
Francisco Gindre 9fa59cf13b
[#985] Release 0.21.0-beta (#986)
Closes #985
2023-04-19 14:32:48 -03:00
Francisco Gindre 802aaa437d
[#959] Fix `v_transactions` view issues with value (#963)
This change switches to a new (future) version of the rust crates
that will get rid of the sent and received transactions Views in
favor of a `v_transaction` view that will do better accounting of
outgoing and incoming funds. Additionally it will support an
outputs view for seeing the inner details of transactions enabling
the SDKs tell the users the precise movement of value that a tx
causes in its multiple possible ways according to the protocol.

the `v_tx_outputs` view is not yet implemented.

Sent and Received transaction sub-types are kept for compatibility
purposes but they are generated from Overviews instead of queried
from a specific view.

In the transaction Overview the value represents the whole value
transfer for the transaction from the point of view of a given
account including fees. This means that the value for a single
transaction Overview struct represents the addition or subtraction
of ZEC value to the account's balance.

Future updates will give clients the possibility to drill into the
inner workings of those value changes in a per-output basis for
each transaction.

Also, the field `pending_unmined` field was added to `v_transactions`
so that wallets can query `DataDb` for pending but yet unmined txs

This will prepare the field for removing the notion of a "PendingDb"
and its nuances.

Also updated test database `darkside_data.db`

Closes #959

Closes #971 ZcashLightClientKitSample main target broken swiftlint script

Demo App improvements: Show Short date and value on transaction list
2023-04-18 09:10:56 -03:00
Michal Fousek 2bbc5800bd [#888] Make actor from ZcashRustBackendWelding
Closes #888.

- `ZcashRustBackend` is actor now. So majority of methods in this actor
  are now async.
- Some methods stayed `static` in `ZcashRustBackend`. It would be hard
  to pass instance of the `ZcashRustBackend` to the places where these
  methods are used in static manner. And it would change lot of APIs.
  But it isn't problem from technical perspective because these methods
  would be `nonisolated` otherwise.
- Methods `lastError()` and `getLastError()` in `ZcashRustBackend` are
  now private. This makes sure that ther won't be aby race condition
  between other methods and these two error methods.
- All the methods for which was `lastError()` used in code now throw
  error. So `lastError()` is no longer needed outside of the
  `ZcashRustBackend`.
- There are in the public API related to `DerivationTool`.
- `DerivationTool` now requires instance of the `ZcashRustBackend`. And
  `ZcashRustBackend` isn't public type. So `DerivationTool` doesn't have
  any public constructor now. It can be created only via
  `Initializer.makeDerivationTool()` instance method.
- `deriveUnifiedSpendingKey()` and `deriveUnifiedFullViewingKey()` in
  `DerivationTool` are now async. It is because these are using
  `ZcashRustBackend` inside. `DerivationTool` offers alternative
  (closure and combine) APIs. But downside is that there is no sync API
  to dervie spending key or viewing key.
- Some methods of the `DerivationTool` are now static. These methods
  don't use anything that requires instance of the `DerivationTool`
  inside.

[#888] Use Sourcery to generate mocks

- I wrote mock for `Synchronizer` manually. And it's tedious and long
  and boring work.
- Now `ZcashRustBackendWelding` is changed a lot so it means
  `MockRustBackend` must be changed a lot. So I decided to introduce
  `sourcery` to generate mocks from protocols so we don't have to do it
  manually ever.
- To generate mocks go to `ZcashLightClientKit/Tests/TestUtils/Sourcery`
  directory and run `generateMocks.sh` script.
- Your protocol must be mentioned in `AutoMockable.swift` file.
  Generated mocks are in `AutoMockable.generated.swift` file.

[#888] Fix Offline tests

- Offline tests target now runs and tests are green.
- There is log of changes in tests. But logic is not changed.
- Updated `AutoMockable.stencil` so sourcery is able to generate mock as
  actor when protocol is marked with: `// sourcery: mockActor`.
- Last few updates in `ZcashRustBackendWelding`. In previous PR `rewindCacheToHeight`
  methods was overlooked and it didn't throw error.
- Removed `MockRustBackend` and using generated
  `ZCashRustBackendWeldingMock` instead.
- Using generated `SynchronizerMock`.

[#888] Fix NetworkTests

- Changed a bit how rust backend mock is used in the tests. Introduced
  `RustBackendMockHelper`. There are some state variables that must be
  preserved within one instance of the mock. This helper does exactly
  this. It keeps this state variables in the memory and helping mock to
  work as expected.

[#888] Fix Darkside tests

Create ZcashKeyDeriving internal protocol

Use New DerivationTool that does not require RustBackend

Remove duplicated methods that had been copied over

[#888] Fix potentially broken tests

I broke the tests because I moved `testTempDirectory` from each
`TestCase` to the `Environment`. By this I caused that each tests uses
exactly same URL. Which is directly against purpose of
`testTempDirectory`.

So now each test calls this one and store it to local variable. So each
test has unique URL.

[#888] Add ability to mock nonisolated methods to AutoMockable.stencil

[#888] Add changelog and fix the documentation in ZcashRustBackendWelding

[#888] Rename derivation rust backend protocol and remove static methods

- Renamed `ZcashKeyDeriving` to `ZcashKeyDerivationBackendWelding`. So
  the naming scheme is same as for `ZcashRustBackendWelding`.
- `ZcashKeyDerivationBackend` is now struct instead of enum.
- Methods in `ZcashKeyDerivationBackendWelding` (except one) are no
  longer static. Because of this the respective methods in
  `DerivationTool` aren't also static anymore.
2023-04-11 17:51:28 +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 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 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 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 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
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
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
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 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 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 3aad1470f1 [#793] Send synchronizerStopped notification only when sync process stops
Closes #793
2023-02-17 08:49:55 +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
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
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 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
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
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
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
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 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
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 382905b06a [#657] Fix typos 2023-01-09 13:29:43 +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
Francisco Gindre 70e732e551 Fix Merge conflict on PR. 2023-01-04 10:49:46 -03:00
Francisco Gindre c0f8d46501 [#698] Updated Checkpoints release 0.17.5-beta 2023-01-03 17:55:02 -03:00
Michal Fousek 4b4416b1e1 Merge branch 'master' into 657_merge_master
- Changed how metrics are pushed when downloading and scanning blocks.
2022-12-22 15:35:11 +01:00
Lukas Korba 3c3b97ca42
[#663] Create a benchmarking section on the Demo App that can be automated (#681)
- 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
2022-12-21 13:30:05 +01:00
Michal Fousek 6c5bf8de27 [#677] Add support for wipe into SDK
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
2022-12-20 13:41:20 +01:00
Francisco Gindre d54ea493fa [#675] release 0.17.4-beta
updates `libzcashlc` to `0.1.1` to fix an error where getting a
transparent balance on an empty database would fail.

closes #675
2022-12-14 18:12:11 -03:00
Francisco Gindre 2dfd096948 Add CHANGELOG.md entry and bump cocoapods version 2022-12-12 17:44:56 -03:00
Francisco Gindre 50e63232e3 New Checkpoints + CHANGELOG.md 2022-12-12 17:39:05 -03:00
Francisco Gindre 3b7202c922
Fix `testShieldFunds()` dataset loading issue. (#659)
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.
2022-12-12 10:00:31 -03:00
Michal Fousek cc2c0ffa65 [#660] Fix the situation when any rewind causes full rescan
This is just hotfix that disables removing of cache DB.

Bump Cocoapods version to 0.17.2-beta
2022-12-06 15:12:34 -03:00
Francisco Gindre 1c672cad59 [#625] Release 0.17.1-beta
Closes #625

See CHANGELOG.md for details
2022-11-30 11:08:48 -03:00
Michal Fousek 7c07b91c5b [#651] Fix rewind when it's called during sync
- When rewind is called during sync then exception is thrown.
2022-11-29 08:33:18 +01:00