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

Support for legacy UTxO witness in Jörmungandr #878

Merged
merged 5 commits into from
Oct 22, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Oct 21, 2019

Issue Number

#779

Overview

  • I have extended mkStdTx so that it would properly handle transactions coming from a RndKey and construct legacy-utxo witnesses for it.

Comments

Jörmungandr doesn't implement creating legacy utxo witnesses from jcli ...

jcli/src/jcli_app/transaction/mk_witness.rs

            WitnessType::OldUTxO => {
                // TODO unimplemented!()
                let _secret_key: SecretKey<Ed25519Bip32> = self.secret()?;
                Err(Error::MakeWitnessLegacyUtxoUnsupported)?;
                unimplemented!()
            }

so I had to construct them by hand according to:

It'd be nice to review our golden if / when the constructor for the witness type gets updated.

putWitness (TxWitness bytes) = do
putWord8 1
putByteString bytes
putWitness (TxWitness bytes) = putByteString bytes
Copy link
Member Author

Choose a reason for hiding this comment

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

The tag is now part of the bytes themselves (cf utxoWitness and legacyUtxoWitness)

tag <- getTxWitnessTag
let len = txWitnessSize tag
tag <- lookAhead getTxWitnessTag
let len = txWitnessSize tag + txWitnessTagSize
Copy link
Member Author

Choose a reason for hiding this comment

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

The tag is now part of the bytes themselves (cf utxoWitness and legacyUtxoWitness)

@@ -190,13 +205,68 @@ mkStdTxSpec = do
\080f5ac10474c7f6decbbc35f1620817b15bf1594981c034b7f6a15d0a24ec743d\
\332f1774eb8733a5d40c"

