The Android and Rust code have previously managed joint custody of the derived data database. With more complex migrations now required, we need to make the Android side read-only. To achieve that, the Android side will remove Room and instead rely on more primitive SQLite APIs for read-only access.
As part of implementing this change, database management throughout the SDK is being refactored.
There will be multiple representations of the data:
- Database representation (and some Entity representations in the places that Room hasn’t been removed yet). These representations are not as type safe and don’t match Kotlin best practices in all cases.
- Once #615 is implemented there will also be network representations
- Type safe models, which often appear in the public API The Database and Network representations will be converted to and from the type safe model representation.
The SDK now exposes UAs primarily, with additional methods for obtaining
corresponding Sapling and transparent addresses for legacy compatibility.
The `Account` DAO is also fixed to use the migrated `accounts` table format.
The demo app now shows the current UA and the legacy Sapling and transparent
addresses.
Closeszcash/zcash-android-wallet-sdk#677.
* [#706] Fix crashes identified by robo tests
- Removed unused xml layouts
- Fixed several xml attributes to be backward compatible
* Reduce number of unnecessary logs in console
* Bump min Android SDK version from 19 to 21
* Bump demo-app minSdk to version 21 too
* Update changelog
Co-authored-by: Carter Jernigan <git@carterjernigan.com>
* Disable baseline file. Too many functions.
* CurrencyFormatter.kt suppress too many functions
* PersistentTransactionManager.kt suppress too many functions
* OutboundTransactionManager suppress too many functions
* Suppress long parameter list
* Too many functions
* Add log to avoid empty block warning
* Fix several magic number warnings
* Solve max line length warnings
* Solve max line length warnings
* Suppress too long method warnings
* Suppress too complex method warnings
* Suppress large class warning
* Fixed empty catch block
* Changed directory path to the file
* Fix too generic and swallowed exception
* Fix print stack trace warning
* Suppressed single top level file name declaration
* Change parameters name
* Suppress Spread operator warning
* Remove unused private code
* Add Locale to suppress default locale used warning
* Solve several forbidden TODOs warnings
* Fixed another max line length warning
* Simplify return statement
* Suppress class to object change
* Make DemoConstants variables const
* Use error() instead of throwing an IllegalStateException
* Solve too complex condition
* Suppress intentionally generic and swallowed exception
* Suppress TooGenericExceptionCaught
* Solve or suppress several TooGenericExceptionCaught
* Fix swallowed exception
* Suppress warning TooGenericExceptionCaught of PersistentTransactionManager
* Suppress warning TooGenericExceptionCaught of WalletTransactionEncoder
* Suppress TooGenericExceptionCaught of SdkSynchronizer
* Suppress TooGenericExceptionCaught in SaplingParamTool
* Suppress TooGenericExceptionCaught in CompactBlockDownloader
* Suppress TooGenericExceptionCaught in CheckpointTool
* Fix TooGenericExceptionCaught in WalletService
* Suppress TooGenericExceptionCaught in DerivedDataDb
* Suppress TooGenericExceptionCaught in CompactBlockProcessor
* Apply ktlint format after all the previous changes
* Remove detekt baseline file
* Set Android studio right margin
* Address comments from review
* Suppress failing tests on CI
UnifiedViewingKey had a bug that made it incompatible with ZIP 316.
For compatibility with the current `zcash/librustzcash` revision we use
a temporary fake UFVK encoding that stores sufficient information to use
the current APIs, and a superset of the actual ZIP 316 FVK information.
This change leverages the gRPC streaming API along with the elimination of bulk inserts to SQLite to reduce the amount of memory required to write blocks.
This includes a few different fixes that prevented the demo app and other SDK consumers from working.
First, initialization of the demo app was fixed to use the sapling activation height rather than the current latest checkpoint.
Second, CompactBlockProcessor wasn’t downloading blocks.
Third, a few potential thread safety issues were resolved by making fields that are accessed by multiple threads volatile.
- Replace int with type safe BlockHeight(Long) object
- Fix down casting bug, as BlockHeight is uint32 but Java only supports int32 or int64
- Rename WalletBirthday to Checkpoint and hide from the public API
While there are a lot of changes, the most significant are:
- Update the main entrypoint of the SDK to use a suspending function and eliminate lazy initialization. This also resolves#310
- Changing Dao methods to `suspend`, allowing Room to implicitly manage the threading model under the hood
- Explicitly set the executor thread for the `CompactBlockDb` and `DerivedDataDb`, which is the same thread used when calling into the Rust native library. Room will then use this thread for `suspend` fun calls into it
- With the above set, remove unnecessary hops to Dispatchers.IO which is a thread pool
- Eliminate lazy initialization in `PagedTransactionRepository` to make it easier to reason about the threading model and resolve#355 where the database was being touched from the UI thread
Note that `PendingTransactionsDb` is not opted into this single-threaded approach, because that database is not shared with the Rust code
To quickly get this implemented, some calls in the demo-app have been wrapped in `runBlocking {}`. This is not ideal and will be addressed in followup issues.
In the process of refactoring the Gradle scripts, ktlint now is applied to all Gradle modules. The demo-app hadn't been linted before, so this applies a series of minor autocorrections to this module.
In addition to using build-conventions to make the build scripts more DRY, the following additional changes are included in this commit:
- Convert build scripts to kts
- Fix a double-build issue with the SDK
- Add configurable options for treating compiler warnings as errors (disabled for now, due to extensive warnings that need to be corrected first)
- Added detekt as an additional static analysis tool
Some tests have been disabled to enable tests to actually complete; there are a number of test failures which need to be addressed.
These tests were failing prior to the refactoring.
The disabled tests can be easily found by searching for the Ignore annotation. They also appear in the Junit results window in Android Studio.
Move SDK from the root gradle project to its own Gradle module
Move the demo app to be a peer of the SDK
This will simplify integration with CI on Bitrise.