Skip to content
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/blockchain: Reset scantxoutset progress before inferring descriptors #19362

Merged
merged 1 commit into from Jun 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rpc/blockchain.cpp
Expand Up @@ -2021,13 +2021,15 @@ class CoinsViewScanReserver
if (g_scan_in_progress.exchange(true)) {
return false;
}
CHECK_NONFATAL(g_scan_progress == 0);
Copy link
Member

Choose a reason for hiding this comment

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

If this were to fail, wouldn't it likely block all future reserves?

Copy link
Member

Choose a reason for hiding this comment

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

You mean this should be fatal?

Copy link
Member

Choose a reason for hiding this comment

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

Since it should be impossible, maybe simplest solution is to just remove it.

Otherwise, it might need something like:

Suggested change
CHECK_NONFATAL(g_scan_progress == 0);
if (g_scan_progress) {
error("ERROR: g_scan_progress was %s when it should be 0, in %s", g_scan_progress, __func__);
g_scan_progress = 0;
}

Or:

Suggested change
CHECK_NONFATAL(g_scan_progress == 0);
if (g_scan_progress) {
g_scan_in_progress = false;
CHECK_NONFATAL(g_scan_progress == 0);
}

Copy link
Member

Choose a reason for hiding this comment

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

Then this should be assert(g_scan_progress == 0). I don't think all RPC code should use CHECK_NONFATAL, at least #17192 doesn't say it.

Copy link
Member

Choose a reason for hiding this comment

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

You can restart your node if this fails, but I don't think there is a need to crash the node.

m_could_reserve = true;
return true;
}

~CoinsViewScanReserver() {
if (m_could_reserve) {
g_scan_in_progress = false;
g_scan_progress = 0;
}
}
};
Expand Down Expand Up @@ -2140,7 +2142,6 @@ UniValue scantxoutset(const JSONRPCRequest& request)
std::vector<CTxOut> input_txos;
std::map<COutPoint, Coin> coins;
g_should_abort_scan = false;
g_scan_progress = 0;
int64_t count = 0;
std::unique_ptr<CCoinsViewCursor> pcursor;
CBlockIndex* tip;
Expand Down