Skip to content

Conversation

Empact
Copy link
Contributor

@Empact Empact commented Apr 25, 2018

Return the failed block as an out arg.

Fixes #11450.

/cc #12275

@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 25a588a to 821c955 Compare April 25, 2018 21:08
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 821c955 to 7b760bc Compare April 25, 2018 23:45
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from 7b760bc to 2c4bc00 Compare April 26, 2018 00:01
@@ -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

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).

Copy link
Contributor Author

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?

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch 2 times, most recently from 3cdfcc3 to 620581f Compare April 29, 2018 16:15
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
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 Compare April 30, 2018 06:44
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch from a4f3cb2 to 8bf206b Compare April 30, 2018 14:49
@Empact
Copy link
Contributor Author

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 Compare May 3, 2018 17:27
@Empact
Copy link
Contributor Author

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 Compare May 18, 2018 20:38
@Empact Empact force-pushed the scan-for-wallet-transactions-ret branch 3 times, most recently from 8d11f05 to 981adda Compare November 13, 2018 09:43
@Empact
Copy link
Contributor Author

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.

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 Compare November 13, 2018 17:51
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK bd3b036

@jonasschnelli
Copy link
Contributor

utACK bd3b036

@maflcko
Copy link
Member

maflcko commented Dec 11, 2018

utACK bd3b036

@maflcko maflcko added this to the 0.18.0 milestone Dec 11, 2018
@meshcollider
Copy link
Contributor

utACK bd3b036

@meshcollider meshcollider merged commit bd3b036 into bitcoin:master Dec 12, 2018
meshcollider added a commit that referenced this pull request 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

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.

Copy link
Contributor Author

@Empact Empact Dec 14, 2018

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Empact Empact deleted the scan-for-wallet-transactions-ret branch December 14, 2018 06:10
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request 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 pull request 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 pull request 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 pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this pull request 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 pull request 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 pushed a commit to Munkybooty/dash that referenced this pull request 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScanForWalletTransactions return value is incorrectly documented
10 participants