describe "mkStdTx unknown input" $ do
unknownInputTest (Proxy @'Mainnet) block0
unknownInputTest (Proxy @'Testnet) block0
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved down.

@KtorZ KtorZ self-assigned this Oct 21, 2019
@KtorZ KtorZ requested a review from Anviking October 21, 2019 14:56
Copy link
Member

@Anviking Anviking left a comment

Choose a reason for hiding this comment

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

👍 but barely looked at the tests

mkTxWitness (Hash block0) inps outs xprv =
let
xpub = getRawKey $ publicKey $ fst xprv
payload = block0 <> getHash (signData inps outs)
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Maybe a bit unfortunate that the payload-calculation is duplicated. Separate "signing" and "payload", or does things stop making sense then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now it would. Initially even the signing was different and I refactored a few things until the point where it got pretty similar. I ended up with this to also make testing a bit easier and the function signature slightly more readable than having a ByteString signature as argument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -109,13 +117,40 @@ newTransactionLayer (Hash block0) = TransactionLayer
$ Left ErrExceededInpsOrOuts
}

-- | Provide a transaction witness for a given private key. The type of witness
-- if different between types of keys and, with backward-compatible support, we
-- may have to support many types for one backend target.
Copy link
Member

Choose a reason for hiding this comment

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

The type of witness if different between types of keys

The type of witness is different between different types of keys

Question: would it be possible to use a the random address scheme with new funds, and put sequential addresses in legacy funds (ignoring the specifics of the current mainnet and coming testnet)? If it is possible, maybe the "why" of the cited statement could be made a bit clearer.

we may have to support many types for one backend target

Why "may"? We are?

Copy link
Member Author

@KtorZ KtorZ Oct 21, 2019

Choose a reason for hiding this comment

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

We are indeed.

would it be possible to use a the random address scheme with new funds

No, because the address structure for new funds makes it impossible to implement the random scheme.

put sequential addresses in legacy funds

No. Jörmungandr doesn't allow that.

Copy link
Member Author

Choose a reason for hiding this comment

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

extended comment to clarify that 👍

rndApi <- apiLayer tr (toWLBlock <$> nl)
seqApi <- apiLayer tr (toWLBlock <$> nl)
let rndTl = newTransactionLayer @n (getGenesisBlockHash bp)
let seqTl = newTransactionLayer @n (getGenesisBlockHash bp)
Copy link
Member

Choose a reason for hiding this comment

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

Why do the transaction layers need to be different? newTransactionLayer is passed the same arguments.

Ah, right! The implicit key type-param!

@KtorZ
Copy link
Member Author

KtorZ commented Oct 22, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 22, 2019
862: jormungandr launch: use --rest-listen instead of generating config.yaml r=KtorZ a=rvl

Relates to #832 and #848.
Supersedes #850.

# Overview

`cardano-wallet-jormungandr launch` specifies the REST API port and storage directory. The user provides the rest of the Jörmungandr configuration (e.g. trusted peers). 

# Comments

The Jörmungandr P2P listen address, port, and log level are no longer configured by cardano-wallet.


864: nix: Provide derivations for Daedalus installer r=KtorZ a=rvl

Relates to #863.
Based on #828.

# Overview

- @disassembler @cleverca22 It's not exactly the same as before but should work ok I think.
- Adds source filtering to avoid unnecessary rebuilds.

# Comments

To build:

```
nix-build -A cardano-wallet-jormungandr
nix-build release.nix -A daedalus-jormungandr.windows -o daedalus-jormungandr-windows
nix-build release.nix -A daedalus-jormungandr.macos -o daedalus-jormungandr-macos
nix-build release.nix -A daedalus-jormungandr.linux -o daedalus-jormungandr-linux
```

Note that `daedalus-jormungandr.{windows,macos,linux}` from `release.nix` reference the same `cardano-wallet-jormungandr` derivation, only with different `system` or `crossSystem` arguments. So Daedalus may also import from `default.nix` rather than `release.nix`.

878: Support for legacy UTxO witness in Jörmungandr r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#779 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have extended `mkStdTx` so that it would properly handle transactions coming from a `RndKey` and construct `legacy-utxo` witnesses for it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

Jörmungandr doesn't implement creating legacy utxo witnesses from jcli ... 

[jcli/src/jcli_app/transaction/mk_witness.rs](https://github.com/input-output-hk/jormungandr/blob/master/jcli/src/jcli_app/transaction/mk_witness.rs#L78-L82)
```rust
            WitnessType::OldUTxO => {
                // TODO unimplemented!()
                let _secret_key: SecretKey<Ed25519Bip32> = self.secret()?;
                Err(Error::MakeWitnessLegacyUtxoUnsupported)?;
                unimplemented!()
            }
``` 

so I had to construct them by hand according to:

- The format defined in [chain-impl-mockchain#witnesses](https://github.com/input-output-hk/chain-libs/blob/incentive/chain-impl-mockchain/doc/format.md#witnesses)

- The format from the source (double checking it matches the doc..) [chain-impl-mockchain/src/transaction/witness.rs](https://github.com/input-output-hk/chain-libs/blob/incentive/chain-impl-mockchain/src/transaction/witness.rs#L173-L176)

It'd be nice to review our golden if / when the constructor for the witness type gets updated.

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


879: Porting the rest of forget pending tx integration tests to CLI r=KtorZ a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#836 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have ported the rest of forgetting pending tx integration tests to CLI

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 22, 2019

Canceled (will resume)

iohk-bors bot added a commit that referenced this pull request Oct 22, 2019
862: jormungandr launch: use --rest-listen instead of generating config.yaml r=KtorZ a=rvl

Relates to #832 and #848.
Supersedes #850.

# Overview

`cardano-wallet-jormungandr launch` specifies the REST API port and storage directory. The user provides the rest of the Jörmungandr configuration (e.g. trusted peers). 

# Comments

The Jörmungandr P2P listen address, port, and log level are no longer configured by cardano-wallet.


864: nix: Provide derivations for Daedalus installer r=KtorZ a=rvl

Relates to #863.
Based on #828.

# Overview

- @disassembler @cleverca22 It's not exactly the same as before but should work ok I think.
- Adds source filtering to avoid unnecessary rebuilds.

# Comments

To build:

```
nix-build -A cardano-wallet-jormungandr
nix-build release.nix -A daedalus-jormungandr.windows -o daedalus-jormungandr-windows
nix-build release.nix -A daedalus-jormungandr.macos -o daedalus-jormungandr-macos
nix-build release.nix -A daedalus-jormungandr.linux -o daedalus-jormungandr-linux
```

Note that `daedalus-jormungandr.{windows,macos,linux}` from `release.nix` reference the same `cardano-wallet-jormungandr` derivation, only with different `system` or `crossSystem` arguments. So Daedalus may also import from `default.nix` rather than `release.nix`.

878: Support for legacy UTxO witness in Jörmungandr r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#779 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have extended `mkStdTx` so that it would properly handle transactions coming from a `RndKey` and construct `legacy-utxo` witnesses for it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

Jörmungandr doesn't implement creating legacy utxo witnesses from jcli ... 

[jcli/src/jcli_app/transaction/mk_witness.rs](https://github.com/input-output-hk/jormungandr/blob/master/jcli/src/jcli_app/transaction/mk_witness.rs#L78-L82)
```rust
            WitnessType::OldUTxO => {
                // TODO unimplemented!()
                let _secret_key: SecretKey<Ed25519Bip32> = self.secret()?;
                Err(Error::MakeWitnessLegacyUtxoUnsupported)?;
                unimplemented!()
            }
``` 

so I had to construct them by hand according to:

- The format defined in [chain-impl-mockchain#witnesses](https://github.com/input-output-hk/chain-libs/blob/incentive/chain-impl-mockchain/doc/format.md#witnesses)

- The format from the source (double checking it matches the doc..) [chain-impl-mockchain/src/transaction/witness.rs](https://github.com/input-output-hk/chain-libs/blob/incentive/chain-impl-mockchain/src/transaction/witness.rs#L173-L176)

It'd be nice to review our golden if / when the constructor for the witness type gets updated.

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


879: Porting the rest of forget pending tx integration tests to CLI r=KtorZ a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#836 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have ported the rest of forgetting pending tx integration tests to CLI

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 22, 2019

Build failed (retrying...)

@KtorZ
Copy link
Member Author

KtorZ commented Oct 22, 2019

bors r-

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 22, 2019

Canceled

@KtorZ
Copy link
Member Author

KtorZ commented Oct 22, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 22, 2019
878: Support for legacy UTxO witness in Jörmungandr r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#779 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have extended `mkStdTx` so that it would properly handle transactions coming from a `RndKey` and construct `legacy-utxo` witnesses for it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

Jörmungandr doesn't implement creating legacy utxo witnesses from jcli ... 

[jcli/src/jcli_app/transaction/mk_witness.rs](https://github.com/input-output-hk/jormungandr/blob/master/jcli/src/jcli_app/transaction/mk_witness.rs#L78-L82)
```rust
            WitnessType::OldUTxO => {
                // TODO unimplemented!()
                let _secret_key: SecretKey<Ed25519Bip32> = self.secret()?;
                Err(Error::MakeWitnessLegacyUtxoUnsupported)?;
                unimplemented!()
            }
``` 

so I had to construct them by hand according to:

- The format defined in [chain-impl-mockchain#witnesses](https://github.com/input-output-hk/chain-libs/blob/incentive/chain-impl-mockchain/doc/format.md#witnesses)

- The format from the source (double checking it matches the doc..) [chain-impl-mockchain/src/transaction/witness.rs](https://github.com/input-output-hk/chain-libs/blob/incentive/chain-impl-mockchain/src/transaction/witness.rs#L173-L176)

It'd be nice to review our golden if / when the constructor for the witness type gets updated.

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 22, 2019

Build succeeded

@iohk-bors iohk-bors bot merged commit 6af04d7 into master Oct 22, 2019
@KtorZ KtorZ deleted the KtorZ/legacy-tx-witness branch October 28, 2019 18:57
@KtorZ KtorZ added this to the Byron Wallet Support milestone Nov 6, 2019
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.

2 participants