Skip to content

Broadcast channel_update due to peer_disconnection after timer expiration #396

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

Closed

Conversation

ariard
Copy link

@ariard ariard commented Nov 18, 2019

  • process_channels_liveness design pattern: IMO kind of the equivalent of process_pending_htlc_forwards to manage gossip messages generation, I'm planning to reuse it for other todos : "Do some kind of timer to set the channel as !is_live() as we don't really wants..." and "Broadcast channel update for closed channels"
  • time_broadcastable duration? see MIN_DELAY_ANNOUNCE_USELESS_CHAN_SECS
  • process_channels_liveness name?

@ariard
Copy link
Author

ariard commented Nov 18, 2019

Let me know on the high-level approach with generating a PendingChannelUpdate and will update tests in consenquence to make them pass.

@TheBlueMatt
Copy link
Collaborator

Hmm, awesome functionality, though I kinda prefer we go a similar route as for #382 - just a generic "timer_tick_60_s()" function (and maybe trait?) which will check for disabled channels and generate BroadcastChannelUpdate events from there.

@ariard
Copy link
Author

ariard commented Nov 21, 2019

Hmmmm, shouldn't change that much and avoid too much test update. Mostly just to reconvert process_channel_liveness as timer_tick_60_s. And better because not have to update other tests due to new event generated

@ariard ariard force-pushed the 2019-11-pending-disabled-chan branch 2 times, most recently from 81b1af7 to 7138c12 Compare November 25, 2019 22:35
@ariard
Copy link
Author

ariard commented Nov 25, 2019

Updated 7138c12, I think right now making it a trait doesn't give any flexibility to API clients due to global lock on channel state?

@ariard
Copy link
Author

ariard commented Nov 25, 2019

Dropped the new event, but the counter-part is now we need to iterate over all channels to verify their state ? Or maybe let the caller pass a set of chans to verify ?

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

This should have some docs in the high-level ChannelManager struct docs so that people don't miss it.

let channel_state = channel_state_lock.borrow_parts();
for (_, chan) in channel_state.by_id {
// Check if channel is still disabled
if !chan.is_live() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may have happened one second ago, though? The channel needs to have been disabled at the last call to this fn.

Copy link
Author

Choose a reason for hiding this comment

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

Right so you need to track pending_disabled_chan in ChannelManager between the calls but it may imply we may worst-case take up to ~120 seconds to announce a ChannelUpdate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep. I think thats totally fine, but if you are worried about it you can also halve the time and make the user call every 30 seconds and then its worst-case 1.5 minutes (but I dont think it matters).

@ariard ariard force-pushed the 2019-11-pending-disabled-chan branch from 7138c12 to 4db90e5 Compare November 29, 2019 06:52
@ariard
Copy link
Author

ariard commented Nov 29, 2019

Okay added a UpdateStatus field in channel with following logic, at peer_disconnected, fresh -> dirty, at timer_chan_freshness_every_min tick, dirty -> staged, at timer_chan_freshness_every_min tick (again), staged -> fresh (+ BroadcastChannelUpdate gen). Staged is assumed to be a disable update now, it may be extended in the future to stage live update.

As say above, we may turn timer_chan_fresness_every_min as a trait in the future to enable more fancy gossip management like batching/pruning, ...

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Looks good, but still think this needs comments at the struct ChannelManager level. It is super easy to miss this as an implementer and not realize you need to call this function every minute.

/// about the uselessness of this channels.
pub fn timer_chan_freshness_every_min(&self) {
let _ = self.total_consistency_lock.read().unwrap();
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

This scope seems unnecessary now?

/// best-effort, which means we may filter out some status transitions to avoid spam.
/// See further timer_chan_freshness_every_min.
#[derive(PartialEq)]
enum UpdateStatus {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find the constant names here confusing, can we use like "Live", "DisabledUnannounced", and "DisabledAnnounced" or so, mostly cause I dont want to look up the constant docs to figure out what to_dirty() and to_fresh() means.

Antoine Riard added 3 commits November 29, 2019 18:12
Added enum and method are only used in next commit.
Latency/peer disconnection may trigger us to mark as disabled
some of our channels. After some time, if channels are still
disabled we need to broadcast ChannelUpdate to inform other network
peers about the uselessness of these channels.
@ariard ariard force-pushed the 2019-11-pending-disabled-chan branch from 4db90e5 to da94bac Compare November 29, 2019 23:14
@TheBlueMatt
Copy link
Collaborator

Will take as #407.

TheBlueMatt added a commit that referenced this pull request Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants