-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
rpc: Enable wallet import on pruned nodes #16037
Conversation
The block lookup should be using findFirstBlockWithTime (see RescanFromTime) and allow some slop, because miners could have wrong clocks and users could have wrong clocks, TIMESTAMP_WINDOW, (again see RescanFromTime). This is particularly important for birthdays because installing the software and instantly generating a key, handing it out, and getting paid is a perfectly sensible sequence of events. Otherwise-- Concept ACK on doing this! |
I think the best place to test this is in |
Jup. And ideally feature_pruning should run with and without the wallet compiled in, so you can either guard it in feature_pruning behind the test framework check for the wallet or add a new test |
90101d2
to
1b35d83
Compare
1b35d83
to
4a2285f
Compare
Updated to include the same check in |
How does that change the error message? Also, the import will happen before the check in importmuli, whereas in importwallet it will happen after. |
4a2285f
to
9066b21
Compare
Now also checking before importing on |
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.
utACK 9066b21
Good stuff
Thanks for the review. I'm going to test these changes and add a release note. I'm leaning towards a new test file like you suggested. BTW is there's a way to change the .blk maximum size? |
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. |
9066b21
to
6cd0add
Compare
Concept ACK. Travis unhappy. Suggest renaming the PR to "[rpc] enable wallet import on pruned nodes" |
6cd0add
to
cffd615
Compare
@Sjors happy travis, and reworded like you suggested, thanks. |
static void EnsureBlockDataFromTime(interfaces::Chain::Lock& locked_chain, int64_t timestamp) | ||
{ | ||
const Optional<int> height = locked_chain.findFirstBlockWithTimeAndHeight(timestamp - TIMESTAMP_WINDOW, 0, nullptr); | ||
if (height && !locked_chain.haveBlockOnDisk(*height)) { |
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.
Shouldn't we fail if any blocks after this one are pruned too?
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.
Is that possible? I mean, if block X is available then X+1 is also available?
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.
Blocks are pruned as entire files, so it's possible block X is in the same file as block X+2, and we don't want to prune block X+2, but we do want to prune block X+1. This can result in block X+1 being pruned before block X.
scripts.push_back(std::pair<CScript, int64_t>(script, birth_time)); | ||
} | ||
} | ||
file.close(); | ||
if (pwallet->chain().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.
Should just check this inside EnsureBlockDataFromTime
Needs rebase |
@@ -101,6 +101,14 @@ static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver, | |||
} | |||
} | |||
|
|||
static void EnsureBlockDataFromTime(interfaces::Chain::Lock& locked_chain, int64_t timestamp) | |||
{ | |||
const Optional<int> height = locked_chain.findFirstBlockWithTimeAndHeight(timestamp - TIMESTAMP_WINDOW, 0, nullptr); |
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.
Please use std::optional
in new code.
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
1 similar comment
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
Marked "up for grabs" |
Closing given #24865 is open. |
564b580 test: Introduce MIN_BLOCKS_TO_KEEP constant (Aurèle Oulès) 71d9a7c test: Wallet imports on pruned nodes (Aurèle Oulès) e6906fc rpc: Enable wallet import on pruned nodes (Aurèle Oulès) Pull request description: Reopens #16037 I have rebased the PR, addressed the comments of the original PR and added a functional test. > Before this change importwallet fails if any block is pruned. This PR makes it possible to importwallet if all required blocks aren't pruned. This is possible because the dump format includes key timestamps. For reviewers: `python test/functional/wallet_pruning.py --nocleanup` will generate a large blockchain (~700MB) that can be used to manually test wallet imports on a pruned node. Node0 is not pruned, while node1 is. ACKs for top commit: kouloumos: ACK 564b580 achow101: reACK 564b580 furszy: ACK 564b580 w0xlt: ACK 564b580 Tree-SHA512: b345a6c455fcb6581cdaa5f7a55d79e763a55cb08c81d66be5b12794985d79cd51b9b39bdcd0f7ba0a2a2643e9b2ddc49310ff03d16b430df2f74e990800eabf
Before this change
importwallet
fails if any block is pruned. This PR makes it possible toimportwallet
if all required blocks aren't pruned. This is possible because the dump format includes key timestamps.