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

Add support for native async `KVStore` persist to `ChainMonitor`

Public commit record

What the developer wrote

Authored by Matt Corallo

85/100 · Strong
Add support for native async `KVStore` persist to `ChainMonitor`

This finally adds support for full native Rust `async` persistence
to `ChainMonitor`.

Way back when, before we had any other persistence, we added the
`Persist` trait to persist `ChannelMonitor`s. It eventualy grew
homegrown async persistence support via a simple immediate return
and callback upon completion. We later added a persistence trait
in `lightning-background-processor` to persist the few fields that
it needed to drive writes for. Over time, we found more places
where persistence was useful, and we eventually added a generic
`KVStore` trait.

In dc75436c673fad8b5b8ed8d5a9db1ac95650685a we removed the
`lightning-background-processor` `Persister` in favor of simply
using the native `KVStore` directly.

Here we continue that trend, building native `async`
`ChannelMonitor` persistence on top of our native `KVStore` rather
than hacking support for it into the `chain::Persist` trait.
Because `MonitorUpdatingPersister` already exists as a common way
to wrap a `KVStore` into a `ChannelMonitor` persister, we build
exclusively on that (though note that the "monitor updating" part
is now optional), utilizing its new async option as our native
async driver.

Thus, we end up with a `ChainMonitor::new_async_beta` which takes
a `MonitorUpdatingPersisterAsync` rather than a classic
`chain::Persist` and then operates the same as a normal
`ChainMonitor`.

While the requirement that users now use a
`MonitorUpdatingPersister` to wrap their `KVStore` before providing
it to `ChainMonitor` is somewhat awkward, as we move towards a
`KVStore`-only world it seems like `MonitorUpdatingPersister`
should eventually merge into `ChainMonitor`.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit adds a new beta way for the Lightning Dev Kit's ChainMonitor to save channel state using native Rust async/await. It is a feature/refactoring change, not a fix for a known vulnerability. The commit message explicitly labels the new API as beta and warns that bugs may be triggered by its use. There is no claim in the commit or supplied references that this resolves a security issue.

Recommended action

Treat this as a normal feature/refactoring commit rather than a security patch. Users of the new beta async API should be aware it is experimental. If reviewing for security, focus on ensuring async write ordering, error handling, and completion signaling are correct in production deployments using this path.

Security signals we found

01

New async persistence path marked beta with explicit 'bugs may be triggered by its use' warning

02

Async completion state is now exposed and drained during event release, replacing a prior TODO

03

Potential for race conditions or ordering issues inherent in any new async I/O path

04

No security advisory, CVE, or bug-fix language present in commit or supplied references

Risk score

Why this scored 27/100

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