getblockchaininfo
never reaches 1.0 as reported in issue #31127.
This PR is based on the reviews given on #31135.
Some calls to the function GuessVerificationProgress
remain unchanged pending comments on this proposal.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31177.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
Concept ACK | jonatack |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, 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.
🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/32216509210
Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Concept ACK, some ideas to encourage review:
GuessVerificationProgress
. This makes it easier for reviewers to build and test your code and see if any test coverage needs to be updated or possibly added. Some reviewers may also wait until your pull has a green CI as enough proof of work before reviewing it more closely.rpc, logging:
This article might be helpful.
best_header
.
5586 } else {
5587- fTxTotal = pindex->m_chain_tx_count + (nNow - pindex->GetBlockTime()) * data.dTxRate;
5588+ fTxTotal = pindex->m_chain_tx_count + (end_of_chain_timestamp - pindex->GetBlockTime()) * data.dTxRate;
5589 }
5590-
5591- return std::min<double>(pindex->m_chain_tx_count / fTxTotal, 1.0);
You are right. If data.nTime
is bigger than end_of_chain_timestamp
we could go into the case where fTxTotal
is smaller than pindex->m_chain_tx_count
.
Maybe @sipa can explain why thinks that after the changes this clamp could be removed? As mentioned in #31135 (comment).
For the moment, I will add it again. Thanks for the observation!
5567@@ -5568,17 +5568,23 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pin
5568 return 0.0;
5569 }
5570
5571- int64_t nNow = time(nullptr);
5572+ int64_t end_of_chain_timestamp = pindex->GetBlockTime();
hindex
every time. If hindex
is supposed to be different for different calls, it would be good to explain why.
Hi, I’m not sure if I understood you correctly, but I guess you say it because it’s possible to call the function with hindex = nullptr
.
To solve that I propose this changes:
0double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex, const CBlockIndex* hindex) {
1 if (pindex == nullptr || hindex == nullptr)
2 return 0.0;
3...
4 int64_t end_of_chain_timestamp;
5
6 if (hindex->nChainWork > pindex->nChainWork) {
7 int64_t header_age = time(nullptr) - hindex->GetBlockTime();
8 end_of_chain_timestamp = header_age < 24 * 60 * 60 ? std::max(pindex->GetBlockTime(), hindex->GetBlockTime()) : pindex->GetBlockTime();
9 } else {
10 end_of_chain_timestamp = pindex -> GetBlockTime();
11 }
12...
Please let me know your thoughts
Hi, I’m not sure if I understood you correctly, but I guess you say it because it’s possible to call the function with
hindex = nullptr
.
I am asking why it needs to be passed at all. Shouldn’t it be the same for all callers?
chainman
and keep the actual structure. Do you think is more reasonable move it inside?
🐙 This pull request conflicts with the target branch and needs rebase.