-
Notifications
You must be signed in to change notification settings - Fork 405
Ensure ChannelMonitorUpdate
s are ordered with full monitor writes
#3196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure ChannelMonitorUpdate
s are ordered with full monitor writes
#3196
Conversation
When we update a channel, then while connecting a block persist a full `ChannelMonitor` prior to persisting the `ChannelMonitorUpdate`, users can end up seeing a full `ChannelMonitor` with a given `latest_update_id` prior to seeing the `ChannelMonitorUpdate` with the same `update_id`. This could cause users to have a full `ChannelMonitor` on disk as well as a `ChannelMonitorUpdate` which was already applied. While this isn't an issue for the LDK-provided update-based `Persist`, its somewhat surprising for users so we avoid it.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3196 +/- ##
==========================================
- Coverage 89.78% 89.74% -0.04%
==========================================
Files 121 121
Lines 100932 100933 +1
Branches 100932 100933 +1
==========================================
- Hits 90619 90582 -37
- Misses 7635 7663 +28
- Partials 2678 2688 +10 ☔ View full report in Codecov by Sentry. |
/// update_persisted_channel, the user returns a | ||
/// Note that this lock must be held from [`ChannelMonitor::update_monitor`] through to | ||
/// [`Persist::update_persisted_channel`] to prevent a race where we call | ||
/// [`Persist::update_persisted_channel`], the user returns a | ||
/// [`ChannelMonitorUpdateStatus::InProgress`], and then calls channel_monitor_updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Since you're already here, mind ticking/linkng channel_monitor_updated
/ Vec
as well?
/// persist a full [`ChannelMonitor`] prior to persisting the [`ChannelMonitorUpdate`]. This | ||
/// could cause users to have a full [`ChannelMonitor`] on disk as well as a | ||
/// [`ChannelMonitorUpdate`] which was already applied. While this isn't an issue for the | ||
/// LDK-provided update-based [`Persist`], its somewhat surprising for users so we avoid it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// LDK-provided update-based [`Persist`], its somewhat surprising for users so we avoid it. | |
/// LDK-provided update-based [`Persist`], it is somewhat surprising for users so we avoid it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
Going ahead and land this, nits could still be addressed in a follow up. |
When we update a channel, then while connecting a block persist a full
ChannelMonitor
prior to persisting theChannelMonitorUpdate
, users can end up seeing a fullChannelMonitor
with a givenlatest_update_id
prior to seeing theChannelMonitorUpdate
with the sameupdate_id
. This could cause users to have a fullChannelMonitor
on disk as well as aChannelMonitorUpdate
which was already applied. While this isn't an issue for the LDK-provided update-basedPersist
, its somewhat surprising for users so we avoid it.I fought for a while with actually changing the locking structure to enforce this, but it ended up breaking the
LockedChannelMonitor
stuff so I gave up.