Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with lightwalletd and librustzcash #16

Closed
wants to merge 21 commits into from
Closed

Conversation

gmale
Copy link
Contributor

@gmale gmale commented Mar 12, 2019

Working branch for integration with the lightwalletd server and librustzcash core library

Update the scanBlocks request and integrate with the data that it generates inside dataDb
…nit5 setup

streaming is working and tests are functional
On the rust side, we now have access to the init DB commands. On the Go side we have time available for blocks
@gmale gmale requested a review from str4d March 12, 2019 17:06
@@ -1,5 +1,6 @@
def protoSrcDir = "src/main/proto"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: I've put zero energy into cleaning this file because it will be deleted once #15 is merged.

@gmale gmale force-pushed the tasks/glue branch 2 times, most recently from 228b39e to b020276 Compare March 12, 2019 18:18
}

@Test
fun testDaoInsert() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test suggests that inserts into the data db from the Android side are okay. Add a comment that this is only for testing purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81141d9

fun findById(id: Int): Note?

@Query("DELETE FROM received_notes WHERE id_note = :id")
fun deleteById(id: Int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows modifications to the data DB from the Android side. Do we want this as part of the public API? What is it used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81141d9

fun getAll(): List<Note>

@Delete
fun delete(block: Note)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how @Delete works, but I assume it does some kind of matching. This allows modifications to the data DB from the Android side.

Also, s/block/note

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81141d9

fun findById(height: Int): Block?

@Query("DELETE FROM blocks WHERE height = :height")
fun deleteById(height: Int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto re: modifications to data DB from Android side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81141d9

use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions;

#[derive(PartialEq,Clone,Default)]
pub struct ValueReceived {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was removed in an earlier commit in master, and has been included here by accident. Remove from this commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in c7d85f2

@@ -56,35 +70,107 @@ android {
sourceSets {
main {
java {
srcDirs "build/generated/source/wire"
srcDirs "build/generated/source/grpc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be src/generated/source/grpc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I can tell, it is.

}

override fun getValue(thisRef: Any?, property: KProperty<*>): String {
// dynamically generating keyes, based on seed is out of scope for this sample
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/keyes/keys

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in c7d85f2

fun findById(id: Long): Transaction?

@Query("DELETE FROM transactions WHERE id_tx = :id")
fun deleteById(id: Long)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto re: modifications to data DB from Android side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only one we allow, maybe. When a user cancels a pending transaction (before it has been sent to the network) we clean it up. Sounds like we should push that behavior down into the rust layer instead of letting apps do cancelled transaction cleanup.

fun getAll(): List<WalletTransaction>

@Delete
fun delete(transaction: Transaction)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto re: modifications to data DB from Android side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto re: cancellation. We may want to discuss and then maybe bubble this up to mary/linda as a near-future feature to add to librustzcash (cancellation support by way of dataDB cleanup)

@str4d str4d mentioned this pull request Mar 13, 2019
gmale added 14 commits March 13, 2019 01:54
…tors

The synchronizer now primarily collaborates with a downloader, processor and repository; each with a more focused set of responsibilities.
The downloader streams blocks into a channel, the processor saves blocks from that channel and scans for transactions, the repository
exposes transaction change events.
When a transaction is sent it transitions through a lifecycle, beginning with creating the raw transaction and ending with it being mined and added to the blockchain
Send is now functional and shows up in active transactions.
This involved:
- reducing the exposure of the seed
- consistently using Ints for blockheight everywhere to match zcash
- adding the use of spending keys
- adding account initialization on startup
- using accounts but defaulting to account 0
- internalizing birthday so we no longer need a reference outside of the library
- enabling cancellation during send
- cleanup active transaction manager
After experiencing several issues that make it more difficult to test send behavior, including the amount of time required to wait for blocks to get mined when testnet is slow,
it became obvious that it was time to investigate mocking. Most of the behavior in the SDK is driven by channels so the mock only has to focus on putting useful data in the
expected channels at the right time. One tradeoff here was the need to make all the synchronizer properties private, that way any implementation can achieve compatability
without necessasily leveraging the same combinations of building blocks. This tradeoff felt acceptable given that these dependencies can be injected and available as singletons,
if needed. This also had a side effect of elevating several channels into the Synchronizer interface, rather than reaching into the synchronizer to directly access those dependencies.
Another benefit is that it's now easier to see what matters most to the app, particularly which channels are essential.
Working with bigdecimals anytime we need to multiply or divide values because it was causing issues when repeatedly toggling currency on the send screen. Coupled this with lots of improvements on the app side to do less processing while changing currencies
It is not really practical to try and use JUnit 5 for Android Instrumentation tests at this time. See documentation in build.gradle for details.
Never start downloading blocks prior to sapling activation height, only allow firstrun when dataDb is empty and also add birthday support. Also added corrections to isFirstRun logic.
This allows the app to show an error dialog rather than crashing silently
This commit will get iteratively polished until the PR is ready
- Addresses PR feedback #16 (comment)
Remove unused functionality and disable modification to tables that should only be written by librustzcash
@gmale
Copy link
Contributor Author

gmale commented Mar 14, 2019

All comments here have been addressed but the work is still in an unpolished state. Closing this PR and renaming the branch to preview per this sprint task. That way, we can continue iterating on the code without committing unfinished work to master and still provide a clear place for 3rd party developers to find the latest stable code.

@gmale gmale closed this Mar 14, 2019
@gmale gmale deleted the tasks/glue branch March 14, 2019 16:52
gmale added a commit that referenced this pull request Mar 27, 2019
This commit will get iteratively polished until the PR is ready
- Addresses PR feedback #16 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants