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

Fix ScanForWalletTransactions to return an enum indicating scan result: success / failure / user_abort #13076

Merged
merged 3 commits into from Dec 12, 2018

Conversation

@Empact
Copy link
Member

@Empact Empact commented Apr 25, 2018

Return the failed block as an out arg.

Fixes #11450.

/cc #12275

src/wallet/rpcwallet.cpp Outdated Show resolved Hide resolved
src/wallet/wallet.cpp Outdated Show resolved Hide resolved
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 25a588a to 821c955 Apr 25, 2018
src/wallet/wallet.cpp Outdated Show resolved Hide resolved
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 821c955 to 7b760bc Apr 25, 2018
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 7b760bc to 2c4bc00 Apr 26, 2018
@@ -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;
Copy link
Contributor

@ryanofsky ryanofsky Apr 26, 2018

I think you might want to drop this line and just return true here, to fix the regression described here: #12275 (comment).

Copy link
Member Author

@Empact Empact Apr 29, 2018

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?

src/wallet/wallet.cpp Outdated Show resolved Hide resolved
Copy link
Member

@promag promag left a comment

Concept ACK.

src/wallet/wallet.cpp Outdated Show resolved Hide resolved
src/wallet/wallet.cpp Outdated Show resolved Hide resolved
src/qt/test/wallettests.cpp Outdated Show resolved Hide resolved
src/wallet/wallet.cpp Outdated Show resolved Hide resolved
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch 2 times, most recently from 3cdfcc3 to 620581f Apr 29, 2018
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
Copy link
Member Author

@Empact Empact Apr 29, 2018

I'll address this todo in a follow-up.

Copy link
Member Author

@Empact Empact Nov 13, 2018

Follow-up is here, I'll wait to open until this is accepted:
https://github.com/Empact/bitcoin/tree/rescan-from-time

Copy link
Member Author

@Empact Empact Dec 14, 2018

@Empact Empact changed the title Fix ScanForWalletTransactions to return a bool indicating success or failure Fix ScanForWalletTransactions to return an enum indicating scan result: success / failure / user_abort Apr 29, 2018
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch 9 times, most recently from d922ab0 to a4f3cb2 Apr 30, 2018
src/wallet/wallet.h Outdated Show resolved Hide resolved
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from a4f3cb2 to 8bf206b Apr 30, 2018
@Empact
Copy link
Member Author

@Empact Empact commented Apr 30, 2018

Dropped explicit values and type from ScanResult enum.

@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 8bf206b to 42fad11 May 3, 2018
@Empact
Copy link
Member Author

@Empact Empact commented May 3, 2018

Rebased and updated to accommodate #12507.

@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 42fad11 to ea9d92b May 18, 2018
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch 3 times, most recently from 8d11f05 to 981adda Nov 13, 2018
@Empact
Copy link
Member Author

@Empact Empact commented Nov 13, 2018

@MarcoFalke see the stop_block commit above. Any idea where the test failures are coming from? I don’t see the connection.

src/qt/test/wallettests.cpp Outdated Show resolved Hide resolved
Accurately reports the last block successfully scanned, replacing a return of
the chain tip, which represented possibly inaccurated data in a race condition.
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 981adda to bd3b036 Nov 13, 2018
Copy link
Contributor

@ryanofsky ryanofsky left a comment

utACK bd3b036

@jonasschnelli
Copy link
Contributor

@jonasschnelli jonasschnelli commented Dec 11, 2018

utACK bd3b036

@MarcoFalke
Copy link
Member

@MarcoFalke MarcoFalke commented Dec 11, 2018

utACK bd3b036

@MarcoFalke MarcoFalke added this to the 0.18.0 milestone Dec 11, 2018
@meshcollider
Copy link
Member

@meshcollider meshcollider commented Dec 12, 2018

utACK bd3b036

@meshcollider meshcollider merged commit bd3b036 into bitcoin:master Dec 12, 2018
2 checks passed
meshcollider added a commit that referenced this issue Dec 12, 2018
…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;

Copy link
Contributor

@ryanofsky ryanofsky Dec 13, 2018

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.

Copy link
Member Author

@Empact Empact Dec 14, 2018

Ah, right, the code does contradict the comments on line 1634. Will open a PR.

Copy link
Member Author

@Empact Empact Dec 14, 2018

@Empact Empact deleted the scan-for-wallet-transactions-ret branch Dec 14, 2018
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Mar 26, 2020
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Mar 26, 2020
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Mar 26, 2020
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
ftrader added a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this issue Aug 17, 2020
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
ftrader pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this issue Aug 17, 2020
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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 5, 2021
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.