mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
GUARDED_BY annotations for nTx, m_chain_tx_count #36876
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36876
Loading…
Reference in a new issue
No description provided.
Delete branch "2026-11/cblockindex-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The cs_main requirement was never made explicit. The nTx field is modified when the block data is received and m_chain_tx_count is modified when all ancestors' block data has been received. Because of this, reading nTx from the getblockheader RPC may race as it does not acquire cs_main. Also, m_chain_tx_count may race in getchaintxstats if a pruned node redownloads a block via getblockfrompeer or if the node is running assumeutxo and tries to read m_chain_tx_count while it is being written to.
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.
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:
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.
🔵 Suggestion · Header JSON serialization reacquires
cs_mainfor every headerWith REST enabled, JSON
/headersrequests gain up to 2,000 avoidablecs_mainacquisitions, although their latency impact has not been measured.Location:
src/rpc/blockchain.cpp:217(head).Review coverage was incomplete.
Reviewed:
2f7a0750ef2b· Review report · Previous reportspermalink
cc @instagibbs
utACK
8775bebbdemicro nit: https://github.com/bitcoin/bitcoin/pull/36876/changes#diff-decae4be02fb8a47ab4557fe74a9cb853bdfa3ec0fa1b515c0a1e5de91f4ad0bR197 above says it's not held, but now it is. Seems to mostly impact REST, didn't checkmark it.
Yes, also the comment seems to imply that the function won't lock which is false. Should I remove the comment and the
AssertLockNotHeld?seems clearer yes
Done in
ad6d75b196, which also removed theLOCKS_EXCLUDEDmacros8775beb->ad6d75b196Removes the
AssertLockNotHeldinblockheaderToJSONand also removes theLOCKS_EXCLUDEDmacros forblockheaderToJSONandblockToJSON. The intent was to show that these functions don't acquire the lock, which is no longer true.Concept ACK
Hm, I'm a bit confused by this.
blockToJSONalready was grabbingcs_maininside of it, but still it had the annotation here. So was this a mistake? Otherwise it would seem fine to just leave them for both since just adding the lock grabbing toblockheaderToJSONdoesn't seem like the right argument to remove it. We seem to have an example for this in the developer notes even for thePreciousBlock(): https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md?plain=1#L1056 And there are a couple of other functions that do this too. While this is not as critical here as elsewhere, the performance argument from the deleted comment probably still holds?This was added in
faea56400d. The annotation just says that the caller must not hold the given capabilities. It doesn't say anything about the function itself.Anything is fine here. It can be dropped, or it can be kept.
reproduced locally:
review ACK
ad6d75b196🏵Show signature
Signature:
Thanks, this was poor justification, I was confused by the comment. I've reverted it in the latest push.
Code review ACK
32429d7b6bThe latest push cleared up the only question I had. The CI failures look like the unrelated failures we currently see a lot.
the commit looks identical to
8775bebbde, so I think you could have pushed that, to avoid re-review churn, but up to you. I'll ack both:(1/2)
review ACK
8775bebbde💿Show signature
Signature:
(2/2)
review ACK
32429d7b6b🎻Show signature
Signature:
Ah, I did not realize they were identical. I'll keep it at
github.com/bitcoin/bitcoin@32429d7b6bsince at this point I will invalidate one ACK either way🐙 This pull request conflicts with the target branch and needs rebase.
review ACK
2f7a0750ef🚟Show signature
Signature:
ACK
2f7a0750ef