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

Allow constructing change output from _any_ input #2484

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Feb 1, 2021

Issue Number

ADP-345

Overview

  • 312b0b1
    📍 allow constructing change output from any input
    In only a few days, this has proven to be a quite major issue users have been running into. The thing is that we can't really control how the shape of the UTxO evolves. Quite easily, a user can end up with large quantity of Ada bound to a particular asset. Before this commit, when transacting on other assets, these Ada would've been locked and the user will be granted with a 'cannot_cover_fee' error, despite having plenty of Ada in his/her wallet. However, because of the way we construct change outputs, it is rather safe and easy to also select from any inputs and construct change outputs accordingly.

    As a matter of fact, the change construction is an iterative trial-and-error process. That is, it works in the following steps:

    • From a given set of input, try to construct valid change output to cover for the transaction need
    • If impossible, select another input and try again.

    Selecting an extra input which contains some potentially new assets will result in a completely different change output. However, since we are re-construct the entire change output sets on each iteration, it doesn't matter much. This processus is still imperfect in the sense that there may be some valid subset of the selection which can result in a valid transaction, whereas some other path may not. Yet, such cases should be rare and "edgy" in practice.

Comments

@KtorZ KtorZ self-assigned this Feb 1, 2021
let inputsSelected = mkInputsSelected selected
let changeSkeleton = NE.toList $ predictChange selected
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this here inside the function body because now, it is possible for the predicted change to change on each iteration due to the selection of new multi-asset outputs.

Copy link
Contributor

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

With the change I am successfully able to send MA tx which was giving me "cannot_cover_fee" error before despite my balance was enough to cover tx/fee.

Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me!

A tiny amount of rebasing will be necessary after #2482 merges. (Since [SelectionFilter] has changed to NonEmpty SelectionFilter.)

  In only a few days, this has proven to be a quite major issue users have been running into. The thing is that we can't really control how the shape of the UTxO evolves.
  Quite easily, a user can end up with large quantity of Ada bound to a particular asset. Before this commit, when transacting on other assets, these Ada would've been
  locked and the user will be granted with a 'cannot_cover_fee' error, despite having plenty of Ada in his/her wallet. However, because of the way we construct change outputs,
  it is rather safe and easy to also select from any inputs and construct change outputs accordingly.

  As a matter of fact, the change construction is an iterative trial-and-error process. That is, it works in the following steps:

  - From a given set of input, try to construct valid change output to cover for the transaction need
  - If impossible, select another input and try again.

  Selecting an extra input which contains some potentially new assets will result in a completely different change output. However, since we are re-construct the entire change
  output sets on each iteration, it doesn't matter much. This processus is still imperfect in the sense that there may be some valid subset of the selection which can result
  in a valid transaction, whereas some other path may not.
@KtorZ KtorZ force-pushed the KtorZ/ADP-345/multi-asset-change-construction branch from 312b0b1 to 63ce689 Compare February 2, 2021 12:02
@KtorZ
Copy link
Member Author

KtorZ commented Feb 2, 2021

bors merge

please.

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 2, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit c33c3b9 into master Feb 2, 2021
@iohk-bors iohk-bors bot deleted the KtorZ/ADP-345/multi-asset-change-construction branch February 2, 2021 12:48
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.

3 participants