-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: coverage for receiving txes with same id but different witness data #25909
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: coverage for receiving txes with same id but different witness data #25909
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
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.
Approach ACK
cd2ce2e
to
398e247
Compare
I've reviewed the diff (398e247), checked out the code and run the tests (using I added extra assertions locally for my own learning. Didn't want to clutter the diff with individual code comments, so I will share them here. I don't know if they are even useful or just redundant. For me, the main thing is it is not immediately obvious that the existing assertions cover the expected presence/absence of witness data. The assertions on the transaction IDs (like Apologies in advance if there are any C++ gotchas with pointers and references that I am not aware of :)
Aside from that I had a few questions to help me understand the PR better:
|
Yep, non-issue. It comes from the segwit definitions (BIP141). if the witness data doesn't exist (or isn't there), then you are serializing only the regular transaction fields, thus why the tx id is equal to the witness id.
Not really. For the test purposes, it could had been a 1-of-2 as well. I just liked more to present a scenario where the user looses data that is hard to re-do if keys are spread across different devices/places.
Both files were just containing utility functions to interact with the wallet. None of them are unit tests. Plus, as |
398e247
to
9530539
Compare
rebased, conflicts solved. |
651ff6a
to
326d030
Compare
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 326d030
Great refactoring and I verified that the tests correctly test the behavior intended.
326d030
to
312f367
Compare
Updated per @aureleoules feedback, thanks! Tiny diff. Only moved from using the test coinbase key to use the custom one, no functional changes. |
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 312f367
…ness data The following cases are covered: 1) Two p2wpkh transactions with the same hash are received: The first one with segwit data stripped, and the second one with segwit data. Result -> the wallet will update the stored tx, saving the witness data. 2) Two p2wsh multisig spending txes with the same hash but a different witness are received: The first is added to the wallet via the mempool acceptance flow. while the second one, is added to the wallet via the block connection flow. Result -> the wallet will NOT update the stored transaction, the first received transaction will take precedence over any following-up transaction. Don't care if the original transaction didn't get into a block and the second one did.
312f367
to
d811ec8
Compare
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.
Result -> the wallet will NOT update the stored transaction. The first received transaction
will take precedence over any following-up transaction. Detached to the fact that the
original transaction didn't get into a block and the second one did.
While it's good to have tests for the behavior that occurs, having tests for incorrect behavior is probably not something we want to be doing as it can make the bug last a lot longer. If the intention is to have a followup soon that fixes the bug, then I would prefer that these test changes just get rolled into that rather than be their own PR. Otherwise the test needs a big warning that it is testing actual incorrect behavior, and not intended behavior.
std::string pks_str; // descriptor data | ||
for (int i=0; i < 5; i++) { | ||
CTxDestination multi_dest = *Assert(spkm->GetNewDestination(OutputType::BECH32)); | ||
auto provider = Assert(spkm->GetSolvingProvider(GetScriptForDestination(multi_dest), /*include_private=*/ true)); |
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 would strongly prefer that we don't have to add new methods to DescSPKM that can export individual keys. This test could just as easily work with generating new random CKeys for the private keys.
Are you still working on this? |
not really. Closing for now. |
Based on #11240 context, adding test coverage for the behavior introduced in #11225 and to the current wallet limitations.
This is the first step towards adding the ability to store multiple transactions with same tx id but different witness data in the wallet. Verifying and testing the current behavior before introducing the new features.
The following cases are covered:
Two p2wpkh spending transactions with the same hash are received:
The first one with segwit data stripped, and the second one with segwit data.
Result -> the wallet will update the stored tx, saving the witness data.
Two p2wsh multisig spending txes with the same hash but a different witness are received:
The first is added to the wallet via the mempool acceptance flow.
while the second one, is added to the wallet via the block connection flow.
Result -> the wallet will NOT update the stored transaction. The first received transaction
will take precedence over any following-up transaction. Detached to the fact that the
original transaction didn't get into a block and the second one did.
Extra Note:
Did it on an unit test merely because wanted to review other parts of the sources while was doing it. Could migrate it into a functional test if reviewers wants it as well.