Print "verifychain" progress every 1 step if user verifies whole blockchain. #19009

pull yakitorifoodie wants to merge 8 commits into bitcoin:master from yakitorifoodie:patch-3 changing 1 files +7 −6
  1. yakitorifoodie commented at 5:38 PM on May 18, 2020: none

    Currently "verifychain" prints progress every 10 steps. If a user tries to verify the whole blockchain (verifychain 4 0) it will take a lot of time and printing progress every 1 step is very useful.

    <!-- *** Please remove the following help text before submitting: *** Pull requests without a rationale and clear improvement may be closed immediately. -->

    <!-- Please provide clear motivation for your patch and explain how it improves Bitcoin Core user experience or Bitcoin Core developer experience significantly: * Any test improvements or new tests that improve coverage are always welcome. * All other changes should have accompanying unit tests (see `src/test/`) or functional tests (see `test/`). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change. * Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed. * Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Bitcoin Core, if possible. * Refactoring changes are only accepted if they are required for a feature or bug fix or otherwise improve developer experience significantly. For example, most "code style" refactoring changes require a thorough explanation why they are useful, what downsides they have and why they *significantly* improve developer experience or avoid serious programming bugs. Note that code style is often a subjective matter. Unless they are explicitly mentioned to be preferred in the [developer notes](/doc/developer-notes.md), stylistic code changes are usually rejected. -->

    <!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->

  2. Print "verifychain" progress every 1 step.
    Currently "verifychain" prints every 10 steps. If a user tries to verify the whole blockchain (verifychain 4 0) it will take a lot of time and printing progress every 1 step is very useful.
    9ac7e69c92
  3. in src/validation.cpp:4265 in 9ac7e69c92 outdated
    4261 | @@ -4262,10 +4262,10 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
    4262 |      for (pindex = ::ChainActive().Tip(); pindex && pindex->pprev; pindex = pindex->pprev) {
    4263 |          boost::this_thread::interruption_point();
    4264 |          const int percentageDone = std::max(1, std::min(99, (int)(((double)(::ChainActive().Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
    4265 | -        if (reportDone < percentageDone/10) {
    4266 | +        if (reportDone < percentageDone/1) {
    


    maflcko commented at 5:45 PM on May 18, 2020:

    Maybe extract this as a constant that is set to 10 when nCheckDepth is less than 1000 blocks and to 1 otherwise?


    laanwj commented at 11:05 AM on May 26, 2020:

    I agree with @MarcoFalke.


    yakitorifoodie commented at 12:52 PM on May 26, 2020:

    @MarcoFalke @laanwj Done. Thank you.

  4. DrahtBot added the label Validation on May 18, 2020
  5. maflcko added the label Waiting for author on May 26, 2020
  6. Update validation.cpp
    report every 10% step if nCheckDepth is <= 1000 blocks else report every 1% step.
    06cd245eed
  7. maflcko removed the label Waiting for author on May 26, 2020
  8. in src/validation.cpp:4262 in 06cd245eed outdated
    4257 | @@ -4258,14 +4258,16 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
    4258 |      int nGoodTransactions = 0;
    4259 |      BlockValidationState state;
    4260 |      int reportDone = 0;
    4261 | +    int logStep;
    4262 | +    logStep = nCheckDepth > 1000 ? 1 : 10;
    


    maflcko commented at 12:54 PM on May 26, 2020:
        const int log_step{nCheckDepth > 1000 ? 1 : 10};
    

    maflcko commented at 12:54 PM on May 26, 2020:

    According to the dev notes

  9. maflcko commented at 12:54 PM on May 26, 2020: member
  10. Update src/validation.cpp
    Co-authored-by: MarcoFalke <falke.marco@gmail.com>
    cf54f1c7b9
  11. Update validation.cpp 97056ac2bf
  12. adamjonas commented at 3:35 PM on June 11, 2020: member

    Hi @yakitorifoodie, nice to see you contributing for the first time! Pinging you on the squash requested above. You'll need to do that before this can be merged.

  13. in src/validation.cpp:4261 in 97056ac2bf outdated
    4257 | @@ -4258,14 +4258,15 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
    4258 |      int nGoodTransactions = 0;
    4259 |      BlockValidationState state;
    4260 |      int reportDone = 0;
    4261 | +    const int log_step{nCheckDepth > 1000 ? 1 : 10};
    


    jonatack commented at 3:55 PM on June 11, 2020:

    Perhaps place the explanatory comment of // report every 10% step if nCheckDepth is <= 1000 blocks else report every 1% step here where you initialize log_step.

  14. in src/validation.cpp:4266 in 97056ac2bf outdated
    4263 |      for (pindex = ::ChainActive().Tip(); pindex && pindex->pprev; pindex = pindex->pprev) {
    4264 |          boost::this_thread::interruption_point();
    4265 |          const int percentageDone = std::max(1, std::min(99, (int)(((double)(::ChainActive().Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
    4266 | -        if (reportDone < percentageDone/10) {
    4267 | -            // report every 10% step
    4268 | +        if (reportDone < percentageDone/log_step) {
    


    jonatack commented at 3:55 PM on June 11, 2020:
            if (reportDone < percentageDone / log_step) {
    
  15. in src/validation.cpp:4269 in 97056ac2bf outdated
    4267 | -            // report every 10% step
    4268 | +        if (reportDone < percentageDone/log_step) {
    4269 | +            // report every 10% step if nCheckDepth is <= 1000 blocks else report every 1% step.
    4270 |              LogPrintf("[%d%%]...", percentageDone); /* Continued */
    4271 | -            reportDone = percentageDone/10;
    4272 | +            reportDone = percentageDone/log_step;
    


    jonatack commented at 3:56 PM on June 11, 2020:
                reportDone = percentageDone / log_step;
    
  16. in src/validation.cpp:4324 in 97056ac2bf outdated
    4320 | @@ -4320,10 +4321,10 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
    4321 |          while (pindex != ::ChainActive().Tip()) {
    4322 |              boost::this_thread::interruption_point();
    4323 |              const int percentageDone = std::max(1, std::min(99, 100 - (int)(((double)(::ChainActive().Height() - pindex->nHeight)) / (double)nCheckDepth * 50)));
    4324 | -            if (reportDone < percentageDone/10) {
    4325 | -                // report every 10% step
    4326 | +            if (reportDone < percentageDone/log_step) {
    


    jonatack commented at 3:56 PM on June 11, 2020:
                if (reportDone < percentageDone / log_step) {
    
  17. in src/validation.cpp:4327 in 97056ac2bf outdated
    4325 | -                // report every 10% step
    4326 | +            if (reportDone < percentageDone/log_step) {
    4327 | +                // report every 10% step if nCheckDepth is <= 1000 blocks else report every 1% step.
    4328 |                  LogPrintf("[%d%%]...", percentageDone); /* Continued */
    4329 | -                reportDone = percentageDone/10;
    4330 | +                reportDone = percentageDone/log_step;
    


    jonatack commented at 3:56 PM on June 11, 2020:
                    reportDone = percentageDone / log_step;
    
  18. jonatack commented at 3:58 PM on June 11, 2020: member

    Concept ACK

    A few formatting nits while retouching to squash the commits.

  19. Update src/validation.cpp
    Co-authored-by: Jon Atack <jon@atack.com>
    d3df4400f0
  20. Update src/validation.cpp
    Co-authored-by: Jon Atack <jon@atack.com>
    5a84237774
  21. Update src/validation.cpp
    Co-authored-by: Jon Atack <jon@atack.com>
    a5ba691d98
  22. Update src/validation.cpp
    Co-authored-by: Jon Atack <jon@atack.com>
    0eb0fc438c
  23. DrahtBot commented at 11:04 PM on August 1, 2020: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  24. adamjonas commented at 10:12 PM on August 13, 2020: member

    @yakitorifoodie - let me know if you'd like a hand with squashing your commits. I'm ajonas on IRC or you can email me at jonas at chaincode.com if you want to talk through it.

  25. maflcko commented at 6:27 PM on August 27, 2020: member

    Are you still working on this. Otherwise I suggest closing "Up for grabs"

  26. fanquake added the label Up for grabs on Aug 28, 2020
  27. fanquake commented at 12:56 AM on August 28, 2020: member

    This can be re-opened if needed.

  28. fanquake closed this on Aug 28, 2020

  29. bitcoin locked this on Feb 15, 2022
  30. maflcko removed the label Up for grabs on Jul 24, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-27 21:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me