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

log,net: avoid `ComputeTotalSize` when logging is disabled

Public commit record

What the developer wrote

Authored by Lőrinc

73/100 · Adequate
log,net: avoid `ComputeTotalSize` when logging is disabled

`PeerManagerImpl::SendBlockTransactions()` computed the total byte size of requested transactions for a debug log line by calling `ComputeTotalSize()` in a tight loop, triggering serialization even when debug logging is off.

Guard the size accumulation with `LogAcceptCategory` so the serialization work only happens when the log line can be emitted.

No behavior change when debug logging is enabled: the reported block hash, transaction count, and byte totals are the same.
The bounds checks still run unconditionally; the debug-only loop iterates the already-validated response contents.

Separating debug-only work from the critical path reduces risk and favors the performance-critical non-debug case.
This also narrows the racy scope of when logging is toggled from another thread.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This is a performance cleanup, not a security fix. A Bitcoin Core network function was doing unnecessary serialization work to calculate transaction byte sizes for a debug log line, even when debug logging was turned off. The change wraps that work in a check so it only runs when the relevant debug log category is actually enabled. There is no behavior change for users and no vulnerability is described or evident in the diff.

Recommended action

No security action required. Treat as a normal performance/refactoring commit. If reviewing for release notes, classify under 'performance' or 'resource usage' rather than security.

Security signals we found

01

No security signal present in commit message or diff

02

Performance optimization only

03

No input validation, authorization, or memory-safety changes

Risk score

Why this scored 19/100

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