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

lightningd: don't copy hooks array into hook request, simply don't shrink it.

Public commit record

What the developer wrote

Authored by Rusty Russell

83/100 · Strong
lightningd: don't copy hooks array into hook request, simply don't shrink it.

We make a copy, then attach a destructor to the hook in case that plugin exits, so we
can NULL it out in the local copy. When we have 300,000 requests pending, this means
we have 300,000 destructors, which don't scale (it's a single-linked list).

Simply NULL out (rather than shrink) the array in the `plugin_hook`.
Then we can keep using that.

tests/test_coinmoves.py::test_generate_coinmoves (100,000, sqlite3):
Time (from start to end of l2 node): 34 seconds **WAS 85**
Worst latency: 24 seconds **WAS 75**

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This is a performance cleanup, not a security fix. Core Lightning used to make a private copy of every plugin-hook list for each pending request and attach a cleanup handler (a destructor) to every entry. With hundreds of thousands of pending requests, that created hundreds of thousands of destructor entries in a single-linked list, slowing the node dramatically. The patch removes the copy and instead marks removed hooks as NULL in the shared list. The commit message explicitly frames this as a speed improvement (test time dropped from 85 seconds to 34 seconds). There is no claim that the old code was unsafe, only that it did not scale.

Recommended action

No security action required. Treat as a normal performance/refactoring patch. Reviewers may optionally verify that NULL entries are consistently skipped in all hook iteration paths, but the diff already shows that.

Security signals we found

01

No security framing in commit title or message

02

No CVE, advisory, or security reference present

03

Change is described as a scalability/performance optimization

04

No new attack surface introduced: same plugin hook mechanism, same trust model

05

No memory-safety bug fixed: old destructor list was slow, not incorrect

Risk score

Why this scored 22/100

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