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

Preparation for testing of integrated CoinSelection module. #2945

Merged

Conversation

jonathanknowles
Copy link
Contributor

@jonathanknowles jonathanknowles commented Oct 4, 2021

Issue Number

ADP-1037

Summary

This PR performs some groundwork in preparation for testing the integrated CoinSelection module. It:

  • Extracts out internal functions from CoinSelection.performSelection to clarify the control flow and make testing easier.
  • Moves prepareOutputsWith to the top-level CoinSelection module.
  • Moves minted and burned assets from SelectionSkeleton to TransactionCtx.
  • Populates the assetsTo{Mint,Burn} field within selectAssets.

@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/test-coin-selection-preparation branch from 3514c2f to 087f859 Compare October 4, 2021 08:52
@jonathanknowles jonathanknowles self-assigned this Oct 4, 2021
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/test-coin-selection-preparation branch 4 times, most recently from b25c4c2 to 9acf950 Compare October 5, 2021 04:46
@jonathanknowles jonathanknowles marked this pull request as ready for review October 5, 2021 04:49
This is intended:

- to make the control flow a little clearer.
- to make individual functions easier to test.
This function is unused within `Balance`, and only used by the top-level
`CoinSelection` module. So it makes sense to locate it within the same
module.
The `estimateTxSize` function is provided with a `TxSkeleton`, which is
constructed from a `SelectionSkeleton` and a `TransactionCtx`.

Therefore, provided that a `TxSkeleton` is constructed with the correct
maps of minted and burned assets, the `estimateTxSize` function does not
mind whether these values originate from a `SelectionSkeleton` or from a
`TransactionCtx`.

However, there are strong advantages to storing minted and burned assets
within `TransactionCtx` instead of `SelectionSkeleton`:

* Minted and burned assets remain constant over the course of an ongoing
  coin selection.

* Therefore, the size and cost of minted and burned assets is constant
  over the course of an ongoing coin selection.

* The `{gen,shrink}SelectionSkeleton` functions will no longer need to
  generate and shrink minted and burned assets.

* The mock `computeMinimumCostLinear` function will no longer need to
  determine the sizes of minted and burned assets, leading to faster
  execution times for `BalanceSpec`.

* The `selectAssets` function will be able to populate the `assetsToMint`
  and `assetsToBurn` fields of the `SelectionParams` object, since it
  already has access to a `TransactionCtx` value.
This is an easy win, as the `TransactionCtx` now provides the maps of
assets to mint and burn.
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/test-coin-selection-preparation branch from 9acf950 to 54279bc Compare October 5, 2021 04:50
@jonathanknowles
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 5, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 4fdfdf7 into master Oct 5, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/adp-1037/test-coin-selection-preparation branch October 5, 2021 07:09
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