Prevent the migration algorithm from creating money. #77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
#74
Summary
The migration algorithm should satisfy the following property:
However, recent test failures have showed that the existing implementation occasionally failed to respect this property, in very rare situations.
In particular, supplying a coin selection where the total value of all inputs (in a given batch) is less than the minimum value of a non-dust coin will reliably produce a set of change coins whose total value is greater than the total value of all inputs. (See #74 for examples of test failures.)
This PR fixes the above issue by adding a guard to the
mkCoinSelection
function, preventing it from creating an initial change coin if that change coin would be higher than the total value of all inputs.Demonstration (with one million tests per property):
Other Changes
This PR also makes the following changes:
isDust
to provide a uniform way to determine whether or not a given coin is a dust coin, and uses it to replace a number of inequality checks.