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

Tweak CLI help for --mainnet #1978

Merged
merged 2 commits into from
Jul 30, 2020
Merged

Tweak CLI help for --mainnet #1978

merged 2 commits into from
Jul 30, 2020

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Jul 29, 2020

Issue Number

ADP-356

Overview

  • Add CLI help for the --mainnet option.
  • Fix some fixmes left over from refactors.

Comments

@rvl rvl added the IMPROVEMENT Mark a PR as an improvement, for auto-generated CHANGELOG label Jul 29, 2020
@rvl rvl self-assigned this Jul 29, 2020
@rvl
Copy link
Contributor Author

rvl commented Jul 30, 2020

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 30, 2020

Build succeeded

@iohk-bors iohk-bors bot merged commit ac9e1d0 into master Jul 30, 2020
@iohk-bors iohk-bors bot deleted the rvl/adp-356/cli-help branch July 30, 2020 01:24
iohk-bors bot added a commit that referenced this pull request Aug 5, 2022
3423: Simplify validation of minimum UTxO values for user-specified outputs. r=Anviking a=jonathanknowles

## Issue Number

#1978

## Summary

This PR adjusts the **_validation_** of **_user-specified_** outputs so that:
- for a given user-specified output `out` with ada quantity `a0`
- if Cardano API function [`calculateMinimumUTxO`](https://github.com/input-output-hk/cardano-node/blob/866c4211a1110ac67f3d866ca6632a6bc51f6041/cardano-api/src/Cardano/Api/Fees.hs#L1219) applied to `out` returns ada quantity `a1` such that `a1 <= a0`
- then wallet API functions will not reject output `out` for having an ada quantity that is too low.

In other words: if a user has previously used the Cardano API to validate the ada quantity of a given output, the wallet API should not reject that ada quantity.

This PR does **_not_** change the way we assign minimum ada quantities to **_auto-generated_** outputs. For auto-generated outputs, we continue to use our previous approach of computing a minimum that can **_always be safely increased_**. This gives the coin selection and migration algorithms the flexibility to freely reassign spare ada without the risk of creating an ada quantity that is invalid.

## Details

This PR introduces the following function:
```hs
isBelowMinimumCoinForUTxO
    :: MinimumUTxO
    -> Address
    -> TokenBundle
    -> Bool
```
This function simply wraps the Cardano API function [`calculateMinimumUTxO`](https://github.com/input-output-hk/cardano-node/blob/866c4211a1110ac67f3d866ca6632a6bc51f6041/cardano-api/src/Cardano/Api/Fees.hs#L1219), returning `True` if (and only) if the resultant ada quantity is **_greater_** than the ada quantity of the original `TokenBundle`, which indicates that the original value was **_insufficient_**.

If applying `isBelowMinimumCoinForUTxO` to a given `TokenBundle` returns `True`, then callers should use `computeMinimumCoinForUTxO` to get a `Coin` value that does satisfy the required minimum.

In particular, the following composition should always evaluate to `False` (arguments left out for brevity):

```hs
isBelowMinimumCoinForUTxO . computeMinimumCoinForUTxO == False
```

This PR makes the `isBelowMinimumCoinForUTxO` function available to the coin selection function `prepareOutputsInternal`, which uses it to validate the ada quantities of user-specified outputs.

Co-authored-by: Jonathan Knowles <[email protected]>
iohk-bors bot added a commit that referenced this pull request Aug 5, 2022
3423: Simplify validation of minimum UTxO values for user-specified outputs. r=Anviking a=jonathanknowles

## Issue Number

#1978

## Summary

This PR adjusts the **_validation_** of **_user-specified_** outputs so that:
- for a given user-specified output `out` with ada quantity `a0`
- if Cardano API function [`calculateMinimumUTxO`](https://github.com/input-output-hk/cardano-node/blob/866c4211a1110ac67f3d866ca6632a6bc51f6041/cardano-api/src/Cardano/Api/Fees.hs#L1219) applied to `out` returns ada quantity `a1` such that `a1 <= a0`
- then wallet API functions will not reject output `out` for having an ada quantity that is too low.

In other words: if a user has previously used the Cardano API to validate the ada quantity of a given output, the wallet API should not reject that ada quantity.

This PR does **_not_** change the way we assign minimum ada quantities to **_auto-generated_** outputs. For auto-generated outputs, we continue to use our previous approach of computing a minimum that can **_always be safely increased_**. This gives the coin selection and migration algorithms the flexibility to freely reassign spare ada without the risk of creating an ada quantity that is invalid.

## Details

This PR introduces the following function:
```hs
isBelowMinimumCoinForUTxO
    :: MinimumUTxO
    -> Address
    -> TokenBundle
    -> Bool
```
This function simply wraps the Cardano API function [`calculateMinimumUTxO`](https://github.com/input-output-hk/cardano-node/blob/866c4211a1110ac67f3d866ca6632a6bc51f6041/cardano-api/src/Cardano/Api/Fees.hs#L1219), returning `True` if (and only) if the resultant ada quantity is **_greater_** than the ada quantity of the original `TokenBundle`, which indicates that the original value was **_insufficient_**.

If applying `isBelowMinimumCoinForUTxO` to a given `TokenBundle` returns `True`, then callers should use `computeMinimumCoinForUTxO` to get a `Coin` value that does satisfy the required minimum.

In particular, the following composition should always evaluate to `False` (arguments left out for brevity):

```hs
isBelowMinimumCoinForUTxO . computeMinimumCoinForUTxO == False
```

This PR makes the `isBelowMinimumCoinForUTxO` function available to the coin selection function `prepareOutputsInternal`, which uses it to validate the ada quantities of user-specified outputs.

Co-authored-by: Jonathan Knowles <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IMPROVEMENT Mark a PR as an improvement, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants