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

Conversation

prusnak
Copy link
Contributor

@prusnak prusnak commented Jun 23, 2020

Fixes #19361 by moving resetting the g_scan_progress variable before inferring the descriptors

Copy link
Member

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK 71fee9c.

There's still a slight chance of getting non zero progress. See b6b1945 for an alternative.

IMO could be backport.

@prusnak
Copy link
Contributor Author

prusnak commented Jun 27, 2020

At first sight, it seems that your patch b6b1945 makes more sense.

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

Still a race, but I don't see an easy fix and this is probably good enough

utACK

@luke-jr
Copy link
Member

luke-jr commented Jul 23, 2020

Oh, @promag's solution does look better though.

@prusnak prusnak force-pushed the rpc-scantxoutset-reset-progress branch from 71fee9c to 8c4129b Compare July 24, 2020 09:05
@prusnak
Copy link
Contributor Author

prusnak commented Jul 24, 2020

I replaced my commit with the change suggested @promag in 8c4129b

@promag
Copy link
Member

promag commented Jul 24, 2020

ACK

@@ -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.

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Aug 15, 2020
Diff-minimised

Github-Pull: bitcoin#19362
Rebased-From: 8c4129b
@prusnak
Copy link
Contributor Author

prusnak commented Nov 23, 2020

Can we decide what to do with this one?

Should we just drop the CHECK_NONFATAL(g_scan_progress == 0); line?

I really want this to get into 0.21 @luke-jr @promag

@promag
Copy link
Member

promag commented Nov 23, 2020

Should we just drop the CHECK_NONFATAL(g_scan_progress == 0); line?

@prusnak I tend to like these invariants, it makes easier to understand the code. I think @luke-jr concern could be addressed by:

const int scan_progress = g_scan_progress.exchange(0);
CHECK_NONFATAL(scan_progress == 0);

I think @jonasschnelli, @MarcoFalke, @laanwj should take a look too for 0.21.

@jonatack
Copy link
Contributor

jonatack commented Nov 24, 2020

Concept ACK. In the absence of test coverage, I agree this should check and fail somewhat loudly if g_scan_progress isn't 0 here.

@maflcko maflcko added this to the 0.21.0 milestone Nov 25, 2020
@achow101
Copy link
Member

achow101 commented Dec 9, 2020

Code review ACK 8c4129b

@maflcko maflcko modified the milestones: 0.21.0, 0.21.1 Dec 15, 2020
@laanwj laanwj modified the milestones: 0.21.1, 0.21.2 Apr 16, 2021
@laanwj
Copy link
Member

laanwj commented Apr 16, 2021

Sorry for bumping the milestone here again. It seems almost ready for merge (could use one more ACK) but we don't want to rush a backport into 0.21.1.

@laanwj laanwj modified the milestones: 0.21.2, 22.0 Jun 24, 2021
@laanwj
Copy link
Member

laanwj commented Jun 24, 2021

This came up in the IRC meeting. Adding this to the 22.0 milestone so it can hopefully be included there.

@maflcko maflcko merged commit 3e306ee into bitcoin:master Jun 25, 2021
@prusnak prusnak deleted the rpc-scantxoutset-reset-progress branch June 25, 2021 09:50
@bitcoin bitcoin locked and limited conversation to collaborators Jun 25, 2021
@bitcoin bitcoin deleted a comment Jun 25, 2021
@fanquake
Copy link
Member

Backported in #22580.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPC: scantxoutset progress reports 100% while deriving keys
8 participants