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

Make `UnboundedCache` bounded

Public commit record

What the developer wrote

Authored by Matt Corallo

58/100 · Thin
Make `UnboundedCache` bounded

In the previous commit we moved to hard-coding `UnboundedCache` in
the `lightning-block-sync` interface. This is great, except that
its an unbounded cache that can use arbitrary amounts of memory
(though never really all that much - its just headers that come in
while we're running).

Here we simply limit the size, and while we're at it give it a more
generic `HeaderCache` name.
✓ Descriptive subject✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit replaces an unbounded memory cache of Bitcoin block headers with a bounded one, limiting it to about one week's worth of headers. The change prevents the cache from growing without limit during long-running operation, which could otherwise consume increasing amounts of memory. It also renames the cache from UnboundedCache to HeaderCache and slightly adjusts how old headers are removed during chain reorganizations.

Recommended action

Review the new HEADER_CACHE_LIMIT value to ensure it is sufficient for typical reorg depths and monitor behavior during deep reorganizations. Verify that the change in blocks_disconnected semantics (retaining headers at fork point height) does not cause stale headers to be reused incorrectly. Consider adding tests that exercise cache eviction and deep reorgs. Update downstream code that referenced UnboundedCache.

Security signals we found

01

Unbounded memory growth replaced with explicit size limit

02

Resource exhaustion / memory bloat risk reduced

03

Behavioral change in reorg handling: blocks_disconnected now retains headers at fork point height

04

Public API type alias replaced by new struct (breaking change)

05

No explicit security advisory or CVE referenced in commit

Risk score

Why this scored 37/100

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