-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Fix ScanForWalletTransactions to return an enum indicating scan result: success / failure / user_abort #13076
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
Fix ScanForWalletTransactions to return an enum indicating scan result: success / failure / user_abort #13076
Conversation
25a588a
to
821c955
Compare
821c955
to
7b760bc
Compare
7b760bc
to
2c4bc00
Compare
@@ -1763,14 +1764,14 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock | |||
if (pindex && !chainActive.Contains(pindex)) { | |||
// Abort scan if current block is no longer active, to prevent | |||
// marking transactions as coming from the wrong block. | |||
ret = pindex; | |||
failed_block = pindex; |
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 you might want to drop this line and just return true here, to fix the regression described here: #12275 (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.
Not sure about that - my inclination is to maintain stricter checking at the risk of spurious failures over less strict checking at the risk of silent failure. How about opening a separate PR for that so it can be considered separately?
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.
3cdfcc3
to
620581f
Compare
src/wallet/wallet.cpp
Outdated
const CBlockIndex* const failedBlock = ScanForWalletTransactions(startBlock, nullptr, reserver, update); | ||
if (failedBlock) { | ||
const CBlockIndex* failedBlock = nullptr; | ||
// TODO: this should take into account failure by ScanResult::USER_ABORTED |
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 address this todo in a follow-up.
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.
Follow-up is here, I'll wait to open until this is accepted:
https://github.com/Empact/bitcoin/tree/rescan-from-time
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.
d922ab0
to
a4f3cb2
Compare
a4f3cb2
to
8bf206b
Compare
Dropped explicit values and type from |
8bf206b
to
42fad11
Compare
Rebased and updated to accommodate #12507. |
42fad11
to
ea9d92b
Compare
8d11f05
to
981adda
Compare
@MarcoFalke see the stop_block commit above. Any idea where the test failures are coming from? I don’t see the connection. |
Accurately reports the last block successfully scanned, replacing a return of the chain tip, which represented possibly inaccurated data in a race condition.
981adda
to
bd3b036
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.
utACK bd3b036
utACK bd3b036 |
utACK bd3b036 |
utACK bd3b036 |
…ing scan result: success / failure / user_abort bd3b036 Add stop_block out arg to ScanForWalletTransactions (Ben Woosley) 3002d6c Return a status enum from ScanForWalletTransactions (Ben Woosley) bb24d68 Make CWallet::ScanForWalletTransactions args and return value const (Ben Woosley) Pull request description: Return the failed block as an out arg. Fixes #11450. /cc #12275 Tree-SHA512: 6a523e5425ebfe24e664a942ae21c797ccc1281c25b1bf8d02ad95c19dae343fd8051985ef11853474de7628fd6bed5f15190fbc087c3466ce6fdecab37d72a9
CBlockIndex* pindex = pindexStart; | ||
CBlockIndex* ret = nullptr; | ||
const CBlockIndex* pindex = pindexStart; | ||
failed_block = nullptr; | ||
|
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 is not setting stop_block
null here, which seems unintended and could lead to uninitialized variables. Would be good to fix this or add documentation if it was done intentionally.
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.
Ah, right, the code does contradict the comments on line 1634. Will open a PR.
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.
Summary: Partial backport of core [[bitcoin/bitcoin#13076 | PR13076]]: bitcoin/bitcoin@bb24d68 Test Plan: ninja all check Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5561
Summary: ``` Return the failed block as an out var. This clarifies the outcome as the prior return value could be null due to user abort or failure. ``` Partial backport of core [[bitcoin/bitcoin#13076 | PR13076]]: bitcoin/bitcoin@3002d6c Depends on D5561. Test Plan: ninja all check check-functional Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5562
Summary: ``` Accurately reports the last block successfully scanned, replacing a return of the chain tip, which represented possibly inaccurated data in a race condition. ``` Completes backport of core [[bitcoin/bitcoin#13076 | PR13076]]: bitcoin/bitcoin@bd3b036 Depends on D5562. Test Plan: ninja all check check-functional Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5563
Summary: Partial backport of core [[bitcoin/bitcoin#13076 | PR13076]]: bitcoin/bitcoin@bb24d68 Test Plan: ninja all check Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5561
Summary: ``` Return the failed block as an out var. This clarifies the outcome as the prior return value could be null due to user abort or failure. ``` Partial backport of core [[bitcoin/bitcoin#13076 | PR13076]]: bitcoin/bitcoin@3002d6c Depends on D5561. Test Plan: ninja all check check-functional Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5562
…indicating scan result: success / failure / user_abort bd3b036 Add stop_block out arg to ScanForWalletTransactions (Ben Woosley) 3002d6c Return a status enum from ScanForWalletTransactions (Ben Woosley) bb24d68 Make CWallet::ScanForWalletTransactions args and return value const (Ben Woosley) Pull request description: Return the failed block as an out arg. Fixes bitcoin#11450. /cc bitcoin#12275 Tree-SHA512: 6a523e5425ebfe24e664a942ae21c797ccc1281c25b1bf8d02ad95c19dae343fd8051985ef11853474de7628fd6bed5f15190fbc087c3466ce6fdecab37d72a9
Return the failed block as an out arg.
Fixes #11450.
/cc #12275