rpc: clarify preciousblock help text #36415

Manually merged
ViniciusCestarii merged 1 commit from preciousblock-help into master 2026-10-03 10:10:53 +00:00 AGit
ViniciusCestarii commented 2026-10-02 13:49:51 +00:00 (Migrated from github.com)

The preciousblock help says only "Treats a block as if it were received before others with the same work". This isn't wrong but could be clearer and it also leaves out cases that confuse users, including me (see discussion in #35300):

  • The call has no effect when the block has less work than the current tip, and that includes any ancestor of the tip. A successful return doesn't mean the tip changed. (code)
  • It only breaks ties between equal-work chains and doesn't pin the chain. If another chain gains more work, the node switches to it as usual. (code)

This adds both points to the help text and doesn't change any behavior.

The preciousblock help says only "Treats a block as if it were received before others with the same work". This isn't wrong but could be clearer and it also leaves out cases that confuse users, including me (see discussion in #35300): - The call has no effect when the block has less work than the current tip, and that includes any ancestor of the tip. A successful return doesn't mean the tip changed. ([code](https://github.com/bitcoin/bitcoin/blob/69142eacd1374925cc9e4ea736c21fcec16307d0/src/validation.cpp#L3504-L3507)) - It only breaks ties between equal-work chains and doesn't pin the chain. If another chain gains more work, the node switches to it as usual. ([code](https://github.com/bitcoin/bitcoin/blob/69142eacd1374925cc9e4ea736c21fcec16307d0/src/node/blockstorage.cpp#L174-L182)) This adds both points to the help text and doesn't change any behavior.
DrahtBot commented 2026-10-02 13:50:00 +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 instagibbs, maflcko

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

<!--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/36415 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36415.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36415#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 | [instagibbs](https://github.com/bitcoin/bitcoin/pull/36415#issuecomment-5960288238), [maflcko](https://github.com/bitcoin/bitcoin/pull/36415#issuecomment-5966556758) | 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-->
First-time contributor

Base: 65896ac58ea63e29ad19d41b492e37f8722ac715
Head: 15d092639957242d443a680d380f8df1def2bd4e

🟡 Minor

Equal work does not ensure the requested block becomes active (src/rpc/blockchain.cpp:1716, head)

The RPC description implies that a block with the same work as the current tip will become active. PreciousBlock only adds the requested index back to the candidate set when it is transaction-valid and has chain transaction data. Otherwise, activation can leave the existing tip active while the RPC returns successfully. P2P header processing adds headers to the block index before block data arrives, so a known header-only branch can reach this case during normal download. Describe the call as preferring the block among eligible equal-work candidates, not as guaranteeing a switch.

Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial_glm review did not complete.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `65896ac58ea63e29ad19d41b492e37f8722ac715` Head: `15d092639957242d443a680d380f8df1def2bd4e` ##### 🟡 Minor **Equal work does not ensure the requested block becomes active** (src/rpc/blockchain.cpp:1716, head) The RPC description implies that a block with the same work as the current tip will become active. `PreciousBlock` only adds the requested index back to the candidate set when it is transaction-valid and has chain transaction data. Otherwise, activation can leave the existing tip active while the RPC returns successfully. P2P header processing adds headers to the block index before block data arrives, so a known header-only branch can reach this case during normal download. Describe the call as preferring the block among eligible equal-work candidates, not as guaranteeing a switch. Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial_glm review did not complete. [Full review report](<https://review.fish.foo/traces/36415-15d092639957242d443a680d380f8df1def2bd4e-312-2.html>)
maflcko commented 2026-10-02 14:17:07 +00:00 (Migrated from github.com)

lgtm ACK 11bd28a567

lgtm ACK 11bd28a56796bcdabfa8644557486bef2f695529
instagibbs (Migrated from github.com) reviewed 2026-10-02 17:01:31 +00:00
instagibbs (Migrated from github.com) commented 2026-10-02 17:01:31 +00:00

"If the submitted block"? we're talking about two blocks kinda mushed together

"If the submitted block"? we're talking about two blocks kinda mushed together
ViniciusCestarii (Migrated from github.com) reviewed 2026-10-02 19:19:41 +00:00
ViniciusCestarii (Migrated from github.com) commented 2026-10-02 19:19:41 +00:00

Good point, Done on 15d0926399. I used the word "specified" instead of "submitted" to avoid any confusion with submitblock.

Good point, Done on 15d092639957242d443a680d380f8df1def2bd4e. I used the word "specified" instead of "submitted" to avoid any confusion with submitblock.
ViniciusCestarii commented 2026-10-02 19:20:34 +00:00 (Migrated from github.com)
Thanks for the reviews. Force-pushed 15d092639957242d443a680d380f8df1def2bd4e addressing https://github.com/bitcoin/bitcoin/pull/36415#discussion_r4167955974
instagibbs commented 2026-10-02 19:53:07 +00:00 (Migrated from github.com)
ACK https://github.com/bitcoin/bitcoin/pull/36415/commits/15d092639957242d443a680d380f8df1def2bd4e
maflcko commented 2026-10-03 06:58:23 +00:00 (Migrated from github.com)

lgtm ACK 15d0926399

lgtm ACK 15d092639957242d443a680d380f8df1def2bd4e
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!36415
No description provided.