Skip to content

rpc: report background validation progress in getchainstates - #36220

Open
arejula27 wants to merge 2 commits into
bitcoin:masterfrom
arejula27:rpc-getchainstates-background-progress
Open

arejula27 wants to merge 2 commits into
bitcoin:masterfrom
arejula27:rpc-getchainstates-background-progress

Conversation

@arejula27

@arejula27 arejula27 commented Sep 10, 2026 •

Copy link
Copy Markdown
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.

@DrahtBot

DrahtBot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

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 <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

@sedited

sedited commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

@arejula27

Copy link
Copy Markdown
Contributor Author

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

@vicjuma vicjuma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept ACK

Comment thread src/rpc/blockchain.cpp
data.pushKV("target", GetTarget(*tip, chainman.GetConsensus().powLimit).GetHex());
data.pushKV("difficulty", GetDifficulty(*tip));
data.pushKV("verificationprogress", chainman.GuessVerificationProgress(tip));
data.pushKV("verificationprogress", cs.TargetBlock() ? chainman.GetBackgroundVerificationProgress(*tip)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Concept ACK

Comment thread src/rpc/blockchain.cpp Resolved
@nervana21

nervana21 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

tACK d9638e4

@musaHaruna musaHaruna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

self.log.info("Check that getchainstates returns the background validation progress")
cs_res = n1.getchainstates()["chainstates"][0]
assert_approx(cs_res["verificationprogress"], expected_verification_progress, vspan=0.01)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

@l0rinc

l0rinc commented Oct 11, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants