Skip to content

Conversation

@Empact
Copy link
Contributor

@Empact Empact commented Jul 13, 2018

Where the outcome does not depend on the result, apart from a simple
success check.

Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason why not just leave this here? It could very well be used by the gui or some other interface to the wallet in the future and had to be moved back. Generally, I'd prefer if code was only moved when necessary, since unnecessary code movement/refactoring makes backports easier to mess up and consumes scarce review resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This move reduces the surface area of CWallet, which is pretty sprawling at the moment (wallet.cpp is ~4500 lines, the 3rd-largest *.cpp file, and the largest outside /qt/), and localizes this code to one implementation file from being more broadly available (wallet.h is included into 26 files).

Grant the concerns you note are serious, and we should draw the line somewhere, but if the codebase is to be in play for a long time, it needs to evolve and progress. Moving incrementally toward minimizing scope of code, dependencies, etc. is attractive from that perspective as it should have payoffs in reducing the overall complexity of the codebase, which should ease changes on an ongoing and cumulative basis.

Other approaches to making better use of scarce review resources come to mind:

  • I've thought of implementing a web site to helps rank PRs by ACKs and other indications of importance. Current solutions like: https://github.com/bitcoin/bitcoin/projects/8 are pretty limited and not decentralized and ACKs are not currently well-exposed across PRs in aggregate.
  • We could add a feature to output the changes between force pushes to the same PR, so that reviewers could review just the incremental subset, and the historical changes are recorded.
  • We could potentially examine and report changes to the build output to give reviewers a sense of the consequence to the output to the binaries.

Seems like these are the sorts of things that will help the project to scale and accelerate.

Copy link
Member

Choose a reason for hiding this comment

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

I've thought of implementing a web site to helps rank PRs by ACKs and other indications of importance. Current solutions like: https://github.com/bitcoin/bitcoin/projects/8 are pretty limited and not decentralized and ACKs are not currently well-exposed across PRs in aggregate.

Are you aware of https://bitcoinacks.com/?desc=1&flt3_label_not_contains=Needs+rebase&flt0_merged_empty=1&flt4_ci_contains=Success&flt1_closed_empty=1&sort=7&flt2_mergeable_contains=Mergeable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, hadn't see that. 👍

@Empact Empact force-pushed the rescan-from-time branch from 110d5e7 to c180c06 Compare July 13, 2018 18:11
@Empact
Copy link
Contributor Author

Empact commented Jul 13, 2018

This refactor raises the following questions:

  • Why does rpc importmulti call pwallet->ReacceptWalletTransactions before aborting on pwallet->IsAbortingRescan(). Should it flip that ordering like the others do?
  • Why do 3 of the 5 calls call pwallet->ReacceptWalletTransactions, while rpc importwallet calls pwallet->MarkDirty() and rpc importprivkey calls neither? This seems like a possible bug in rpc importprivkey.

@Empact Empact force-pushed the rescan-from-time branch 4 times, most recently from c764dd6 to 65c06a3 Compare July 13, 2018 18:59
@Empact
Copy link
Contributor Author

Empact commented Jul 13, 2018

Updated to minimize git diff --color-moved=dimmed_zebra --minimal head^^

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 13, 2018

Note to reviewers: 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.

@sipa
Copy link
Member

sipa commented Jul 14, 2018

I don't like this. Code that interacts with the wallet should be in the wallet, not in the RPC code. I'm aware that there is an enormous amount of internal logic already in the RPC code, but we should be moving stuff in the other direction.

@maflcko
Copy link
Member

maflcko commented Jul 14, 2018

utACK second commit, if the first one is dropped.

Where the outcome does not depend on the result, apart from a simple
success check.
@Empact Empact force-pushed the rescan-from-time branch from 65c06a3 to 348dd37 Compare July 14, 2018 17:06
@Empact
Copy link
Contributor Author

Empact commented Jul 14, 2018

Dropped the first commit, and added handling of the ShutdownRequested rescan abort condition:

bitcoin/src/wallet/wallet.cpp

Lines 1759 to 1763 in b25a4c2

if (pindex && fAbortRescan) {
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, progress_current);
} else if (pindex && ShutdownRequested()) {
LogPrintf("Rescan interrupted by shutdown request at block %d. Progress=%f\n", pindex->nHeight, progress_current);
}

@Empact Empact changed the title [wallet] [moveonly] Move rescanning from time logic into wallet/rpcdump.cpp rpc: Report when rescan aborts due to ShutdownRequested Jul 14, 2018
@Empact Empact force-pushed the rescan-from-time branch from 348dd37 to f3f1d1c Compare July 14, 2018 17:27
@Empact
Copy link
Contributor Author

