-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet, assumeutxo: Don't Assume m_chain_tx_count, Improve wallet RPC errors #30909
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30909. 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. 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. |
alfonsoromanz
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.
src/validation.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.
Question, is debug logging this enough, unsure but e.g. in the various RPCs (and CLI -getinfo) that return a "verificationprogress" field, are there any where it would be a good idea to describe the what/why of a returned 0.0 value due to this case.
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 think this should only be possible to trigger with the rescan, the various RPCs are always called with a block (usually the tip) that is guaranteed to have m_chain_tx_count set.
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.
And aside from only hitting this in the context of rescan + blocks missing this is just about showing the progress and not the actual functionality the user seeks. So it didn't feel important enough for me to use another category mainly because of that. Unless there are strong opinions against it I will keep this as is.
Can you explain this a bit better? IIRC the snapshot base block itself has the count set, as well as any validated blocks after it. See |
mzumsande
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.
Whereas calling a rescan on the (missing) background blocks seems like a bug that should be avoided at the call site, no?
Well, the approach seems to be similar with pruning:
importdescriptors tries to scan as many blocks as possible (no stopping after a failure due to missing block data), and then returns a failure / warns the user that the result may be incomplete. It could probably have been implentend differently, checking if we are missing blocks due to pruning and refuse to import the descriptors, but it doesn't do that.
If that is seen as a viable way for the pruning case, maybe it would be a bit inconsistent to just forbid it in the assumeutxo background sync case?! In which case just dealing with the progress estimation error would be ok?
Sure, if that is the case, the pull request description should mention it. Also, the error message could probably be updated, because it only mentions pruning, no AU. (Note to self: Reminds me of #26282) |
|
Though one could also make a case for not allowing importdescriptor/rescan during background sync if non-downloaded blocks are affected, with the reasoning "just wait a little bit longer" that doesn't really apply to the pruning case. Would be interesting to know if this has ever been discussed for assumeutxo. |
9be080a to
fa821ad
Compare
Yeah, my statement was wrong. I think I managed to confuse myself with some wrongfully placed debug logging. I have fixed the description.
Updated the error message and realized that he same issue exists in EDIT: I also add coverage for
I had a similar thoughts when I looked into this earlier. But I think going that route might either break workflows with Also, while "just wait a little bit longer" might be a good answer, we could also say "just run another rescan later" and that may ultimately be a better experience for the users. I don't have a strong opinion here but it seems like these ideas may better be scoped out in a separate issue first and then potentially be implemented as a follow-up. |
d7bc556 to
04a78f1
Compare
|
@achow101 do you have thoughts on descriptor import/rescan behavior with missing blocks because of ongoing assumeutxo background sync? |
04a78f1 to
58a4622
Compare
src/wallet/rpc/transactions.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.
I wonder if it is easy to provide an accurate error message. Otherwise it could be a bit confusing for a user that had AU enabled (with 100% progress) as well as pruning, not knowing the exact cause and what they need to do to work around the error. Not sure how easy that is, so up to you.
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.
Improving the error message is reasonably easy but I didn't see a way without expanding the chain interface. I have implemented what I think is a step in the right direction but not a full solution to every edge case in order to keep the scope of this PR reasonable. Looking for feedback if people still think this is right approach and if I should expand it further or if adding more is going too far.
I think the assumeutxo + pruning use-case is pretty hard to deal with accurately for these wallet use-cases, especially if the pruning target is small. I am not sure if we can really give users a perfect answer in that case. Users could request a window for rescan that is larger than the prune target so I think pruning takes precedent because it requires a reindex to "fix" while AU just takes some time and resolves itself. Also, in the case of au+pruning a block could be not available because it wasn't synced yet during the first time the user tries to import a descriptor. But then the second time the user tries the same block that wasn't synced yet before could now be pruned already, assuming a small prune target. I mean to say, a perfect solution requires changing how the RPC works and I think that's beyond the scope of this PR. I could think about it a bit more and open an issue on it though if that is desirable.
58a4622 to
589b849
Compare
|
Improved the error messages for |
589b849 to
da299be
Compare
|
Rebased and addressed nit from @maflcko |
Particularly add more details in the case of pruning or assumeutxo.
a9f1c8a to
9d2d9f7
Compare
|
Addressed feedback from @mzumsande |
mzumsande
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 9d2d9f7
src/interfaces/chain.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.
Makes sense, I got confused there!
It just seemed a bit unusual, plus we generally use CHECK_NONFATAL instead of assert in rpc code, which may not be the ideal choice for possible future interface users (though it is currently just used in another rpc call, so it's not an actual problem).
But I'm not an expert on the design of our interfaces, so I don't know if moving it somewhere else is necessary.
furszy
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 9d2d9f7
| LogWarning("Internal bug detected: block %d has unset m_chain_tx_count (%s %s). Please report this issue here: %s\n", | ||
| pindex->nHeight, CLIENT_NAME, FormatFullVersion(), CLIENT_BUGREPORT); | ||
| if (pindex->m_chain_tx_count == 0) { | ||
| LogDebug(BCLog::VALIDATION, "Block %d has unset m_chain_tx_count. Unable to estimate verification progress.\n", pindex->nHeight); |
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.
tiny nit: the validation category is a bit odd in the wallet scan context or GUI updates.
|
ACK 9d2d9f7 |

A test that is added as part of #30455 uncovered this issue: The
GuessVerificationProgressfunction is used during during descriptor import and relies onm_chain_tx_count. In #29370 anAssumewas added expecting them_chaint_tx_countto be set. However, as the test uncovered,GuessVerificationProgressis called with background sync blocks that havem_chaint_tx_count = 0when they have not been downloaded and processed yet.The simple fix is to remove the
Assume. Users should not be thrown off by theInternal bug detectederror. The behavior ofimportdescriptoris kept consistent with the behavior for blocks missing due to pruning.The test by alfonsoromanz is cherry-picked here to show that the CI errors should be fixed by this change.
This PR also improves error messages returned by the
importdescriptorsandrescanblockchainRPCs. The error message now changes depending on the situation of the node, i.e. if pruning is happening or an assumutxo backgroundsync is active.