-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Return errors from importmulti if complete rescans are not successful #9773
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
Concept ACK Don't forget that you may want to include the grace period in detecting whether it scanned enough. |
Concept ACK.
There's |
Concept ACK. Will test/review further. |
Please rebase on #9761 so we can verify the grace period works properly |
094699f
to
34e4209
Compare
Rebased |
src/wallet/wallet.cpp
Outdated
int posInBlock; | ||
for (posInBlock = 0; posInBlock < (int)block.vtx.size(); posInBlock++) | ||
{ | ||
if (AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate)) | ||
ret++; | ||
AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate); |
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 loop should also be skipped if ReadBlockFromDisk fails
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.
Skipped in d6f6a23
…cessful Skip empty loop if ReadBlockFromDisk fails as suggested bitcoin#9773 (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.
Add test for CWallet::ScanForWalletTransactions in e3d4f25
src/wallet/wallet.cpp
Outdated
int posInBlock; | ||
for (posInBlock = 0; posInBlock < (int)block.vtx.size(); posInBlock++) | ||
{ | ||
if (AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate)) | ||
ret++; | ||
AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate); |
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.
Skipped in d6f6a23
e3d4f25
to
455b8f7
Compare
src/wallet/rpcdump.cpp
Outdated
} else { | ||
UniValue result = UniValue(UniValue::VOBJ); | ||
result.pushKV("success", UniValue(false)); | ||
result.pushKV("error", JSONRPCError(RPC_MISC_ERROR, strprintf("Failed to rescan before time %" PRId64 ", transactions may be missing.", (long long)scannedRange->GetBlockTimeMax()))); |
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.
just curious: Is there an advantage using PRId64
over %ul
(rest of the code uses this)?
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.
Actually I need to change this to either remove PRId64 or the (long long) cast.
You're supposed to use PRId64 whenever you pass an int64_t type to printf. %ld or %lld aren't always correct because longs and long longs just have minimum widths in standard c++, not fixed widths that are the same on all systems.
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.
Removed cast in e49f039.
Previously squashed e3d4f25 -> 455b8f7 (multicheck.2 -> multicheck.3) |
…cessful Add missing response.setArray call and fix string formatting issue pointed out bitcoin#9773 (comment)
e64cdfb
to
b73252d
Compare
Added C++ test for new importmulti RPC code in e64cdfb Squashed e64cdfb -> b73252d (multicheck.4 -> multicheck.5) |
Note that our strprintf is a wrapper around tfm::format, and doesn't need type specs at all. |
lightly tested ACK b73252d |
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 b73252d
src/wallet/rpcdump.cpp
Outdated
} else { | ||
UniValue result = UniValue(UniValue::VOBJ); | ||
result.pushKV("success", UniValue(false)); | ||
result.pushKV("error", JSONRPCError(RPC_MISC_ERROR, strprintf("Failed to rescan before time %" PRId64 ", transactions may be missing.", scannedRange->GetBlockTimeMax()))); |
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 remove the PRI64d here. It gives problems with some platforms, and as @sipa says don't need 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.
Ok will change, but what are the problems with some platforms?
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.
Removed in aaaf65a.
Reason I am asking about the problem you're seeing is that not using PRI64d for int64_t would prevent us from using compile time format string checking (as suggested in #9423 (comment)) which would be much better than the runtime checking we currently use.
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.
Ok will change, but what are the problems with some platforms?
The conceptual problem is that PRI64d can evaluate to anything depending on the platform, e.g. "%ponyfood". tinyformat.h
cannot know about all these platform-dependent escape sequences, so might produce garbled output or even raise an exception. We had a lot of problems with this back in the day with windows and mingw. It is wrong to pass platform-specific stuff to a platform-independent library. Also PRI64d is C99, so not all C++ compilers are guaranteed to have it at all.
Offline checking could still work, the script would just need to be smart enough to cope with a) translations b) tinyformat's specifiers and type-safety. (b) is actually a subset, not a superset of what platform printfs support (none of the insecure ones like %n) so if anything that should make it easier.
b73252d
to
90671ee
Compare
Rebased b73252d -> 90671ee (multicheck.5 -> multicheck.6) |
…cessful Avoid PRId64 as requested bitcoin#9773 (comment)
aaaf65a
to
1425c72
Compare
Squashed aaaf65a -> 1425c72 (multicheck.7 -> multicheck.8) |
Somehow travis didn't like your commit.
…On Fri, Feb 17, 2017 at 1:25 PM, Russell Yanofsky ***@***.***> wrote:
Squashed aaaf65a
<aaaf65a>
-> 1425c72
<1425c72>
(multicheck.7
<https://github.com/ryanofsky/bitcoin/commits/pr/multicheck.7> ->
multicheck.8
<https://github.com/ryanofsky/bitcoin/commits/pr/multicheck.8>)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9773 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGGmvze2Mxoj5bq4mVJGQPY4YpClnvOlks5rdZGogaJpZM4MCUp0>
.
|
Appears to be a spurious error. The travis run for b72521dd7f570b0c557439d534f7523a5be52999 which is aaaf65a merged into 9828f9a succeeded: https://travis-ci.org/bitcoin/bitcoin/builds/202600321 Only the travis run for 64072b74ebbf7b5585b39f6c117c6ffa9dc820f0 which is 1425c72 merged into 9828f9a failed: https://travis-ci.org/bitcoin/bitcoin/builds/202600549 There are no differences between the two commits:
|
1425c72
to
68da3ee
Compare
Touched CommitDate to rerun travis 1425c72 -> e2e2f4c (multicheck.8 -> multicheck.12) |
68da3ee
to
99d032e
Compare
99d032e
to
e2e2f4c
Compare
Concept ACK |
…ot successful e2e2f4c Return errors from importmulti if complete rescans are not successful (Russell Yanofsky)
// Verify ScanForWalletTransactions picks up transactions in both the old | ||
// and new block files. | ||
{ | ||
CWallet wallet; |
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.
This brings a few Wshadow warnings:
Wshadow statistics:
1 wallet/test/wallet_tests.cpp:377:17: warning: declaration shadows a variable in namespace 'wallet_tests' [-Wshadow]
1 wallet/test/wallet_tests.cpp:391:17: warning: declaration shadows a variable in namespace 'wallet_tests' [-Wshadow]
1 wallet/test/wallet_tests.cpp:399:17: warning: declaration shadows a variable in namespace 'wallet_tests' [-Wshadow]
Warnings introduced by commit e2e2f4c "Return errors from importmulti if complete rescans are not successful" and reported by Pavel Janík <Pavel@Janik.cz> in bitcoin#9773 and bitcoin#9827 wallet/test/wallet_tests.cpp: In member function ‘void wallet_tests::rescan::test_method()’: wallet/test/wallet_tests.cpp:377:17: warning: declaration of ‘wallet’ shadows a global declaration [-Wshadow] CWallet wallet;
…s are not successful e2e2f4c Return errors from importmulti if complete rescans are not successful (Russell Yanofsky)
…s are not successful e2e2f4c Return errors from importmulti if complete rescans are not successful (Russell Yanofsky)
…s are not successful e2e2f4c Return errors from importmulti if complete rescans are not successful (Russell Yanofsky)
This is supposed to address the concern from @gmaxwell in #9761 that importmulti rescans on pruned nodes could unsuccessfully scan pruned blocks and fail to inform the user.
An alternative approach of just simply disabling importmulti rescans on pruned nodes was initially discussed in https://botbot.me/freenode/bitcoin-core-dev/msg/81023921/, but running being able to import keys and do partial rescans on pruned nodes was determined to be an important use-case.