Commit Graph

1017 Commits

Author SHA1 Message Date
Lukas Korba 562780ef4f [#1180] Handle production GetSubtreeRootsArg
- the value 65536 set only for testnet
2023-08-10 08:30:58 +02:00
Lukas Korba 5bfd8aee31 [#1189] Implement continuity check and RewindAction
- RewindAction added
- rust's isContinuityError() emulated on iOS side
- verify scan range is now properly handled with rewind as well as check for continuity error

[#1189] Implement continuity check and RewindAction (#1195)

- TODO cleanup
2023-08-09 20:20:59 +02:00
Lukas Korba ff3af58a81 [#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-08-09 13:21:10 +02:00
Lukas Korba 458aeeea4c [#1169] Step 5 -Get the suggested scan ranges from the wallet database
- initial action in place
- verify loop WIP

[#1169] Step 5 -Get the suggested scan ranges from the wallet database

- firstUnenhancedHeight fix

[#1169] Step 5 -Get the suggested scan ranges from the wallet database

- first working version implemented
- download, scan and enhance actions are dependent on the context values only
2023-08-09 13:21:10 +02:00
Lukas Korba 2a095d270f [#1167] Step 3 - Download chain tip metadata from lightwalletd
- update chain tip action added

[#1167] Step 3 - Download chain tip metadata from lightwalletd

- roots removed from the ActionContext

[#1167] Step 3 - Download chain tip metadata from lightwalletd

- fallback to linear sync until next step is implemented

[#1167] Step 3 - Download chain tip metadata from lightwalletd

- offline tests fixed
2023-08-09 13:19:44 +02:00
Lukas Korba df7d86f4ff [#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
2023-08-09 13:19:44 +02:00
Lukas Korba d163d9a079 [#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-08-09 13:19:44 +02:00
Lukas Korba 84620ed747
Merge pull request #1187 from zcash/rust-checkpoint-and-memo-bugfixes
Update Rust dependencies with checkpoint and memo bugfixes
2023-08-09 13:16:16 +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
Lukas Korba 4d95f2cb9d
Merge pull request #1185 from LukasKorba/1184-FirstUnenhancedHeight-not-called
[#1184] FirstUnenhancedHeight not called
2023-08-04 11:08:07 +02:00
Lukas Korba ad99fdeae8 [#1184] FirstUnenhancedHeight not called
- firstUnenhancedHeight is now properly used
- fixed tests
2023-08-04 09:56:57 +02:00
Lukas Korba b9524ae1ab
Merge pull request #1183 from LukasKorba/1182-Update-checkpoints
[#1182] Update checkpoints
2023-08-03 11:48:18 +02:00
Lukas Korba a6d0f97351 [#1182] Update checkpoints
- mainnet & testnet checkpoints
2023-08-03 11:43:29 +02:00
Lukas Korba e4cea0c265
Merge pull request #1173 from zcash/update-rust-deps
Update Rust dependencies with bugfixes
2023-07-31 11:56:35 +02:00
Lukas Korba d6507b7b84 epk key refactor
epk -> ephemeralKey refactor done so offline tests in the SDK pass, therefore the CI passes as well
2023-07-31 11:47:29 +02: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
str4d 27b7e78bcc
Merge pull request #1163 from LukasKorba/1162-Remove-duplicated-SubtreeRoot
[#1162] Remove duplicated SubtreeRoot
2023-07-21 23:00:15 +01: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
Lukas Korba 87faf91096
Merge pull request #1160 from zcash/fast-spendability
Migrate to Rust backend with fast spendability support
2023-07-21 09:25:24 +02:00
Lukas Korba dd5a54e88a
Merge pull request #1159 from LukasKorba/1157-Update-proto-files
[#1157] Update proto files
2023-07-20 13:22:38 +02:00
Jack Grigg 6eb39561ec Migrate to Rust backend with fast spendability support 2023-07-19 18:13:59 +01:00
Lukas Korba 0bc33addf0 [#1157] Update proto files
- compact_formats, service and Darkside proto files updated
- swift files generated
2023-07-19 08:15:26 +02:00
Lukas Korba 6bb054ba2f
Merge pull request #1156 from LukasKorba/1147-Update-cbp_state_machine-png
[#1147] Update cbp_state_machine_png
2023-07-05 13:28:48 +02:00
Lukas Korba 6687b914fd [#1147] Update cbp_state_machine_png
- uml diagram updated
- png file updated
2023-07-04 12:45:34 +02:00
Lukas Korba 8065aa718d
Merge pull request #1155 from tw0po1nt/1154-fix-inverted-sync-status-flags
Fix inverted sync status flags
2023-07-03 15:10:41 +02:00
Matthew Watt 52a80edbd9 Fix inverted sync status flags, and update internal structure to follow same, simpler if pattern 2023-07-02 15:32:47 -05:00
Lukas Korba d2b5341fa1
code_ql.yml deleted 2023-06-30 15:11:17 +02:00
Lukas Korba 015ed66873
Merge pull request #1151 from LukasKorba/1150-Remove-Travis-CI-yml-file 2023-06-29 21:01:58 +02:00
Lukas Korba 25642eb582 [#1150] Remove Travis CI yml file
- file removed
2023-06-29 19:26:32 +02:00
Lukas Korba 605af0417f
Merge pull request #1149 from zcash/feature/pre-dag
The feature branch consists of 3 main parts of the new synchronization management

- the State Machine being aware of previous state
- the new firstUnenhancedHeight API
- ClearCache being called at the beginning of the State Machine
2023-06-28 15:00:37 +02:00
Lukas Korba d930517348
Merge pull request #1148 from LukasKorba/1140-ClearCache-action-before-anything-starts
ClearCache action called 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
ChecksBeforeSyncAction removed
Offline tests fixed
fixed injection of a wallet birthday, the sync range must start with wallet BD instead of lower bound
Network tests fixed
rewind actions extension in compact block processor added
DarkSideTests fixed
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
SyncRanges struct not anymore, refactored to SyncControlData, holding just 3 mentioned values
code cleanup
2023-06-28 14:28:16 +02: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 90a9e0057d
Merge pull request #1146 from LukasKorba/1144-Make-State-Machine-context-aware-of-previous-state
[#1144] Make State Machine context aware of previous state
2023-06-20 11:57:06 +02:00
Lukas Korba 9984e7fd0d
Merge pull request #1145 from LukasKorba/1141-Implement-getLastEnhancedHeight
[#1141] Implement firstUnenhancedHeight
2023-06-20 11:56:44 +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
Lukas Korba 440910282a [#1144] Make State Machine context aware of previous state
- ActionContext extended to hold an optional previous state value
- unit tests for the ActionContext previous state
2023-06-15 17:07:44 +02:00
Michal Fousek 3629861b7a
Merge pull request #1136 from zcash/feature/700_cbp_as_state_machine
[#700] Rewrite CompactBlockProcessor as state machine
2023-05-30 15:26:40 +02:00
Michal Fousek 21a3c06b00 [#700] CompactBlockProcessor as state machine proof of concept
- For now I created `CompactBlockProcessorNG` where I started with
  implementation of the state machine. I did it to not break the rest of
  the SDK. This change will be merged to the feature branch. And before
  it is merged to `main` branch code from `CompactBlockProcessorNG` will
  be moved to `CompactBlockProcessor`.
- The new code is not used. It just shows and explains how it is done.
  It is proof of concept.
- I did put either commented current code or comment to some places to
  explain what should be done there.
- New important data types:
  - `ActionContext` is context that can hold any data that needs to be
    shared between actions. For example sync ranges or current state.
  - `CBPState` is state of the `CompactBlockProcessor`. Each state is
    handled by one action. This doesn't apply to terminal states like
    `finished` or `failed`.
  - `ActionProgress` is very similar to `CompactBlockProgress`.
    Different actions reports progress differently and `ActionProgress`
    represents this.
  - `Action` is protocol that defines API of an action. It has one run
    method that executes the code of the action
- CBP first creates actions for (almost) each state in `makeActions()`
  method. Then the "magic" is done in `CompactBlockProcessorNG.run()` method.
  Here is main loop which takes action for current state and execute it.
  It's expected that action does it's work and then updates the context
  with new state. And this happens until some terminal state
  (`finished`, `failed`, `stopped`) is reached.
- After the transition to state machine API of the
  `CompactBlockProcessor` should stay the same. No changes should be
  required in `SDKSynchronizer`.

[#700] Add documentation for CompactBlockProcessor state machine

- plantuml tool is used to generate diagram.

[#1054] Add config to state machine CBP

Closes #1054

[#1043] Implement DownloadAction

Closes #1043

[#1049] Implement ValidateAction

Closes #1049

[#1050] Implement ValidateServerAction

Closes #1050

[#1056] Add constructors to state machine CBP

Closes #1056

[#1061] Add failure methods for state machine CBP

Closes #1061

[#1055] Implement retry timer to state machine CBP

Closes #1055

[#1057] Implement start for state machine CBP

Closes #1057

[#1058] Implement stop for state machine CBP

Closes #1058

[#1052] Implement AfterSyncHooksManager when using state machine CBP

Closes #1052

[#1060] Implement wipe for state machine CBP

Closes #1060

[#1059] Implement rewind for state machine CBP

Closes #1059

[#700] Add idle state to CBP state machine

This is required so the CBP can detect start of the sync process.

[#700] Implement sending of some events from CompactBlockProcessorNG

[#700] Implement progress reporting in state machine CBP

[#1045] Implement FetchUTXOsAction

- draft of the fetching

[#1045] Implement FetchUTXOsAction

- updated the way Actions communicate data back to the CBP
- used this mechanism to pass result of utxos fetch so it's passed to the SDKSynchronizer as an Event

[#1042] Implement ComputeSyncRangesAction

Closes #1042

[#700] Implement cache clearing when some actions fail

[#1043] Fix batch range computation in DownloadAction

[#1046] Implement SaplingParamsAction

- action for sapling param files finished

[#1048] Implement ScanDownloadedButUnscannedAction

- scan downloaded but unscanned blocks

[#1047] Implement ScanAction

- scan action with the proper ranges computed

[#1047] Implement ScanAction (#1085)

- fixed logger message

[#1044] Implement EnhanceAction

Closes #1044

[#1041] Implement ClearCacheAction

Closes #1041

[#1040] Implement ClearAlreadyScannedBlocksAction

Closes #1040

[#1039] Implement ChecksBeforeSyncAction

Closes #1039

[#700] Make CBP state machine work

[#1050] Implement ValidateServerAction

- broken tests commented out and tracked in the tickets
- new test for ValidateServerAction

[#1051] Update how progress is computed after switch to state machine

Closes #1051

- new proposal for the progress computation
- OverallProgress value is passed to the Synchronizer as a Float
- OverallProgress is a result of fetch, scan and enhance operations
- Order of actions no longer influences the computation
- Actions report partial updates, CompactBlockProgress actor holds current state and computes the OverallProgress

[#1049] Implement ValidateAction

- synchronizer offline tests updated so it compiles, review is requested in a different ticket
- ValidateAction tests added
- BlockValidator mock generated

[#1047] Implement ScanAction

- ScanAction tests
- refactor of validateAction -> validateServerAction
- generated few more mocks for the DI

[#1045] Implement FetchUTXOsAction

- FetchUTXOsAction tests
- UTXOFetcher mocks

[#1045] Implement FetchUTXOsAction

- enhanced with mocked values and more checks

[#1046] Implement SaplingParamsAction

- SaplingParamsAction tests
- added TODO for TestCoordinator reset()
- SaplingParametersHandler mock added

[#1046] Implement SaplingParamsAction

- SaplingParamsAction tests
- added TODO for TestCoordinator reset()
- SaplingParametersHandler mock added

[#1046] Implement SaplingParamsAction

- rebased so I get functionality of improved mock checks
- enhanced SaplingParamsAction tests
- enhanced ValidateAction tests
- enhanced ScanAction tests

[#1046] Implement SaplingParamsAction

- scanAction tests more checks added

[#1044] Implement EnhanceAction

- EnhanceAction tests focused on 2 different methods:
- decideWhatToDoNext covered separately, decisions where the state machine goes next
- run tests for different cases
- new mocks generated for enhacer
- some typos fixed

[#1044] Implement EnhanceAction (#1107)

- empty assert messages fixed

[#700] Get rid of ScanDownloadedButUnscannedAction

Before the state machine download and scan was called in one loop. And
processing range for one batch was same for both of them. Therefore
there was code which scanned downloaded but not scanned blocks.

But now download and scan are independent. So it is possible to remove
`ScanDownloadedButUnscannedAction`.

[#700] Make NetworkTests compilable

Some tests are disabled for now (list is in #1115). And `NetworkTests`
can be compiled and all the enabled tests work.

[#1043] Implement DownloadAction

- DownloadAction tests
- BlockDownloader mock

[#1043] Implement DownloadAction (#1110)

- support functions set to private

[#1039] Implement ChecksBeforeSyncAction

- ChecksBeforeSyncAction tests
- all support functions in Action tests are set to private
- let _ = -> _ = refactor
- CompactBlockRepository mock added

[#1040] Implement ClearAlreadyScannedBlocksAction

- Implement ClearAlreadyScannedBlocksAction tests
- CompactBlockRepository mock added

[#1041] Implement ClearCacheAction

- ClearCacheAction tests
- CompactBlockRepository mock added

[#1042] Implement ComputeSyncRangesAction

- ComputeSyncRangesAction tests
- fixed all tests after merge of latest SDK changes related InternalSyncProgress
- all actions marked as final class

[#1042] Implement ComputeSyncRangesAction (#1120)

- Custom LatestBlocksDataProviderMock removed from the project

[#1122] Implement FileManager protocol and dependency

- ZcashFileManager implemented
- MigrateLegacyCacheDBAction refactored to be dependent on ZcashFileManager
- ZcashFileManager mock added

[#1122] Implement FileManager protocol and dependency (#1124)

- code cleanup

[#1121] Implement MigrateLegacyCacheDBAction

- MigrateLegacyCacheDBAction tests WIP
- tests naming cleanup

[#1121] Implement MigrateLegacyCacheDBAction

- MigrateLegacyCacheDBAction tests finished

[#700] Fix DarksideTests

Closes #1102

Some tests that can't be compiled are disabled for now. List is in #1126.

This PR contains multiple fixes. Most of the fixes is done in the code.
Not in the tests. That is good news.

Fixes:
- `config` inside `CompactBlockProcessor` can be updated during the
  tests. And it must be also updated inside the actions. So
  `ConfigProvider` is added and it is wrapper for config that is passed
  to any instance of `Action` and provides updated config.
- Fixed `EnhanceAction`. Now it should update all the blocks in the
  enhance range even when the remaining count of blocks is lower than
  1000.
- Fixed `fail()` and `validationFailed()`. These two were canceling
  `syncTask`. But that stopped run loop in a bad way.

[#1129] Final check of all State Machine Action tests

- XTCAsset messages checked
- test naming checked and fixed

[#1126] Fix DarksideTests in state machine branch

Closes #1126

Fix offline tests

Closes #1098
Closes #1095
Closes #1094

Most of the tests is removed. Either the code that was tested doesn't
exists. Or now tests for state machine actions do this work.

[#1115] Fix NetworkTests in state machine branch

Closes #1115

[#700] Fix progress reporting

Some actions in the sync process may not run. For example there are no
transactions to enhance and therefore there is no enhance progress. And in
cases like this computation of final progress won't work properly.
So let's fake 100% progress at the end of the sync process.
2023-05-30 15:01:42 +02:00
Michal Fousek e8d5e9cd43
Merge pull request #1130 from Chlup/1128_fix_switch_to_disconnect
[#1128] Fix switch to error state after Synchronizer.prepare() call
2023-05-24 22:23:43 +02:00
Michal Fousek 9144f26b35 [#1128] Fix switch to error state after Synchronizer.prepare() call
Closes #1128
2023-05-24 15:25:11 +02:00
Michal Fousek ee3d082155
Merge pull request #1114 from Chlup/1111_isp_disk_storage
[#1111] Change storage for InternalSyncProgress
2023-05-23 18:43:24 +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
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
Francisco Gindre c1e0740519
[#1105] Release 0.22.0-beta (#1106)
Checkpoints and CHANGELOG.md updates
Closes #1105
2023-05-22 15:21:21 -03:00
Michal Fousek ea4da6e0e6
Merge pull request #1093 from Chlup/1016_stream_per_batch_parallel
[#1016] Rebuild download stream periodically while downloading
2023-05-17 17:00:55 +02:00
Francisco Gindre 630737e511
fix typo on log 2023-05-17 11:22:25 -03:00
Michal Fousek d091660b79 [#1016] Rebuild download stream periodically while downloading
- Rebuild download stream in `BlockDownloaderImpl` each 10 batches. So
  currently stream downloads 1000 blocks and then new stream is created.
- Memory stays between 60MB and 70MB during sync in the Sample app.
2023-05-17 10:36:02 +02:00
Francisco Gindre bb3d7d06c5
[#780] part of Adopt green policy (#1064)
fixes docs and deletes fixme for [#783]

closes #783

[#785]: Fix test testSingleNoteNoChangeTransaction

[#786] fix testVerifyChangeTransaction

Closes #786

[#790] mark as fixed testRewindAfterSendingTransaction

Closes #790

[#865] Fix test testStoringTenSandblastedBlocks

Closes #865

[#791] Fix test testRewindAfterSendingTransaction

Closes #791

[#783]: Fix test testMaxAmountSendBroadcast

Closes #783
2023-05-11 08:13:20 -03:00
Francisco Gindre f98692c0ea
[#781] This fixes test `testMaxAmountMinusOneSend` by creating two se… (#1034)
* [#781] This fixes test `testMaxAmountMinusOneSend` by creating two separate
tests:
  - testMaxAmountMinusOneSendFails
  - testMaxAmountSend

Also includes new functionality that tracks sent transactions so
that users can be notified specifically when they are mined and uses "idea B" of
issue #1033.

closes #1033
closes #781

* Fix tests
2023-05-10 17:13:29 -03:00
Francisco Gindre cf53edb3b8
[#1037] Empty string memo throws `ZcashError.memoTextInputEndsWithNullBytes` (#1038)
Fixes the case where the SDK would read an empty string from the Db and would
throw this error incorrectly
closes #1037
2023-05-10 12:39:34 -03:00