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

newTransactionLayer for Jormungandr #437

Merged
merged 5 commits into from
Jun 20, 2019

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented Jun 19, 2019

Issue Number

#219

Overview

  • I have added implementation for newTransactionLayer (mkStdTx is taken from Johannes PR)
  • I have added unit tests for estimateSize

Comments

@paweljakubas paweljakubas self-assigned this Jun 19, 2019

-- | Construct a 'TransactionLayer' compatible with Shelley and 'Jörmungandr'
newTransactionLayer :: TransactionLayer t
newTransactionLayer
:: TransactionLayer (Jormungandr 'Testnet)
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be fixed to 'TestNet but left as t or, at the very least KnownNetwork n => Jormungandr n

return (tx, txWitnesses)

-- NOTE: at this point 'Jörmungandr' node does not support fee calculation
, estimateSize = \_ -> Quantity 0
Copy link
Member

Choose a reason for hiding this comment

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

👍

-- The wallet only cares about the 'SignTx' tag. In 'cardano-sl' there was
-- a lot more cases.
newtype SignTag
= SignTx (Hash "Tx")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this exists in Jormungandr ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, signing will be different here, @Anviking will push proper signing. I will concentrate on testing estimateSize in this PR. In the next, I or Johannes will address signing golden tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

taken signing from Johannes PR as it is

@paweljakubas paweljakubas force-pushed the paweljakubas/219/jormungandr-newTransactionLayer branch from b642dfb to 8bed612 Compare June 19, 2019 13:39
@paweljakubas paweljakubas marked this pull request as ready for review June 19, 2019 13:41
@paweljakubas paweljakubas requested a review from KtorZ June 19, 2019 13:42
@KtorZ KtorZ mentioned this pull request Jun 19, 2019
12 tasks
instance Arbitrary Address where
shrink _ = []
arbitrary =
pure $ Address "\131\&3$\195xi\193\"h\154\&5\145}\245:O\"\148\163\165/h^\ENQ\245\248\229;\135\231\234E/"
Copy link
Contributor Author

@paweljakubas paweljakubas Jun 19, 2019

Choose a reason for hiding this comment

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

probably will need to be not so specific here, for the test (checking estimatedSize) I added, seems not forbidden

Hash {getHash = "\216OY\rX\199\234\188.<O\\\244Y\211\210\254\224`i\216\DC3\167\132\139\154\216\161T\174\247\155"}
tl = newTransactionLayer blockHash :: TransactionLayer (Jormungandr n)
calcSize = estimateSize tl sel
in calcSize === Quantity 0
Copy link
Member

Choose a reason for hiding this comment

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

So I take it that we're going to implement the size calculation the transaction layer after all? Or are you planning to leave the quantity at 0? In which case, the whole property + arbitrary instances is maybe overkill don't you think 😅 ?

Copy link
Contributor Author

@paweljakubas paweljakubas Jun 19, 2019

Choose a reason for hiding this comment

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

yeah, coin selection at this moment should probably be as dummy as possible as estimateSize ignores it. But it will change soon (that is my understanding) and Jormungandr will support fee calculation and they will be valid...

Copy link
Member

Choose a reason for hiding this comment

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

Generally speaking, it's best to not do things that aren't required on the moment. We have actually no idea when Jormungandr will support fee calculation, although we know that they eventually will.

But, now that it's done, I'd almost be tempted to really implement the size estimator...

Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

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

Cool

}
where
withEither :: e -> Maybe a -> Either e a
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor - there's functions in both the errors or either packages for this. I find errors pretty useful.

Copy link
Contributor Author

@paweljakubas paweljakubas Jun 20, 2019

Choose a reason for hiding this comment

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

indeed, in Data.Either.Combinators of either package :

maybeToRight :: b -> Maybe a -> Either b a 

Maybe produce a Right, otherwise produce a Left.

>>> maybeToRight "default" (Just 12)
Right 12
>>> maybeToRight "default" Nothing
Left "default"

@KtorZ KtorZ merged commit c82a201 into master Jun 20, 2019
@KtorZ KtorZ deleted the paweljakubas/219/jormungandr-newTransactionLayer branch June 20, 2019 09:16
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

3 participants