Commit Graph

19 Commits

Author SHA1 Message Date
Lukas Korba e51f425c54 [#1369] SynchronizerState refactor
- plural of account balances refactor to singular

[#1369] SynchronizerState refactor

- transaprent balance removed from SynchronizerState
- all balances are now handled with AccountBalance

[#1369] SynchronizerState refactor and balances cleanup

- WalletBalance has been removed from the SDK, replaced with AccountBalance
- public APIs for individual balances (getTransparent, getShielded, getShieldedVerfied) have been removed from the SDK, replaced with getAccountBalance
- tests refactored

[#1369] SynchronizerState refactor and balances cleanup

- dark side tests refactored

[#1369] SynchronizerState refactor and balances cleanup (#1372)

- addressed comments

[#1369] SynchronizerState refactor

- ZcashError for spending key does not belong to the wallet
2024-02-12 17:41:26 +01:00
Lukas Korba c7369057f1 [#1153] Allow runtime switch of lightwalletd servers
- new public API switchTo(endpoint:) implemented

[#1153] Allow runtime switch of lightwalletd servers

- API documented
- code cleaned up

[#1153] Allow runtime switch of lightwalletd servers

- mocks generated

[#1153] Allow runtime switch of lightwalletd servers (#1373)

- sever validation added

[#1153] Allow runtime switch of lightwalletd servers (#1373)

- enhanced validation of the server

[#1153] Allow runtime switch of lightwalletd servers (#1373)

- new ZcashError.synchronizerServerSwitch that represents the state when the endpoint fails validation

[#1153] Allow runtime switch of lightwalletd servers (#1373)

- ZcashError definition update

[#1153] Allow runtime switch of lightwalletd servers (#1373)

- addressed comments

[#1153] Allow runtime switch of lightwalletd servers (#1373)

- changelog revert according to proposal
2024-02-12 17:13:08 +01:00
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 4b45c15a96 Comments addressed
- all comments from the review (round 1) resolved
2023-09-13 09:24:26 +02:00
Lukas Korba 60780f4c83 [#1238] Report sync progress with the new getScanProgress
- getScanProgress used for reporting of the syncing progress

[#1238] Report sync progress with the new getScanProgress

- comment added

[#1238] Report sync progress with the new getScanProgress (#1239)

- TODOs + offline tests fixed
2023-09-08 12:19:54 +02:00
Lukas Korba c894f46ce9 [#1188] Working prototype of SbS
- cleaned up the code
- ScanAlgorithm enum added to the SDK
- preferred sync algorithm set to .linear as default but can be changed to Spend before Sync as the Initializer.init parameter

[#1188] Working prototype of SbS

- error codes for failure states in the SbS State Machine changes added

[#1188] Working prototype of SbS (#1192)

- offline tests fixed
2023-09-07 13:23:47 +02:00
Lukas Korba 8f7294c3e1 [#1165] draft
draft

[#1165] Step 1 - Download note commitment tree data from lightwalletd

- code cleanup after draft

[#1165] Step 1 - Download note commitment tree data from lightwalletd

- UpdateSubtreeRootsAction added, ensuring the roots are downloaded and stored in the DB

[#1165] Step 1 - Download note commitment tree data from lightwalletd

- added ZcashError for putSaplingSubtreeRoots failure
- cleaned up action

[#1165] Step 1 - Download note commitment tree data from lightwalletd

- demo app config temporarily updated to Nighthawk server

[#1165] Step 1 - Download note commitment tree data from lightwalletd

- file header updated

[#1165] Step 1 - Download note commitment tree data from lightwalletd (#1174)

- demo app config cleaned up

[#1165] Step 1 - Download note commitment tree data from lightwalletd (#1174)

- offline tests fixed
2023-09-07 13:23:47 +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
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 6eb39561ec Migrate to Rust backend with fast spendability support 2023-07-19 18:13:59 +01:00
Lukas Korba 34af1f1611 [#1140] ClearCache action before anything starts
- draft

[#1140] ClearCache action before anything starts

- ClearCache action right after the idle action, clearing out metadata so the sync process can be fully restored from the DB and live blockchain values only.
- InternalSyncProgress removed
- InternalSyncProgressStorage removed
- Sync process control logic updated, controlled by latestScannedHeight and firstUnenhancedHeight only
- cleaned up unused code

[#1140] ClearCache action before anything starts

- ChecksBeforeSyncAction removed
- Offline tests fixed

[#1140] ClearCache action before anything starts

- fixed injection of a wallet birthday, the sync range must start with wallet BD instead of lower bound

[#1140] ClearCache action before anything starts

- Network tests fixed
- DarkSideTests partially fixed

[#1140] ClearCache action before anything starts

- rewind actions extension in compact block processor added

[#1140] ClearCache action before anything starts

- draft

[#1140] ClearCache action before anything starts

- DarkSideTests fixed

[#1140] ClearCache action before anything starts

- SyncRanges modified to be even less dependent on ranges, now it holds just 3 values (latest block height, latest scanned height if any, first unenhanced height if any), the rest is computed on the fly

[#1140] ClearCache action before anything starts

- SyncRanges struct not anymore, refactored to SyncControlData, holding just 3 mentioned values

[#1140] ClearCache action before anything starts

- cleanup

[#1140] ClearCache action before anything starts (#1148)

- TODO solved, the UTXOs fetcher doesn't work with range anymore, therefore reporting 100%
2023-06-28 12:34:41 +02:00
Lukas Korba f1c4947a2c [#1141] Implement firstUnenhancedHeight
- Transaction repository extended to provide first unenhanced height or nil

[#1141] Implement firstUnenhancedHeight (#1145)

- tests and mocks extended to be aware of firstUnenhancedBlock
2023-06-15 17:11:09 +02:00
Michal Fousek c0c0c426d5 [#1111] Change storage for InternalSyncProgress
Closes #1111

- `InternalSyncProgress` has now new disk storage implementation:
  `InternalSyncProgressDiskStorage`.
- When then `UserDefaults` was used as disk storage there were no IO errors
  to handle. But now the code in `InternalSyncProgressDiskStorage`
  writes to files and reads from files. So there are errors to handle.
  Because of this protocol `InternalSyncProgressStorage` changed a bit
  and API of `InternalSyncProgress` changed a bit. Now all the functions
  throws.
- It is possible to make progress storage IO errors silent but I think
  that storing of the progress is very essential to the sync process. So
  I think that when progress storage fails then the sync process should
  fail.
- `Initializer` has new parameter `generalStorageURL`. It is directory
  where `InternalSyncProgressDiskStorage` stores progress files. In
  future this can be used for storing any data the SDK wants.
2023-05-22 20:42:11 +02:00
Lukas Korba 355a3fc4f5
Merge pull request #1036 from LukasKorba/1035-Create-ZcashError.unknown
- new ZcashError.unknown that wraps and handles any Error addedCreate ZcashError.unknown
2023-05-10 14:49:03 +02:00
Lukas Korba 9c611b31e3 [#1035] Create ZcashError.unknown
- new ZcashError.unknown that wraps and handles any Error added

[#1035] Create ZcashError.unknown (#1036)

- improved the conversion of error -> ZcashError

[#1035] Create ZcashError.unknown (#1036)

- detailed comments of the unknown case
2023-05-10 14:48:16 +02:00
Lukas Korba 44e17ca042 [#843] Simplify Synchronizer Status
- SyncStatus refactored to InternalSyncStatus, so the SDK works internally with the SyncStatus as previously
- new SyncStatus is a computed property that maps InternalSyncStatus to simplified SyncStatus

[#843] Simplify Synchronizer Status (#1010)

- simplification of SyncStatus done
- % computation moved to the mapping function so the rest of the SDK works just like before
- fixed unit tests
- new unit tests checking the boundaries of the new progress

[#843] Simplify Synchronizer Status (#1010)

- removed commented code

[#843] Simplify Synchronizer Status (#1010)

- package.resolved

[#843] Simplify Synchronizer Status (#1010)

- fixed dark side tests

[#843] Simplify Synchronizer Status (#1010)

- package.resolved
2023-05-09 12:35:49 +02: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
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