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

Use effective values throughout coin selection #17331

Open
wants to merge 9 commits into
base: master
from

Conversation

@achow101
Copy link
Member

achow101 commented Oct 31, 2019

Changes KnapsackSolver to be use effective values instead of just the nominal txout value. Since fees are taken into account during the selection itself, we finally get rid of the CreateTransaction loop as well as a few other things that only were only necessary because of that loop.

This should not change coin selection behavior at all (except maybe remove weird edge cases that were caused by the loop). In order to keep behavior the same, KnapsackSolver will select outputs with a negative effective value (as it did before).

Requires #17290 and #17458

@fanquake fanquake added the Wallet label Oct 31, 2019
@DrahtBot

This comment has been minimized.

Copy link
Contributor

DrahtBot commented Oct 31, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17566 (Switch to weight units for all feerates computation by darosior)
  • #17458 (Refactor OutputGroup effective value calculations and filtering to occur within the struct by achow101)
  • #17211 (Allow fundrawtransaction and walletcreatefundedpsbt to take external inputs by achow101)
  • #17208 (Make all tests pass UBSan without using any UBSan suppressions by practicalswift)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@instagibbs

This comment has been minimized.

Copy link
Member

instagibbs commented Nov 1, 2019

concept ACK, unifying to effective value should make 95% of my consternation with Core coin selection go away by making further improvements easier.

So with this change another idea is to have an opt-in Single Random Draw(SRD) which should be pretty drop-in after this which would allow more experimentation with less systemic risk.

@laanwj

This comment has been minimized.

Copy link
Member

laanwj commented Nov 2, 2019

Concept ACK, thanks for making this code more understandable.

@achow101

This comment has been minimized.

Copy link
Member Author

achow101 commented Nov 13, 2019

I think there's a bug in here somewhere. I ran some simulations and it looks like there is a significant difference in some things (e.g. minimum change value) but it should be the same as master. I'm investigating that.

Edit: I think I fixed it. Requires #17458 now.

achow101 added 5 commits Oct 30, 2019
Instead of switching which algorithm to use based on use_bnb, just run
both in SelectCoinsMinConf. If BnB fails, do Knapsack.
OutputGroup::m_value is the true value, not the effective value,
so use the true values of the outputs, not their effective values.
Instead of having callers set the fees, effective values, and filtering
of outputs, do these within OutputGroups themselves as member functions.
@achow101 achow101 force-pushed the achow101:effective-value branch from 75b29f6 to dcfa6ef Dec 2, 2019
achow101 added 4 commits Oct 30, 2019
These booleans are no longer needed
Remove the CreateTransaction while loop. Removes variables that were
only needed because of that loop. Also renames a few variables and
moves their declarations to where they are used.

Some subtractFeeFromOutputs handling is moved to after coin selection
in order to reduce their amounts once the fee is known.

If subtracting the fee reduces the change to dust, we will also now
remove the change output
@achow101 achow101 force-pushed the achow101:effective-value branch from dcfa6ef to aee449e Dec 2, 2019
@DrahtBot DrahtBot removed the Needs rebase label Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.