Skip to content

Conversation

@TheBlueMatt
Copy link
Collaborator

@TheBlueMatt TheBlueMatt commented Nov 1, 2025

In c084767 we a ChainMonitor::new_async_beta and a corresponding MonitorUpdatingPersisterAsync struct. To avoid circular references, the ChainMonitor owns the MonitorUpdatingPersisterAsync which uses a FutureSpawner to let async writes happen in the background after it returns control flow ownership to the ChainMonitor. This is great, except that because MonitorUpdatingPersisterAsync thus doesn't have a reference to the ChainMonitor, we have to poll for completion of the futures.

We do so in the new Persist::get_and_clear_completed_updates that was added in the above-referenced commit. But on async monitor write completion we're supposed to call ChainMonitor's event_notifier.notify() (ultimately waking up the background processor which awaits the corresponding update future). This didn't happen in the new async flow.

Here we move ChainMonitor's event_notifier into an Arc and pass a reference to it through to the MonitorUpdatingPersisterAsync which can then directly notify() it and wake the background processor.

@TheBlueMatt TheBlueMatt added this to the 0.2 milestone Nov 1, 2025
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Nov 1, 2025

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

In c084767 we a
`ChainMonitor::new_async_beta` and a corresponding
`MonitorUpdatingPersisterAsync` struct. To avoid circular
references, the `ChainMonitor` owns the
`MonitorUpdatingPersisterAsync` which uses a `FutureSpawner` to let
async writes happen in the background after it returns control flow
ownership to the `ChainMonitor`. This is great, except that because
`MonitorUpdatingPersisterAsync` thus doesn't have a reference to
the `ChainMonitor`, we have to poll for completion of the futures.

We do so in the new `Persist::get_and_clear_completed_updates` that
was added in the above-referenced commit. But on async monitor
write completion we're supposed to call `ChainMonitor`'s
`event_notifier.notify()` (ultimately waking up the background
processor which `await`s the corresponding update future). This
didn't happen in the new async flow.

Here we move `ChainMonitor`'s `event_notifier` into an `Arc` and
pass a reference to it through to the
`MonitorUpdatingPersisterAsync` which can then directly `notify()`
it and wake the background processor.
@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.86%. Comparing base (c1bca16) to head (092a50a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4200   +/-   ##
=======================================
  Coverage   88.85%   88.86%           
=======================================
  Files         180      180           
  Lines      137901   137910    +9     
  Branches   137901   137910    +9     
=======================================
+ Hits       122537   122551   +14     
+ Misses      12552    12549    -3     
+ Partials     2812     2810    -2     
Flag Coverage Δ
fuzzing 21.43% <6.25%> (-0.01%) ⬇️
tests 88.70% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tnull tnull requested review from tnull and removed request for valentinewallace November 2, 2025 09:44
@tnull tnull changed the title 2025 11 async mon notify notify ChainMonitor's EventNotifier on async write completion Nov 2, 2025
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, simple bugfix, landing.

I took the liberty of updating the PR description and title.

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@tnull tnull merged commit 7177cfc into lightningdevkit:main Nov 2, 2025
23 of 25 checks passed
@TheBlueMatt
Copy link
Collaborator Author

I took the liberty of updating the PR description and title.

Ha, thanks, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants