-
Notifications
You must be signed in to change notification settings - Fork 403
Persist unresolved ChannelMonitors on empty height change #3442
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
Persist unresolved ChannelMonitors on empty height change #3442
Conversation
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.
Thanks!
lightning/src/chain/chainmonitor.rs
Outdated
have_monitors_to_prune = true; | ||
let (is_fully_resolved, needs_persistence) = monitor_holder.monitor.process_claim_resolution_status(&logger); | ||
if is_fully_resolved || needs_persistence { | ||
have_monitors_to_persist_or_prune = true; |
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.
You can keep the bool as it was, we don't need the write
lock to persist a monitor, we can do that in this loop and only do the bottom block if we need to prune.
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.
done
/// This function returns true only if [`Self::get_claimable_balances`] has been empty for at least | ||
/// This function returns a tuple of two booleans, the first indicating whether the monitor is | ||
/// fully resolved, and the second whether the monitor needs persistence as a consequence of | ||
/// checking its claim resolution status. |
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.
This is kinda weird "checking -> needs persistence" should be explained a bit. Maybe "the second whether the monitor needs persistence to ensure it is reliably marked as resolved in 4032 blocks."?
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.
done
/// 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. | ||
pub fn is_fully_resolved<L: Logger>(&self, logger: &L) -> bool { | ||
pub fn process_claim_resolution_status<L: Logger>(&self, logger: &L) -> (bool, bool) { |
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.
Maybe check_update_fully_resolved_status
? claim
(singular) is a bit weird as we're not talking about a specific claim but rather all possible funds to claim. Also nice to give it a clear "update" in the name cause we might need to persist and we're updating the fully-resolved-status so that it clears in 4k blocks.
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.
I honestly hate every name I could come up with and this one, too, but I guess it's the least bad option. I added an and, but can drop it if you prefer
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3442 +/- ##
==========================================
+ Coverage 89.69% 90.14% +0.45%
==========================================
Files 130 130
Lines 107335 110095 +2760
Branches 107335 110095 +2760
==========================================
+ Hits 96273 99249 +2976
+ Misses 8660 8522 -138
+ Partials 2402 2324 -78 ☔ View full report in Codecov by Sentry. |
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.
Two doc nits otherwise LGTM, feel free to just fix the nits and squash in one go.
@@ -1994,10 +1994,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> { | |||
|
|||
/// Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of | |||
/// its outputs and balances (i.e. [`Self::get_claimable_balances`] returns an empty set). | |||
/// Additionally updates the empty balances height if necessary. |
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.
I'm not sure we expect users to know what the "empty balances height" is :).
/// Additionally updates the empty balances height if necessary. | |
/// Additionally may update state to track when the balances set became empty. |
0a3c718
to
6f9300f
Compare
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.
This is trivial, it just a new return value and code to handle it. Commit really could have used a description but its not worth holding this up on that.
This hopefully fixes #3121.