AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 19 Bitcoin

Merge bitcoin/bitcoin#35474: node: move index ownership to NodeContext

Public commit record

What the developer wrote

Authored by merge-script

81/100 · Strong
Merge bitcoin/bitcoin#35474: node: move index ownership to NodeContext

bb357fcd2fc55807905868e3c394579306ec4b44 node: move block filter index ownership to NodeContext (woltx)
66892cdd56338c4e780c05cfd8d8045f09a826bb net_processing: get block filter index via PeerManager::Options (woltx)
e5b76bbdbba852a0072b3d2b52cb41c7785c495e rpc: get index info from NodeContext indexes (woltx)
fafedc683a74b3b1fab58f8df2dfd9c1516fee15 node: move coinstatsindex ownership to NodeContext (woltx)
2d1dc8f18a2a781ac9c5e40435165d821e0ca410 node: move txospenderindex ownership to NodeContext (woltx)
530cf35c17fc07456a7837e4806be5360c939f91 node: move txindex ownership to NodeContext (woltx)

Pull request description:

This removes the remaining process-global index ownership and stores node-owned indexes in `NodeContext` instead.

Indexes moved:

- `g_txindex`
- `g_txospenderindex`
- `g_coin_stats_index`
- `g_filter_indexes`

`NodeContext` now owns these index instances, while `node.indexes` remains a non-owning list used for common index startup, shutdown, and `getindexinfo` handling.

Behavior should be unchanged, apart from the key order in `getindexinfo` output. Indexes are still created from the same startup options, started in the same init step, stopped before destruction, and destroyed while `validation_signals` is still alive so they can unregister safely.

The block filter index registry is moved to `node/indexes.{h,cpp}` so `index/` code does not depend on `NodeContext`. `PeerManager` receives a small lookup callback instead of reaching into global state.

Review notes:
- The first four commits are small and mostly mechanical: move `txindex`, `txospenderindex`, and `coinstatsindex` ownership to `NodeContext`, then make `getindexinfo` use `node.indexes`. The first commit also adds custom deleters in `node/indexes.cpp`, so `node/context.cpp` does not include index headers, which would create circular dependencies.
- The fifth commit adds a block filter index lookup callback to `PeerManager::Options`, still backed by the global registry.
- The last commit is the main one to review carefully. It moves block filter index ownership to `NodeContext`, moves the block filter registry to `node/indexes.{h,cpp}`, and points the `PeerManager` lookup at `NodeContext` instead of global state.

ACKs for top commit:
fjahr:
ACK bb357fcd2fc55807905868e3c394579306ec4b44
maflcko:
review ACK bb357fcd2fc55807905868e3c394579306ec4b44 💬
andrewtoth:
ACK bb357fcd2fc55807905868e3c394579306ec4b44

Tree-SHA512: 00bf7743241e844bc60c9e9d4d5e1f467d8c99a9f38583f701bdd6b36d57efa929e40697f5575488c78b8421edf689e93981f6d3d92766c24b956c8dc35f1a20
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a code-cleanup change in Bitcoin Core that moves ownership of several optional indexes (used to look up transactions, block filters, and coin statistics) from global variables into the NodeContext object. The pull request description explicitly states behavior should be unchanged, and the diff shows a mechanical refactor: replacing global pointers with node.txindex, node.coin_stats_index, node.block_filter_indexes, etc., and passing a lookup callback to the peer manager instead of reading global state. There is no direct evidence in the commit of a security vulnerability being fixed or introduced.

Recommended action

No immediate security action required. Treat as a normal refactor review: verify that index startup/shutdown order and lifetime are preserved, that the custom deleter does not introduce use-after-free or double-delete, and that the getindexinfo output key-order change is acceptable. Regression testing of -txindex, -coinstatsindex, -txospenderindex, and block filter index RPC/REST/peer behavior is appropriate.

Security signals we found

01

Removal of global mutable state for indexes

02

Introduction of custom IndexDeleter to manage index lifetimes within NodeContext

03

PeerManager now uses an injected callback for block filter index lookup instead of a global function

04

No explicit security fix or vulnerability disclosure in commit message or diff

Risk score

Why this scored 19/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 3/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.