-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: Save wallet scan progress #25036
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
Conversation
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 had thought about this too a bit:
ScanForWalletTransactions() can also be invoked from rescanblockchain RPC with a start_height and stop_height - I think we wouldn't want to save the progress in this case, e.g. if a user chooses to run rescanblockchain for some historic range, the best block should stay at the tip. So maybe only save progress if the function is invoked from AttachChain() ?
5d84920 to
170fb4c
Compare
|
@mzumsande #25036 (review) addressed in 170fb4c |
|
37f192b addresses #25036 (comment) and #25036 (comment). . |
|
Rebased. |
furszy
left a 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.
Concept ACK, code reviewed 6b879a1.
I think that we could simplify it a bit more in this way: furszy@e48ec2e (squash it directly if you like it, no need to add any co-authorship nor mention).
Side from that, might worth to think on ways to test this new functionality.
A quick idea could be make INTERVAL_TIME customizable and set it to 0, mock the wallet database and check how many times a BESTBLOCK key is written during the scan process. Then compare the obtained value with the number of blocks in the test chain.
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, agree with @furszy that test coverage would be good.
src/node/interfaces.cpp
Outdated
| const CChain& active = Assert(m_node.chainman)->ActiveChain(); | ||
| return active.GetLocator(); | ||
| } | ||
| std::optional<CBlockLocator> getLocator(const uint256& block_hash) override |
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 this child implementation member can be private. See #24150 for rationale.
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 didn't quite understand the suggestion. If this method is changed to private, the wallet will not be able to access it.
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.
re: #25036 (comment)
I didn't quite understand the suggestion. If this method is changed to private, the wallet will not be able to access it.
I'm neutral on the suggestion (don't see concrete benefits), but the wallet can still call the method even if it is private because it's virtual and the overridden method is public.
If you want to take implement suggestion of making it private, for the sake of consistency I would suggest making all the methods private not this just one method.
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.
for the sake of consistency I would suggest making all the methods private
So I think it would be better to do this in a follow-up PR since it involves other unrelated methods.
514d17d to
2475146
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
|
cool @w0xlt. It wasn't needed but appreciated 👍🏼 . yeah, an unit test so the wallet db can be mocked and write calls intercepted. It should be simpler to implement than a functional test. We could chat tomorrow via IRC if you want as well. |
ryanofsky
left a 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.
src/node/interfaces.cpp
Outdated
| const CChain& active = Assert(m_node.chainman)->ActiveChain(); | ||
| return active.GetLocator(); | ||
| } | ||
| std::optional<CBlockLocator> getLocator(const uint256& block_hash) override |
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.
re: #25036 (comment)
I didn't quite understand the suggestion. If this method is changed to private, the wallet will not be able to access it.
I'm neutral on the suggestion (don't see concrete benefits), but the wallet can still call the method even if it is private because it's virtual and the overridden method is public.
If you want to take implement suggestion of making it private, for the sake of consistency I would suggest making all the methods private not this just one method.
2475146 to
18926f9
Compare
|
@ryanofsky Thanks for suggestions. I initially pushed a test that changed the time interval to 0s (as suggested by @furszy) but I think adding to |
ryanofsky
left a 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.
Code review ACK 089f3ccc8769c1d1d096f5c45f4a29e5cce85557, but the first commit doesn't compile and it would be good to fix that. Only suggested changes since last review
ryanofsky
left a 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.
Code review ACK 0ef383dd058a783bf0912c8562597823e2dbb29b. Only changes since last review: cleaning up the wonky Assert() and moving a change to the second commit so the first commit compiles
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 review ACK 0ef383dd
Verified that the added test saves the progress for the two scanned blocks (100 and 101).
Left two non-blocking nits.
Currently, the wallet scan progress is not saved. If it is interrupted, it will be necessary to start from scratch on the next load. With this change, progress is saved every 60 seconds. Co-authored-by: furszy <matiasfurszyfer@protonmail.com> Co-authored-by: Jon Atack <jon@atack.com> Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
0ef383d to
230a2f4
Compare
furszy
left a 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.
re-ACK 230a2f4
Only changes were the missing space and logging.
achow101
left a 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.
ACK 230a2f4
| bool haveBlockOnDisk(int height) override | ||
| { | ||
| LOCK(cs_main); | ||
| LOCK(::cs_main); |
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.
In a89ddfb "wallet: Save wallet scan progress"
nit: Unrelated change. Also in getTipLocator, findLocatorFork, GuessVerificationProgress and havePruned.
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.
would second to not include these unnecessary changes, git blame depth
ryanofsky
left a 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.
Code review ACK 230a2f4. Only change since last review is tweaking whitespace and adding log print
230a2f4 wallet test: Add unit test for wallet scan save_progress option (Ryan Ofsky) a89ddfb wallet: Save wallet scan progress (w0xlt) Pull request description: Currently, the wallet scan progress is not saved. If it is interrupted, it will be necessary to start from scratch on the next load. This PR changes this and the progress is saved right after checking a block. Close bitcoin#25010 ACKs for top commit: furszy: re-ACK 230a2f4 achow101: ACK 230a2f4 ryanofsky: Code review ACK 230a2f4. Only change since last review is tweaking whitespace and adding log print Tree-SHA512: 1a9dec207ed22b3443fb06a4daf967637bc02bcaf71c070b7dc33605d0cab959551e4014c9e92293a63f54c5cbcc98bb9f8844a8c60bc32a1482b1c4130fab32
Currently, the wallet scan progress is not saved.
If it is interrupted, it will be necessary to start from scratch on the next load.
This PR changes this and the progress is saved right after checking a block.
Close #25010