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

Add collateral to coin selection: preparation work #2934

Conversation

jonathanknowles
Copy link
Contributor

Issue Number

ADP-1037

Summary

This PR makes the following changes in preparation for adding collateral to coin selection:

  • Extracts out a searchSpaceLimitDefault constant, and uses this constant in the test suite.
  • Adds type synonyms to CoinSelection.Collateral to simplify type signatures in CoinSelection.
  • Uses the intCast function to replace fromInteger, allowing the compiler to check that integer conversions are safe.
  • Changes the type of maximumCollateralInputCount to Int.

@jonathanknowles jonathanknowles self-assigned this Sep 30, 2021
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/add-collateral-to-coin-selection-preparation branch from fe56267 to dc7a08d Compare September 30, 2021 02:02
This constant defines a default search space limit for collateral
selection.

We reuse this constant from the test suite, so we can be reasonably
confident that performing selections with this limit will not use
inordinate amounts of time and space.
This commit arranges that we have:

- PerformSelectionOf inputId
- PerformSelection

- Selection{Error,Params,Result}Of inputId
- Selection{Error,Params,Result}

The variants with the `Of` suffix all have an `inputId` type parameter,
allowing the test suite to use whatever type of input identifier is most
convenient.

The variants without the `Of` suffix are all specialized to `TxIn`,
making it easier for external modules to use these types.

As a result of this commit, the top-level `CoinSelection` module will no
longer need to state `TxIn` in every type signature that uses a type
from the `Collateral` module.
This library offers the `intCast` function, which provides a safer
alternative to the `fromIntegral` function.

This will compile:

    > intCast @word8 @Word16

But this will not:

    > intCast @Word16 @word8
We also use `intCastMaybe` where necessary.
This will help to avoid multiple integral type conversions within the
`CoinSelection` module.

It requires a safe cast within the `Wallet` layer.
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/add-collateral-to-coin-selection-preparation branch from dc7a08d to d88bfcc Compare September 30, 2021 02:03
@jonathanknowles
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 30, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit ce31509 into master Sep 30, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/adp-1037/add-collateral-to-coin-selection-preparation branch September 30, 2021 03:21
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