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

Remove the input selection limit from coin selection. #3921

Merged
merged 20 commits into from
May 11, 2023

Conversation

jonathanknowles
Copy link
Member

@jonathanknowles jonathanknowles commented May 11, 2023

Issue

ADP-3029

Summary

This PR:

  • removes the notion of an "input selection limit" from coin selection.
  • removes the computeSelectionLimit field from all coin-selection-related constraint records.
  • removes the SelectionLimit type.
  • removes the SelectionLimitReached error, thus simplifying the hierarchy of errors returned by balanceTransaction.

Context

For many years, the coin selection algorithm has provided an ability to limit the number of inputs it selects.

This ability was added as a way to prevent transactions from growing too large, which would render them invalid for submission to the network.

However, the advent of the multi-asset era invalidated one of the assumptions on which this design was based: namely that all inputs should require roughly the same amount of space to encode. In the multi-asset era, each input can reference an output with an arbitrary selection of tokens, and thus different inputs can require wildly different amounts of space to encode the change that they generate.

For example, it's quite possible to build a transaction with 10 inputs that requires more space than a transaction with 100 inputs.

Since all wallet endpoints now use the balanceTransaction function to perform coin selection, and since balanceTransaction does not use the selection limit functionality in any way, there are now no code paths that require this limit to be present.

Therefore, we can simply delete it.

Note that this necessitates removing some coverage checks that some
selections will terminate due to reaching a limit.
All selections are now unlimited, so we no longer need to test coverage
for that case.
It's no longer possible for this error to be created.
The selection input count can never exceed the limit, as there is no
limit, so the condition can never fail.
There is nothing left to adjust, as there can never be a limit.
@jonathanknowles jonathanknowles changed the title Remove the SelectionLimit type. Remove the input selection limit from coin selection. May 11, 2023
@jonathanknowles jonathanknowles marked this pull request as ready for review May 11, 2023 06:01
@jonathanknowles jonathanknowles self-assigned this May 11, 2023
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.

nice! lgtm

@jonathanknowles
Copy link
Member Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 11, 2023

Build succeeded:

@iohk-bors iohk-bors bot merged commit 8bb1eeb into master May 11, 2023
@iohk-bors iohk-bors bot deleted the jonathanknowles/remove-selection-limit branch May 11, 2023 07:28
WilliamKingNoel-Bot pushed a commit that referenced this pull request May 11, 2023
…lection. r=jonathanknowles a=jonathanknowles ## Issue ADP-3029
 
 ## Summary
 
 This PR:
 - removes the notion of an "input selection limit" from coin selection.
 - removes the `computeSelectionLimit` field from all coin-selection-related constraint records.
 - removes the `SelectionLimit` type.
 - removes the `SelectionLimitReached` error, thus simplifying the hierarchy of errors returned by `balanceTransaction`.
 
 ## Context
 
 For many years, the coin selection algorithm has provided an ability to limit the number of inputs it selects.
 
 This ability was added as a way to prevent transactions from growing too large, which would render them invalid for submission to the network.
 
 However, the advent of the multi-asset era invalidated one of the assumptions on which this design was based: namely that all inputs should require roughly the same amount of space to encode. In the multi-asset era, each input can reference an output with an arbitrary selection of tokens, and thus different inputs can require wildly different amounts of space to encode the change that they generate.
 
 For example, it's quite possible to build a transaction with 10 inputs that requires more space than a transaction with 100 inputs.
 
 Since all wallet endpoints now use the `balanceTransaction` function to perform coin selection, and since `balanceTransaction` does not use the selection limit functionality in any way, there are now no code paths that require this limit to be present.
 
 Therefore, we can simply delete it. Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io> Source commit: 8bb1eeb
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