-
Notifications
You must be signed in to change notification settings - Fork 220
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
Minimal Viable Wallet Layer #43
Conversation
return $ if predicate then Just out else Nothing | ||
|
||
forMaybe :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b] | ||
forMaybe xs = fmap catMaybes . for xs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to Cardano/Wallet
9776d23
to
7b1cf62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Have some questions to understand the code better plus indicated minor typos.
, binary | ||
, bytestring | ||
, cborg | ||
, containers | ||
, cryptonite | ||
, deepseq | ||
, digest | ||
, fmt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet there are some strong argument in favor of using fmt vs formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some arguments. See #sl-core (I'll send you a link in PM)
-- License: MIT | ||
-- | ||
-- Here we find the "business logic" to manage a Cardano wallet. This is a | ||
-- direct implementation of the model from the [Formal Specification for a Cardano Wallet](https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/wallet/formal-specification-for-a-cardano-wallet.pdf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we want to split it into two lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish but we can't split the link :(
-- k = 2160 is currently hard-coded here. In the short-long run, we do | ||
-- want to get that as an argument or, leave that decision to the caller | ||
-- though it is not trivial at all. If it shrinks, it's okay because we | ||
-- have enough checkpoints, but if it does increase, then we have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean the problematic situation would be: the caller has an ability to set k in applyBlocks? and the wallet persists the state and then is called with higher k at some point, and for some period it misses checkpoints to be compliant with new k parameter. And then rollback comes that has depth covering those missing checkpoints? Maybe in that case k->k' , where k'>k some kind of "restotration" should take place to compensate it....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I meant yes. So, there are different way to deal with this indeed, but it's not trivial, hence the warning.
|
||
-- | A polymorphic wrapper type with a custom show instance to display data | ||
-- through 'Buildable' instances. | ||
newtype ShowFmt a = ShowFmt a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is because we do not want to deliver separate instances of Show for Utxo, Adresses, Block,... Instead we wrap them in ShowFmt and in one go use any type's Buildable instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is because we do not want to write custom show instances in practice. Though, because of the way QuickCheck, HSpec and some other libraries work, they use Show
to output results and counterexamples which is very unpractical to read for some types (like the UTxO). For those, we may opt-in for a ShowFmt
wrapper around a type to get a nice output. Though, we don't want to be changing the stock Show
instance for those types.
test/unit/Cardano/WalletSpec.hs
Outdated
{------------------------------------------------------------------------------- | ||
Basic Model - See Wallet Specification, section 3 | ||
|
||
Our implementation of 'applyBlock' is a bit more complexe than the basic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
complexe - typo
prefilterBlock b (Wallet !utxo _ !s) = | ||
let | ||
txs = transactions b | ||
(ourOuts, s') = txOutsOurs txs s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the previous code prefiltering acted on the whole set of transactions. now we make sure we intersect only on those belonging to us. Nice!
{------------------------------------------------------------------------------- | ||
Test Data | ||
|
||
In practice, we may want to generate arbitrary valid sequences of block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe block sequences
instead of sequences of block
7b1cf62
to
d4573c7
Compare
d4573c7
to
f912702
Compare
Issue Number
#20
Overview
Show
instances (like the UTxO, cf comments)applyBlock
and compare it to a basic model.Comments
UTxO through
Buildable
looks like the following: