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

validation: collect block inputs in CoinsViewOverlay before ConnectBlock

Public commit record

What the developer wrote

Authored by Andrew Toth

73/100 · Adequate
validation: collect block inputs in CoinsViewOverlay before ConnectBlock

Introduce CoinsViewOverlay::StartFetching, which maps all input prevouts of a
block to a new m_inputs vector of InputToFetch elements. Returns a ResetGuard
which is lifetime bound to the block, while the InputToFetch elements are
lifetime bound to the block as well.

Inputs spending outputs of an earlier transaction in the same block won't
be in the cache or the db. They also won't be requested by FetchCoinFromBase,
so we filter them out while building m_inputs to not waste time trying to
fetch them. Build an unordered set of seen txids while flattening m_inputs and
skip any prevout whose hash is already in the set.

Introduce StopFetching to clear the m_inputs vector.
CCoinsViewCache::Reset is made virtual and is overridden in CoinsViewOverlay.
StopFetching is called on Reset, so the InputToFetch objects will not
exceed the lifetime of the block.

Introduce ProcessInput to fetch the utxo of an individual input in m_inputs.
Each caller fetches the input at m_input_head and increments it, so each call
will fetch the next input in the queue.

Fetch coins from the m_inputs vector in FetchCoinFromBase by comparing the
requested outpoint against the single input at m_input_tail. ConnectBlock
requests prevouts in the same order StartFetching queued them, and same-block
spends are filtered out, so the coin to serve is always the one at m_input_tail
(aside from BIP30 checks, an invalid block, or when the thread pool is not yet.
These cases fall back to base->PeekCoin).

This is designed deliberately so multiple threads can call ProcessInput independently.

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit is a performance optimization for Bitcoin Core's block validation. It pre-fetches the previous transaction outputs (the 'coins' being spent) for all inputs in a block before the main validation work begins, and it does so in parallel using a thread pool. It is not a security fix and does not change consensus rules or network behavior visible to users.

Recommended action

No security action required. Treat as a normal performance/refactoring change; review for correctness of lifetime and concurrency assumptions during ordinary code review.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 12/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/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.