Commit Graph

46 Commits

Author SHA1 Message Date
Jack Grigg ded20fe7b0 Migrate to in-progress version of FFI backend 0.5.0
Includes:
- Exposed `WalletSummary`.
- Exposed transaction proposals.
- `ScanSummary` returned from `ZcashRustBackend.scanBlocks`.

Closes Electric-Coin-Company/zcash-swift-wallet-sdk#1259.
Closes Electric-Coin-Company/zcash-swift-wallet-sdk#1299.
2024-01-29 09:47:14 -08:00
Lukas Korba fb7eb1978d [#1310] Release 2-0-3
- checkpoints updated

[#1310] Release 2-0-3

- FFI version bumped
- other dependencies bumped as well

[#1310] Release 2-0-3

- checkpoints mentioned in the changelog
2023-10-20 12:46:15 +02:00
Kris Nuttycombe 71a6f580fc Update `zcash-light-client-ffi` for 2.0.0 final release. 2023-09-25 15:55:49 -06:00
Kris Nuttycombe d8b069fd15 Update librustzcash to fix transparent balance issues. 2023-09-22 18:18:10 -06:00
Kris Nuttycombe 404eff21b1 Update to zcash-light-client-ffi version 0.4.0-rc.3 2023-09-19 15:43:52 -06:00
Kris Nuttycombe 4b754c5378 Update zcash-light-client-ffi package revision. 2023-09-19 12:09:28 -06:00
Kris Nuttycombe 2c526dbcd6 Update `zcash-light-client-ffi` to adopt fix for missing transparent history.
Fixes #1271

Co-Authored-By: Jack Grigg <jack@electriccoin.co>
Co-Authored-By: Lukas Korba <lukas.korba@seznam.cz>
2023-09-19 08:26:03 -06:00
Kris Nuttycombe 2ac984a0dd Update zcash-light-client-ffi to version 0.4.0-rc.2 2023-09-12 10:06:25 -06:00
Kris Nuttycombe 457cc9a9e7 Update zcash-light-client-ffi to fix an error with checkpoint depths.
See [zcash/librustzcash#963]
2023-09-11 19:16:17 -06:00
Kris Nuttycombe e28035292f Release 2.0.0-rc1
* Updates to `zcash-light-client-ffi 0.4.0-rc.1`
* Makes some cleanup updates to the CHANGELOG; a complete changelog will
  be prepared for the 2.0.0 final release.
2023-09-11 19:10:55 -06:00
Kris Nuttycombe 6c3dd362b6 Update Rust dependencies with bugfixes.
The previous `zcash-light-client-ffi` revisions should be treated as
ephemeral; they will be removed upon creation of the SDK 2.0.0 release
candidate.
2023-09-07 23:16:26 -06:00
Jack Grigg 01436c9a93 Update Rust dependencies with bugfixes
The previous FFI repo revisions no longer exist; commits between
87faf91096 and here will not build.
2023-09-07 19:54:12 +01:00
Lukas Korba 7e2e787aef [#1223] Requested height [over latestheight] does not exist in the block cache
- the end of scan range is now properly filled

[#1223] Requested height [over latestheight] does not exist in the block cache

- the end of scan range is now properly filled
- unit tests for this change, checking if range.upperBound is set as expected

[#1223] Requested height [over latestheight] does not exist in the block cache

- code cleanup
2023-09-07 13:23:50 +02:00
Lukas Korba 95536638e5 [#1176] Cover Spend before Sync with tests
- WIP

[#1176] Cover Spend before Sync with tests

- next batch of updates

[#1176] Cover Spend before Sync with tests

- last batch of fixes and new tests

[#1176] Cover Spend before Sync with tests

- package.resolved updated

[#1176] Cover Spend before Sync with tests (#1212)

- added tests for brand new actions related Spend before Sync
- RewindActionTests
- UpdateChainTipActionTests
- UpdateSubtreeRootsActionTests
- ProcessSuggestedScanRangesActionTests
2023-09-07 13:23:50 +02:00
Jack Grigg e7621204e5 Update Rust dependencies with account birthdays and scan progress
The previous FFI repo revisions no longer exist; commits between
87faf91096 and here will not build.

Update Rust dependencies with account birthdays and scan progress

- fixes for SampleApp
2023-09-07 09:26:48 +02:00
Kris Nuttycombe 8f2962f060 Update the `zcash-light-client-ffi` dependency version. 2023-08-28 10:08:12 -06:00
Jack Grigg bc052872fd Update Rust dependencies with scanning and spending bugfixes
The previous FFI repo revisions no longer exist; commits between
87faf91096 and here will not build.
2023-08-17 21:47:27 -07:00
Jack Grigg cddf6891fd Update Rust dependencies with checkpoint and memo bugfixes
The previous FFI repo revisions no longer exist; commits between
87faf91096 and here will not build.
2023-08-08 12:30:28 +01:00
Jack Grigg ea3281edde Update Rust dependencies with bugfixes
The previous FFI repo revision no longer exists; commits between
87faf91096 and here will not build.
2023-07-31 09:56:40 +02:00
Lukas Korba 5e8985d24e [#1162] Remove duplicated SubtreeRoot
- SubtreeRoot placeholder removed, we can rely on the generated one from the gprc
2023-07-21 13:52:58 +02:00
Francisco Gindre f33280c8c4
[#1108] Instrument rust backend tracing (#1109)
* [#1108] Instrument rust backend tracing

This adds a parameter to the `Initializer` constructor that allows
developers to turn on performance trancing tooling on the Rust
backend. It can't be disabled on the fly. It's either OFF or ON
all the life-span for the Synchronizer.

Closes #1108

Update ffi framework commit hash

* update resolved filed
2023-05-23 13:31:30 -03: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 08d9d3986e Upgrade SPM packages in the SDK sample app 2023-04-20 15:21:09 +02: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 be8afabec4 [#770] Update GRPC swift library
Closes #770
2023-02-09 19:55:46 +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 bb57d5d9fe [#728] Remove Swiftilint SPM package plugin
Closes #728
2023-01-20 09:24:50 +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
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 44a6970b73 [#616] Dont send notification from SDK on main thread
Closes #616

- Added small helper `NotificationSender` which is used to send
  notifications.
- No notificaiton is sent on main thread.
- Change how `status` is stored and update in `SDKSynchronizer`. It is
  now protected by lock. Before this wasn't needed because status was
  updated from main thread everywhere.
- `SyncBlocksViewController` in the sample app now uses
  `SDKSynchronizer` instead of `CompactBlockProcessor` directly.
2022-11-21 16:33:42 +01:00
Michal Fousek 5e723566ba [#619] Correctly resume syncing process in scanning phase
Closes #619

- When computing next action in `NextStateHelper.nextStateAsync` now
  scanning state is also taken into consideration.
- When processing blocks download phase is skipped when it's detected
  that everything is already downloaded.
2022-11-11 14:54:44 +01:00
Francisco Gindre bb015008cf 0.17.0-alpha.4 2022-11-04 15:28:13 -03:00
Michal Fousek d3291a6664 Fix Package.resolved file for Sample SDK app 2022-11-03 17:12:09 +01:00
Francisco Gindre dbd4b8934c Merge branch 'master' into merge-master 2022-10-31 09:34:38 -03:00
Francisco Gindre 245f2324b5 [#597] SDK does not build with SQLite 0.14 2022-10-28 14:20:52 -03: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
Francisco Gindre 1d97ad920b [#581] getTransparentBalanceForAccount error not handled 2022-10-26 20:26:37 -03:00
Michal Fousek d4dc571f27 Fix compilation 2022-10-04 17:32:32 +02: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 a9805cfe7e [#530] Implement ability to extract available typecodes from UA
this introduces several types under UnifiedAddress `ReceiverTypecodes`
and `UnifiedAddress.Errors` to host possible errors on third-party
generated UAs and their composition

Implement extracting the typecodes from a UA
2022-09-19 14:52:30 -03: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
Kris Nuttycombe 905ee401d1 Use zcash_client_sqlite to manage migrations for the wallet db.
This change removes responsibility for maintaining the state of
the wallet database from `ZcashLightClientKit` in favor of using
the migration system now provided by librustzcash. This will help
to ensure that the structure of the database is kept consistent with
the functions that query and update the database state.

Co-authored-by: Francisco Gindre <francisco.gindre@gmail.com>
2022-08-24 09:38:42 -06:00
Francisco Gindre b9ae012e09
[#381] Move Zatoshi and Amount Types to the SDK (#396)
Closes #381

This commit brings a Zatoshi type developed on the Secant project,
helper classes like Clamped and tests.

Zatoshi has been incorporated as a Codable type for SQLite Swift
to allow serialization into the pending database.

FIXES on Demo App

fix comments
2022-06-22 16:45:37 -03:00
Francisco Gindre 605a3e9881 Update changelog.md and podspec version
Fix Travis CI builds

fix travis build

Fix Travis CI

fix travis

Fix Travis CI

Delete unneeded test

Change scheme

Fix Project file so that it compile and tests for Travis CI

restore Demo app scheme

fix dumb typo

Fix Tests. Add workflow

fix workflow for github action

blank line
2022-03-03 19:07:03 -03:00
Daniel Haight 86d1257ab5 Remove dependecy on rust sources 2022-02-28 17:03:20 +00:00