Skip to content

Fail create_channel early if peer is disconnected #2437

Closed

Description

@dunxen

We need to ensure in the case where a peer is disconnected that we fail early when we invoke ChannelManager::create_channel for their_network_key.

The only thing we currently do is check if we know about the peer at all (they're in the per_peer_state):

let peer_state_mutex = per_peer_state.get(&their_network_key)

We also need to check for .is_connected if we know about the peer.

See #2382 (comment)

Activity

  1. TheBlueMatt commented on Jul 24, 2023

    @TheBlueMatt
    Collaborator

    Bonus points if we instead address #2096 (ie don't fail but rebroadcast the open_channel message on reconnect, failing in a minute or two from a timeout instead).

  2. henghonglee commented on Jul 24, 2023

    @henghonglee
    Contributor

    @dunxen i can try this one

  3. dunxen commented on Jul 24, 2023

    @dunxen
    ContributorAuthor

    @dunxen i can try this one

    Great, thanks! Matt’s bonus points would be good to handle from his comment above alternatively :)

  4. nafisalawalidris commented on Sep 15, 2023

    @nafisalawalidris

    To ensure robustness, I propose adding a check for peer disconnection within this function. Currently, we only verify if we know about the peer through the per_peer_state. However, it is crucial to also consider the peer's connection status by using .is_connected. This enhancement will enable us to fail early when attempting to invoke ChannelManager::create_channel for a disconnected peer. Here's the proposed code modification:

    // Existing code
    let peer_state_mutex = per_peer_state.get(&their_network_key)

    // Proposed modification
    if let Some(peer_state) = per_peer_state.get(&their_network_key) {
    if peer_state.is_connected {
    // Proceed with create_channel logic
    } else {
    // Handle the case where the peer is disconnected
    // (e.g., return an error or take appropriate action)
    }
    }

    By implementing this check, we can proactively address issues related to disconnected peers when using ChannelManager::create_channel.

  5. shaavan commented on Nov 4, 2023

    @shaavan
    Member

    Hi! I couldn't help but notice the PR has been open for a little while. I've given it a shot at solving the issue. I would absolutely love to hear your thoughts on what I've come up with. Thanks a bunch! :)

  6. TheBlueMatt commented on Nov 12, 2023

    @TheBlueMatt
    Collaborator

    Oh, oops, dup of #2096.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions