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.
GUARDED_BY annotations for nTx, m_chain_tx_count #36876
pull Crypt-iQ wants to merge 1 commits into bitcoin:master from Crypt-iQ:2026-11/cblockindex-guard changing 5 files +16 −7-
Crypt-iQ commented at 9:37 PM on November 14, 2026: contributor
-
8775bebbde
GUARDED_BY annotations for CBlockIndex's nTx, m_chain_tx_count
The 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.
-
DrahtBot commented at 9:37 PM on November 14, 2026: contributor
<!--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/36876
- Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36876.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36876#author-ralph
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline and AI policy for information on the review process. A summary of reviews will appear here.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
-
fanquake commented at 2:20 AM on November 15, 2026: member
cc @instagibbs