Skip to content
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

Handle connection better: make connectd know which peers are important #7630

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Commits on Aug 31, 2024

  1. connectd: send self-advertizing gossip rather than having gossipd do it.

    It's now trivial for us to do this ourselves, since we have gossmap.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    e30c0c8 View commit details
    Browse the repository at this point in the history
  2. connectd: get our own addresses to contact node from node_announcements.

    Let lightningd feed us hints to try first, but we can extract the
    addresses from node_announcement messages ourselves.
    
    (Lightningd used to ask gossipd on our behalf: this is far simpler!)
    
    One side effect of this is that we don't hand back address hints given to us
    by lightningd: it would use these again for reconnecting.  This is breaks
    test_sendpay_grouping, so we disable it temporarily.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    a2edbfb View commit details
    Browse the repository at this point in the history
  3. connectd: expose --dev-no-reconnect and --dev-fast-reconnect options.

    Once connectd is controlling reconnections, it'll need these.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    01e8c30 View commit details
    Browse the repository at this point in the history
  4. lightningd: generalize peer_any_channel to filter on entire channel, …

    …not just state.
    
    We're going to use this to ask if there are any channels which make it
    important to reconnect to the peer.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    1a2d3cb View commit details
    Browse the repository at this point in the history
  5. wallet: save last known address.

    If we connected out, remember that address.  We always remember the last
    address, but that may be an incoming address.  This is explicitly the last
    outgoing address which worked.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    92b1043 View commit details
    Browse the repository at this point in the history
  6. common: routine to make wireaddr_internal from wireaddr.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    61ba409 View commit details
    Browse the repository at this point in the history
  7. recovery: save last_known_addr for peer if we know it.

    This is more useful than the last address, which may be it connecting
    to us.  And use it when we restore it.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    45c54f5 View commit details
    Browse the repository at this point in the history
  8. connectd: reconnect for non-transient connections.

    Rather than have lightningd call us repeatedly to try to connect, have
    it tell us what peers are transient and aren't, and connectd will
    automatically try to maintain that connection.
    
    There's a new "downgrade_peer" message to tell it a peer is now
    transient: to make it non-transient we simply tell connectd to
    connect as a non-transient.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Changed: `connectd` now handles maintaining/reconnecting to important peers, and we remember the last successful address we connected to.
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    087b8e4 View commit details
    Browse the repository at this point in the history
  9. pytest: restore test_sendpay_grouping test.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    fbe6ab3 View commit details
    Browse the repository at this point in the history
  10. connectd: remove transient flag.

    The important flag replaces it, and now we can be more intelligent about
    eviction in overload.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    83f84b0 View commit details
    Browse the repository at this point in the history
  11. connectd: limit to 10 connections at once.

    We wait until a connection fails, or a subd is connected to the peer,
    before letting another one through.  This should prevent us from
    overwhelming lightningd on large nodes, but unlike the previous back-off,
    it's based on how fast lightningd is, not an arbitrary time.
    
    We also let one through each second, in case we're connecting to many,
    but not doing anything but gossip (e.g. 100 explicit connect
    commands).
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Changed: Reconnecting to peers at startup should be significantly faster (dependent on machine speed).
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    09c9242 View commit details
    Browse the repository at this point in the history
  12. pytest: add test for connection ratelimiting.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    153bbe1 View commit details
    Browse the repository at this point in the history