rpc: report background validation progress in getchainstates #36220

Open
arejula27 wants to merge 2 commits from rpc-getchainstates-background-progress into master AGit
arejula27 commented 2026-09-10 15:05:18 +00:00 (Migrated from github.com)

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.

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 commented 2026-09-10 15:05:26 +00:00 (Migrated from github.com)

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

Reviewers, this pull request conflicts with the following ones:

  • #37094 (validation: validate assumeutxo snapshots with a single chainstate by fjahr)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36220 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36220.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36220#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [nervana21](https://github.com/bitcoin/bitcoin/pull/36220#issuecomment-5634829757) | | Concept NACK | [l0rinc](https://github.com/bitcoin/bitcoin/pull/36220#issuecomment-6104706320) | | Concept ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/36220#issuecomment-5621277255), [vicjuma](https://github.com/bitcoin/bitcoin/pull/36220#pullrequestreview-5170591325), [musaHaruna](https://github.com/bitcoin/bitcoin/pull/36220#pullrequestreview-5480981407) | 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. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#37094](https://github.com/bitcoin/bitcoin/pull/37094) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37094.svg"></sub> (validation: validate assumeutxo snapshots with a single chainstate by fjahr) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
sedited commented 2026-09-10 15:35:18 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
arejula27 commented 2026-09-10 16:06:27 +00:00 (Migrated from github.com)

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

would be interesting to add a new field "targetBlock" to show until which block must validate the background chainstate?
vicjuma (Migrated from github.com) reviewed 2026-09-10 17:59:43 +00:00
vicjuma (Migrated from github.com) left a comment

Concept ACK

Concept ACK
vicjuma (Migrated from github.com) commented 2026-09-10 17:59:26 +00:00

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.

I feel like this change better aligns the [assumeutxo.md](https://github.com/bitcoin/bitcoin/blob/master/doc/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 2026-09-10 22:47:23 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
nervana21 (Migrated from github.com) reviewed 2026-09-11 13:02:45 +00:00
nervana21 (Migrated from github.com) commented 2026-09-11 13:02:46 +00:00

2e2deb8262: rpc: report background validation progress in getchainstates

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

nit

2e2deb8262f2297af61b152aa7646e3cabcc4f40: rpc: report background validation progress in getchainstates ```suggestion data.pushKV("verificationprogress", cs.TargetBlock().has_value() ? chainman.GetBackgroundVerificationProgress(*tip) ``` nit
nervana21 commented 2026-09-11 13:03:28 +00:00 (Migrated from github.com)

tACK d9638e49f6

tACK d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55
arejula27 (Migrated from github.com) reviewed 2026-09-11 17:29:05 +00:00
arejula27 (Migrated from github.com) commented 2026-09-11 17:29:05 +00:00

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

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 (Migrated from github.com) reviewed 2026-09-11 17:36:20 +00:00
nervana21 (Migrated from github.com) commented 2026-09-11 17:36:20 +00:00

ahh, you're right. my mistake!

ahh, you're right. my mistake!
musaHaruna (Migrated from github.com) reviewed 2026-10-10 22:09:51 +00:00
musaHaruna (Migrated from github.com) left a comment

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.

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.
musaHaruna (Migrated from github.com) reviewed 2026-10-10 22:10:12 +00:00
musaHaruna (Migrated from github.com) commented 2026-10-10 22:10:12 +00:00
        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.

```suggestion 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.
First-time contributor

Base: aa76bd266df9742a266d52e0e5da8dbf033658f6
Head: d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55

Previously reported concerns remain unresolved: 1 minor.

Previous findings
[Minor · still present] Provide a compatibility path for the changed progress meaning

This changes the existing getchainstates.verificationprogress meaning for a historical chainstate from progress toward the network tip to progress toward the snapshot target. The previous help text documented the network-tip meaning, and doc/developer-notes.md treats logical-meaning changes as potentially backward-incompatible, recommending a -deprecatedrpc compatibility path and release note. Please preserve the old result during a migration period or establish why this field’s prior meaning is not a compatibility contract. No specific downstream consumer relying on the old value was identified in the checkout, so production client impact is unconfirmed.

Location: src/rpc/blockchain.cpp:3614 (head).

First reported at d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55. Last checked at d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55.

Review coverage was incomplete.

Review limitations
  • independent: Model API request failed.
  • concurrency: Model API request failed.
  • verifier: The upstream independent and concurrency discovery stages failed (model API errors). I statically inspected the whole diff (the getchainstates progress selection, the help text and the functional test). I also checked how Chainstate::TargetBlock and ChainstateManager::GetBackgroundVerificationProgress behave. Since there were no candidates to verify, these gaps do not affect any decision.

Review tier: standard

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:ab973404fb8e3c0d560a5f0df76c1f96a2e0e21182cfc208ac10a039068cb623:00633cd9cb08c8f4661c30fbf00eaba6318f037423dd36deda26cc4a9d01c2c2 --> Base: `aa76bd266df9742a266d52e0e5da8dbf033658f6` Head: `d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55` <!-- ralph-case:59c94a4f3aa486f4fbbb4db585cdd7f282378825608a3474a8198318f8dc5479 --> Previously reported concerns remain unresolved: 1 minor. ##### Previous findings <details> <summary>[Minor · still present] Provide a compatibility path for the changed progress meaning</summary> This changes the existing getchainstates.verificationprogress meaning for a historical chainstate from progress toward the network tip to progress toward the snapshot target. The previous help text documented the network-tip meaning, and doc/developer-notes.md treats logical-meaning changes as potentially backward-incompatible, recommending a -deprecatedrpc compatibility path and release note. Please preserve the old result during a migration period or establish why this field’s prior meaning is not a compatibility contract. No specific downstream consumer relying on the old value was identified in the checkout, so production client impact is unconfirmed. Location: `src/rpc/blockchain.cpp:3614` (head). First reported at `d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55`. Last checked at `d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55`. </details> Review coverage was incomplete. ##### Review limitations - independent: Model API request failed. - concurrency: Model API request failed. - verifier: The upstream independent and concurrency discovery stages failed (model API errors). I statically inspected the whole diff (the getchainstates progress selection, the help text and the functional test). I also checked how Chainstate::TargetBlock and ChainstateManager::GetBackgroundVerificationProgress behave. Since there were no candidates to verify, these gaps do not affect any decision. Review tier: standard [Full review report](<https://review.fish.foo/traces/36220-d9638e49f6a7ef70dbe31cb85e809d9f81e3ce55-1560-2.html>)
l0rinc commented 2026-10-11 02:41:33 +00:00 (Migrated from github.com)

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.

I understand this fixes an existing reporting inconsistency, but I’d prefer us to revisit the underlying synchronization design and costs discussed in [#36476](https://github.com/bitcoin/bitcoin/issues/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 in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36220
No description provided.