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

Implement Jörmungandr TransactionLayer #439

Merged
merged 11 commits into from
Jun 22, 2019
Merged

Implement Jörmungandr TransactionLayer #439

merged 11 commits into from
Jun 22, 2019

Conversation

Anviking
Copy link
Collaborator

@Anviking Anviking commented Jun 19, 2019

Issue Number

#219

⚠️ base branch is KtorZ/transaction-id-golden-tests ⚠️

Overview

  • I have implemented a preliminary TransactionLayer

Comments

  • Golden tests are wip (not pushed). I'd call for merging this as soon as possible still.

@KtorZ KtorZ self-requested a review June 19, 2019 12:19
newTransactionLayer = TransactionLayer
{ mkStdTx = error "TODO: See http-bridge as starting point"
newTransactionLayer
:: forall n . Hash "Block0Hash"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@KtorZ

I am not sure about this type ... And, does this really have to be the hash from the first block header?

To my knowledge — yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Anviking
Copy link
Collaborator Author

I resurrected this from #418 and merged in the \-> Quantity 0 from #437.

@Anviking
Copy link
Collaborator Author

Hm… the diff is messed up since I force-pushed anviking/219/txid :/

@Anviking Anviking force-pushed the anviking/219/signing branch 2 times, most recently from 86f81c4 to 1a85616 Compare June 19, 2019 13:27
@paweljakubas
Copy link
Contributor

paweljakubas commented Jun 19, 2019

general comment : the signing looks good at first sight, but I will be persuaded if extensive golden tests will support this feeling :-)

@Anviking Anviking self-assigned this Jun 19, 2019
@Anviking Anviking changed the base branch from anviking/219/txid to master June 21, 2019 03:45
Copy link
Contributor

@akegalj akegalj left a comment

Choose a reason for hiding this comment

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

It mostly looks good to me. There are few places where I am not sure in the correctness (I wasn't able to find the corresponding place in rust code)

putMessage :: Message -> Put
putMessage m = withSizeHeader16be $ case m of
Transaction (tx, wits) -> do
putWord8 2
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably add a comment explaining why constant 2 (or reference to the actuall rust api line containing this info)

@@ -244,37 +258,43 @@ putSignedTransaction (tx, witnesses) = do
putWitness :: TxWitness -> Put
putWitness witness =
case witness of
PublicKeyWitness xPub (Hash sig) -> do
PublicKeyWitness _xPub (Hash sig) -> do
-- Witness sum type:
Copy link
Contributor

Choose a reason for hiding this comment

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

we might want to define sum type that would describe the constants in this module, at least for documentation

putWord8 1
putByteString xPub
--putByteString xPub
Copy link
Contributor

Choose a reason for hiding this comment

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

But then old address scheme won't work, right? (as it expects xPub in its format)

mapM_ putInput inputs
mapM_ putOutput outputs
where
putInput (TxIn inputId inputIx) = do
-- NOTE: special value 0xff indicates account spending
-- only old utxo/address scheme supported for now
putWord8 $ fromIntegral inputIx
putWord64be 14 -- TODO: We need input value!
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -84,7 +79,7 @@ genesis = BlockHeader
-- The corresponding rust implementation is:
-- https://github.com/input-output-hk/rust-cardano/blob/e5d974f7bedeb00c9c9d688ac66094a34bf8f40d/chain-impl-mockchain/src/transaction/transaction.rs#L115-L119
instance TxId (Jormungandr n) where
txId = blake2b256 . putTokenTransfer
txId = blake2b256 . putTxBody
Copy link
Contributor

Choose a reason for hiding this comment

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

lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs Outdated Show resolved Hide resolved
let keyFrom _ = Just (key, pwd)
let inps = pure
( txin
, TxOut (Address "used for lookup") (Coin 14)
Copy link
Contributor

Choose a reason for hiding this comment

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

address content is not important?

@KtorZ KtorZ changed the base branch from master to KtorZ/transaction-id-golden-tests June 21, 2019 19:51
@KtorZ KtorZ self-assigned this Jun 21, 2019
@KtorZ KtorZ force-pushed the KtorZ/transaction-id-golden-tests branch 2 times, most recently from 55cfa17 to 8f5b202 Compare June 22, 2019 00:17
@KtorZ
Copy link
Member

KtorZ commented Jun 22, 2019

This PR is to merge after:

cc @paweljakubas @Anviking

@KtorZ KtorZ force-pushed the KtorZ/transaction-id-golden-tests branch from 8f5b202 to 43f1aca Compare June 22, 2019 11:41
@KtorZ KtorZ changed the base branch from KtorZ/transaction-id-golden-tests to master June 22, 2019 12:35
Anviking and others added 7 commits June 22, 2019 14:36
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
This makes it more flexible to manipulate 'TxWitness'
across different backend target. The application layer
only regards it as a bunch of bytes anyway.

Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@KtorZ KtorZ merged commit de43053 into master Jun 22, 2019
@KtorZ KtorZ deleted the anviking/219/signing branch June 22, 2019 15:01
@KtorZ KtorZ mentioned this pull request Jul 3, 2019
12 tasks
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

4 participants