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

[wallet] Rescan abortability #10208

Merged
merged 2 commits into from Apr 18, 2017

Conversation

Projects
None yet
10 participants
@kallewoof
Member

kallewoof commented Apr 14, 2017

The wallet importprivkey command triggers a rescan of the entire block chain unless explicitly asked not to. This oftentimes is not intentional, and there has so far not existed a way to abort a rescan in progress.

This PR adds support for a new RPC command abortrescan which will prompt ScanForWalletTransactions to stop scanning.

Show outdated Hide outdated src/wallet/rpcdump.cpp Outdated
@@ -1558,7 +1560,12 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
}
}
if (pindex && fAbortRescan) {

This comment has been minimized.

@NicolasDorier

NicolasDorier Apr 14, 2017

Member

need to set fAbortRescan to false again.

EDIT: Actually it should be fine... I think it is best that the end state of the variable is known though.

@NicolasDorier

NicolasDorier Apr 14, 2017

Member

need to set fAbortRescan to false again.

EDIT: Actually it should be fine... I think it is best that the end state of the variable is known though.

This comment has been minimized.

@kallewoof

kallewoof Apr 14, 2017

Member

It's set at line 1530 above. I was thinking of setting it to false at end but it doesn't really matter as it's reset at top anyway.

@kallewoof

kallewoof Apr 14, 2017

Member

It's set at line 1530 above. I was thinking of setting it to false at end but it doesn't really matter as it's reset at top anyway.

Show outdated Hide outdated src/wallet/rpcdump.cpp Outdated
if (request.fHelp || request.params.size() > 0)
throw std::runtime_error(
"abortrescan\n"
"\nStops current wallet rescan triggered e.g. by an importprivkey call.\n"

This comment has been minimized.

@jonasschnelli

jonasschnelli Apr 14, 2017

Member

nit: Usually we have the HelpExampleCli and HelpExampleRpc here.

@jonasschnelli

jonasschnelli Apr 14, 2017

Member

nit: Usually we have the HelpExampleCli and HelpExampleRpc here.

This comment has been minimized.

@kallewoof

kallewoof Apr 14, 2017

Member

@jonasschnelli I wasn't sure that was the case even for no-arg commands. Will add.

@kallewoof

kallewoof Apr 14, 2017

Member

@jonasschnelli I wasn't sure that was the case even for no-arg commands. Will add.

This comment has been minimized.

@kallewoof

kallewoof Apr 14, 2017

Member

Added.

@kallewoof

kallewoof Apr 14, 2017

Member

Added.

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Apr 14, 2017

Member

Nice. Concept ACK.
Have you tested this together with the GUI? Are you willing to expand this to the GUI?

Member

jonasschnelli commented Apr 14, 2017

Nice. Concept ACK.
Have you tested this together with the GUI? Are you willing to expand this to the GUI?

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Apr 14, 2017

Member

Accidentally closed. Reopening.

Member

jonasschnelli commented Apr 14, 2017

Accidentally closed. Reopening.

@jonasschnelli jonasschnelli reopened this Apr 14, 2017

@kallewoof

This comment has been minimized.

Show comment
Hide comment
@kallewoof

kallewoof Apr 14, 2017

Member

@jonasschnelli I haven't tried with the GUI. Definitely willing to add that, but wonder if that should be a separate PR?

Member

kallewoof commented Apr 14, 2017

@jonasschnelli I haven't tried with the GUI. Definitely willing to add that, but wonder if that should be a separate PR?

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Apr 14, 2017

Member

Can be separate if this PR does not break the GUI rescan additions (the popup window).

Member

jonasschnelli commented Apr 14, 2017

Can be separate if this PR does not break the GUI rescan additions (the popup window).

@kallewoof

This comment has been minimized.

Show comment
Hide comment
@kallewoof

kallewoof Apr 14, 2017

Member

Gotcha. I will test the GUI. If it doesn't seem overly complex I'll add support there as well while at it.

Member

kallewoof commented Apr 14, 2017

Gotcha. I will test the GUI. If it doesn't seem overly complex I'll add support there as well while at it.

@kallewoof

This comment has been minimized.

Show comment
Hide comment
@kallewoof

kallewoof Apr 14, 2017

Member

@jonasschnelli I tested out the GUI. The only way I could find importing keys was the Help > Debug > Console > importprivkey ... route. It brings up the "Rescanning..." popup with the progress bar, and locks input so I can't abort the rescan to test that part. But the actual GUI works fine.

Adding an "Abort" button to the progress popup seems sensible, but I'm going to declare that as a separate PR for now as I don't immediately see a neat solution to doing so.

Member

kallewoof commented Apr 14, 2017

@jonasschnelli I tested out the GUI. The only way I could find importing keys was the Help > Debug > Console > importprivkey ... route. It brings up the "Rescanning..." popup with the progress bar, and locks input so I can't abort the rescan to test that part. But the actual GUI works fine.

Adding an "Abort" button to the progress popup seems sensible, but I'm going to declare that as a separate PR for now as I don't immediately see a neat solution to doing so.

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Apr 14, 2017

Member

@kallewoof You can run bitcoin-qt with the -server flag, and then issue command through bitcoin-cli or any other RPC client.

Member

sipa commented Apr 14, 2017

@kallewoof You can run bitcoin-qt with the -server flag, and then issue command through bitcoin-cli or any other RPC client.

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Apr 14, 2017

Member

@kallewoof: Great. Yes. Let's fix this in an upcoming PR. I think you can also rescan by ./bitcoin-qt -server or ./bitcoin-qt -rescan.

Member

jonasschnelli commented Apr 14, 2017

@kallewoof: Great. Yes. Let's fix this in an upcoming PR. I think you can also rescan by ./bitcoin-qt -server or ./bitcoin-qt -rescan.

@kallewoof

This comment has been minimized.

Show comment
Hide comment
@kallewoof

kallewoof Apr 14, 2017

Member

@sipa Ahh that let me try abortrescan from CLI while doing import from the GUI. Thanks!

@jonasschnelli GUI fully tested and appears functional.

Member

kallewoof commented Apr 14, 2017

@sipa Ahh that let me try abortrescan from CLI while doing import from the GUI. Thanks!

@jonasschnelli GUI fully tested and appears functional.

@NicolasDorier

This comment has been minimized.

Show comment
Hide comment
@NicolasDorier
Member

NicolasDorier commented Apr 14, 2017

utACK 33b93f5

@rawodb

rawodb approved these changes Apr 14, 2017

@KibbledJiveElkZoo

This comment has been minimized.

Show comment
Hide comment
@KibbledJiveElkZoo

KibbledJiveElkZoo Apr 14, 2017

Contributor

"Wallet is being asked to abort rescan despite already pending rescan abort"

I would change "abort" to "abortion"; I believe it may be more grammatically correct, and we need the word abortion in the core code.

Contributor

KibbledJiveElkZoo commented Apr 14, 2017

"Wallet is being asked to abort rescan despite already pending rescan abort"

I would change "abort" to "abortion"; I believe it may be more grammatically correct, and we need the word abortion in the core code.

Show outdated Hide outdated src/wallet/wallet.h Outdated
@gmaxwell

I wish we didn't need this, but we do. Concept ACK.

@rawodb

This comment has been minimized.

Show comment
Hide comment
@rawodb

rawodb commented Apr 17, 2017

ACK

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Apr 17, 2017

Member

nice! utACK after squash

Member

laanwj commented Apr 17, 2017

nice! utACK after squash

@kallewoof

This comment has been minimized.

Show comment
Hide comment
@kallewoof

kallewoof Apr 17, 2017

Member

Squashed. ~~~Edit: Crap. Fixing...~~~

Member

kallewoof commented Apr 17, 2017

Squashed. ~~~Edit: Crap. Fixing...~~~

@TheBlueMatt

One comment, utACK otherwise.

Show outdated Hide outdated src/wallet/rpcdump.cpp Outdated
@kallewoof

This comment has been minimized.

Show comment
Hide comment
@kallewoof

kallewoof Apr 18, 2017

Member

Per #10208 (comment) I have replaced the RPC throws with true/false for "did something" / "did nothing" return values in abortrescan.

Unsquashed history: 123∈2

Member

kallewoof commented Apr 18, 2017

Per #10208 (comment) I have replaced the RPC throws with true/false for "did something" / "did nothing" return values in abortrescan.

Unsquashed history: 123∈2

@laanwj laanwj merged commit 9141622 into bitcoin:master Apr 18, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Apr 18, 2017

Merge #10208: [wallet] Rescan abortability
9141622 [rpc] Add abortrescan command to RPC interface. (Kalle Alm)
75a08e7 [wallet] Add support for aborting wallet transaction rescans. (Kalle Alm)

Tree-SHA512: 18545a1dc48c6dc112993f971f3adc7c0341fa621186c6d70bef1052e1d127ca116c5769595d721a209d502ca2019f2ad33876fe35d2b17216393404607a6c76
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Apr 18, 2017

Member

This still needs (in follow-up PR):

  • a test in test/functional
  • mention in the release notes
Member

laanwj commented Apr 18, 2017

This still needs (in follow-up PR):

  • a test in test/functional
  • mention in the release notes

@laanwj laanwj referenced this pull request Apr 18, 2017

Closed

TODO for release notes 0.15.0 #9889

12 of 12 tasks complete

@kallewoof kallewoof deleted the kallewoof:rescan-abortability branch Apr 18, 2017

@TheBlueMatt

This comment has been minimized.

Show comment
Hide comment
@TheBlueMatt

TheBlueMatt Apr 18, 2017

Contributor

postumous utACK

Contributor

TheBlueMatt commented Apr 18, 2017

postumous utACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment