Skip to content

Conversation

@jonatack
Copy link
Member

in getblockchaininfo/-getinfo and getchainstates, as requested in issues #31127 and #26433. Verification progress estimates in the debug logging remain unchanged.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 22, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

when the block height equals the headers height
@jonatack jonatack marked this pull request as draft October 22, 2024 17:30
when the block height equals the headers height, and update the
verificationprogress help to that of getblockchaininfo.
@jonatack jonatack force-pushed the 2024-10-verification-progress branch from f6472d6 to b27e20d Compare October 22, 2024 19:43
@jonatack jonatack marked this pull request as ready for review October 22, 2024 20:26
data.pushKV("bestblockhash", tip->GetBlockHash().GetHex());
data.pushKV("difficulty", GetDifficulty(*tip));
data.pushKV("verificationprogress", GuessVerificationProgress(Params().TxData(), tip));
data.pushKV("verificationprogress", height == headers ? 1 : GuessVerificationProgress(Params().TxData(), tip));
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to pass chainman.m_best_header->nTime to GuessVerificationProgress() (which then uses that instead of the current time)? That would make the result always consistently report progress w.r.t. the headers tip, instead of w.r.t. the current time.

@laanwj
Copy link
Member

laanwj commented Oct 23, 2024

i think doing this is fine, it's reported often enough--however, wouldn't it make sense to implement the functionality in GuessVerificationProgress itself so that other places (like the GUI and logging) consistently show the same value?

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Not sure about the current fix. It seems to "fix" one style issue in a value that is meant as an estimate, but it may be adding two new issues at the same time?

data.pushKV("bestblockhash", tip->GetBlockHash().GetHex());
data.pushKV("difficulty", GetDifficulty(*tip));
data.pushKV("verificationprogress", GuessVerificationProgress(Params().TxData(), tip));
data.pushKV("verificationprogress", height == headers ? 1 : GuessVerificationProgress(Params().TxData(), tip));
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this. Hard-coding the value to 1 when height == headers means that the value may inconsistently jump from 1 to 0.xxxx (in a loop), when headers pre-sync is disabled and the node is fed blocks one-by-one (header before block).

Also, if the node is eclipsed (intentionally, or just accidentally due to a network config error), this may also return 1, when the node is far behind the real network.

Copy link
Member

Choose a reason for hiding this comment

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

it should probably only do the "round last bit" thing when it's actually within some small delta of 1, not like from 0.5 to 1

@sipa
Copy link
Member

sipa commented Oct 23, 2024

So overall, this is effectively changing from estimating progress based on time, to estimating progress based on comparing with the best headers chain. I think that's a reasonable thing to do, but I would suggest doing it more completely and cleanly, and add some safeguards.

  • Guess an "end of chain timestamp" as the maximum of:
    • The timestamp of the active chain tip
    • The best headers tip's timestamp if it has more work than minchainwork; the current timestamp otherwise. There could also be a condition that the headers tip timestamp must not be more than 1 day old or so.
  • Use that timestamp in the progress estimation formula in GuessVerificationProgress (instead of nNow).
  • Do as much of that as possible inside GuessVerificationProgress (could pass it pointers to both active tip and headers tip), so that whatever we believe is the best way of estimating progress gets used everywhere.

I believe this avoids the need for any special casing for "1" (and can even get rid of the std::min inside GuessVerificationProgress to clamp at 1.0.

@maflcko I think this would address the problems you point out?

@jonatack
Copy link
Member Author

jonatack commented Oct 24, 2024

I agree with the approaches suggested by @sipa and @laanwj above and will be happy to review them. However, I am not confident of garnering sufficient ACKs if I implement those approaches here myself, so leaving it up for grabs.

@edilmedeiros
Copy link
Contributor

Maybe #31127 might be marked as Good First Issue?

@laanwj
Copy link
Member

laanwj commented Oct 25, 2024

maybe... im not sure it's a super good first issue, implementing it properly isn't super complicated but does require some knowledge of how various parts work and interact

@polespinasa
Copy link
Member

Hi, I tried to go with a proposal on this based on the comments given here #31177

@bitcoin bitcoin locked and limited conversation to collaborators Oct 29, 2025
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.

8 participants