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

liquidity ads #4639

Merged
merged 56 commits into from
Jul 20, 2021
Merged

liquidity ads #4639

merged 56 commits into from
Jul 20, 2021

Commits on Jul 19, 2021

  1. liquidity-ads: import from spec

    Import the wires from spec. Here we go!
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    463626d View commit details
    Browse the repository at this point in the history
  2. lease_rates: parse them out of node_announcements

    When we get a node announcement out, we can now pull out its offer
    characteristic
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    b5fc2ac View commit details
    Browse the repository at this point in the history
  3. gossip/liquidity-ad: node_ann comparison, optional TLV check

    Correctly mark whether or not the TLV's are the same/different, given two
    node announcements
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    cdb934e View commit details
    Browse the repository at this point in the history
  4. gossipd: signal whether node_ann is updated, are we starting up?

    If there's a rate-card for liquidity, we don't know about it until
    after startup (the plugin *should* call us at init to tell us what their
    current rates are)
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    cbfd35e View commit details
    Browse the repository at this point in the history
  5. setleaserates: new RPC to pass in lease rates

    Changelog-Experimental: JSON-RPC: new RPC `setleaserates`, for passing in the rates to advertise for a channel lease (option_will_fund)
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    1adadee View commit details
    Browse the repository at this point in the history
  6. option_will_fund: print out lease rates in listnodes

    Note that we use the names from the spec.
    
    Changelog-Experimental: JSON-RPC: `listnodes` now includes the `lease_rates`, if available
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    de11c5d View commit details
    Browse the repository at this point in the history
  7. libplugin: add u16_option parsing

    A couple of the fields for liquidity_ads are u16
    niftynei committed Jul 19, 2021
    Configuration menu
    Copy the full SHA
    0227cd1 View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2021

  1. gossipd: turn off lease offers if the rates are empty

    If received lease rates are empty (all zeroes), turn them off
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    e4b4020 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d93b193 View commit details
    Browse the repository at this point in the history
  3. funder_policy: set default to 0

    As we move to advertising liquidity, set the default to not have any
    fuzz. This means we won't randomly reject an offer to buy liquidity.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    5e5987b View commit details
    Browse the repository at this point in the history
  4. funder-liqudity-ads: support options + setliquidity ad

    Implement support for liquidity ads in `funder` plugin. We set the
    command line options for the leases, as well as sending the updated ads
    to lightningd (who then passes them through to gossipd)
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    3e40c83 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5c5e7a1 View commit details
    Browse the repository at this point in the history
  6. tests: add test for setting/updating node announce

    Make sure everything updates/flows through as expected.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    8aedc13 View commit details
    Browse the repository at this point in the history
  7. amount: add 'is_zero' helper

    convenience, mostly
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    1dd656c View commit details
    Browse the repository at this point in the history
  8. hsmd: method to sign liquidity ad offer

    When we accept a bid to create a channel lease, we send back a signature
    committing to our max channel lease amounts.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    c94b4e6 View commit details
    Browse the repository at this point in the history
  9. liquidity-ads: pipe through request to funder, update policy

    When a request comes through, we forward it over to the funder who
    uses the currently set policy to figure out how to handle it.
    
    Includes small update to the policy engine which decides whether or not
    to fund a request.
    
    Changelog-Experimental: Plugins: `openchannel2` hook now includes optional fields for a channel lease request
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    03fb9e3 View commit details
    Browse the repository at this point in the history
  10. liquidity-ad: request amount, pass through to dualopend

    Changelog-Experimental: EXPERIMENTAL-DUAL-FUND: JSON-RPC: openchannel_init now takes a `requested_amt`, which is an amount to request from peer
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    26e739a View commit details
    Browse the repository at this point in the history
  11. liquidity-ad: pipe request_amt all the way out to fundchannel

    Changelog-Added: JSON-RPC: `fundchannel` now takes optional `request_amt` parameter
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    25499e0 View commit details
    Browse the repository at this point in the history
  12. liquidity-ad: fill in acceptance response

    Asks HSMD for signed lease termsheet, fills in the details to the
    accept_channel2 TLV
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    93a848f View commit details
    Browse the repository at this point in the history
  13. dualopend, openchannel_init: pull out feerate parsing logic

    we'll use it again here shortly
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    3210dd8 View commit details
    Browse the repository at this point in the history
  14. rpc: add queryrates

    Undocumented RPC call for asking a peer what their rates are
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    a4968b6 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    9f3d9ad View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    f1b0660 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    ade8db8 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    d834de2 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    bb25dad View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    fd331ef View commit details
    Browse the repository at this point in the history
  21. onchaind: add recovery scans for option-will-fund

    option_will_fund changes the to_remote/to_local commitment tx
    outputs by altering the CSV lock for leased channels.
    
    We need to grind/scan for these outputs now, provided the defaults don't
    work.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    de7d3a0 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    f707bdb View commit details
    Browse the repository at this point in the history
  23. liquidity-ads: persist channel blockheight states to disk

    Adds new tables to database, backfills, basically copies the fee_rates
    state machine for channeld.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    817e5ce View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    1e6950b View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    2493bcc View commit details
    Browse the repository at this point in the history
  26. chaintopology: new command 'parsefeerate'

    Useful for parsing a passed in feerate before calling lightningd with
    it, e.g. when you need to know what the feerate is for a fundpsbt before
    calling fundpsbt
    
    Changelog-Added: JSON-RPC: new command `parsefeerate` which takes a feerate string and returns the calculated perkw/perkb
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    3ab59fb View commit details
    Browse the repository at this point in the history
  27. channel lease: set csv_lock for commitment transactions

    If the channel is under lease, the lessor's (accepter, really)
    funds have a CSV lock that reflects the length of the remainder of the
    lease.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    484bcbe View commit details
    Browse the repository at this point in the history
  28. channel utxo: persist the 'csv' lock value to database

    Channel leases modify the CSV height that an output is eligible for
    being spent at,  persist this to the database
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    7d756e0 View commit details
    Browse the repository at this point in the history
  29. utxo: don't add outputs that aren't currently eligible to be spent

    If an output's CSV lock hasn't been surpassed yet, don't try to
    include it in a transaction
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    4ff926a View commit details
    Browse the repository at this point in the history
  30. channeld: don't forget channels that we've put funds into

    Typically we forget a channel if 2016 blocks have passed and
    the funding transaction hasn't been mined yet, however we
    SHOULD NOT forget these channels if we've got funds in them!
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    27657cf View commit details
    Browse the repository at this point in the history
  31. channel lease: fail leased channel if peer offline + blockheight behind

    If the channel is leased and our peer is too far behind, fail the
    channel.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    9c39e6a View commit details
    Browse the repository at this point in the history
  32. close: param to force-close a leased channel

    By default, we won't close a channel that we leased to a peer.
    You can override this with the `force_lease_closed` flag.
    
    Changelog-Added: JSON-RPC: close now has parameter to force close a leased channel (option_will_fund)
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    8097937 View commit details
    Browse the repository at this point in the history
  33. channel lease: update the blockheight on reconnect, also

    We need to update the peer wrt our blockheight on reconnect
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    74ccf75 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    8666cbb View commit details
    Browse the repository at this point in the history
  35. channel leases: pass expected lease rates around in compat form

    We need to know what the lease we're expecting is. To do this
    we pass around the hex encoded portion of the wire format.
    
    We can use this passed in expected lease rates to confirm that the peer
    is, in fact, using the same rates as what we have currently.
    
    Changelog-Added: JSON-RPC: fundchannel, multifundchannel, and openchannel_init now accept a 'compact_lease' for any requested funds
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    85fbd28 View commit details
    Browse the repository at this point in the history
  36. channel leases: add expected lease fee to opening PSBT

    We need to parse the feerate string, so we can figure out what our
    weight fee will be for a leased channel, so we go get the feerate
    and use that to calculate what our expected lease fee will be for
    the requested amount.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    93854d5 View commit details
    Browse the repository at this point in the history
  37. channel-lease: reject if we're not currently advertising liquidity

    If there's no plugin currently in place, we simply won't return any
    funding at all, in which case we'd expect them to handle however
    they want. (our implementation would fail the open, as we only accept
    opens that have at least as much as we've requested provided)
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    6e7b36b View commit details
    Browse the repository at this point in the history
  38. nit: better error messages on dualopend's check_balances failures

    Make it easier to figure out what the inputs were to check_balances
    on two failure cases
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    02644be View commit details
    Browse the repository at this point in the history
  39. channel-leases: add lease fee to accepter's funding earlier up

    We need the 'actual' accepter's funding for the reserve calculations,
    which includes the lease fee that the opener is paying them, so we
    calculate it before doing all that jazz.
    
    However, we MUST send the actual "on paper" (e.g. without lease fee)
    amount to the peer in accept_channel2, so we stash the original amount
    and send it.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    1d6f313 View commit details
    Browse the repository at this point in the history
  40. dualopend: hold onto open_tlv for longer than the tmpctx persists

    with channel leases, we use the open_tlv data after a round of talking
    to the peer (which clears out the tmpctx). It'll get cleaned up
    when this peer opens/fails.
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    64123f1 View commit details
    Browse the repository at this point in the history
  41. lease-channels: tests for the test gods

    Check that channel leases work as expected for unilateral closes
    and cheats!
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    86dacd9 View commit details
    Browse the repository at this point in the history
  42. queryrates: make it dev-only

    Since we now use 'compact_lease' to gate an open (if the rates have
    changed, we fail), we no longer need to rely on query rates for figuring
    things out, so we make it dev-only.
    
    Changelog-Changed: JSON-API: queryrates is now developer only
    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    8729d6b View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    7049c30 View commit details
    Browse the repository at this point in the history
  44. overflows: helpers for integer assignment overflows.

    Signed-off-by: Rusty Russell <[email protected]>
    rustyrussell authored and niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    48a46a3 View commit details
    Browse the repository at this point in the history
  45. lease_rates, funder: use overflow helpers

    Signed-off-by: Rusty Russell <[email protected]>
    rustyrussell authored and niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    26474c7 View commit details
    Browse the repository at this point in the history
  46. gossipd: de-duplicate code.

    Signed-off-by: Rusty Russell <[email protected]>
    rustyrussell authored and niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    4a967ba View commit details
    Browse the repository at this point in the history
  47. lease_rates: lease_rates_eq.

    We don't actually use the NULL-is-equal in the one caller, so ignore that.
    
    Signed-off-by: Rusty Russell <[email protected]>
    rustyrussell authored and niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    f8f4e43 View commit details
    Browse the repository at this point in the history
  48. common/lease_rates: more things const.

    And fix up lease_rates_fromhex to be the obvious calling convention.
    
    Signed-off-by: Rusty Russell <[email protected]>
    rustyrussell authored and niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    103d3f1 View commit details
    Browse the repository at this point in the history
  49. printlogs for failing tests

    niftynei committed Jul 20, 2021
    Configuration menu
    Copy the full SHA
    7be8e71 View commit details
    Browse the repository at this point in the history