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

Connect the wallet primitive to the chain producer through the wallet layer #69

Closed
7 tasks done
KtorZ opened this issue Mar 14, 2019 · 3 comments
Closed
7 tasks done
Assignees

Comments

@KtorZ
Copy link
Member

KtorZ commented Mar 14, 2019

Context

We have:

  • A set of core primitives and types to represent and keep track of a wallet
  • A network layer that retrieves blocks from a chain producer (i.e. the cardano-http-bridge)
  • A db layer that define an interface for persisting pieces of information to some db engine / storage
  • A wallet layer that connects the dots and make use of the above to provide a simple interface for wallet clients (like the API layer or the CLI)

Decision

We do need to implement the wallet layer to make sure that we process blocks from the chain producer and apply them as we received them. Also, this should ideally make use of the DB layer to keep track of the checkpoints and, restart from a given position when needed.

Acceptance Criteria

  • The wallet layer must process blocks from the NetworkLayer using the wallet primitives
  • The wallet layer should flush its latest state to the database after processing blocks
  • The wallet layer may quickly catch up with the network tip when started

Development Plan

  • Draft a first pipeline that tight together the various layers in order to restore a wallet from a given mnemonic.
  • Look at the heap and time profiling for restoring a wallet against mainnet
  • Write test code for the DBLayer
  • Write test code for the WalletLayer

PR

Number Base
#73 master
#82 master
#88 master

QA

  • We've finalized the first draft implementation of the wallet layer as described by WalletLayer. To implement this layer, we had to pull strings from the DBLayer and NetworkLayer, ultimately tightening them together alongside the wallet primitive logic to accomplish basic wallet work.

  • Usage of the watchWallet have been manually tested and profiled and the result can be seen in comment of Connect Primitives to Layers #73 (note that, I have later removed the corresponding code from the CLI executable as it seemed to confuse people).

  • @paweljakubas also added extra unit tests to test basic properties on our fake DB engine for now, that are visible in Cardano/DBLayer/MVarSpec.hs

  • We do also have similar tests working directly at the WalletLayer level and checking additional invariant (like, conflict between ids), cf: Cardano/WalletLayerSpec.hs

@piotr-iohk
Copy link
Contributor

@KtorZ, code coverage on WalletLayer.hs is rather low now ~53%. Mostly due to not exercised watchWallet (and called within it applyBlocks and printInfo).

Perhaps it would be possible to add some integration tests for watchWallet similar to HttpBridgeSpec?

@KtorZ
Copy link
Member Author

KtorZ commented Mar 22, 2019

@piotr-iohk
Yup, I am actually about to cover those as part of the debt ticket we have (those are mentioned points). The watch wallet is a bit tricky to cover since it runs forever; I believe we can just run it for a while in a thread and then, nuke the thread at some point 🤔
Will do as part of #94

@piotr-iohk
Copy link
Contributor

oh yes, I actually glimpsed at #94 but somehow missed the second table (Unused code), where it actually is stated. :)

lgtm 👍

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

No branches or pull requests

3 participants