rpc: report background validation progress in getchainstates #36220

pull arejula27 wants to merge 2 commits into bitcoin:master from arejula27:rpc-getchainstates-background-progress changing 2 files +7 −2
  1. arejula27 commented at 3:05 PM on September 10, 2026: contributor

    After #33259, getblockchaininfo reports the progress of the background chainstate relative to the snapshot base block, but getchainstates still computes verificationprogress against the network tip for every chainstate, so the same node reports two different numbers for the same chainstate.

    This PR modifies verificationprogress value to report the correct value, relative to the block the chainstate actually stops at.

  2. rpc: report background validation progress in getchainstates 2e2deb8262
  3. DrahtBot added the label RPC/REST/ZMQ on Sep 10, 2026
  4. DrahtBot commented at 3:05 PM on September 10, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK nervana21
    Concept NACK l0rinc
    Concept ACK sedited, vicjuma, musaHaruna

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. test: check background validation progress in getchainstates d9638e49f6
  6. sedited commented at 3:35 PM on September 10, 2026: contributor

    Concept ACK

  7. arejula27 commented at 4:06 PM on September 10, 2026: contributor

    would be interesting to add a new field "targetBlock" to show until which block must validate the background chainstate?

  8. in src/rpc/blockchain.cpp:3614 in d9638e49f6
    3610 | @@ -3641,7 +3611,8 @@ return RPCMethod{
    3611 |          data.pushKV("bits", strprintf("%08x", tip->nBits));
    3612 |          data.pushKV("target", GetTarget(*tip, chainman.GetConsensus().powLimit).GetHex());
    3613 |          data.pushKV("difficulty", GetDifficulty(*tip));
    3614 | -        data.pushKV("verificationprogress", chainman.GuessVerificationProgress(tip));
    3615 | +        data.pushKV("verificationprogress", cs.TargetBlock() ? chainman.GetBackgroundVerificationProgress(*tip)
    


    vicjuma commented at 5:59 PM on September 10, 2026:

    I feel like this change better aligns the assumeutxo.md documentation (accurate monitoring)

    After the snapshot has loaded, the syncing process of both the snapshot chain and the background IBD chain can be monitored with the getchainstates RPC.


    nervana21 commented at 1:02 PM on September 11, 2026:

    2e2deb8262f2297af61b152aa7646e3cabcc4f40: rpc: report background validation progress in getchainstates

            data.pushKV("verificationprogress", cs.TargetBlock().has_value() ? chainman.GetBackgroundVerificationProgress(*tip)
    

    nit


    arejula27 commented at 5:29 PM on September 11, 2026:

    Thanks for the review! TargetBlock() returns a const CBlockIndex* rather than a std::optional, so I don't think .has_value() would work here.


    nervana21 commented at 5:36 PM on September 11, 2026:

    ahh, you're right. my mistake!

  9. vicjuma commented at 5:59 PM on September 10, 2026: contributor

    Concept ACK

  10. nervana21 commented at 10:47 PM on September 10, 2026: contributor

    Concept ACK

  11. nervana21 commented at 1:03 PM on September 11, 2026: contributor

    tACK d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55

  12. DrahtBot requested review from sedited on Sep 11, 2026
  13. DrahtBot requested review from vicjuma on Sep 11, 2026
  14. DrahtBot added the label CI failed on Sep 18, 2026
  15. maflcko removed the label CI failed on Sep 18, 2026
  16. musaHaruna commented at 10:09 PM on October 10, 2026: contributor

    Concept ACK

    I’m currently running a node with AssumeUTXO, so I checked this before and after applying the change. My snapshot base is at height 935000.

    Before the fix, at background height 474828, the background chainstate’s verificationprogress in getchainstates reported 16.73%, while backgroundvalidation.verificationprogress in getblockchaininfo reported 18.22% for the same block. After the fix, at height 475948, both reported exactly 0.1834620809971763. This is a good improvement: getchainstates now reports background progress toward the snapshot base, as getblockchaininfo already does.

    Locally, the full functional test passed. Reverting only the RPC fix made the background-progress assertion fail; restoring it made the full test pass again.

  17. in test/functional/feature_assumeutxo.py:571 in d9638e49f6
     564 | @@ -565,6 +565,10 @@ def check_dump_output(output):
     565 |          expected_verification_progress = background_tx_count / snapshot_tx_count
     566 |          assert_approx(bv_res["verificationprogress"], expected_verification_progress, vspan=0.01)
     567 |  
     568 | +        self.log.info("Check that getchainstates returns the background validation progress")
     569 | +        cs_res = n1.getchainstates()["chainstates"][0]
     570 | +        assert_approx(cs_res["verificationprogress"], expected_verification_progress, vspan=0.01)
     571 | +
    


    musaHaruna commented at 10:10 PM on October 10, 2026:
            background, active = n1.getchainstates()["chainstates"]
            assert_approx(background["verificationprogress"], expected_verification_progress)
    
            self.log.info("Check that getchainstates returns the active chainstate verification progress")
            assert_approx(active["verificationprogress"], res["verificationprogress"])
    
    

    Optional suggestion: could we also check the active chainstate’s verificationprogress against the top-level value from getblockchaininfo? Both chainstates are already available in the test, so this would also check that active-chainstate progress is still reported correctly.

  18. l0rinc commented at 2:41 AM on October 11, 2026: contributor

    I understand this fixes an existing reporting inconsistency, but I’d prefer us to revisit the underlying synchronization design and costs discussed in #36476, rather than keep adding special cases around background validation. I think we should discuss that broader direction before extending this approach further. Concept NACK on the direction of endless patches for a broken feature.


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-10-21 19:51 UTC

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