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

Compiler error #9

Open
wants to merge 51 commits into
base: connectd-demux-part-2
Choose a base branch
from

Commits on Dec 15, 2021

  1. lightningd: close one more fd for subdaemons.

    Noticed by stracing for an unrelated problem.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    31d4457 View commit details
    Browse the repository at this point in the history
  2. lightningd: handle channel cleanups more explicitly.

    1. Freeing an unconfirmed channel already releases the subd, so don't
       do that explicitly.
    2. Use channel->owner to transfer ownership where possible, using
       channel_set_owner() which handles all the cases.
    
    This simplifies the code and makes it more readable, IMHO.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    b7268b3 View commit details
    Browse the repository at this point in the history
  3. common: is_msg_gossip_broadcast() for putting things in filter.

    We don't need the other "gossip" messages in our echo-suppression filter.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    23e0c9e View commit details
    Browse the repository at this point in the history
  4. connectd: clean up lightningd connection handling.

    They all returned the same thing anyway.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    3bf0a20 View commit details
    Browse the repository at this point in the history
  5. common: generalize extract_channel_id().

    connectd is going to end up using this do demux; make it fast and complete.
    
    Fixing this reveals a problem in openingd: it now extracts the channel_id
    from funding_signed (which is where we transition off the temporary), and
    gets upset.  So fix that.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    0fd02f7 View commit details
    Browse the repository at this point in the history
  6. common/socket_close: don't wait forever.

    The "read until closed" trick doesn't work if the other end doesn't
    close (as found in the next patch, where we use DEV_DISCONNECT_DISABLE_AFTER).
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    bb635a0 View commit details
    Browse the repository at this point in the history
  7. pytest: disable dev-disconnect blackhole tests.

    These would have to be done by connectd, not the local daemon, once it's
    intermediating.  Otherwise the remote peer won't see any change.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    99c08f3 View commit details
    Browse the repository at this point in the history
  8. dev_disconnect: remove @ marker.

    Once connectd is doing this, we can't close as soon as we send,
    and in fact we can't do 'fail write' either.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    81abdcd View commit details
    Browse the repository at this point in the history
  9. channeld: add dev-disable-commit-after instead of dev-disconnect -noc…

    …ommit
    
    It was always a hack, but an impossible one once connectd will be
    interpreting dev-disconnect!
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    d4ad4ce View commit details
    Browse the repository at this point in the history
  10. gossipd: local_direction helper to generalize is_local_channel.

    Increasingly we want to know is it local, and get the direction: it's
    more efficient to do both at once.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    2975aa3 View commit details
    Browse the repository at this point in the history
  11. gossipd: rewrite update generation, remove local_chan.

    local_chan was mainly around so we could "soft" disable channels (and
    really disable them once we used the channel_update in an error
    message).
    
    Instead we introduce the idea of a "deferred_update": it's either
    deferred indefinitely (a peer goes offline, if we need to send it in
    an error we'll apply it immediatly), or simply delayed to avoid
    spamming everyone.
    
    The resulting rewrite is much clearer, IMHO.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    37abe30 View commit details
    Browse the repository at this point in the history
  12. gossipd: make request handlers return void.

    They all returned the next io_plan, but it was always the same.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    63265ed View commit details
    Browse the repository at this point in the history
  13. connectd: rename struct peer in peer_exchange_initmsg to early_peer.

    We want to have a real (persistent) struct peer eventually.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    65beadd View commit details
    Browse the repository at this point in the history
  14. connectd: keep timeout timer around so we can disable it.

    connectd will be keeping the conn open, so it needs to free this
    "conn_timeout" timer.  Pass it through, so we can do that.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    f28c3f1 View commit details
    Browse the repository at this point in the history
  15. connectd: maintain connection with peer, shuffle data.

    Instead of passing the incoming socket to lightningd for the
    subdaemon, create a new one and simply shuffle data between them,
    keeping connectd in the loop.
    
    For the moment, we don't decrypt at all, just shuffle.  This means our
    buffer code is kind of a hack, but that goes away once we start
    actually decrypting and understanding message boundaries.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    769b368 View commit details
    Browse the repository at this point in the history
  16. gossipwith: create our own internal sync_crypto functions.

    This avoids changes to crypto_sync which are coming in next patch.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    c40ac7c View commit details
    Browse the repository at this point in the history
  17. connectd: do decryption for peers.

    We temporarily hack to sync_crypto_write/sync_crypto_read functions to
    not do any crypto, and do it all in connectd.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    a2271cd View commit details
    Browse the repository at this point in the history
  18. peer_io: replace crypto_sync in daemons, use normal wire messages.

    Now connectd is doing the crypto, we can use normal wire io.  We
    create helper functions to clearly differentiate between "peer" comms
    and intra-daemon comms though.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    bc4eff8 View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2021

  1. per_peer_state: remove struct crypto_state

    Now that connectd does the crypto, no need to hand around crypto_state.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    22ecac7 View commit details
    Browse the repository at this point in the history
  2. connectd: do dev_disconnect logic.

    As connectd handles more packets itself, or diverts them to/from gossipd,
    it's the only place we can implement the dev_disconnect logic.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    ff26d89 View commit details
    Browse the repository at this point in the history
  3. connectd: do nagle by packet type.

    channeld can't do it any more: it's using local sockets.  Connectd
    can do it, and simply does it by type.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    381b62e View commit details
    Browse the repository at this point in the history
  4. common: add routine for absolute timeouts (vs. relative).

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    ff57f6d View commit details
    Browse the repository at this point in the history
  5. connectd: serve gossip_store file for the peer.

    We actually intercept the gossip_timestamp_filter, so the gossip_store
    mechanism inside the per-peer daemon never kicks off for normal connections.
    
    The gossipwith tool doesn't set OPT_GOSSIP_QUERIES, so it gets both, but
    that only effects one place.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    5c7d7b7 View commit details
    Browse the repository at this point in the history
  6. subdaemons: don't stream gossip_store at all.

    We now let gossipd do it.
    
    This also means there's nothing left in 'struct per_peer_state' to
    send across the wire (the fds are sent separately), so that gets
    removed from wire messages too.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    d131293 View commit details
    Browse the repository at this point in the history
  7. lightningd: remove per_peer_state struct.

    Just hand around the two fds.  We have to take a little care to close them
    manually now, though.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    be86bae View commit details
    Browse the repository at this point in the history
  8. connectd: remove per_peer_state in favor of keeping gossip_fd directly.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    006a335 View commit details
    Browse the repository at this point in the history
  9. connectd: put more stuff into struct gossip_state.

    We're the only ones who use it now, so put our fields inside it and
    make it local.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    71b02f4 View commit details
    Browse the repository at this point in the history
  10. connectd: get addresses from lightningd, not gossipd.

    It's weird to have connectd ask gossipd, when lightningd can just do it
    and hand all the addresses together.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    d802834 View commit details
    Browse the repository at this point in the history
  11. lightningd: start gossipd after channels are loaded.

    This is in preparation for gossipd feeding us the latest channel_updates,
    rather than having lightningd and channeld query gossipd when it wants
    to send an onion error with an update included.
    
    This means gossipd will start telling us the updates, so we need the
    channels loaded first.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    aee1b46 View commit details
    Browse the repository at this point in the history
  12. gossipd: infrastructure to tell lightningd about local channel updates.

    We want it to keep the latest, so it can make its own error msgs without
    asking us.  This installs (but does not use!) the message handler.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    3e00b5d View commit details
    Browse the repository at this point in the history
  13. gossipd: feed lightningd the channel_updates as soon as we make them.

    Even if we're deferring putting them in the store and broadcasting them,
    we tell lightningd so it will use it in any error messages.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    40dac53 View commit details
    Browse the repository at this point in the history
  14. lightningd: tell gossipd when we use the channel_update.

    This way it can flush it if it was pending.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    d581a86 View commit details
    Browse the repository at this point in the history
  15. lightningd: use our cached channel_update for errors instead of askin…

    …g gossipd.
    
    We also no longer strip the type off: everyone handles both forms, and
    Eclair doesn't strip (and it's easier!).
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    0842e89 View commit details
    Browse the repository at this point in the history
  16. channeld: keep local copy of latest channel_update for errors.

    Now we don't ask gossipd, but lightningd keeps channeld up-to-date.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    a668ed2 View commit details
    Browse the repository at this point in the history
  17. pytest: fix unlikely flake

    This only happened once, but it's possible if the node gets the new
    node announcement while we're querying, we could see both old and new.
    
    ```
            # Get node_announcements.
            msgs = l1.query_gossip('gossip_timestamp_filter',
                                   genesis_blockhash,
                                   '0', '0xFFFFFFFF',
                                   # Filter out gossip_timestamp_filter,
                                   # channel_announcement and channel_updates.
                                   filters=['0109', '0102', '0100'])
        
    >       assert len(msgs) == 2
    E       assert 3 == 2
    E         +3
    E         -2
    ```
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    ae5efef View commit details
    Browse the repository at this point in the history
  18. channeld: send channel updates and announcements via lightningd.

    We're weaning per-peer daemons off having a direct gossipd connection.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    d336fa7 View commit details
    Browse the repository at this point in the history
  19. channeld: tell gossipd about new channel earlier.

    We're about to change this to go via lightningd, not direct to gossipd,
    and connectd will send gossip direct to gossipd.
    
    Once we do this, it introduces a race.  The peer sends funding_locked
    then immediately sends an update_channel.  channeld used to process
    the funding_locked from the peer, tell gossipd about the new
    channel, then finally forward the channel_update.
    
    With the new architecture, we can have the channel_update hit gossipd
    before we've told it about the channel.  It ignores the channel_update.
    
    Better is to tell gossipd as soon as *we* are ready to send
    funding_locked; this gives a round trip time at least, before gossipd
    could get the update.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    ad5a53e View commit details
    Browse the repository at this point in the history
  20. dualopend: tell lightningd about new channel as soon as it's locked in.

    Once we send funding_locked, gossipd could start seeing channel_updates
    from the peer (which get sent so we can use the channel in routehints
    even before it's announcable).
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    4078ac8 View commit details
    Browse the repository at this point in the history
  21. connectd: temporarily have two fds to gossipd.

    We want to stream gossip through this, but currently connectd treats the
    fd as synchronous.  While we work on getting rid of that, it's easiest to
    have two fds.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    08af613 View commit details
    Browse the repository at this point in the history
  22. gossipd: add routines to send gossip messages to and from connectd.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    e1e7e76 View commit details
    Browse the repository at this point in the history
  23. connectd: divert gossip messages directly to gossipd.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    4248fbe View commit details
    Browse the repository at this point in the history
  24. gossipd: send all gossip msgs directly to connectd, not peer.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    c7c0bef View commit details
    Browse the repository at this point in the history
  25. connectd: handle pings and pongs.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Changed: JSON_RPC: `ping` now works with connected peers, even without a channel.
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    e3e8718 View commit details
    Browse the repository at this point in the history
  26. connectd: handle onion messages.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    23ca389 View commit details
    Browse the repository at this point in the history
  27. connectd: handle custom messages.

    This is neater than what we had before, and slightly more general.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Changed: JSON_RPC: `sendcustommsg` now works with any connected peer, even when shutting down a channel.
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    ef6364d View commit details
    Browse the repository at this point in the history
  28. channeld: simply exit if hsmd vanishes.

    We currently die when gossipd vanishes, but our direct connection will
    go away.  We then complain if the node is shutting down while we're talking
    to hsmd.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    460d78e View commit details
    Browse the repository at this point in the history
  29. subdaemons: remove gossipd fd from per-peer daemons.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    bcf867d View commit details
    Browse the repository at this point in the history
  30. gossipd: don't hand out fds.

    Gossipd now simply gets told by channeld when peers arrive or leave.
    (it only needs to know for the seeker).
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    eb178b8 View commit details
    Browse the repository at this point in the history
  31. connectd: remove second gossip fd.

    Now we only send and receive gossip messages on this fd.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    39c241b View commit details
    Browse the repository at this point in the history
  32. connectd: don't received useless peer fd if we're told to send final …

    …msg.
    
    We don't need the connection to ourselves!
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Dec 20, 2021
    Configuration menu
    Copy the full SHA
    8950384 View commit details
    Browse the repository at this point in the history

Commits on Dec 31, 2021

  1. Compiler error

    I'm guessing doing a 16 bit swap on WIRE_GOSSIP_STORE_ENDED is the solution
    
    Error on Mac OSX 11.6:
    common/gossip_store.c:132:16: error: result of comparison of constant 152043520 with expression of type 'be16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                    if (buf.type == CPU_TO_BE32(WIRE_GOSSIP_STORE_ENDED))
    
    $ gcc -v
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
    Apple clang version 13.0.0 (clang-1300.0.29.30)
    Target: x86_64-apple-darwin20.6.0
    ddustin authored Dec 31, 2021
    Configuration menu
    Copy the full SHA
    aa88b6a View commit details
    Browse the repository at this point in the history