Empact commented Jul 14, 2018

Added full handing of rescan failure conditions to CWallet::CreateWalletFromFile

@promag
Copy link
Contributor

promag commented Jul 14, 2018

Kind of NACK the current approach. If you want to touch this consider improving CWallet::ScanForWalletTransactions signature, like:

enum WalletScanError
{
    NONE = 0, // when ScanForWalletTransactions return is true
    ABORTED,
    SHUTDOWN_REQUEST,
};
struct WalletScanResult {
    WalletScanError error;
    std::string message;
    // other outputs
};
bool CWallet::ScanForWalletTransactions(WalletScanResult& result, ...);

This way the callers don't have to check what caused the error.

Edit: I like the RescanWallet abstraction in rpcdump.cpp

@Empact
Copy link
Contributor Author

Empact commented Jul 14, 2018

@promag I did something like that here #13076, and while I think the result is ok, I've been thinking more of updating it to return bool as prompted by jimpo in #13582:
#13582 (comment)

Have that follow-up in mind.

@Empact
Copy link
Contributor Author

Empact commented Jul 14, 2018

I'll split these up for separate consideration.

@Empact Empact force-pushed the rescan-from-time branch from f3f1d1c to 3fe836b Compare July 14, 2018 20:48
@Empact Empact changed the title rpc: Report when rescan aborts due to ShutdownRequested Extract RescanWallet to handle a simple rescan Jul 14, 2018
@promag
Copy link
Contributor

promag commented Jul 14, 2018

@Empact my suggestion is in line with @jimpo suggestion.

@promag
Copy link
Contributor

promag commented Jul 17, 2018

utACK 3fe836b.

Side note, not sure if this should be tagged moveonly.

@maflcko
Copy link
Member

maflcko commented Jul 17, 2018

utACK 3fe836b

@Empact Empact changed the title Extract RescanWallet to handle a simple rescan [moveonly] Extract RescanWallet to handle a simple rescan Jul 17, 2018
static const bool DEFAULT_WALLETBROADCAST = true;
static const bool DEFAULT_DISABLE_WALLET = false;

static const int64_t TIMESTAMP_MIN = 0;
Copy link
Member

Choose a reason for hiding this comment

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

good to move this locally, it's a really aspecific constant name

@laanwj laanwj merged commit 3fe836b into bitcoin:master Jul 25, 2018
laanwj added a commit that referenced this pull request Jul 25, 2018
3fe836b [moveonly] Extract RescanWallet to handle a simple rescan (Ben Woosley)

Pull request description:

  Where the outcome does not depend on the result, apart from a simple
  success check.

Tree-SHA512: e0d29c6fc0c7f99a730289e5a80deb586b2848aead56b5198a71ef01f65374812468dfd57be0b8b076eb9be4090d5101d28d979a1d5c3d2f1caeca77b303e90e
@Empact Empact deleted the rescan-from-time branch July 25, 2018 14:41
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 13, 2019
Summary:
3fe836b [moveonly] Extract RescanWallet to handle a simple rescan (Ben Woosley)

Pull request description:

  Where the outcome does not depend on the result, apart from a simple
  success check.

Tree-SHA512: e0d29c6fc0c7f99a730289e5a80deb586b2848aead56b5198a71ef01f65374812468dfd57be0b8b076eb9be4090d5101d28d979a1d5c3d2f1caeca77b303e90e

Backport of Core PR12658
bitcoin/bitcoin#13658

Test Plan:
  make check
  ./bitcoin-qt -> help -> debug -> console -> rescanblockchain
  ./bitcoind
  ./bitcoin-cli rescanblockchain

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4020
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 1, 2021
…le rescan

3fe836b [moveonly] Extract RescanWallet to handle a simple rescan (Ben Woosley)

Pull request description:

  Where the outcome does not depend on the result, apart from a simple
  success check.

Tree-SHA512: e0d29c6fc0c7f99a730289e5a80deb586b2848aead56b5198a71ef01f65374812468dfd57be0b8b076eb9be4090d5101d28d979a1d5c3d2f1caeca77b303e90e
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 2, 2021
…le rescan

3fe836b [moveonly] Extract RescanWallet to handle a simple rescan (Ben Woosley)

Pull request description:

  Where the outcome does not depend on the result, apart from a simple
  success check.

Tree-SHA512: e0d29c6fc0c7f99a730289e5a80deb586b2848aead56b5198a71ef01f65374812468dfd57be0b8b076eb9be4090d5101d28d979a1d5c3d2f1caeca77b303e90e
@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.

7 participants