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

funder cleanups! #5650

Merged
merged 13 commits into from
Oct 20, 2022
Merged

funder cleanups! #5650

merged 13 commits into from
Oct 20, 2022

Conversation

niftynei
Copy link
Collaborator

@niftynei niftynei commented Oct 7, 2022

I've been dying to clean up some things in funder that are/were subpar. Here they are!

  • We used to not send back original lease data in RBF attempts, which meant if you RBF'd a channel w/ a lease on it, the lease request would rather silently disappear. Oops. Now we attempt to satisfy them on RBFs as well.
  • We didn't used to re-use the utxos from the original tx on RBF, now we do.

I kinda think that's it? That might be it.

@cdecker cdecker self-assigned this Oct 12, 2022
@cdecker cdecker added this to the v22.11 milestone Oct 12, 2022
Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Excellent cleanups 👍

ACK 3a98aa4

Comment on lines 748 to 762
/* iiuc deserialized gets called multiple times? */
if (!payload->rates)
payload->rates = tal(payload, struct lease_rates);
Copy link
Member

Choose a reason for hiding this comment

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

Yes, once for each plugin that gets called :-)


/* Next add available utxos until we surpass the
* requested funds goal */
/* FIXME: Update `utxopsbt` to automatically add more inputs? */
Copy link
Member

Choose a reason for hiding this comment

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

Could be an extra RPC method called fundpsbt to mirror bitcoind's API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already have a fundpsbt that behaves slightly differently.

@cdecker
Copy link
Member

cdecker commented Oct 14, 2022

Seems there is one json scan that doesn't always match the payload:

`openchannel2` payload did not scan Parsing '{openchannel2:{id:%,channel_id:%,their_funding_msat:%,max_htlc_value_in_flight_msat:%,htlc_minimum_msat:%,funding_feerate_per_kw:%,commitment_feerate_per_kw:%,feerate_our_max:%,feerate_our_min:%,to_self_delay:%,max_accepted_htlcs:%,channel_flags:%,locktime:%,channel_max_msat:': object does not have member channel_max_msat: {"openchannel2":{"id":"0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518","channel_id":"252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7","their_funding_msat":16777216000,"dust_limit_msat":546000,"max_htlc_value_in_flight_msat":18446744073709551615,"htlc_minimum_msat":0,"funding_feerate_per_kw":7500,"commitment_feerate_per_kw":7500,"feerate_our_max":150000,"feerate_our_min":1875,"to_self_delay":5,"max_accepted_htlcs":483,"channel_flags":1,"locktime":102}}

The offending field is channel_max_msat

We were leaving out the `channel_max_msat` for `openchannel2` when
channels are 'wumbo' (the conversion to msat in the json helper
overflowed, which resulted in the field not being printed)

Changelog-Changed: Plugins: `openchannel2` now always includes the `channel_max_msat`
Parse the channel_max along with everything else.
We're gonna need it for rbf requests/re-negotiations
if they request less than we wanted/accepted

FIXME: add a test for this?
If more than one plugin calls `openchannel2`, the payload will get
re-freshed/re-parsed.
let's let RBFs know about our lease info!
We're going to need to know what utxos we used if we RBF this channel;
so we serialize our inputs and save them to the datastore under the channel_id.
It'd be nice to know which utxos we used previously, so we can rebuild a
transaction using them!
Still need to use them to build the PSBT for the rbf however.
We use the saved previous outputs (plus maybe some new ones?) to build a
psbt for an RBF request.

RBFs utxo reuse is now working so we can unfail the test (and update
it to reflect that the lease sticks around through an RBF cycle).

Changelog-Fixed: Plugins: `funder` now honors lease requests across RBFs
If for some reason a utxo we used previously is no longer 'unspent',
we shouldn't use it for the next transaction.
Let's not leave old state hanging around! Note that this fires
for pretty much every/any channel (even if we're not the opener).
@niftynei
Copy link
Collaborator Author

Seems there is one json scan that doesn't always match the payload:

`openchannel2` payload did not scan Parsing '{openchannel2:{id:%,channel_id:%,their_funding_msat:%,max_htlc_value_in_flight_msat:%,htlc_minimum_msat:%,funding_feerate_per_kw:%,commitment_feerate_per_kw:%,feerate_our_max:%,feerate_our_min:%,to_self_delay:%,max_accepted_htlcs:%,channel_flags:%,locktime:%,channel_max_msat:': object does not have member channel_max_msat: {"openchannel2":{"id":"0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518","channel_id":"252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7","their_funding_msat":16777216000,"dust_limit_msat":546000,"max_htlc_value_in_flight_msat":18446744073709551615,"htlc_minimum_msat":0,"funding_feerate_per_kw":7500,"commitment_feerate_per_kw":7500,"feerate_our_max":150000,"feerate_our_min":1875,"to_self_delay":5,"max_accepted_htlcs":483,"channel_flags":1,"locktime":102}}

The offending field is channel_max_msat

Oh fun. We don't include channel_max_msat if wumbo is on because we set it to UINT_MAX, which fails to mulitply by 1000 to convert to sats when adding it to the openchannel2 JSON.

Added a new commit, b6ef966, which now uses a non-overflow-ing number for channel_max_msat!

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

ACK ebcc865

@cdecker cdecker merged commit e008578 into ElementsProject:master Oct 20, 2022
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.

3 participants