Uh oh!
There was an error while loading. Please reload this page.
Setup Support for delaying ChannelMonitorUpdate flight until an Event completes - #2111
Conversation
2aae7c8 to
91707fbCompareCodecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@## main #2111 +/- ##
==========================================
+ Coverage 91.57% 92.14% +0.56%
==========================================
Files 104 105 +1 Lines 51930 61222 +9292 Branches 51930 61222 +9292 ==========================================
+ Hits 47556 56410 +8854 - Misses 4374 4812 +438
☔ View full report in Codecov by Sentry. |
91707fb to
c595331Compare57bebe7 to
9852b84CompareUh oh!
There was an error while loading. Please reload this page.
| log_bytes!(self.channel_id)); | ||
| self.pending_monitor_updates.push(monitor_update); | ||
| return Ok(self.pending_monitor_updates.last().unwrap()); | ||
| let fly_monitor = self.pending_monitor_updates.iter().all(|upd| upd.flown); |
There was a problem hiding this comment.
Do you see any benefit in tracking the flown/dispatched pending updates in a separate Vec?
There was a problem hiding this comment.
Uhhhhhhhhhh. Maybe? Not sure yet, honestly. It would clean up a bit of code, and make some other code a bit more complicated, kinda a wash, but I'm not 100% sure where this is gonna end up , I think this is all of the holding logic we're gonna need for it, but if we find some other bug in there in the future we could end up with more going on in the struct and a two-struct approach will be confusing.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9852b84 to
2ba5289Compare
wpaulino
left a comment
There was a problem hiding this comment.
Feel free to squash the existing fixups
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ae76ed0 to
08ae599Comparewpaulino
commented
Apr 5, 2023
Feel free to squash, will give it a final pass after a second reviewer. |
08ae599 to
d2d3036CompareTheBlueMatt
commented
Apr 6, 2023
Squashed without further changes. |
d2d3036 to
207af69Compare207af69 to
7014813CompareTheBlueMatt
commented
Apr 13, 2023
Fixed a silent rebase conflict as well as a bug that the further upstream lockorder detection surfaced. |
7014813 to
a626549CompareTheBlueMatt
commented
Apr 17, 2023
Actually, gonna slip this cause it should really go in the same release as its followup, which isn't gonna make 115. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6f1263d to
87bcf91Compare87bcf91 to
51c3b37CompareTheBlueMatt
commented
Apr 28, 2023
Rebased. |
wpaulino
commented
May 2, 2023
Will do another full pass after squash |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| $chan.get_latest_monitor_update_id() == $update_id | ||
| { | ||
| $chan.complete_one_mon_update($update_id); | ||
| if $chan.no_monitor_updates_pending() { |
There was a problem hiding this comment.
I think we can use this check in channel_monitor_updated too (maybe redundant with @wpaulino's comment above). Or move this check into the handle_monitor_update_completion macro
There was a problem hiding this comment.
Yea, I want to clean this logic up, mind if I do it in a followup, though? I have a handful of changes I'm working on to the monitor completion logic here that I can incorporate this into.
In the coming commits, we need to delay `ChannelMonitorUpdate`s until future actions (specifically `Event` handling). However, because we should only notify users once of a given `ChannelMonitorUpdate` and they must be provided in-order, we need to track which ones have or have not been given to users and, once updating resumes, fly the ones that haven't already made it to users. To do this we simply add a `bool` in the `ChannelMonitorUpdate` set stored in the `Channel` which indicates if an update flew and decline to provide new updates back to the `ChannelManager` if any updates have their flown bit unset. Further, because we'll now by releasing `ChannelMonitorUpdate`s which were already stored in the pending list, we now need to support getting a `Completed` result for a monitor which isn't the only pending monitor (or even out of order), thus we also rewrite the way monitor updates are marked completed.
This will allow us to block `ChannelMonitorUpdate`s on `Event` processing in the next commit. Note that this gets dangerously close to breaking forwards compatibility - if we have an `Event` with an `EventCompletionAction` tied to it, we persist a new, even, TLV in the `ChannelManager`. Hopefully this should be uncommon, as it implies an `Event` was delayed until after a full round-trip to a peer.
This adds handling of the new `EventCompletionAction`s after `Event`s are handled, letting `ChannelMonitorUpdate`s which were blocked fly after a relevant `Event`.
The previous commits set up the ability for us to hold `ChannelMonitorUpdate`s which are pending until we're ready to pass them to users and have them be applied. However, if the `ChannelManager` is persisted while we're waiting to give the user a `ChannelMonitorUpdate` we'll be confused on restart - seeing our latest `ChannelMonitor` state as stale compared to our `ChannelManager` - a critical error. Luckily the solution is trivial, we simply need to store the pending `ChannelMonitorUpdate` state and load it with the `ChannelManager` data, allowing stale monitors on load as long as we have the missing pending updates between where we are and the latest `ChannelMonitor` state.
51c3b37 to
9dfe42cCompareTheBlueMatt
commented
May 2, 2023
Squashed without further changes. |
valentinewallace
commented
May 2, 2023
Looks good after @wpaulino takes another look! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
880d88e to
9c36735CompareTheBlueMatt
commented
May 4, 2023
oops sorry that commit was buggy, sec |
TheBlueMatt
commented
May 4, 2023
Actually, just gonna drop the last/new commit, its...hard, so we need to (a) |
9c36735 to
9dfe42cCompareTheBlueMatt
commented
May 4, 2023
The tests on #2112 failed with that commit, specifically, like all the tests. |
This does all the work that will be required to pause
ChannelMonitorUpdateflight until anEventcompletes, but doesn't actually use the new behavior. Sadly, I think we should consider splitting this work across release, as the commitTrack an EventCompletionAction for after an Event is processedindicates -Still, I'm open to discussion on it -
Events generally should be reliably processed before a full round-trip happens, and it sucks to fix major bugs across releases just over worry of a hopefully-very-rare race breaking forwards, but not backwards, compat.