-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: Consolidate CInputCoin and COutput #24091
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
wallet: Consolidate CInputCoin and COutput #24091
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Reviewed the first 3 commits up to 95338d3b4bf3be2492cc654029ebfb28bedda42d, got a bit confused after that, as I think some of 864b4ed accidentally landed in 6d54822.
While you're touching this, it would be helpful to document the COutput class (now in coinselection.h) and how it relates to CWalletTx and COutputEntry (which is in receive.h, but used in the listtransactions RPC). For example, I was somewhat confused to see that CWalletTx does not in fact contain a list of COutputs.
95338d3b4bf3be2492cc654029ebfb28bedda42d: do you want to move AvailableCoins, ListCoins, etc from spend.h to coinselection.h too? Those all use COutput. Or is that more involved?
src/wallet/coinselection.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
864b4edf130afe2b77142ca343022b3de6d3fec5: this is not set and not used (in this commit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used later, but I didn't want that commit to be too big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
06cf38fce16f327579b008ee8fb78fa851cc8fce: it compiles fine now. But ideally you would move some more code from d840d84f547e911ec88f098d1ece7ed86f100cbc into this commit to set and use them. Not sure if that's practical.
|
I've split up a few commits and introduced the variables added to
No. |
efa72a5 to
2278038
Compare
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. I need this for some wallet stuff.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
|
Just read commits up to 1f475858590a50a8a3f37a02df2c2d7b803f9834 (wallet: Remove CWalletTx from COutput's constructor) and so far I have not found any obvious issue. Nice PR. |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Light code review ACK 2278038d3f9c2488421cf7ed1131ac77a6f22380.
nit, drop COutput forward declaration in wallet.h
|
concept ACK |
Sjors
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed everything except d840d84f547e911ec88f098d1ece7ed86f100cbc, which still gives me a bit of a headache, but will look at it later.
src/wallet/coinselection.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
06cf38fce16f327579b008ee8fb78fa851cc8fce: it compiles fine now. But ideally you would move some more code from d840d84f547e911ec88f098d1ece7ed86f100cbc into this commit to set and use them. Not sure if that's practical.
2278038 to
3f5ed18
Compare
Sjors
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 3f5ed1858eba99253153f6b692625af075107f60
instagibbs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3f5ed1858eba99253153f6b692625af075107f60
|
Concept ACK |
kallewoof
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept/utACK 3f5ed1858eba99253153f6b692625af075107f60
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 3f5ed1858eba99253153f6b692625af075107f60. All my suggestions are minor, and you can ignore them. This is a nice simplification and the changes are generally pretty easy to follow. Main feedback would be to drop the struct m_ prefixes (Ugly!)
3f5ed18 to
98812f1
Compare
|
CI seems a bit unhappy |
Update the member variables to match the new style -BEGIN VERIFY SCRIPT- sed -i 's/fSpendableIn/spendable/' $(git grep -l "fSpendableIn") sed -i 's/fSpendable/spendable/' $(git grep -l "fSpendable") sed -i 's/fSolvableIn/solvable/' $(git grep -l "fSolvableIn") sed -i 's/fSolvable/solvable/' $(git grep -l "fSolvable") sed -i 's/fSafeIn/safe/' $(git grep -l "fSafeIn") sed -i 's/fSafe/safe/' $(git grep -l "fSafe") sed -i 's/nInputBytes/input_bytes/' $(git grep -l "nInputBytes") sed -i 's/nDepthIn/depth/' $(git grep -l "nDepthIn" src/wallet src/bench) sed -i 's/nDepth/depth/' src/wallet/spend.h sed -i 's/\.nDepth/.depth/' $(git grep -l "\.nDepth" src/wallet/) sed -i 's/nDepth, FormatMoney/depth, FormatMoney/' src/wallet/spend.cpp -END VERIFY SCRIPT-
Instead of determining whether the containing transaction is from the wallet dynamically as needed, just pass it in to COutput and store it. The transaction ownership isn't going to change.
98812f1 to
1a3e984
Compare
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 1a3e984a09343ac1d804f6106a52c9cf527f7dba
Nice simplification and easy review!
src/wallet/coinselection.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "coinselection: Add effective value and fees to COutput" (03245baac1b8a9bef2cad09942cdd6a618e3b7ef)
Note (just for understanding): These new members come from the existing CInputCoin struct and are added here unchanged so COutput can replace CInputCoin later
src/wallet/coinselection.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "coinselection: Use COutput instead of CInputCoin" (f2cf89eefefec98aa6f5f7a8d3f6f0abc0e0d526)
Note: parameter isn't actually changing here, obsolete comment is just being brought up to date with current code. (At first I thought this change was more significant than it really is)
Sjors
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-utACK 1a3e984a09343ac1d804f6106a52c9cf527f7dba
glozow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
light code review ACK 1a3e984a09343ac1d804f6106a52c9cf527f7dba, just a few nits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, thanks for doing, I'm glad to see CInputCoin go away. Got some nits and questions.
src/bench/coin_selection.cpp
Outdated
| std::vector<COutput> coins; | ||
| for (const auto& wtx : wtxs) { | ||
| coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* depth */, true /* spendable */, true /* solvable */, true /* safe */); | ||
| coins.emplace_back(wallet, *wtx, /*iIn=*/ 0, /*depth=*/ 6 * 24, /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ true, /*use_max_sig_in=*/ false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 4602295 I missed at first that you added explicit values for use_max_sig_in in a few places while removing the default value. The style amendment first made me think that the default value removal was the only code change. In the future, perhaps consider splitting style edits and functional code changes.
src/wallet/spend.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably for a follow-up, but I think
COutput could have a function that takes a feerate, and sets the COutput.effective_value, or perhaps we could even have COutput take a feerate in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave that for a followup.
w0xlt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK 1a3e984
Instead of having a pointer to the CWalletTx in COutput, we can just store the COutPoint and the CTxOut as those are the only things we need from the CWalletTx. Other things CWalletTx used to provide were time and fIsFromMe but these are also being stored by COutput.
1a3e984 to
6c05fa5
Compare
Also rename setPresetCoins to preset_coins
It is no longer needed as everything it was doing is now done by COutput
These operators are used only by the tests in std::mismatch. As std::mismatch can take a binary predicate, we can use a lambda that achieves the same instead.
6c05fa5 to
049003f
Compare
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 049003f, just adding comments and removing == operators since last review
w0xlt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 049003f
murchandamus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 049003f
…ake COutput a struct fab287c Clarify that COutput is a struct, not a class (MarcoFalke) fa61cdf wallet: Fix coinselection include (MarcoFalke) Pull request description: * Fix include (see commit message) * `{}`-init, see bitcoin/bitcoin#24091 (comment) * `struct`, see bitcoin/bitcoin#24091 (comment) ACKs for top commit: theStack: Code-review ACK fab287c Tree-SHA512: dd2cfb9c06a92295dbd8fbb6d56afcf00ebda2a0440e301d392cd183d1b9cd87626311d539e302a9e6c6521d69d6183c74a51934e3fc16e64a5dcaba60c7e3ce
While working on coin selection code, it occurred to me that
CInputCoinis really a subset ofCOutputand the conversion of aCOutputto aCInputCoindoes not appear to be all that useful. So this PR adds fields that are present inCInputCointoCOutputand replaces the usage ofCInputCoinwithCOutput.COutputis also moved to coinselection.h. As part of this move, the usage ofCWalletTxis removed fromCOutput. It is instead replaced by storing aCOutPointand theCTxOutrather than the entireCWalletTxas coin selection does not really need the fullCWalletTx. TheCWalletTxwas only used for figuring out whether the transaction containing the output was from the current wallet, and for the transaction's time. These are now parameters toCOutput's constructor.