Commit Graph

22 Commits

Author SHA1 Message Date
Francisco Gindre c0f1aa959a Fix SendViewController `viewDidLoad` 2022-10-31 20:45:58 -03:00
Francisco Gindre a0d02c4d57 PR Suggestions
`XCAsyncTestCase` does not work as intended but `wait {}` does what
we need.

restored `needsToStartScanningWhenStopped` as a Bool var on actor

fixed Enhancement test
2022-10-31 20:17:21 -03:00
Francisco Gindre 01d85f5748 Fix compiler errors 2022-10-31 09:57:10 -03:00
Francisco Gindre dbd4b8934c Merge branch 'master' into merge-master 2022-10-31 09:34:38 -03:00
Michal Fousek 571166cc8a [#579] Fix database lock
Closes #579

This is what happens when database was locked:
- App is syncing.
- While rustBackend.scanBlocks(…) is in progress app goes to background. Background task is launched and
  ECC works for some time in background.
- When background task is finished synchronizer.stop() is called.
- Inside CompactBlockProcessor.stop()is called. In this method cancelableTask is canceled and state is
  set to stopped no matter what. And this is the problem. Because even when canceled is called rust
  scanning isn’t canceled. But state doesn’t care about it. And next time when app is launched new
  synchronisation is started and now you have processing code running in two threads causing DB lock.

So I moved setting state to stopped to processNewBlocks method. It's set
after the work is canceled and really stopped. When doing this there is
still one problem. When app goes to foreground new sync is not started
and current one is just stopped.
    So I added new variable and condition. And when this variable is set
to true new syncing process starts when the previous one is canceled.
This should cover all the problems.
2022-10-31 09:57:32 +01:00
Francisco Gindre b5d659e8a8 Fix various tests and deleted some that are not useful anymore
Closes #588
Closes #584
Closes #589
Closes #591
2022-10-27 20:09:08 -03:00
Lukas Korba cfe71d5da2
[#523] Make a CompactBlockProcessor an Actor (#565)
- Sample app refactored for the processor being an actor
- tests refactored as well
- dark side tests fixed
- utilities separated to new file
- synchronizer's start and stop are no longer in async context
- updating the UI for the scan fixed
2022-10-27 12:51:38 +02:00
Kris Nuttycombe 91ea6f5476 Update to latest librustzcash 2022-10-17 15:00:08 -06:00
Francisco Gindre 7f480e417d Merge branch 'master' into merge-master 2022-10-03 20:15:40 -03:00
Lukas Korba 9b6ff51b29
[#492] Get rid of blocking API (#551)
- blocking API removed, only latestBlockHeight() stayed
- non-blocking closure based API removed
- unit tests updated to use async API

[#492] Get rid of blocking API (#551)

- forgotten commented code cleaned up
- some comments were still mentioning result (completion closure), removed
2022-10-03 20:05:11 -03:00
Francisco Gindre 7806b5114f
Use UnifiedSpendingKey for shielding and Spending (#535)
[#534] Use UnifiedSpendingKey for shielding and Spending

This commit implements the use of Unified Spending Keys for shielding
and spending as well as rolling Unified Addresses.

Users should obtain addresses by rolling them from the SDK.
USKs replace Sapling Extended Spending keys and TransparentAccountPrivKeys
when shielding or spending

Closes #534

Co-authored-by: Kris Nuttycombe <kris@nutty.land>

* Fix rebase issues

* PR Suggestion. Make `lastError` an Optional

* Fix test `testReOrgRemovesOutboundTxAndIsNeverMined`

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-10-02 23:11:17 -03:00
Francisco Gindre bee1c9db80 Merge branch 'master' into merge_master_to_zip_316 2022-09-15 11:04:49 -03:00
Lukas Korba 2b65bd46e4 [476] CompactBlockProcessor to async/await
- getting rid of the Operation Queue
- the cleanup is needed
- the update of tests is needed
- tested and it successfully finishes the sync process

[476] CompactBlockProcessor to async/await

- old processNewBlocks() removed

[476] CompactBlockProcessor to async/await

- unused operations removed

[476] CompactBlockProcessor to async/await

- unit tests update

[476] CompactBlockProcessor to async/await

- unit tests refactored

[476] CompactBlockProcessor to async/await

- cleanup of deprecated method

[476] CompactBlockProcessor to async/await

- fail(error) was called even for canceled tasks but that must be excluded

[476] CompactBlockProcessor to async/await

- removal of all ZcashOperations from the code (unit test will follow)

[476] CompactBlockProcessor to async/await

- network tests in building and success order again

[476] CompactBlockProcessor to async/await

- offline tests in building and success order

[476] CompactBlockProcessor to async/await (519)

- cleanup of suspending the task

[476] CompactBlockProcessor to async/await (519)

- most comments resolved

[476] CompactBlockProcessor to async/await (519)

- thread safe state for both sync and async context

[476] CompactBlockProcessor to async/await (519)

- fixed build for a sample project

[476] CompactBlockProcessor to async/await (519)

- func testStartNotifiesSuscriptors() reverted

[476] CompactBlockProcessor to async/await (519)

- TODO added to track why we used NSLock instead of an Actor
- Task priority enhanced

[476] CompactBlockProcessor to async/await (519)

- cleanup in Tasks and priorities
2022-09-15 08:10:12 +02:00
Francisco Gindre ed87a2781c [#461] Adopt a Type-Safe Keys and Addresses API
This PR creates data types for Addresses and Keys so that they are
not represented by Strings anymore. This avoids mistakenly use
the wrong keys because they are all alike for the type system.

New Protocols:
=============

StringEncoded -> Protocol that makes a type can be expressed in an
string-encoded fashion either for UI or Interchange purposes.

Undescribable -> A protocol that implements methods that override default
decriptions used by debuggers, loggers and event trackers to avoid types
conforming to it to be leaked to logs.

Deleted Protocols:
==================

UnifiedFullViewingKey --> turned into a struct.
UnifiedAddress --> turned into a struct

new Error Type:
================

````
enum KeyEncodingError: Error {
    case invalidEncoding
}
````

This error is thrown when an Address or Key type (addresses are public
keys in the end) can be decoded from their String representation,
typically upon initialization from a User input.

New Types:
=========

SaplingExtendedSpendingKey -> Type for Sapling Extended Full Viewing Keys
this type will be replaced with Unified Spending Keys soon.

SaplingExtendedFullViewingKey -> Extended Full Viewing Key for Sapling.
Maintains existing funcionality. Will be probably deprecated in favor of
UFVK.

TransparentAccountPrivKey -> Private key for transparent account. Used
only for shielding operations. Note: this will probably be deprecated soon.

UnifiedFullViewingKey -> Replaces the protocol that had the same name.

TransparentAddress -> Replaces a type alias with a struct

SaplingAddress --> Represents a Sapling receiver address. Comonly called zAddress. This address corresponds to the Zcash Sapling shielded pool.
Although this it is fully functional, we encourage developers to
choose `UnifiedAddress` before Sapling or Transparent ones.

UnifiedAddress -> Represents a UA. String-encodable and Equatable. Use of
UAs must be favored instead of individual receivers for different pools.
This type can't be decomposed into their Receiver types yet.

Recipient -> This represents all valid receiver types to be used as
inputs for outgoing transactions.

````
public enum Recipient: Equatable, StringEncoded {
    case transparent(TransparentAddress)
    case sapling(SaplingAddress)
    case unified(UnifiedAddress)
````

The wrapped concrete receiver is a valid receiver type.

Deleted Type Aliases:
=====================

The following aliases were deleted and turned into types
````
public typealias TransparentAddress = String
public typealias SaplingShieldedAddress = String

````

Changes to Derivation Tool
==========================

DerivationTool has been changed to accomodate this new types and
remove Strings whenever possible.

Changes to Synchronizer and CompactBlockProcessor
=================================================
Accordingly these to components have been modified to accept the
new types intead of strings when possible.

Changes to Demo App
===================
The demo App has been patch to compile and work with the new types.
Developers must consider that the use (and abuse) of forced_try and
forced unwrapping is a "license" that maintainers are using for the
sake of brevity. We consider that clients of this SDK do know how to
handle Errors and Optional and it is not the objective of the demo
code to show good practices on those matters.

Closes #461
2022-09-05 15:09:07 -03:00
Jack Grigg def779e5bc Migrate to ZIP 316 UFVKs
This also brings in various associated changes to the FFI methods in
zcash-light-client-kit as a result of moving to the main branch of
zcash/librustzcash.
2022-08-24 09:33:42 -06:00
Lukas Korba 6d0f241ed6
[#475] NextStateHelper to async/await (#495)
- refactored to await/async
2022-08-23 16:58:15 -03:00
Francisco Gindre 40df80ef25
[#455] revert queue priority downgrade changes from [#435] (#456)
Closes #455

this reverts queue priority changes from commit `a5d0e447748257d2af5c9101391dd05a5ce929a2` since we detected it might prevent downloads to be scheduled in a
timely fashion

Co-authored-by: pacu <pacu@pacus-MacBook-Pro.local>
2022-08-15 17:03:03 -03:00
Francisco Gindre a2283f0171
[#449] Use CompactBlock Streamer download instead of batch downloads (#451)
* [#449] Use CompactBlock Streamer download instead of batch downloade

This commit implements a small buffer for the stream download operation
so it does not store a block at a time and does it in batches instead.

Closes #449

* Fix tests

* PR Suggestions
2022-07-30 20:01:18 -03:00
Francisco Gindre a5d0e44774
[#435] thread sanitizer issues (#448)
* [#435] this commit attempts to fix thread being starved dues to inversion
of priorities where a .userInitiated thread ends up depending on a lower
priority one on GRPC.

* Add an Synchronizer State struct to report state at once

* Make CompactBlockProcessor's downloader available internally for SDKSynchronizer
remove duplicate handling of processor finished

* PR Suggestions
2022-07-29 15:20:55 -03:00
Francisco Gindre 96520aeb7c
[#440] Split constants for Download Batches and Scanning Batches (#441)
this commit splits the batch sizes so that wallets can be tweaked to either scan or download more or less blocks depending of the CompactBlockProcessor.Config used. Defaults are provided

This also bumps up the default time out for GRPC services to 30 seconds to unary calls and 100 seconds to streaming calls
Also, adds some documentation formatting that won't hurt

PR Suggestions

PR Suggestions
2022-07-29 10:07:08 -03:00
Francisco Gindre 2fcfa6fdbe
[#398] Make WalletBirthday an internal type (#414)
This commit makes Renames `WalletBirthday` to `Checkpoint` and
makes Checkpoint an internal type. Public ocurrences of this
type is replaced by `BlockHeight` (Int) and then retrieval of the
Checkpoint is deferred to the appropiate place in the code

Add an extension method to `BlockHeight` to get latest checkpoint
height present in the SDK's bundle

PR Suggestions:

Add test for integer overflow on JSON
File renamed from WalletBirthday to Checkpoint
2022-07-12 16:36:12 -03:00
Daniel Haight 86d1257ab5 Remove dependecy on rust sources 2022-02-28 17:03:20 +00:00