Commit Graph

1011 Commits

Author SHA1 Message Date
Lukas Korba 95ab2a2047 [#1045] Implement FetchUTXOsAction
- FetchUTXOsAction tests
- UTXOFetcher mocks

[#1045] Implement FetchUTXOsAction

- enhanced with mocked values and more checks
2023-05-18 14:48:49 +02:00
Michal Fousek 4dc8d986ef Improve mocks generating 2023-05-18 13:24:04 +02:00
Lukas Korba 5f9a430a2f
Merge pull request #1101 from LukasKorba/1047-Implement-ScanAction
[#1047] Implement ScanAction
2023-05-18 09:12:27 +02:00
Lukas Korba 6cb6f62bb2 [#1047] Implement ScanAction
- ScanAction tests
- refactor of validateAction -> validateServerAction
- generated few more mocks for the DI
2023-05-18 09:02:06 +02:00
Lukas Korba c890498f92
Merge pull request #1099 from LukasKorba/1049-Implement-ValidateAction
[#1049] Implement ValidateAction
2023-05-18 08:47:21 +02:00
Lukas Korba 1f42d28b2d [#1049] Implement ValidateAction
- synchronizer offline tests updated so it compiles, review is requested in a different ticket
- ValidateAction tests added
- BlockValidator mock generated
2023-05-17 16:50:44 +02:00
Lukas Korba 841f42ab6e [#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
2023-05-17 15:19:12 +02:00
Lukas Korba c3e11989dc [#1050] Implement ValidateServerAction
- broken tests commented out and tracked in the tickets
- new test for ValidateServerAction
2023-05-17 12:07:00 +02:00
Michal Fousek 56d70ee164 [#700] Make CBP state machine work 2023-05-15 15:49:28 +02:00
Michal Fousek 97f3699436 [#1039] Implement ChecksBeforeSyncAction
Closes #1039
2023-05-15 09:59:40 +02:00
Michal Fousek d068851af7 [#1040] Implement ClearAlreadyScannedBlocksAction
Closes #1040
2023-05-15 09:59:40 +02:00
Michal Fousek 687abff8d0 [#1041] Implement ClearCacheAction
Closes #1041
2023-05-15 09:59:40 +02:00
Michal Fousek d40f3d3675 [#1044] Implement EnhanceAction
Closes #1044
2023-05-15 09:59:40 +02:00
Michal Fousek 1ee6c7f630 Fix compilation 2023-05-15 09:59:40 +02:00
Lukas Korba 16fb61c774 [#1047] Implement ScanAction
- scan action with the proper ranges computed

[#1047] Implement ScanAction (#1085)

- fixed logger message
2023-05-15 09:59:40 +02:00
Lukas Korba 0fee045ca9 [#1048] Implement ScanDownloadedButUnscannedAction
- scan downloaded but unscanned blocks
2023-05-15 09:59:40 +02:00
Lukas Korba f4f6cbaf0b [#1046] Implement SaplingParamsAction
- action for sapling param files finished
2023-05-15 09:59:40 +02:00
Michal Fousek 63e852aeed [#1043] Fix batch range computation in DownloadAction 2023-05-15 09:59:40 +02:00
Michal Fousek d699d935b4 [#700] Implement cache clearing when some actions fail 2023-05-15 09:59:40 +02:00
Michal Fousek 75a9e3622e [#1042] Implement ComputeSyncRangesAction
Closes #1042
2023-05-15 09:59:40 +02:00
Lukas Korba ce8fcdf3cc [#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
2023-05-15 09:59:40 +02:00
Michal Fousek 98226d8a6d [#700] Implement progress reporting in state machine CBP 2023-05-15 09:59:39 +02:00
Michal Fousek 52ef45970d [#700] Implement sending of some events from CompactBlockProcessorNG 2023-05-15 09:58:37 +02:00
Michal Fousek fcb00b9051 [#700] Add idle state to CBP state machine
This is required so the CBP can detect start of the sync process.
2023-05-15 09:58:37 +02:00
Michal Fousek 0101e710cb [#1059] Implement rewind for state machine CBP
Closes #1059
2023-05-15 09:58:37 +02:00
Michal Fousek 2f47d2d99d [#1060] Implement wipe for state machine CBP
Closes #1060
2023-05-15 09:58:37 +02:00
Michal Fousek 05f629c4ee [#1052] Implement AfterSyncHooksManager when using state machine CBP
Closes #1052
2023-05-15 09:58:37 +02:00
Michal Fousek 4efab5a3fb [#1058] Implement stop for state machine CBP
Closes #1058
2023-05-15 09:58:37 +02:00
Michal Fousek 1d029ff90f [#1057] Implement start for state machine CBP
Closes #1057
2023-05-15 09:58:37 +02:00
Michal Fousek f8030e0a73 [#1055] Implement retry timer to state machine CBP
Closes #1055
2023-05-15 09:58:37 +02:00
Michal Fousek 4d9d4a48ef [#1061] Add failure methods for state machine CBP
Closes #1061
2023-05-15 09:58:37 +02:00
Michal Fousek ea54da2c56 [#1056] Add constructors to state machine CBP
Closes #1056
2023-05-15 09:58:37 +02:00
Michal Fousek 4147868aae [#1050] Implement ValidateServerAction
Closes #1050
2023-05-15 09:58:37 +02:00
Michal Fousek b378778c02 [#1049] Implement ValidateAction
Closes #1049
2023-05-15 09:58:37 +02:00
Michal Fousek d8f189a799 [#1043] Implement DownloadAction
Closes #1043
2023-05-15 09:58:37 +02:00
Michal Fousek 776deeb002 Fix docs 2023-05-15 09:58:37 +02:00
Michal Fousek da8c05b2d9 [#1054] Add config to state machine CBP
Closes #1054
2023-05-15 09:58:37 +02:00
Michal Fousek 2b528f150a Action.stop is now async 2023-05-15 09:58:37 +02:00
Michal Fousek cfc5fa12fa [#700] Add documentation for CompactBlockProcessor state machine
- plantuml tool is used to generate diagram.
2023-05-15 09:58:37 +02:00
Michal Fousek 5810294b3a Small updates 2023-05-15 09:58:37 +02:00
Michal Fousek 661d362225 [#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`.
2023-05-15 09:58:37 +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
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 c477e483ff
Merge pull request #1010 from LukasKorba/843-Simplify-Synchronizer-Status-internal
[#843] Simplify Synchronizer Status
2023-05-09 16:45:36 +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
Michal Fousek 336c5a7c38
Merge pull request #1032 from zcash/features/1012_depedency_injection
[#1012] Introduce dependency injection in the SDK
2023-05-08 19:00:00 +02:00
Michal Fousek 5d2b2298b5 [#1012] Introduce dependency injection in the SDK
Closes #1012

- This is the first change for the dependency injection. This change
  adds `DIContainer` which is used to register and resolve dependencies.
- Then this change shows how `DIContainer` can be used to resolve
  dependencies. And it also shows how to mock dependencies in tests.
- Constructors of `Initializer` are changed to support mocking of
  depedendencies. But it doesn't affect public API in any way.
- Depedencies are registered in `Dependencies.setup()`. Then in the code
  `container.resolve(SomeType.self)` is called to get instance of the
  dependency.
- `ZcashTestCase` class is added. It inherits from `XCTestCase` and
  should be used for base class in tests. `ZcashTestCase` takes care of
  creation of `DIContainer` for dependencies mocking. In future we can
  maybe move there more things that are used in each test.
- Lot is missing here. Not all the code is using dependency injection.
  Tests for `DIContainer` are missing. Only `OfflineTests` work now
  (other tests can't be even compiled). It will be added in future
  changes.
2023-05-08 14:58:49 +02:00