-
Notifications
You must be signed in to change notification settings - Fork 421
Correctly handle new ChannelMonitorUpdate
s to old post-FC chans
#4136
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1601,6 +1601,8 @@ where | |
/// the highest `update_id` of all the pending in-flight updates (note that any pending updates | ||
/// not yet applied sitting in [`ChannelManager::pending_background_events`] will also be | ||
/// considered as they are also in [`Self::in_flight_monitor_updates`]). | ||
/// | ||
/// Note that channels which were closed prior to LDK 0.1 may have a value here of `u64::MAX`. | ||
closed_channel_monitor_update_ids: BTreeMap<ChannelId, u64>, | ||
/// The peer is currently connected (i.e. we've seen a | ||
/// [`BaseMessageHandler::peer_connected`] and no corresponding | ||
|
@@ -13262,7 +13264,8 @@ where | |
.closed_channel_monitor_update_ids | ||
.get_mut(&channel_id) | ||
.expect("Channels originating a payment resolution must have a monitor"); | ||
*update_id += 1; | ||
// Note that for channels closed pre-0.1, the latest update_id is `u64::MAX`. | ||
*update_id = update_id.saturating_add(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the current and future caveats described in the commit msg, does this need a log on overflow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, not sure if its really needed. Maybe the commit message isn't clear, but I don't see any issues with this with the current code. I do call out that its possible that other code changes in the future which introduces an issue, but I don't think we really need to log a warning on the assumption that future code might break really ancient channel closes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I think the commit message is clear. For someone looking at this statement though, it must be hard to understand why this is safe. I thought a warning log would both help debug any future issue with this, and at the same time add a bit more documentation. Or maybe move some of the commit message to a code comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still pretty thin and doesn't explain why it is okay to not increment when at the max already. |
||
|
||
let update = ChannelMonitorUpdate { | ||
update_id: *update_id, | ||
|
@@ -16523,7 +16526,9 @@ where | |
should_queue_fc_update = !monitor.no_further_updates_allowed(); | ||
let mut latest_update_id = monitor.get_latest_update_id(); | ||
if should_queue_fc_update { | ||
latest_update_id += 1; | ||
// Note that for channels closed pre-0.1, the latest update_id is | ||
// `u64::MAX`. | ||
latest_update_id = latest_update_id.saturating_add(1); | ||
} | ||
per_peer_state | ||
.entry(counterparty_node_id) | ||
|
@@ -17170,7 +17175,9 @@ where | |
.closed_channel_monitor_update_ids | ||
.get_mut(channel_id) | ||
.expect("Channels originating a preimage must have a monitor"); | ||
*update_id += 1; | ||
// Note that for channels closed pre-0.1, the latest | ||
// update_id is `u64::MAX`. | ||
*update_id = update_id.saturating_add(1); | ||
|
||
pending_background_events.push(BackgroundEvent::MonitorUpdateRegeneratedOnStartup { | ||
counterparty_node_id: monitor.get_counterparty_node_id(), | ||
|
Uh oh!
There was an error while loading. Please reload this page.